Skip to content

Commit

Permalink
refactor(chombobox): commands come from caps
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcMcIntosh committed Jan 16, 2024
1 parent 086d10b commit 2fa292d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
[x] combobox for the @commands
[x] add combobox to chat form and maybe pass text-area as a child component
[ ] remove test commands
[ ] rag commands come from the caps url.

### EVENTS TODO FOR IDEs

Expand Down
6 changes: 4 additions & 2 deletions src/components/ChatForm/ChatForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ErrorCallout, Callout } from "../Callout";
import { Select } from "../Select/Select";
import { FileUpload } from "../FileUpload";
import { Button } from "@radix-ui/themes";
import { ComboBox, testCommands } from "../ComboBox";
import { ComboBox } from "../ComboBox";

const CapsSelect: React.FC<{
value: string;
Expand Down Expand Up @@ -52,6 +52,7 @@ export const ChatForm: React.FC<{
onStopStreaming: () => void;
handleContextFile: () => void;
hasContextFile: boolean;
commands: string[];
}> = ({
onSubmit,
onClose,
Expand All @@ -66,6 +67,7 @@ export const ChatForm: React.FC<{
onStopStreaming,
handleContextFile,
hasContextFile,
commands,
}) => {
const [value, setValue] = React.useState("");
const isOnline = useIsOnline();
Expand Down Expand Up @@ -120,7 +122,7 @@ export const ChatForm: React.FC<{
onSubmit={() => handleSubmit()}
>
<ComboBox
commands={testCommands}
commands={commands}
value={value}
onChange={setValue}
onSubmit={handleEnter}
Expand Down
4 changes: 2 additions & 2 deletions src/contexts/config-context.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { useContext, createContext } from "react";

export type Config = {
vecdb: boolean;
rag?: boolean; // TODO: remove this
host: "web" | "ide"; // | "vscode" | "jetbrains"
tabbed?: boolean;
lspUrl?: string;
};

const ConfigContext = createContext<Config>({ vecdb: false, host: "web" });
const ConfigContext = createContext<Config>({ host: "web" });

const ConfigProvider: React.FC<{
children: React.ReactNode;
Expand Down
3 changes: 2 additions & 1 deletion src/features/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const Chat: React.FC<{ style?: React.CSSProperties }> = (props) => {
hasContextFile,
} = useEventBusForChat();

// TODO: ide's won't need this to be as big as the light dark button won't be there
// TODO: ide's won't need this to be as big because the light dark button won't be there
const LeftRightPadding: Responsive<
"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
> = {
Expand Down Expand Up @@ -78,6 +78,7 @@ export const Chat: React.FC<{ style?: React.CSSProperties }> = (props) => {
onStopStreaming={stopStreaming}
handleContextFile={handleContextFile}
hasContextFile={hasContextFile}
commands={state.rag_commands}
/>
</Flex>
);
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/useEventBusForChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function reducer(state: ChatState, action: ActionToChat): ChatState {
const default_cap = action.payload.caps.code_chat_default_model;
const available_caps = Object.keys(action.payload.caps.code_chat_models);
const error = available_caps.length === 0 ? "No available caps" : null;
const rag_commands = action.payload.caps.chat_rag_functions ?? [];
return {
...state,
error,
Expand All @@ -146,6 +147,7 @@ function reducer(state: ChatState, action: ActionToChat): ChatState {
default_cap: default_cap || available_caps[0] || "",
available_caps,
},
rag_commands,
};
}

Expand Down Expand Up @@ -249,6 +251,7 @@ export type ChatState = {
streaming: boolean;
error: string | null;
caps: ChatCapsState;
rag_commands: string[];
};

function createInitialState(): ChatState {
Expand All @@ -267,6 +270,7 @@ function createInitialState(): ChatState {
default_cap: "",
available_caps: [],
},
rag_commands: [],
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import { render } from "./lib";
const element = document.getElementById("refact-chat");

if (element) {
render(element, { host: "web", vecdb: false });
render(element, { host: "web" });
}
1 change: 1 addition & 0 deletions src/services/refact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,5 @@ export type CapsResponse = {
telemetry_corrected_snippets_dest: string;
tokenizer_path_template: string;
tokenizer_rewrite_path: Record<string, unknown>;
chat_rag_functions?: string[];
};

0 comments on commit 2fa292d

Please sign in to comment.