Skip to content

Commit 92b5c4c

Browse files
Patrick-Erichsensestinjdevbyjonah
authored
fix: cmd+shft+l closes sidebar if focused (#1638)
* docs: add docs and schema for "OS" provider (#1536) * ignore .env * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * add voyage rerank-1 * import Handlebars * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * small UI tweaks * media query * feat: add best experience onboarding * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * chore: add telemetry for full screen toggle (#1618) * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * manually implement stop tokens for hf inference api * chore: onboarding metrics (#1626) * fix: pageview tracking * feat: add onboarding telemetry * create single `onboardingStatus` type * improved var naming * remove console logs * fix windows performance issue * rename vscodeExtension.ts * migration of onboarding variables * "stash" instead of "delete" in indexing progress * fix preview.yaml * also fix main.yaml * Update troubleshooting.md (#1637) * feat: close panel if main input is focused * add skip param * Update TipTapEditor.tsx * merge dev * Update commands.ts --------- Co-authored-by: Nate Sesti <[email protected]> Co-authored-by: Nate Sesti <[email protected]> Co-authored-by: Jonah Wagner <[email protected]>
1 parent 5d8f73b commit 92b5c4c

File tree

8 files changed

+73
-45
lines changed

8 files changed

+73
-45
lines changed

core/indexing/LanceDbIndex.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class LanceDbIndex implements CodebaseIndex {
6565
"lancedb_sqlite_artifact_id_column",
6666
async () => {
6767
await db.exec(
68-
`ALTER TABLE lance_db_cache ADD COLUMN artifact_id TEXT NOT NULL DEFAULT 'UNDEFINED'`,
68+
"ALTER TABLE lance_db_cache ADD COLUMN artifact_id TEXT NOT NULL DEFAULT 'UNDEFINED'",
6969
);
7070
resolve(undefined);
7171
},

core/protocol/passThrough.ts

+1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] =
5454
"indexProgress",
5555
"addContextItem",
5656
"refreshSubmenuItems",
57+
"isContinueInputFocused",
5758
"didChangeAvailableProfiles",
5859
];

core/protocol/webview.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type ToWebviewFromIdeOrCoreProtocol = {
55
getDefaultModelTitle: [undefined, string];
66
indexProgress: [IndexingProgressUpdate, void];
77
refreshSubmenuItems: [undefined, void];
8+
isContinueInputFocused: [undefined, boolean];
89
addContextItem: [
910
{
1011
historyIndex: number;

extensions/vscode/src/debugPanel.ts renamed to extensions/vscode/src/ContinueGUIWebviewViewProvider.ts

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ export class ContinueGUIWebviewViewProvider
2525
}
2626

2727
private _webview?: vscode.Webview;
28+
private _webviewView?: vscode.WebviewView;
29+
30+
get isVisible() {
31+
return this._webviewView?.visible;
32+
}
2833

2934
get webview() {
3035
return this._webview;

extensions/vscode/src/commands.ts

+32-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
quickPickStatusText,
2020
setupStatusBar,
2121
} from "./autocomplete/statusBar";
22-
import { ContinueGUIWebviewViewProvider } from "./debugPanel";
22+
import { ContinueGUIWebviewViewProvider } from "./ContinueGUIWebviewViewProvider";
2323
import { DiffManager } from "./diff/horizontal";
2424
import { VerticalPerLineDiffManager } from "./diff/verticalPerLine/manager";
2525
import { QuickEdit } from "./quickEdit/QuickEdit";
@@ -82,7 +82,6 @@ function addCodeToContextFromRange(
8282
}
8383

8484
async function addHighlightedCodeToContext(
85-
edit: boolean,
8685
webviewProtocol: VsCodeWebviewProtocol | undefined,
8786
) {
8887
const editor = vscode.window.activeTextEditor;
@@ -322,19 +321,42 @@ const commandsMap: (
322321
fullScreenPanel?.reveal();
323322
}
324323
sidebar.webviewProtocol?.request("focusContinueInput", undefined);
325-
await addHighlightedCodeToContext(false, sidebar.webviewProtocol);
324+
await addHighlightedCodeToContext(sidebar.webviewProtocol);
326325
},
327326
"continue.focusContinueInputWithoutClear": async () => {
328-
if (!getFullScreenTab()) {
329-
vscode.commands.executeCommand("continue.continueGUIView.focus");
330-
}
331-
sidebar.webviewProtocol?.request(
332-
"focusContinueInputWithoutClear",
327+
const fullScreenTab = getFullScreenTab();
328+
329+
const isContinueInputFocused = await sidebar.webviewProtocol.request(
330+
"isContinueInputFocused",
333331
undefined,
334332
);
335-
await addHighlightedCodeToContext(true, sidebar.webviewProtocol);
333+
334+
if (isContinueInputFocused) {
335+
// Handle closing the GUI only if we are focused on the input
336+
if (fullScreenTab) {
337+
fullScreenPanel?.dispose();
338+
} else {
339+
vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar");
340+
}
341+
} else {
342+
// Handle opening the GUI otherwise
343+
if (!fullScreenTab) {
344+
// focus sidebar
345+
vscode.commands.executeCommand("continue.continueGUIView.focus");
346+
} else {
347+
// focus fullscreen
348+
fullScreenPanel?.reveal();
349+
}
350+
351+
sidebar.webviewProtocol?.request(
352+
"focusContinueInputWithoutClear",
353+
undefined,
354+
);
355+
356+
await addHighlightedCodeToContext(sidebar.webviewProtocol);
357+
}
336358
},
337-
"continue.quickEdit": (injectedPrompt?: string) => {
359+
"continue.quickEdit": async (injectedPrompt?: string) => {
338360
captureCommandTelemetry("quickEdit");
339361
quickEdit.run(injectedPrompt);
340362
},

extensions/vscode/src/extension/VsCodeExtension.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from "../autocomplete/statusBar";
1616
import { registerAllCommands } from "../commands";
1717
import { registerDebugTracker } from "../debug/debug";
18-
import { ContinueGUIWebviewViewProvider } from "../debugPanel";
18+
import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvider";
1919
import { DiffManager } from "../diff/horizontal";
2020
import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager";
2121
import { VsCodeIde } from "../ideProtocol";

gui/src/components/mainInput/TipTapEditor.tsx

+9-22
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ function TipTapEditor(props: TipTapEditorProps) {
151151
);
152152
const useActiveFile = useSelector(selectUseActiveFile);
153153

154-
const [inputFocused, setInputFocused] = useState(false);
155-
156154
const { saveSession } = useHistory(dispatch);
157155

158156
const inSubmenuRef = useRef<string | undefined>(undefined);
@@ -655,16 +653,14 @@ function TipTapEditor(props: TipTapEditorProps) {
655653
],
656654
);
657655

658-
// On linux+jetbrains only was stealing focus
659-
// useEffect(() => {
660-
// if (props.isMainInput && editor && document.hasFocus()) {
661-
// editor.commands.focus();
662-
// // setTimeout(() => {
663-
// // // https://github.com/continuedev/continue/pull/881
664-
// // editor.commands.blur();
665-
// // }, 0);
666-
// }
667-
// }, [editor, props.isMainInput, historyLength, ignoreHighlightedCode]);
656+
useWebviewListener(
657+
"isContinueInputFocused",
658+
async () => {
659+
return props.isMainInput && editorFocusedRef.current;
660+
},
661+
[editorFocusedRef, props.isMainInput],
662+
!props.isMainInput,
663+
);
668664

669665
const [showDragOverMsg, setShowDragOverMsg] = useState(false);
670666

@@ -748,22 +744,13 @@ function TipTapEditor(props: TipTapEditorProps) {
748744
<EditorContent
749745
spellCheck={false}
750746
editor={editor}
751-
onFocus={() => {
752-
setInputFocused(true);
753-
}}
754-
onBlur={() => {
755-
// hack to stop from cancelling press of "Enter"
756-
setTimeout(() => {
757-
setInputFocused(false);
758-
}, 100);
759-
}}
760747
onClick={(event) => {
761748
event.stopPropagation();
762749
}}
763750
/>
764751
<InputToolbar
765752
showNoContext={optionKeyHeld}
766-
hidden={!(inputFocused || props.isMainInput)}
753+
hidden={!(editorFocusedRef.current || props.isMainInput)}
767754
onAddContextItem={() => {
768755
if (editor.getText().endsWith("@")) {
769756
} else {

gui/src/hooks/useWebviewListener.ts

+23-11
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,31 @@ export function useWebviewListener<T extends keyof ToWebviewProtocol>(
77
messageType: T,
88
handler: (data: ToWebviewProtocol[T][0]) => Promise<ToWebviewProtocol[T][1]>,
99
dependencies?: any[],
10+
skip?: boolean,
1011
) {
1112
const ideMessenger = useContext(IdeMessengerContext);
1213

13-
useEffect(() => {
14-
const listener = async (event: { data: Message }) => {
15-
if (event.data.messageType === messageType) {
16-
const result = await handler(event.data.data);
17-
ideMessenger.respond(messageType, result, event.data.messageId);
14+
useEffect(
15+
() => {
16+
let listener;
17+
18+
if (!skip) {
19+
listener = async (event: { data: Message }) => {
20+
if (event.data.messageType === messageType) {
21+
const result = await handler(event.data.data);
22+
ideMessenger.respond(messageType, result, event.data.messageId);
23+
}
24+
};
25+
26+
window.addEventListener("message", listener);
1827
}
19-
};
20-
window.addEventListener("message", listener);
21-
return () => {
22-
window.removeEventListener("message", listener);
23-
};
24-
}, dependencies ?? []);
28+
29+
return () => {
30+
if (listener) {
31+
window.removeEventListener("message", listener);
32+
}
33+
};
34+
},
35+
dependencies ? [...dependencies, skip] : [skip],
36+
);
2537
}

0 commit comments

Comments
 (0)