diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts
index 60b6723b8..c3c2cdf7e 100644
--- a/extensions/vscode/e2e/tests/GUI.test.ts
+++ b/extensions/vscode/e2e/tests/GUI.test.ts
@@ -1,4 +1,11 @@
-import { EditorView, WebView, WebDriver, Key } from "vscode-extension-tester";
+import {
+ EditorView,
+ WebView,
+ WebDriver,
+ Key,
+ WebElement,
+ VSBrowser,
+} from "vscode-extension-tester";
import { expect } from "chai";
import { GUIActions } from "../actions/GUI.actions";
import { GUISelectors } from "../selectors/GUI.selectors";
@@ -12,6 +19,7 @@ describe("GUI Test", () => {
before(async function () {
this.timeout(DEFAULT_TIMEOUT.XL);
+ await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver);
await GlobalActions.openTestWorkspace();
});
@@ -184,6 +192,36 @@ describe("GUI Test", () => {
});
describe("Chat Paths", () => {
+ it("Open chat and type → open history → cmd+l → chat opens, empty and in focus", async () => {
+ const originalTextInput = await GUISelectors.getMessageInputFieldAtIndex(
+ view,
+ 0,
+ );
+ await originalTextInput.click();
+ await originalTextInput.sendKeys("Hello");
+ expect(await originalTextInput.getText()).to.equal("Hello");
+
+ await view.switchBack();
+
+ await (await GUISelectors.getHistoryNavButton(view)).click();
+ await GUIActions.switchToReactIframe();
+
+ await view.switchBack();
+ await (await GUISelectors.getNewSessionNavButton(view)).click();
+ await GUIActions.switchToReactIframe();
+
+ const newTextInput = await TestUtils.waitForSuccess(() =>
+ GUISelectors.getMessageInputFieldAtIndex(view, 0),
+ );
+ const activeElement: WebElement = await driver.switchTo().activeElement();
+ const newTextInputHtml = await newTextInput.getAttribute("outerHTML");
+ const activeElementHtml = await activeElement.getAttribute("outerHTML");
+ expect(newTextInputHtml).to.equal(activeElementHtml);
+
+ const textInputValue = await newTextInput.getText();
+ expect(textInputValue).to.equal("");
+ }).timeout(DEFAULT_TIMEOUT.XL);
+
it("chat → history → chat", async () => {
const messagePair1 = TestUtils.generateTestMessagePair(1);
await GUIActions.sendMessage({
diff --git a/extensions/vscode/e2e/tests/KeyboardShortcuts.test.ts b/extensions/vscode/e2e/tests/KeyboardShortcuts.test.ts
index dcc2892fa..cc3f6691d 100644
--- a/extensions/vscode/e2e/tests/KeyboardShortcuts.test.ts
+++ b/extensions/vscode/e2e/tests/KeyboardShortcuts.test.ts
@@ -77,6 +77,8 @@ describe("Cmd+L Shortcut Test", () => {
expect(await textInput.isDisplayed()).to.equal(true);
await GUIActions.executeFocusContinueInputShortcut(driver);
+
+ await driver.wait(until.elementIsNotVisible(textInput), DEFAULT_TIMEOUT.XS);
expect(await textInput.isDisplayed()).to.equal(false);
}).timeout(DEFAULT_TIMEOUT.XL);
diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts
index 690063628..30d3988cd 100644
--- a/extensions/vscode/src/commands.ts
+++ b/extensions/vscode/src/commands.ts
@@ -432,6 +432,7 @@ const getCommandsMap: (
core.invoke("context/indexDocs", { reIndex: true });
},
"continue.focusContinueInput": async () => {
+ // debugger;
const isContinueInputFocused = await sidebar.webviewProtocol.request(
"isContinueInputFocused",
undefined,
@@ -466,6 +467,7 @@ const getCommandsMap: (
);
}
} else {
+ // debugger;
focusGUI();
sidebar.webviewProtocol?.request(
"focusContinueInputWithNewSession",
diff --git a/gui/src/App.tsx b/gui/src/App.tsx
index c9f01ad7a..18df91b86 100644
--- a/gui/src/App.tsx
+++ b/gui/src/App.tsx
@@ -16,7 +16,7 @@ import { SubmenuContextProvidersProvider } from "./context/SubmenuContextProvide
const router = createMemoryRouter([
{
- path: "/",
+ path: ROUTES.HOME,
element: ,
errorElement: ,
children: [
@@ -25,7 +25,7 @@ const router = createMemoryRouter([
element: ,
},
{
- path: "/",
+ path: ROUTES.HOME,
element: ,
},
{
diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx
index 78085b431..e8a0deb12 100644
--- a/gui/src/components/Layout.tsx
+++ b/gui/src/components/Layout.tsx
@@ -65,6 +65,44 @@ const Layout = () => {
const showDialog = useAppSelector((state) => state.ui.showDialog);
+ useWebviewListener(
+ "newSession",
+ async () => {
+ navigate(ROUTES.HOME);
+ await dispatch(
+ saveCurrentSession({
+ openNewSession: true,
+ }),
+ );
+ dispatch(exitEditMode());
+ },
+ [],
+ );
+
+ useWebviewListener(
+ "isContinueInputFocused",
+ async () => {
+ return false;
+ },
+ [location.pathname],
+ location.pathname === ROUTES.HOME,
+ );
+
+ useWebviewListener(
+ "focusContinueInputWithNewSession",
+ async () => {
+ navigate(ROUTES.HOME);
+ await dispatch(
+ saveCurrentSession({
+ openNewSession: true,
+ }),
+ );
+ dispatch(exitEditMode());
+ },
+ [location.pathname],
+ location.pathname === ROUTES.HOME,
+ );
+
useWebviewListener(
"openDialogMessage",
async (message) => {
diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx
index bcd7328a2..29c6b108a 100644
--- a/gui/src/components/mainInput/TipTapEditor.tsx
+++ b/gui/src/components/mainInput/TipTapEditor.tsx
@@ -647,6 +647,17 @@ function TipTapEditor(props: TipTapEditorProps) {
[props.onEnter, editor, props.isMainInput],
);
+ useEffect(() => {
+ if (props.isMainInput) {
+ /**
+ * I have a strong suspicion that many of the other focus
+ * commands are redundant, especially the ones inside
+ * useTimeout.
+ */
+ editor.commands.focus();
+ }
+ }, [props.isMainInput, editor]);
+
// Re-focus main input after done generating
useEffect(() => {
if (editor && !isStreaming && props.isMainInput && document.hasFocus()) {
diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx
index 781d712db..bb4cb4e8f 100644
--- a/gui/src/pages/gui/Chat.tsx
+++ b/gui/src/pages/gui/Chat.tsx
@@ -321,14 +321,8 @@ export function Chat() {
useWebviewListener(
"newSession",
async () => {
- await dispatch(
- saveCurrentSession({
- openNewSession: true,
- }),
- );
// unwrapResult(response) // errors if session creation failed
mainTextInputRef.current?.focus?.();
- dispatch(exitEditMode());
},
[mainTextInputRef],
);