Merge pull request #3515 from continuedev/tomasz/fix-input-history

fix: cycling through chat messages
This commit is contained in:
Tomasz Stefaniak 2024-12-23 12:57:11 -08:00 • committed by GitHub
commit ec5fa382ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 63 additions and 7 deletions

View file

@ -5,6 +5,7 @@ import {
Key,
WebElement,
VSBrowser,
until,
} from "vscode-extension-tester";
import { expect } from "chai";
import { GUIActions } from "../actions/GUI.actions";
@ -192,7 +193,63 @@ describe("GUI Test", () => {
});
describe("Chat Paths", () => {
it("Open chat and type → open history → cmd+l → chat opens, empty and in focus", async () => {
it("Open chat and send message → press arrow up and arrow down to cycle through messages → submit another message → press arrow up and arrow down to cycle through messages", async () => {
await GUIActions.sendMessage({
view,
message: "MESSAGE 1",
inputFieldIndex: 0,
});
const input1 = await TestUtils.waitForSuccess(async () => {
return GUISelectors.getMessageInputFieldAtIndex(view, 1);
});
expect(await input1.getText()).to.equal("");
await input1.sendKeys(Key.ARROW_UP);
await driver.wait(
until.elementTextIs(input1, "MESSAGE 1"),
DEFAULT_TIMEOUT.SM,
);
await input1.sendKeys(Key.ARROW_DOWN); // First press - bring caret to the end of the message
await input1.sendKeys(Key.ARROW_DOWN); // Second press - trigger message change
await driver.wait(until.elementTextIs(input1, ""), DEFAULT_TIMEOUT.SM);
await GUIActions.sendMessage({
view,
message: "MESSAGE 2",
inputFieldIndex: 1,
});
const input2 = await TestUtils.waitForSuccess(async () => {
return GUISelectors.getMessageInputFieldAtIndex(view, 2);
});
expect(await input2.getText()).to.equal("");
await input2.sendKeys(Key.ARROW_UP);
await driver.wait(
until.elementTextIs(input2, "MESSAGE 2"),
DEFAULT_TIMEOUT.SM,
);
await input2.sendKeys(Key.ARROW_UP);
await driver.wait(
until.elementTextIs(input2, "MESSAGE 1"),
DEFAULT_TIMEOUT.SM,
);
await input2.sendKeys(Key.ARROW_DOWN); // First press - bring caret to the end of the message
await input2.sendKeys(Key.ARROW_DOWN); // Second press - trigger message change
await driver.wait(
until.elementTextIs(input2, "MESSAGE 2"),
DEFAULT_TIMEOUT.SM,
);
await input2.sendKeys(Key.ARROW_DOWN);
await driver.wait(until.elementTextIs(input2, ""), DEFAULT_TIMEOUT.SM);
}).timeout(DEFAULT_TIMEOUT.XL);
it("Open chat and type → open history → press new session button → chat opens, empty and in focus", async () => {
const originalTextInput = await GUISelectors.getMessageInputFieldAtIndex(
view,
0,

View file

@ -637,12 +637,11 @@ function TipTapEditor(props: TipTapEditorProps) {
return;
}
props.onEnter(json, modifiers, editor);
if (props.isMainInput) {
const content = editor.state.toJSON().doc;
addRef.current(content);
addRef.current(json);
}
props.onEnter(json, modifiers, editor);
},
[props.onEnter, editor, props.isMainInput],
);

View file

@ -52,9 +52,9 @@ export function useInputHistory(historyKey: string) {
) {
setCurrentIndex(inputHistory.length);
return;
} else {
setCurrentIndex(inputHistory.length + 1);
}
setCurrentIndex(inputHistory.length + 1);
setInputHistory((prev) => {
return [...prev, inputValue].slice(-MAX_HISTORY_LENGTH);
});