Skip to content

Commit 7a8af76

Browse files
author
Calvinn Ng
committed
update GUI
1 parent 93d1756 commit 7a8af76

File tree

14 files changed

+76
-55
lines changed

14 files changed

+76
-55
lines changed

gui/package-lock.json

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"vscode-webview": "^1.0.1-beta.1"
5858
},
5959
"devDependencies": {
60+
"@google/generative-ai": "^0.11.4",
6061
"@types/node": "^20.5.6",
6162
"@types/node-fetch": "^2.6.4",
6263
"@types/react": "^18.0.27",

gui/src/components/dialogs/AddDocsDialog.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { SiteIndexingConfig } from "core";
12
import { usePostHog } from "posthog-js/react";
23
import React, { useContext, useLayoutEffect } from "react";
34
import { useDispatch } from "react-redux";
@@ -15,9 +16,11 @@ const GridDiv = styled.div`
1516
`;
1617

1718
function AddDocsDialog() {
19+
const defaultMaxDepth = 3;
1820
const [docsUrl, setDocsUrl] = React.useState("");
1921
const [docsTitle, setDocsTitle] = React.useState("");
2022
const [urlValid, setUrlValid] = React.useState(false);
23+
const [maxDepth, setMaxDepth] = React.useState<number | string>(""); // Change here
2124
const dispatch = useDispatch();
2225

2326
const { addItem } = useContext(SubmenuContextProvidersContext);
@@ -58,7 +61,13 @@ function AddDocsDialog() {
5861
disabled={!docsUrl || !urlValid}
5962
className="ml-auto"
6063
onClick={() => {
61-
postToIde("context/addDocs", { url: docsUrl, title: docsTitle });
64+
const siteIndexingConfig: SiteIndexingConfig = {
65+
startUrl: docsUrl,
66+
rootUrl: docsUrl,
67+
title: docsTitle,
68+
maxDepth: typeof maxDepth === "string" ? defaultMaxDepth : maxDepth, // Ensure maxDepth is a number
69+
};
70+
postToIde("context/addDocs", siteIndexingConfig);
6271
setDocsTitle("");
6372
setDocsUrl("");
6473
dispatch(setShowDialog(false));

gui/src/components/gui/StepContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ function StepContainer(props: StepContainerProps) {
7373
const sendFeedback = (feedback: boolean) => {
7474
setFeedback(feedback);
7575
if (props.item.promptLogs?.length) {
76-
for (const [prompt, completion] of props.item.promptLogs) {
76+
for (const promptLog of props.item.promptLogs) {
7777
postToIde("devdata/log", {
7878
tableName: "chat",
79-
data: { prompt, completion, feedback },
79+
data: { ...promptLog, feedback },
8080
});
8181
}
8282
}

gui/src/components/mainInput/InputToolbar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
vscForeground,
1414
vscInputBackground,
1515
} from "..";
16+
import { selectUseActiveFile } from "../../redux/selectors";
1617
import { defaultModelSelector } from "../../redux/selectors/modelSelectors";
1718
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
1819

@@ -73,6 +74,7 @@ function InputToolbar(props: InputToolbarProps) {
7374
const [fileSelectHovered, setFileSelectHovered] = useState(false);
7475

7576
const defaultModel = useSelector(defaultModelSelector);
77+
const useActiveFile = useSelector(selectUseActiveFile);
7678

7779
return (
7880
<StyledDiv hidden={props.hidden} onClick={props.onClick} id="input-toolbar">
@@ -138,6 +140,7 @@ function InputToolbar(props: InputToolbarProps) {
138140
onClick={(e) => {
139141
props.onEnter({
140142
useCodebase: true,
143+
noContext: !useActiveFile,
141144
});
142145
}}
143146
className={"hover:underline cursor-pointer float-right"}
@@ -155,6 +158,7 @@ function InputToolbar(props: InputToolbarProps) {
155158
onClick={(e) => {
156159
props.onEnter({
157160
useCodebase: isMetaEquivalentKeyPressed(e),
161+
noContext: useActiveFile ? e.altKey : !e.altKey,
158162
});
159163
}}
160164
>

gui/src/components/mainInput/TipTapEditor.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { SubmenuContextProvidersContext } from "../../App";
2929
import useHistory from "../../hooks/useHistory";
3030
import useUpdatingRef from "../../hooks/useUpdatingRef";
3131
import { useWebviewListener } from "../../hooks/useWebviewListener";
32+
import { selectUseActiveFile } from "../../redux/selectors";
3233
import { defaultModelSelector } from "../../redux/selectors/modelSelectors";
3334
import { setEditingContextItemAtIndex } from "../../redux/slices/stateSlice";
3435
import { RootState } from "../../redux/store";
@@ -137,6 +138,8 @@ function TipTapEditor(props: TipTapEditorProps) {
137138
(store: RootState) => store.state.history.length,
138139
);
139140

141+
const useActiveFile = useSelector(selectUseActiveFile);
142+
140143
const [inputFocused, setInputFocused] = useState(false);
141144

142145
const { saveSession } = useHistory(dispatch);
@@ -250,15 +253,20 @@ function TipTapEditor(props: TipTapEditorProps) {
250253
return false;
251254
}
252255

253-
onEnterRef.current({ useCodebase: false });
256+
onEnterRef.current({
257+
useCodebase: false,
258+
noContext: !useActiveFile,
259+
});
254260
return true;
255261
},
256262

257263
"Cmd-Enter": () => {
258-
onEnterRef.current({ useCodebase: true });
264+
onEnterRef.current({
265+
useCodebase: true,
266+
noContext: !useActiveFile,
267+
});
259268
return true;
260269
},
261-
262270
"Shift-Enter": () =>
263271
this.editor.commands.first(({ commands }) => [
264272
() => commands.newlineInCode(),
@@ -409,7 +417,7 @@ function TipTapEditor(props: TipTapEditorProps) {
409417
return;
410418
}
411419
editor?.commands.insertContent(data.input);
412-
onEnterRef.current({ useCodebase: false });
420+
onEnterRef.current({ useCodebase: false, noContext: true });
413421
},
414422
[editor, onEnterRef.current, props.isMainInput],
415423
);

gui/src/components/mainInput/inputModifiers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ import { InputModifiers } from "core";
22

33
export const defaultInputModifiers: InputModifiers = {
44
useCodebase: false,
5-
};
5+
noContext: true,
6+
};

gui/src/hooks/useChatHandler.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
InputModifiers,
99
LLMReturnValue,
1010
MessageContent,
11+
PromptLog,
1112
RangeInFile,
1213
SlashCommandDescription,
1314
} from "core";
@@ -64,11 +65,12 @@ function useChatHandler(dispatch: Dispatch) {
6465
next = await gen.next();
6566
}
6667

67-
let returnVal = next.value as LLMReturnValue;
68+
let returnVal = next.value as PromptLog;
6869
if (returnVal) {
69-
dispatch(
70-
addPromptCompletionPair([[returnVal?.prompt, returnVal?.completion]]),
71-
);
70+
// dispatch(
71+
// addPromptCompletionPair([[returnVal?.prompt, returnVal?.completion]]),
72+
// );
73+
dispatch(addPromptCompletionPair([returnVal]));
7274
}
7375
}
7476

gui/src/hooks/useSetup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function useSetup(dispatch: Dispatch<any>) {
7474
});
7575

7676
useWebviewListener("submitMessage", async (data) => {
77-
streamResponse(data.message, { useCodebase: false });
77+
streamResponse(data.message, { useCodebase: false, noContext: true },);
7878
});
7979

8080
useWebviewListener("addContextItem", async (data) => {

gui/src/redux/selectors/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ export const selectContextProviderDescriptions = createSelector(
2323
return providers.filter((desc) => desc.type === "submenu") || [];
2424
}
2525
);
26+
27+
export const selectUseActiveFile = createSelector(
28+
[(store: RootState) => store.state.config.experimental?.defaultContext],
29+
(defaultContext) => defaultContext?.includes("activeFile"),
30+
);

0 commit comments

Comments
 (0)