From fe8eb5dcbc23abd65f18fec54e9206246876d720 Mon Sep 17 00:00:00 2001 From: Fred Bricon Date: Fri, 18 Jul 2025 19:08:16 +0200 Subject: [PATCH 01/15] feat: allow Cmd+L / Cmd+I on empty selection to select the entire file Signed-off-by: Fred Bricon --- .../e2e/tests/KeyboardShortcuts.test.ts | 71 +++++++++++++++++-- extensions/vscode/package.json | 5 +- extensions/vscode/src/util/addCode.ts | 56 ++++++++++----- 3 files changed, 106 insertions(+), 26 deletions(-) diff --git a/extensions/vscode/e2e/tests/KeyboardShortcuts.test.ts b/extensions/vscode/e2e/tests/KeyboardShortcuts.test.ts index 5dff86d5e..c557708ef 100644 --- a/extensions/vscode/e2e/tests/KeyboardShortcuts.test.ts +++ b/extensions/vscode/e2e/tests/KeyboardShortcuts.test.ts @@ -4,12 +4,12 @@ import { InputBox, Key, TextEditor, + until, VSBrowser, WebDriver, WebElement, WebView, Workbench, - until, } from "vscode-extension-tester"; import { GlobalActions } from "../actions/Global.actions"; @@ -47,11 +47,31 @@ describe("Keyboard Shortcuts", () => { afterEach(async function () { this.timeout(DEFAULT_TIMEOUT.XL * 1000); + await cleanupChat(); await view.switchBack(); await editor.clearText(); await new EditorView().closeAllEditors(); }); + async function cleanupChat(chatInput?: WebElement) { + try { + if (!chatInput) { + chatInput = await TestUtils.waitForSuccess(async () => { + return GUISelectors.getMessageInputFieldAtIndex(view, 0); + }); + } + if ( + chatInput && + (await chatInput.isDisplayed()) && + (await chatInput.isEnabled()) + ) { + await chatInput.clear(); + } + } catch (e) { + console.error(`Failed to clear chat: ${e}`); + } + } + it("Should correctly undo and redo using keyboard shortcuts when writing a chat message", async () => { await GUIActions.executeFocusContinueInputShortcut(driver); ({ view } = await GUIActions.switchToReactIframe()); @@ -105,10 +125,8 @@ describe("Keyboard Shortcuts", () => { ); }).timeout(DEFAULT_TIMEOUT.XL); - it("Should not create a code block when Cmd+L is pressed without text highlighted", async () => { - const text = "Hello, world!"; - - await editor.setText(text); + it("Should not create a code block when Cmd+L is pressed on an empty document", async () => { + expect((await editor.getText()).trim()).to.equal(""); await GUIActions.executeFocusContinueInputShortcut(driver); @@ -174,6 +192,9 @@ describe("Keyboard Shortcuts", () => { await driver.wait(until.elementIsNotVisible(textInput), DEFAULT_TIMEOUT.XS); expect(await textInput.isDisplayed()).to.equal(false); + + // Make sure the view is visible again, so it can be cleared in afterEach() + await GUIActions.executeFocusContinueInputShortcut(driver); }).timeout(DEFAULT_TIMEOUT.XL); it("Should create a code block when Cmd+L is pressed with text highlighted", async () => { @@ -197,4 +218,44 @@ describe("Keyboard Shortcuts", () => { await GUIActions.executeFocusContinueInputShortcut(driver); }).timeout(DEFAULT_TIMEOUT.XL); + + it("Should create a code block with the whole file when Cmd+L is pressed on an empty line", async () => { + const text = "Hello,\n\n\nworld!"; + + await editor.setText(text); + await editor.moveCursor(2, 1); //Move cursor to an empty line + + await GUIActions.executeFocusContinueInputShortcut(driver); + + ({ view } = await GUIActions.switchToReactIframe()); + + const codeBlock = await TestUtils.waitForSuccess(() => + GUISelectors.getInputBoxCodeBlockAtIndex(view, 0), + ); + const codeblockContent = await codeBlock.getAttribute( + "data-codeblockcontent", + ); + + expect(codeblockContent).to.equal(text); + }); + + it("Should create a code block when Cmd+L is pressed on a non-empty line", async () => { + const text = "Hello, world!"; + + await editor.setText(text); + await editor.moveCursor(1, 7); //Move cursor to the 1st space + + await GUIActions.executeFocusContinueInputShortcut(driver); + + ({ view } = await GUIActions.switchToReactIframe()); + + const codeBlock = await TestUtils.waitForSuccess(() => + GUISelectors.getInputBoxCodeBlockAtIndex(view, 0), + ); + const codeblockContent = await codeBlock.getAttribute( + "data-codeblockcontent", + ); + + expect(codeblockContent).to.equal(text); + }).timeout(DEFAULT_TIMEOUT.XL); }); diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 3eaf44c21..63b7f00d6 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -540,13 +540,12 @@ "continue.continueSubMenu": [ { "command": "continue.focusContinueInputWithoutClear", - "group": "Continue", - "when": "editorHasSelection" + "group": "Continue" }, { "command": "continue.focusEdit", "group": "Continue", - "when": "editorHasSelection && !editorReadonly" + "when": "!editorReadonly" } ], "explorer/context": [ diff --git a/extensions/vscode/src/util/addCode.ts b/extensions/vscode/src/util/addCode.ts index 524d77e88..05d9c3afe 100644 --- a/extensions/vscode/src/util/addCode.ts +++ b/extensions/vscode/src/util/addCode.ts @@ -36,22 +36,38 @@ export function getRangeInFileWithContents( }; } - if (selection.isEmpty && !allowEmpty) { + if ((selection.isEmpty && !allowEmpty) || isEmptyFile(editor.document)) { return null; } - let selectionRange = new vscode.Range(selection.start, selection.end); - const document = editor.document; - // Select the context from the beginning of the selection start line to the selection start position - const beginningOfSelectionStartLine = selection.start.with(undefined, 0); - const textBeforeSelectionStart = document.getText( - new vscode.Range(beginningOfSelectionStartLine, selection.start), - ); - // If there are only whitespace before the start of the selection, include the indentation - if (textBeforeSelectionStart.trim().length === 0) { - selectionRange = selectionRange.with({ - start: beginningOfSelectionStartLine, - }); + let selectionRange: vscode.Range | undefined; + // if the selection is empty and document is not empty, select the whole document + if (selection.isEmpty) { + selectionRange = new vscode.Range( + new vscode.Position(0, 0), + new vscode.Position( + editor.document.lineCount - 1, + editor.document.lineAt( + editor.document.lineCount - 1, + ).range.end.character, + ), + ); + } + + if (!selectionRange) { + selectionRange = new vscode.Range(selection.start, selection.end); + const document = editor.document; + // Select the context from the beginning of the selection start line to the selection start position + const beginningOfSelectionStartLine = selection.start.with(undefined, 0); + const textBeforeSelectionStart = document.getText( + new vscode.Range(beginningOfSelectionStartLine, selection.start), + ); + // If there are only whitespace before the start of the selection, include the indentation + if (textBeforeSelectionStart.trim().length === 0) { + selectionRange = selectionRange.with({ + start: beginningOfSelectionStartLine, + }); + } } const contents = editor.document.getText(selectionRange); @@ -61,12 +77,12 @@ export function getRangeInFileWithContents( contents, range: { start: { - line: selection.start.line, - character: selection.start.character, + line: selectionRange.start.line, + character: selectionRange.start.character, }, end: { - line: selection.end.line, - character: selection.end.character, + line: selectionRange.end.line, + character: selectionRange.end.character, }, }, }; @@ -78,7 +94,7 @@ export function getRangeInFileWithContents( export async function addHighlightedCodeToContext( webviewProtocol: VsCodeWebviewProtocol | undefined, ) { - const rangeInFileWithContents = getRangeInFileWithContents(); + const rangeInFileWithContents = getRangeInFileWithContents(true); if (rangeInFileWithContents) { webviewProtocol?.request("highlightedCode", { rangeInFileWithContents, @@ -129,6 +145,10 @@ export async function addEntireFileToContext( }); } +export function isEmptyFile(document: vscode.TextDocument) { + return document.lineCount === 1 && document.lineAt(0).range.isEmpty; +} + export function addCodeToContextFromRange( range: vscode.Range, webviewProtocol: VsCodeWebviewProtocol, From ebded1fc6710a9d07090efcd7a2857dadf26e63b Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 9 Sep 2025 11:11:04 -0700 Subject: [PATCH 02/15] Add autoformatting detection for edit tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement autoformatting detection similar to Cline's approach to improve reliability of edit operations. When edit tools (multiEdit/editFile) are executed, the system now captures file content before and after save operations to detect editor autoformatting changes. Key changes: - Add `createPrettyPatch` utility using existing `myersDiff` function - Capture pre/post save content in `processDiff.ts` - Add `autoFormattingDiff` field to `ApplyState` protocol - Include autoformatting diff in tool responses with guidance for language model - Help prevent future edit failures due to undetected formatting changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- core/config/types.ts | 1 + core/index.d.ts | 1 + extensions/vscode/src/diff/processDiff.ts | 34 ++++++++++++--- extensions/vscode/src/util/diffUtils.ts | 41 +++++++++++++++++++ .../redux/thunks/handleApplyStateUpdate.ts | 19 ++++++++- 5 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 extensions/vscode/src/util/diffUtils.ts diff --git a/core/config/types.ts b/core/config/types.ts index 6048cf4d3..0b76419df 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -1061,6 +1061,7 @@ declare global { filepath?: string; fileContent?: string; originalFileContent?: string; + autoFormattingDiff?: string; } export interface RangeInFileWithContents { diff --git a/core/index.d.ts b/core/index.d.ts index a31e02c67..815fd9448 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1382,6 +1382,7 @@ export interface ApplyState { fileContent?: string; originalFileContent?: string; toolCallId?: string; + autoFormattingDiff?: string; } export interface StreamDiffLinesPayload { diff --git a/extensions/vscode/src/diff/processDiff.ts b/extensions/vscode/src/diff/processDiff.ts index f350e12b4..d46b4ef9d 100644 --- a/extensions/vscode/src/diff/processDiff.ts +++ b/extensions/vscode/src/diff/processDiff.ts @@ -1,7 +1,9 @@ import { Core } from "core/core"; import { DataLogger } from "core/data/log"; + import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvider"; import { editOutcomeTracker } from "../extension/EditOutcomeTracker"; +import { createPrettyPatch, normalizeContent } from "../util/diffUtils"; import { VsCodeIde } from "../VsCodeIde"; import { VerticalDiffManager } from "./vertical/manager"; @@ -42,7 +44,8 @@ export async function processDiff( } if (streamId) { - const fileContent = await ide.readFile(newOrCurrentUri); + // Capture file content before save to detect autoformatting + const preSaveContent = await ide.readFile(newOrCurrentUri); // Record the edit outcome before updating the apply state await editOutcomeTracker.recordEditOutcome( @@ -51,16 +54,37 @@ export async function processDiff( DataLogger.getInstance(), ); + // Save the file + await ide.saveFile(newOrCurrentUri); + + // Capture file content after save to detect autoformatting + const postSaveContent = await ide.readFile(newOrCurrentUri); + + // Detect autoformatting by comparing normalized content + let autoFormattingDiff: string | undefined; + const normalizedPreSave = normalizeContent(preSaveContent); + const normalizedPostSave = normalizeContent(postSaveContent); + + if (normalizedPreSave !== normalizedPostSave) { + // Auto-formatting was applied by the editor + autoFormattingDiff = createPrettyPatch( + newOrCurrentUri, + preSaveContent, + postSaveContent, + ); + } + await sidebar.webviewProtocol.request("updateApplyState", { - fileContent, + fileContent: postSaveContent, // Use post-save content filepath: newOrCurrentUri, streamId, status: "closed", numDiffs: 0, toolCallId, + autoFormattingDiff, // Include autoformatting diff }); + } else { + // Save the file even if no streamId + await ide.saveFile(newOrCurrentUri); } - - // Save the file - await ide.saveFile(newOrCurrentUri); } diff --git a/extensions/vscode/src/util/diffUtils.ts b/extensions/vscode/src/util/diffUtils.ts new file mode 100644 index 000000000..4e53fb8c6 --- /dev/null +++ b/extensions/vscode/src/util/diffUtils.ts @@ -0,0 +1,41 @@ +import { myersDiff } from "core/diff/myers"; + +/** + * Creates a pretty patch diff string similar to unified diff format + * Uses Continue's existing myersDiff function for diff calculation + */ +export function createPrettyPatch( + filename: string = "file", + oldStr: string = "", + newStr: string = "", +): string { + if (oldStr === newStr) { + return ""; + } + + const diffLines = myersDiff(oldStr, newStr); + const patchLines: string[] = []; + + for (const diffLine of diffLines) { + switch (diffLine.type) { + case "old": + patchLines.push(`-${diffLine.line}`); + break; + case "new": + patchLines.push(`+${diffLine.line}`); + break; + case "same": + patchLines.push(` ${diffLine.line}`); + break; + } + } + + return patchLines.join("\n"); +} + +/** + * Normalizes content by trimming whitespace for comparison + */ +export function normalizeContent(content: string): string { + return content.trim(); +} \ No newline at end of file diff --git a/gui/src/redux/thunks/handleApplyStateUpdate.ts b/gui/src/redux/thunks/handleApplyStateUpdate.ts index 25532e750..8d7c1bec0 100644 --- a/gui/src/redux/thunks/handleApplyStateUpdate.ts +++ b/gui/src/redux/thunks/handleApplyStateUpdate.ts @@ -83,6 +83,24 @@ export const handleApplyStateUpdate = createAsyncThunk< } if (accepted) { + // Add autoformatting diff to tool output if present + if (applyState.autoFormattingDiff) { + dispatch( + updateToolCallOutput({ + toolCallId: applyState.toolCallId, + contextItems: [ + { + icon: "info", + name: "Auto-formatting Applied", + description: "Editor auto-formatting changes", + content: `Along with your edits, the editor applied the following auto-formatting:\n\n${applyState.autoFormattingDiff}\n\n(Note: Pay close attention to changes such as single quotes being converted to double quotes, semicolons being removed or added, long lines being broken into multiple lines, adjusting indentation style, adding/removing trailing commas, etc. This will help you ensure future SEARCH/REPLACE operations to this file are accurate.)`, + hidden: false, + }, + ], + }), + ); + } + if (toolCallState.status !== "errored") { dispatch( acceptToolCall({ @@ -98,7 +116,6 @@ export const handleApplyStateUpdate = createAsyncThunk< ); } } - // TODO return output from edit tools so the model knows the result } } } From 1f5389f070bb368badf3ed99a8ba02449078f181 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 9 Sep 2025 14:14:35 -0700 Subject: [PATCH 03/15] updates --- extensions/vscode/src/diff/processDiff.ts | 25 +++++++++----- extensions/vscode/src/util/diffUtils.ts | 41 ----------------------- 2 files changed, 17 insertions(+), 49 deletions(-) delete mode 100644 extensions/vscode/src/util/diffUtils.ts diff --git a/extensions/vscode/src/diff/processDiff.ts b/extensions/vscode/src/diff/processDiff.ts index d46b4ef9d..eda40e162 100644 --- a/extensions/vscode/src/diff/processDiff.ts +++ b/extensions/vscode/src/diff/processDiff.ts @@ -1,10 +1,11 @@ import { Core } from "core/core"; import { DataLogger } from "core/data/log"; +import { myersDiff } from "core/diff/myers"; import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvider"; import { editOutcomeTracker } from "../extension/EditOutcomeTracker"; -import { createPrettyPatch, normalizeContent } from "../util/diffUtils"; import { VsCodeIde } from "../VsCodeIde"; + import { VerticalDiffManager } from "./vertical/manager"; export async function processDiff( @@ -62,16 +63,24 @@ export async function processDiff( // Detect autoformatting by comparing normalized content let autoFormattingDiff: string | undefined; - const normalizedPreSave = normalizeContent(preSaveContent); - const normalizedPostSave = normalizeContent(postSaveContent); + const normalizedPreSave = preSaveContent.trim(); + const normalizedPostSave = postSaveContent.trim(); if (normalizedPreSave !== normalizedPostSave) { // Auto-formatting was applied by the editor - autoFormattingDiff = createPrettyPatch( - newOrCurrentUri, - preSaveContent, - postSaveContent, - ); + const diffLines = myersDiff(preSaveContent, postSaveContent); + autoFormattingDiff = diffLines + .map(line => { + switch (line.type) { + case "old": + return `-${line.line}`; + case "new": + return `+${line.line}`; + case "same": + return ` ${line.line}`; + } + }) + .join("\n"); } await sidebar.webviewProtocol.request("updateApplyState", { diff --git a/extensions/vscode/src/util/diffUtils.ts b/extensions/vscode/src/util/diffUtils.ts deleted file mode 100644 index 4e53fb8c6..000000000 --- a/extensions/vscode/src/util/diffUtils.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { myersDiff } from "core/diff/myers"; - -/** - * Creates a pretty patch diff string similar to unified diff format - * Uses Continue's existing myersDiff function for diff calculation - */ -export function createPrettyPatch( - filename: string = "file", - oldStr: string = "", - newStr: string = "", -): string { - if (oldStr === newStr) { - return ""; - } - - const diffLines = myersDiff(oldStr, newStr); - const patchLines: string[] = []; - - for (const diffLine of diffLines) { - switch (diffLine.type) { - case "old": - patchLines.push(`-${diffLine.line}`); - break; - case "new": - patchLines.push(`+${diffLine.line}`); - break; - case "same": - patchLines.push(` ${diffLine.line}`); - break; - } - } - - return patchLines.join("\n"); -} - -/** - * Normalizes content by trimming whitespace for comparison - */ -export function normalizeContent(content: string): string { - return content.trim(); -} \ No newline at end of file From f7e91eccc11b21bc42bc4a6aac8946938d8ff416 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 8 Sep 2025 22:01:14 +0530 Subject: [PATCH 04/15] feat(cli): message queing --- extensions/cli/src/stream/messageQueue.ts | 57 +++++++++++++++++++++++ extensions/cli/src/ui/UserInput.tsx | 27 +++++------ extensions/cli/src/ui/hooks/useChat.ts | 13 ++++++ 3 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 extensions/cli/src/stream/messageQueue.ts diff --git a/extensions/cli/src/stream/messageQueue.ts b/extensions/cli/src/stream/messageQueue.ts new file mode 100644 index 000000000..d91f2d398 --- /dev/null +++ b/extensions/cli/src/stream/messageQueue.ts @@ -0,0 +1,57 @@ +import { InputHistory } from "../util/inputHistory.js"; +import { logger } from "../util/logger.js"; + +export interface QueuedMessage { + message: string; + imageMap?: Map; + timestamp: number; +} + +export interface MessageProcessor { + (message: string, imageMap?: Map): Promise; +} + +/** + * A queue to store messages that need to be processed later + */ +class MessageQueue { + private queue: QueuedMessage[] = []; + private inputHistory: InputHistory | undefined; + + async enqueueMessage( + message: string, + imageMap?: Map, + inputHistory?: InputHistory, + ): Promise { + this.inputHistory = inputHistory; + + const queuedMessage: QueuedMessage = { + message, + imageMap, + timestamp: Date.now(), + }; + + this.queue.push(queuedMessage); + logger.debug("MessageQueue: Message queued", { + queueLength: this.queue.length, + }); + + return true; + } + + public getLatestMessage() { + if (this.queue.length === 0) return undefined; + const latestMessage = this.queue.shift(); + logger.debug("MessageQueue: Message dequeued", { + queueLength: this.queue.length, + }); + this.inputHistory?.addEntry(latestMessage!.message); + return latestMessage; + } + + getQueueLength(): number { + return this.queue.length; + } +} + +export const messageQueue = new MessageQueue(); diff --git a/extensions/cli/src/ui/UserInput.tsx b/extensions/cli/src/ui/UserInput.tsx index 4b5deb5bc..97b04949a 100644 --- a/extensions/cli/src/ui/UserInput.tsx +++ b/extensions/cli/src/ui/UserInput.tsx @@ -9,6 +9,7 @@ import type { PermissionMode } from "../permissions/types.js"; import type { FileIndexServiceState } from "../services/FileIndexService.js"; import { SERVICE_NAMES, serviceContainer } from "../services/index.js"; import { modeService } from "../services/ModeService.js"; +import { messageQueue } from "../stream/messageQueue.js"; import { InputHistory } from "../util/inputHistory.js"; import { FileSearchUI } from "./FileSearchUI.js"; @@ -515,7 +516,7 @@ const UserInput: React.FC = ({ } // Normal Enter behavior - submit if there's content - if ((textBuffer.text.trim() || wasInterrupted) && !isWaitingForResponse) { + if (textBuffer.text.trim() || wasInterrupted) { // Get images before expanding paste blocks const imageMap = textBuffer.getAllImages(); @@ -523,14 +524,19 @@ const UserInput: React.FC = ({ textBuffer.expandAllPasteBlocks(); const submittedText = textBuffer.text.trim(); - // Only add to history if there's actual text (not when resuming) - if (submittedText) { + if (isWaitingForResponse) { + // Process message later when LLM has responded + void messageQueue.enqueueMessage( + submittedText, + imageMap, + inputHistory, + ); + } else { + // Submit with images inputHistory.addEntry(submittedText); + onSubmit(submittedText, imageMap); } - // Submit with images - onSubmit(submittedText, imageMap); - textBuffer.clear(); setInputText(""); setCursorPosition(0); @@ -647,15 +653,6 @@ const UserInput: React.FC = ({ return; } - // Allow typing during streaming, but block submission - if (!inputMode) { - // Block only Enter key submission during streaming - if (key.return && !key.shift) { - return; - } - // Allow all other input (typing, navigation, etc.) - } - // Handle slash command navigation if (showSlashCommands) { if (handleSlashCommandNavigation(key)) { diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index 9b9cc5871..ed8fa2cd4 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -11,6 +11,7 @@ import { updateSessionHistory, } from "../../session.js"; import { handleSlashCommands } from "../../slashCommands.js"; +import { messageQueue } from "../../stream/messageQueue.js"; import { telemetryService } from "../../telemetry/telemetryService.js"; import { formatError } from "../../util/formatError.js"; import { logger } from "../../util/logger.js"; @@ -306,6 +307,16 @@ export function useChat({ setIsWaitingForResponse(false); setResponseStartTime(null); setInputMode(true); + + // Check if there are queued messages and process them after a microtask delay + // This ensures the GUI state has been updated before processing the next message + const latestQueuedMessage = messageQueue.getLatestMessage()?.message; + if (latestQueuedMessage) { + logger.debug("processing queued message", { latestQueuedMessage }); + await new Promise((resolve) => setTimeout(resolve, 100)); + // Note: InputHistory entry was already added when the message was first submitted + await handleUserMessage(latestQueuedMessage); + } } }; @@ -484,6 +495,8 @@ export function useChat({ const newHistory = [...currentChatHistory, newUserMessage]; setChatHistory(newHistory); + logger.debug("debug1 streaming started again"); + // Execute the streaming response await executeStreamingResponse(newHistory, currentCompactionIndex); }; From 04d680ac006188cc2080d784c46164946c1790aa Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 8 Sep 2025 22:06:43 +0530 Subject: [PATCH 05/15] comment --- extensions/cli/src/ui/hooks/useChat.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index ed8fa2cd4..72467fbf4 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -313,8 +313,7 @@ export function useChat({ const latestQueuedMessage = messageQueue.getLatestMessage()?.message; if (latestQueuedMessage) { logger.debug("processing queued message", { latestQueuedMessage }); - await new Promise((resolve) => setTimeout(resolve, 100)); - // Note: InputHistory entry was already added when the message was first submitted + await new Promise((resolve) => setTimeout(resolve, 100)); // add timeout for react to render the tui await handleUserMessage(latestQueuedMessage); } } From 4c7c2954333592cb6ddfd6b63e05c16f0ada9642 Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Mon, 8 Sep 2025 15:55:03 -0700 Subject: [PATCH 06/15] queued messages show up in chat --- extensions/cli/src/stream/messageQueue.ts | 48 ++++- extensions/cli/src/ui/TUIChat.tsx | 2 + .../src/ui/components/StaticChatContent.tsx | 14 +- extensions/cli/src/ui/hooks/useChat.ts | 169 +++++++++++++----- 4 files changed, 177 insertions(+), 56 deletions(-) diff --git a/extensions/cli/src/stream/messageQueue.ts b/extensions/cli/src/stream/messageQueue.ts index d91f2d398..50e4fb12e 100644 --- a/extensions/cli/src/stream/messageQueue.ts +++ b/extensions/cli/src/stream/messageQueue.ts @@ -1,3 +1,4 @@ +import { EventEmitter } from "events"; import { InputHistory } from "../util/inputHistory.js"; import { logger } from "../util/logger.js"; @@ -14,10 +15,14 @@ export interface MessageProcessor { /** * A queue to store messages that need to be processed later */ -class MessageQueue { +class MessageQueue extends EventEmitter { private queue: QueuedMessage[] = []; private inputHistory: InputHistory | undefined; + constructor() { + super(); + } + async enqueueMessage( message: string, imageMap?: Map, @@ -36,17 +41,48 @@ class MessageQueue { queueLength: this.queue.length, }); + // Emit event for UI to show the queued message + this.emit("messageQueued", queuedMessage); + return true; } - public getLatestMessage() { + public getAllQueuedMessages() { if (this.queue.length === 0) return undefined; - const latestMessage = this.queue.shift(); - logger.debug("MessageQueue: Message dequeued", { + + // Combine all queued messages into one + const combinedMessage = this.queue.map((msg) => msg.message).join("\n"); + const combinedImageMap = new Map(); + + // Merge all image maps + for (const queuedMsg of this.queue) { + if (queuedMsg.imageMap) { + for (const [key, value] of queuedMsg.imageMap) { + combinedImageMap.set(key, value); + } + } + } + + const result = { + message: combinedMessage, + imageMap: combinedImageMap.size > 0 ? combinedImageMap : undefined, + timestamp: Date.now(), + }; + + // Add to input history and clear the queue + this.inputHistory?.addEntry(combinedMessage); + this.queue = []; + + logger.debug("MessageQueue: All messages dequeued and combined", { + combinedLength: combinedMessage.length, queueLength: this.queue.length, }); - this.inputHistory?.addEntry(latestMessage!.message); - return latestMessage; + + return result; + } + + public getLatestMessage() { + return this.getAllQueuedMessages(); } getQueueLength(): number { diff --git a/extensions/cli/src/ui/TUIChat.tsx b/extensions/cli/src/ui/TUIChat.tsx index a60ec85b4..554e36513 100644 --- a/extensions/cli/src/ui/TUIChat.tsx +++ b/extensions/cli/src/ui/TUIChat.tsx @@ -188,6 +188,7 @@ const TUIChat: React.FC = ({ inputMode, activePermissionRequest, wasInterrupted, + queuedMessages, handleUserMessage, handleInterrupt, handleFileAttached, @@ -282,6 +283,7 @@ const TUIChat: React.FC = ({ model={services.model?.model || undefined} mcpService={services.mcp?.mcpService || undefined} chatHistory={chatHistory} + queuedMessages={queuedMessages} renderMessage={renderMessage} refreshTrigger={staticRefreshTrigger} /> diff --git a/extensions/cli/src/ui/components/StaticChatContent.tsx b/extensions/cli/src/ui/components/StaticChatContent.tsx index 4c1c9f133..ee0012a46 100644 --- a/extensions/cli/src/ui/components/StaticChatContent.tsx +++ b/extensions/cli/src/ui/components/StaticChatContent.tsx @@ -1,9 +1,10 @@ import type { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml"; -import { Box, Static, useStdout } from "ink"; +import { Box, Static, Text, useStdout } from "ink"; import React, { useCallback, useEffect, useRef, useState } from "react"; import type { ChatHistoryItem } from "../../../../../core/index.js"; import type { MCPService } from "../../services/MCPService.js"; +import type { QueuedMessage } from "../../stream/messageQueue.js"; import { useTerminalSize } from "../hooks/useTerminalSize.js"; import { IntroMessage } from "../IntroMessage.js"; @@ -13,6 +14,7 @@ interface StaticChatContentProps { model?: ModelConfig; mcpService?: MCPService; chatHistory: ChatHistoryItem[]; + queuedMessages?: QueuedMessage[]; renderMessage: (item: ChatHistoryItem, index: number) => React.ReactElement; refreshTrigger?: number; // Add a prop to trigger refresh from parent } @@ -23,6 +25,7 @@ export const StaticChatContent: React.FC = ({ model, mcpService, chatHistory, + queuedMessages = [], renderMessage, refreshTrigger, }) => { @@ -140,6 +143,15 @@ export const StaticChatContent: React.FC = ({ {item} ))} + + {/* Queued messages - show at bottom with queue indicators */} + {queuedMessages.length > 0 && ( + + + {queuedMessages.map((msg) => msg.message).join("\n")} + + + )} ); }; diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index 72467fbf4..83748d3dd 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -11,7 +11,7 @@ import { updateSessionHistory, } from "../../session.js"; import { handleSlashCommands } from "../../slashCommands.js"; -import { messageQueue } from "../../stream/messageQueue.js"; +import { messageQueue, QueuedMessage } from "../../stream/messageQueue.js"; import { telemetryService } from "../../telemetry/telemetryService.js"; import { formatError } from "../../util/formatError.js"; import { logger } from "../../util/logger.js"; @@ -167,6 +167,22 @@ export function useChat({ // Track interrupted state for resume functionality const [wasInterrupted, setWasInterrupted] = useState(false); + // Track queued messages for immediate display + const [queuedMessages, setQueuedMessages] = useState([]); + + // Set up message queue listeners + useEffect(() => { + const onMessageQueued = (queuedMessage: QueuedMessage) => { + setQueuedMessages((prev) => [...prev, queuedMessage]); + }; + + messageQueue.on("messageQueued", onMessageQueued); + + return () => { + messageQueue.off("messageQueued", onMessageQueued); + }; + }, []); + // Clean up abort controller on unmount useEffect(() => { return () => { @@ -310,11 +326,26 @@ export function useChat({ // Check if there are queued messages and process them after a microtask delay // This ensures the GUI state has been updated before processing the next message - const latestQueuedMessage = messageQueue.getLatestMessage()?.message; - if (latestQueuedMessage) { + const queuedMessageData = messageQueue.getLatestMessage(); + if (queuedMessageData) { + const { message: latestQueuedMessage, imageMap } = queuedMessageData; logger.debug("processing queued message", { latestQueuedMessage }); + + // Clear all queued messages from display since we're processing them all together + setQueuedMessages([]); + + // Add the queued message to chat history so it shows in the GUI + const formattedQueuedMessage = await formatMessageWithFiles( + latestQueuedMessage, + [], // No attached files for queued messages + imageMap, + ); + setChatHistory((prev) => [...prev, formattedQueuedMessage]); + await new Promise((resolve) => setTimeout(resolve, 100)); // add timeout for react to render the tui - await handleUserMessage(latestQueuedMessage); + + // Process the queued message using the internal processing logic without re-adding to history + await processQueuedMessage(latestQueuedMessage, imageMap); } } }; @@ -408,20 +439,11 @@ export function useChat({ .join(""); }; - const handleUserMessage = async ( + const processMessage = async ( message: string, imageMap?: Map, + isQueuedMessage: boolean = false, ) => { - // Check if this is a resume request (empty message after interruption) - if (await handleResumeRequest(message)) { - return; - } - - // Clear interrupted state if user types a new message - if (wasInterrupted && message !== "") { - setWasInterrupted(false); - } - // Handle special commands const handled = await handleSpecialCommands({ message, @@ -450,27 +472,9 @@ export function useChat({ // Track telemetry trackUserMessage(message, model); - // Format message with attached files and images - logger.debug("Processing message with images", { - hasImages: !!(imageMap && imageMap.size > 0), - imageCount: imageMap?.size || 0, - }); - const newUserMessage = await formatMessageWithFiles( - message, - attachedFiles, - imageMap, - ); - logger.debug("Message formatted successfully"); - - if (attachedFiles.length > 0) { - setAttachedFiles([]); - } - // In remote mode, send message to server instead of processing locally if (isRemoteMode && remoteUrl) { - const messageContentString = convertMessageContentToString( - newUserMessage.message.content, - ); + const messageContentString = convertMessageContentToString(message); await handleRemoteMessage({ remoteUrl, @@ -479,25 +483,89 @@ export function useChat({ return; } - // Check if auto-compacting is needed BEFORE adding user message - const { currentChatHistory, currentCompactionIndex } = - await handleAutoCompaction({ - chatHistory, - model, - llmApi, - compactionIndex, - setChatHistory: setChatHistory, - setCompactionIndex, + // For non-queued messages, format and add to chat history + if (!isQueuedMessage) { + // Format message with attached files and images + logger.debug("Processing message with images", { + hasImages: !!(imageMap && imageMap.size > 0), + imageCount: imageMap?.size || 0, }); + const newUserMessage = await formatMessageWithFiles( + message, + attachedFiles, + imageMap, + ); + logger.debug("Message formatted successfully"); - // Add the formatted user message to history - const newHistory = [...currentChatHistory, newUserMessage]; - setChatHistory(newHistory); + if (attachedFiles.length > 0) { + setAttachedFiles([]); + } - logger.debug("debug1 streaming started again"); + // Check if auto-compacting is needed BEFORE adding user message + const { currentChatHistory, currentCompactionIndex } = + await handleAutoCompaction({ + chatHistory, + model, + llmApi, + compactionIndex, + setChatHistory: setChatHistory, + setCompactionIndex, + }); - // Execute the streaming response - await executeStreamingResponse(newHistory, currentCompactionIndex); + // Add the formatted user message to history + const newHistory = [...currentChatHistory, newUserMessage]; + setChatHistory(newHistory); + + logger.debug("debug1 streaming started again"); + + // Execute the streaming response + await executeStreamingResponse(newHistory, currentCompactionIndex); + } else { + // For queued messages, chat history is already updated + // Check if auto-compacting is needed with current history + const { currentChatHistory, currentCompactionIndex } = + await handleAutoCompaction({ + chatHistory, + model, + llmApi, + compactionIndex, + setChatHistory: setChatHistory, + setCompactionIndex, + }); + + // Execute the streaming response with the current history (which already includes the queued message) + await executeStreamingResponse( + currentChatHistory, + currentCompactionIndex, + ); + } + }; + + const processQueuedMessage = async ( + message: string, + imageMap?: Map, + ) => { + // For queued messages, we can reuse the core message processing logic + // by calling the internal processing function directly + await processMessage(message, imageMap, true); + }; + + const handleUserMessage = async ( + message: string, + imageMap?: Map, + ) => { + // Check if this is a resume request (empty message after interruption) + if (await handleResumeRequest(message)) { + return; + } + + // Clear interrupted state if user types a new message + if (wasInterrupted && message !== "") { + setWasInterrupted(false); + } + + // Use the common message processing logic + await processMessage(message, imageMap, false); }; const handleInterrupt = () => { @@ -549,6 +617,8 @@ export function useChat({ additionalRules, ); setChatHistory(newHistory); + // Clear any queued messages when resetting chat + setQueuedMessages([]); }; const handleToolPermissionResponse = async ( @@ -626,6 +696,7 @@ export function useChat({ attachedFiles, activePermissionRequest, wasInterrupted, + queuedMessages, handleUserMessage, handleInterrupt, handleFileAttached, From 2377a791d0d68d95144351a4c534310edacebf9c Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Wed, 10 Sep 2025 18:31:32 +0530 Subject: [PATCH 07/15] remove log and fix eslint --- extensions/cli/src/ui/hooks/useChat.ts | 40 ++++++++++++-------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index 83748d3dd..6d2c98ad1 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -484,7 +484,25 @@ export function useChat({ } // For non-queued messages, format and add to chat history - if (!isQueuedMessage) { + if (isQueuedMessage) { + // For queued messages, chat history is already updated + // Check if auto-compacting is needed with current history + const { currentChatHistory, currentCompactionIndex } = + await handleAutoCompaction({ + chatHistory, + model, + llmApi, + compactionIndex, + setChatHistory: setChatHistory, + setCompactionIndex, + }); + + // Execute the streaming response with the current history (which already includes the queued message) + await executeStreamingResponse( + currentChatHistory, + currentCompactionIndex, + ); + } else { // Format message with attached files and images logger.debug("Processing message with images", { hasImages: !!(imageMap && imageMap.size > 0), @@ -516,28 +534,8 @@ export function useChat({ const newHistory = [...currentChatHistory, newUserMessage]; setChatHistory(newHistory); - logger.debug("debug1 streaming started again"); - // Execute the streaming response await executeStreamingResponse(newHistory, currentCompactionIndex); - } else { - // For queued messages, chat history is already updated - // Check if auto-compacting is needed with current history - const { currentChatHistory, currentCompactionIndex } = - await handleAutoCompaction({ - chatHistory, - model, - llmApi, - compactionIndex, - setChatHistory: setChatHistory, - setCompactionIndex, - }); - - // Execute the streaming response with the current history (which already includes the queued message) - await executeStreamingResponse( - currentChatHistory, - currentCompactionIndex, - ); } }; From 9cc3d69e4dfc467fefd9cd98b90ed9be64df8468 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 10 Sep 2025 18:15:23 -0700 Subject: [PATCH 08/15] fix: edit impl --- .../redux/thunks/handleApplyStateUpdate.ts | 27 +++++++++++++++++++ gui/src/util/clientTools/editImpl.ts | 14 +++------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/gui/src/redux/thunks/handleApplyStateUpdate.ts b/gui/src/redux/thunks/handleApplyStateUpdate.ts index 25532e750..1a28cc3d4 100644 --- a/gui/src/redux/thunks/handleApplyStateUpdate.ts +++ b/gui/src/redux/thunks/handleApplyStateUpdate.ts @@ -89,6 +89,33 @@ export const handleApplyStateUpdate = createAsyncThunk< toolCallId: applyState.toolCallId, }), ); + dispatch( + updateToolCallOutput({ + toolCallId: applyState.toolCallId, + contextItems: [ + { + name: "Edit Success", + content: `Successfully edited ${applyState.filepath}`, + description: "", + hidden: true, + }, + ], + }), + ); + } else { + dispatch( + updateToolCallOutput({ + toolCallId: applyState.toolCallId, + contextItems: [ + { + name: "Edit Failed", + content: `Failed to edited ${applyState.filepath}. To continue working with the file, read it again to see the most up-to-date contents`, + description: "", + hidden: true, + }, + ], + }), + ); } void dispatch( diff --git a/gui/src/util/clientTools/editImpl.ts b/gui/src/util/clientTools/editImpl.ts index cefc6832f..967b3cc8d 100644 --- a/gui/src/util/clientTools/editImpl.ts +++ b/gui/src/util/clientTools/editImpl.ts @@ -17,13 +17,13 @@ export const editToolImpl: ClientToolImpl = async ( filepath = filepath.slice(2); } - const openFiles = await extras.ideMessenger.ide.getOpenFiles(); let firstUriMatch = await resolveRelativePathInDir( filepath, extras.ideMessenger.ide, ); - + if (!firstUriMatch) { + const openFiles = await extras.ideMessenger.ide.getOpenFiles(); for (const uri of openFiles) { if (uri.endsWith(filepath)) { firstUriMatch = uri; @@ -46,13 +46,7 @@ export const editToolImpl: ClientToolImpl = async ( ); return { - respondImmediately: true, - output: [ - { - name: "File edited successfully", - content: `Successfully initiated edit for ${firstUriMatch}`, - description: "File edit operation started", - }, - ], + respondImmediately: false, + output: undefined, // no immediate output - output for edit tools should be added based on apply state coming in }; }; From 0136215913e572bbd4ee3ffa81b93bf4456a946e Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 10 Sep 2025 18:20:12 -0700 Subject: [PATCH 09/15] fix: prettier --- gui/src/util/clientTools/editImpl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/util/clientTools/editImpl.ts b/gui/src/util/clientTools/editImpl.ts index 967b3cc8d..ccc7cc3fa 100644 --- a/gui/src/util/clientTools/editImpl.ts +++ b/gui/src/util/clientTools/editImpl.ts @@ -21,7 +21,7 @@ export const editToolImpl: ClientToolImpl = async ( filepath, extras.ideMessenger.ide, ); - + if (!firstUriMatch) { const openFiles = await extras.ideMessenger.ide.getOpenFiles(); for (const uri of openFiles) { From d9dbbe636af8c3b756443c0681af5849b652f94d Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 10 Sep 2025 19:05:05 -0700 Subject: [PATCH 10/15] Update gui/src/redux/thunks/handleApplyStateUpdate.ts Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- gui/src/redux/thunks/handleApplyStateUpdate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/redux/thunks/handleApplyStateUpdate.ts b/gui/src/redux/thunks/handleApplyStateUpdate.ts index 1a28cc3d4..5080b13c2 100644 --- a/gui/src/redux/thunks/handleApplyStateUpdate.ts +++ b/gui/src/redux/thunks/handleApplyStateUpdate.ts @@ -109,7 +109,7 @@ export const handleApplyStateUpdate = createAsyncThunk< contextItems: [ { name: "Edit Failed", - content: `Failed to edited ${applyState.filepath}. To continue working with the file, read it again to see the most up-to-date contents`, + content: `Failed to edit ${applyState.filepath}. To continue working with the file, read it again to see the most up-to-date contents`, description: "", hidden: true, }, From a3e6b9b136f5b25e1b0de0a471ca8315d531ad1b Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 10 Sep 2025 21:44:11 -0700 Subject: [PATCH 11/15] chore: format --- extensions/vscode/src/diff/processDiff.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/src/diff/processDiff.ts b/extensions/vscode/src/diff/processDiff.ts index eda40e162..cbff6f4a3 100644 --- a/extensions/vscode/src/diff/processDiff.ts +++ b/extensions/vscode/src/diff/processDiff.ts @@ -70,7 +70,7 @@ export async function processDiff( // Auto-formatting was applied by the editor const diffLines = myersDiff(preSaveContent, postSaveContent); autoFormattingDiff = diffLines - .map(line => { + .map((line) => { switch (line.type) { case "old": return `-${line.line}`; From fc3e72dfe1c624ef5f2776e4cf83a6d2c54b578e Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 11 Sep 2025 12:50:05 +0530 Subject: [PATCH 12/15] feat: do not show context fill display when model changes --- .../components/mainInput/ContextStatus.tsx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gui/src/components/mainInput/ContextStatus.tsx b/gui/src/components/mainInput/ContextStatus.tsx index 4ed048d86..abf06c19c 100644 --- a/gui/src/components/mainInput/ContextStatus.tsx +++ b/gui/src/components/mainInput/ContextStatus.tsx @@ -1,3 +1,4 @@ +import { useMemo, useRef } from "react"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { saveCurrentSession } from "../../redux/thunks/session"; import { useCompactConversation } from "../../util/compactConversation"; @@ -8,15 +9,36 @@ const ContextStatus = () => { const contextPercentage = useAppSelector( (state) => state.session.contextPercentage, ); + const selectedChatModel = useAppSelector( + (state) => state.config.config.selectedModelByRole.chat?.model, + ); + const previousHistoryLength = useRef(null); + const previousSelectedChatModel = useRef(null); const history = useAppSelector((state) => state.session.history); const percent = Math.round((contextPercentage ?? 0) * 100); const isPruned = useAppSelector((state) => state.session.isPruned); + const isDifferentModelAndSameHistory = useMemo(() => { + if (!selectedChatModel) return false; + // only reset if history changes + if (previousHistoryLength.current !== history.length) { + previousHistoryLength.current = history.length; + previousSelectedChatModel.current = selectedChatModel; + return false; + } + return previousSelectedChatModel.current !== selectedChatModel; + }, [history.length, selectedChatModel]); + const compactConversation = useCompactConversation(); if (!isPruned && percent < 60) { return null; } + // if user changed to a different model, we shouldn't show the context status until the user sends a new message + if (isDifferentModelAndSameHistory) { + return null; + } + const barColorClass = isPruned ? "bg-error" : "bg-description"; return ( From cda58d24678031b8def0a38305b112c9585ec52c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Sep 2025 09:09:21 +0000 Subject: [PATCH 13/15] build(deps): bump continuedev/continue from 1.4.38 to 1.4.39 Bumps [continuedev/continue](https://github.com/continuedev/continue) from 1.4.38 to 1.4.39. - [Release notes](https://github.com/continuedev/continue/releases) - [Commits](https://github.com/continuedev/continue/compare/b3f4b82600f603ca28c65a319b80ec36c4644ed7...5dc7a050db441934c26eb910b8433291f627db7f) --- updated-dependencies: - dependency-name: continuedev/continue dependency-version: 1.4.39 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/continue-detailed-review.yaml | 2 +- .github/workflows/continue-general-review.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continue-detailed-review.yaml b/.github/workflows/continue-detailed-review.yaml index f718deeca..45ad818d1 100644 --- a/.github/workflows/continue-detailed-review.yaml +++ b/.github/workflows/continue-detailed-review.yaml @@ -18,7 +18,7 @@ jobs: timeout-minutes: 10 steps: - name: Run Detailed PR Review - uses: continuedev/continue/actions/detailed-review@b3f4b82600f603ca28c65a319b80ec36c4644ed7 + uses: continuedev/continue/actions/detailed-review@5dc7a050db441934c26eb910b8433291f627db7f with: continue-api-key: ${{ secrets.CONTINUE_API_KEY }} continue-org: continuedev diff --git a/.github/workflows/continue-general-review.yaml b/.github/workflows/continue-general-review.yaml index 01fffa316..16a5af935 100644 --- a/.github/workflows/continue-general-review.yaml +++ b/.github/workflows/continue-general-review.yaml @@ -18,7 +18,7 @@ jobs: timeout-minutes: 10 steps: - name: Run Continue PR Review Action - uses: continuedev/continue/actions/general-review@b3f4b82600f603ca28c65a319b80ec36c4644ed7 + uses: continuedev/continue/actions/general-review@5dc7a050db441934c26eb910b8433291f627db7f with: continue-api-key: ${{ secrets.CONTINUE_API_KEY }} continue-org: "continuedev" From 49655ef7d9511ac0eddff97ffc1ee664c0d634d3 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 11 Sep 2025 19:09:52 +0530 Subject: [PATCH 14/15] fix lint --- extensions/cli/src/stream/messageQueue.ts | 1 + extensions/cli/src/ui/hooks/useChat.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/extensions/cli/src/stream/messageQueue.ts b/extensions/cli/src/stream/messageQueue.ts index 50e4fb12e..3703a4644 100644 --- a/extensions/cli/src/stream/messageQueue.ts +++ b/extensions/cli/src/stream/messageQueue.ts @@ -1,4 +1,5 @@ import { EventEmitter } from "events"; + import { InputHistory } from "../util/inputHistory.js"; import { logger } from "../util/logger.js"; diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index 6d2c98ad1..37ce38266 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-lines */ import type { ChatHistoryItem, Session } from "core/index.js"; import { useApp } from "ink"; import { useEffect, useRef, useState } from "react"; From 878464fcacf79defb55a175ea02b79f3c0968e4a Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 11 Sep 2025 19:36:30 +0530 Subject: [PATCH 15/15] add tests --- .../cli/src/stream/messageQueue.test.ts | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 extensions/cli/src/stream/messageQueue.test.ts diff --git a/extensions/cli/src/stream/messageQueue.test.ts b/extensions/cli/src/stream/messageQueue.test.ts new file mode 100644 index 000000000..8646258aa --- /dev/null +++ b/extensions/cli/src/stream/messageQueue.test.ts @@ -0,0 +1,62 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +vi.mock("../util/logger.js", () => ({ + logger: { + debug: vi.fn(), + info: vi.fn(), + warn: vi.fn(), + error: vi.fn(), + setLevel: vi.fn(), + configureHeadlessMode: vi.fn(), + getLogPath: vi.fn(), + getSessionId: vi.fn(), + }, +})); + +import { messageQueue } from "./messageQueue.js"; + +describe("messageQueue", () => { + beforeEach(() => { + // Drain any leftover items from previous tests + while (messageQueue.getAllQueuedMessages()) {} + }); + + it("enqueues and emits messageQueued", async () => { + const event = new Promise((resolve) => + messageQueue.once("messageQueued", resolve), + ); + + const ok = await messageQueue.enqueueMessage("hello world"); + expect(ok).toBe(true); + expect(messageQueue.getQueueLength()).toBe(1); + + const queued = await event; + expect(queued.message).toBe("hello world"); + }); + + it("combines messages, merges image maps, writes history, and clears queue", async () => { + const bufA = Buffer.from("A"); + const bufB = Buffer.from("B"); + + const img1 = new Map([["a", bufA]]); + const img2 = new Map([["b", bufB]]); + + const history = { addEntry: vi.fn() } as any; + + await messageQueue.enqueueMessage("one", img1); + await messageQueue.enqueueMessage("two", img2, history); + + const combined = messageQueue.getAllQueuedMessages(); + expect(combined).toBeTruthy(); + expect(combined!.message).toBe("one\ntwo"); + expect(combined!.imageMap).toBeDefined(); + expect(combined!.imageMap!.get("a")).toEqual(bufA); + expect(combined!.imageMap!.get("b")).toEqual(bufB); + + // queue should be cleared + expect(messageQueue.getQueueLength()).toBe(0); + + // input history should receive the combined message + expect(history.addEntry).toHaveBeenCalledWith("one\ntwo"); + }); +});