From bad857a71e46e25c2edbe8e0a4099e5860c8d9ba Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:46:05 -0700 Subject: [PATCH 01/31] feat: return usage for openai providers --- packages/openai-adapters/src/apis/Gemini.ts | 31 ++++++++- packages/openai-adapters/src/apis/Relace.ts | 27 +++++++- .../openai-adapters/src/test/main.test.ts | 65 +++++++++++++++++-- 3 files changed, 112 insertions(+), 11 deletions(-) diff --git a/packages/openai-adapters/src/apis/Gemini.ts b/packages/openai-adapters/src/apis/Gemini.ts index c9c29fb9e..51d96f720 100644 --- a/packages/openai-adapters/src/apis/Gemini.ts +++ b/packages/openai-adapters/src/apis/Gemini.ts @@ -22,6 +22,7 @@ import { chatChunkFromDelta, customFetch, embedding, + usageChatChunk, } from "../util.js"; import { convertOpenAIToolToGeminiFunction, @@ -37,6 +38,8 @@ import { RerankCreateParams, } from "./base.js"; +type UsageInfo = { total_tokens: number; completion_tokens: number; prompt_tokens: number }; + export class GeminiApi implements BaseLlmApi { apiBase: string = "https://generativelanguage.googleapis.com/v1beta/"; @@ -240,6 +243,7 @@ export class GeminiApi implements BaseLlmApi { signal: AbortSignal, ): Promise { let completion = ""; + let usage: UsageInfo | undefined = undefined; for await (const chunk of this.chatCompletionStream( { ...body, @@ -247,7 +251,12 @@ export class GeminiApi implements BaseLlmApi { }, signal, )) { - completion += chunk.choices[0].delta.content; + if (chunk.choices.length > 0) { + completion += chunk.choices[0].delta.content || ""; + } + if (chunk.usage) { + usage = chunk.usage; + } } return { id: "", @@ -266,12 +275,13 @@ export class GeminiApi implements BaseLlmApi { }, }, ], - usage: undefined, + usage, }; } async *handleStreamResponse(response: any, model: string) { let buffer = ""; + let usage: UsageInfo | undefined = undefined; for await (const chunk of streamResponse(response as any)) { buffer += chunk; if (buffer.startsWith("[")) { @@ -300,6 +310,15 @@ export class GeminiApi implements BaseLlmApi { throw new Error(data.error.message); } + // Check for usage metadata + if (data.usageMetadata) { + usage = { + prompt_tokens: data.usageMetadata.promptTokenCount || 0, + completion_tokens: data.usageMetadata.candidatesTokenCount || 0, + total_tokens: data.usageMetadata.totalTokenCount || 0, + }; + } + // In case of max tokens reached, gemini will sometimes return content with no parts, even though that doesn't match the API spec const contentParts = data?.candidates?.[0]?.content?.parts; if (contentParts) { @@ -338,6 +357,14 @@ export class GeminiApi implements BaseLlmApi { buffer = ""; } } + + // Emit usage at the end if we have it + if (usage) { + yield usageChatChunk({ + model, + usage, + }); + } } async *chatCompletionStream( diff --git a/packages/openai-adapters/src/apis/Relace.ts b/packages/openai-adapters/src/apis/Relace.ts index e983a9968..618917d22 100644 --- a/packages/openai-adapters/src/apis/Relace.ts +++ b/packages/openai-adapters/src/apis/Relace.ts @@ -16,7 +16,12 @@ import { import { Model } from "openai/resources/models.mjs"; import { z } from "zod"; import { OpenAIConfigSchema } from "../types.js"; -import { chatChunk, chatCompletion, customFetch } from "../util.js"; +import { + chatChunk, + chatCompletion, + customFetch, + usageChatChunk, +} from "../util.js"; import { BaseLlmApi, CreateRerankResponse, @@ -24,6 +29,8 @@ import { RerankCreateParams, } from "./base.js"; +type UsageInfo = { total_tokens: number; completion_tokens: number; prompt_tokens: number }; + // Relace only supports apply through a /v1/apply endpoint export class RelaceApi implements BaseLlmApi { private apiBase = "https://instantapply.endpoint.relace.run/v1/"; @@ -41,6 +48,7 @@ export class RelaceApi implements BaseLlmApi { signal: AbortSignal, ): Promise { let content = ""; + let usage: UsageInfo | undefined = undefined; // Convert the non-streaming params to streaming params const streamingBody: ChatCompletionCreateParamsStreaming = { @@ -52,12 +60,18 @@ export class RelaceApi implements BaseLlmApi { streamingBody, signal, )) { - content += chunk.choices[0]?.delta?.content || ""; + if (chunk.choices.length > 0) { + content += chunk.choices[0]?.delta?.content || ""; + } + if (chunk.usage) { + usage = chunk.usage; + } } return chatCompletion({ content, model: body.model, + usage, }); } @@ -115,6 +129,15 @@ export class RelaceApi implements BaseLlmApi { content: mergedCode, model: body.model, }); + + yield usageChatChunk({ + model: body.model, + usage: { + prompt_tokens: result.usage.prompt_tokens || 0, + completion_tokens: result.usage.completion_tokens || 0, + total_tokens: result.usage.total_tokens, + }, + }); } completionNonStream( diff --git a/packages/openai-adapters/src/test/main.test.ts b/packages/openai-adapters/src/test/main.test.ts index 4e477c53d..0652c36b4 100644 --- a/packages/openai-adapters/src/test/main.test.ts +++ b/packages/openai-adapters/src/test/main.test.ts @@ -51,6 +51,20 @@ const TESTS: Omit[] = [ model: "gpt-4o", apiKey: process.env.OPENAI_API_KEY!, roles: ["chat"], + options: { + skipTools: false, + expectUsage: true, + }, + }, + { + provider: "openai", + model: "gpt-4o-mini", + apiKey: process.env.OPENAI_API_KEY!, + roles: ["chat"], + options: { + skipTools: false, + expectUsage: true, + }, }, { provider: "anthropic", @@ -67,14 +81,31 @@ const TESTS: Omit[] = [ model: "gemini-1.5-flash-latest", apiKey: process.env.GEMINI_API_KEY!, roles: ["chat"], + options: { + skipTools: false, + expectUsage: true, + }, + }, + { + provider: "gemini", + model: "gemini-2.5-flash", + apiKey: process.env.GEMINI_API_KEY!, + roles: ["chat"], + options: { + skipTools: false, + expectUsage: true, + }, + }, + { + provider: "mistral", + model: "codestral", + apiKey: process.env.MISTRAL_API_KEY!, + roles: ["chat"], + options: { + skipTools: false, + expectUsage: true, + }, }, - // { - // provider: "mistral", - // model: "codestral-latest", - // apiKey: process.env.MISTRAL_API_KEY!, - // apiBase: "https://api.mistral.ai/v1", - // roles: ["autocomplete"], - // }, // { // provider: "deepseek", // model: "deepseek-coder", @@ -111,6 +142,26 @@ const TESTS: Omit[] = [ apiKey: process.env.VOYAGE_API_KEY!, roles: ["rerank"], }, + { + provider: "relace", + model: "instant-apply", + apiKey: process.env.RELACE_API_KEY!, + roles: ["chat"], + options: { + skipTools: true, + expectUsage: true, + }, + }, + { + provider: "inception", + model: "mercury-coder", + apiKey: process.env.INCEPTION_API_KEY!, + roles: ["chat"], + options: { + skipTools: false, + expectUsage: true, + }, + }, // { // provider: "cohere", // model: "rerank-v3.5", From 7e484ed31d4749cd9495d27910e8d77f00bfad13 Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Thu, 28 Aug 2025 13:15:01 -0700 Subject: [PATCH 02/31] fix --- packages/openai-adapters/src/apis/Gemini.ts | 6 +++++- packages/openai-adapters/src/apis/Relace.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/openai-adapters/src/apis/Gemini.ts b/packages/openai-adapters/src/apis/Gemini.ts index 51d96f720..2f2446414 100644 --- a/packages/openai-adapters/src/apis/Gemini.ts +++ b/packages/openai-adapters/src/apis/Gemini.ts @@ -38,7 +38,11 @@ import { RerankCreateParams, } from "./base.js"; -type UsageInfo = { total_tokens: number; completion_tokens: number; prompt_tokens: number }; +type UsageInfo = { + total_tokens: number; + completion_tokens: number; + prompt_tokens: number; +}; export class GeminiApi implements BaseLlmApi { apiBase: string = "https://generativelanguage.googleapis.com/v1beta/"; diff --git a/packages/openai-adapters/src/apis/Relace.ts b/packages/openai-adapters/src/apis/Relace.ts index 618917d22..c2799d376 100644 --- a/packages/openai-adapters/src/apis/Relace.ts +++ b/packages/openai-adapters/src/apis/Relace.ts @@ -29,7 +29,11 @@ import { RerankCreateParams, } from "./base.js"; -type UsageInfo = { total_tokens: number; completion_tokens: number; prompt_tokens: number }; +type UsageInfo = { + total_tokens: number; + completion_tokens: number; + prompt_tokens: number; +}; // Relace only supports apply through a /v1/apply endpoint export class RelaceApi implements BaseLlmApi { From c7ffe89be36056c85069d60bfdecc1833a540434 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 2 Sep 2025 19:17:49 -0700 Subject: [PATCH 03/31] feat: bash mode --- extensions/cli/package-lock.json | 6 - extensions/cli/spec/bash-mode.md | 64 +++++++++++ extensions/cli/src/slashCommands.ts | 3 + .../cli/src/tools/runTerminalCommand.ts | 9 +- extensions/cli/src/ui/UserInput.tsx | 48 +++++++- .../cli/src/ui/hooks/useChat.bashMode.test.ts | 108 ++++++++++++++++++ extensions/cli/src/ui/hooks/useChat.ts | 53 +++++++++ extensions/cli/src/ui/hooks/useUserInput.ts | 3 + 8 files changed, 281 insertions(+), 13 deletions(-) create mode 100644 extensions/cli/spec/bash-mode.md create mode 100644 extensions/cli/src/ui/hooks/useChat.bashMode.test.ts diff --git a/extensions/cli/package-lock.json b/extensions/cli/package-lock.json index d52b3f219..6510bc717 100644 --- a/extensions/cli/package-lock.json +++ b/extensions/cli/package-lock.json @@ -9,12 +9,6 @@ "version": "0.0.0-dev", "license": "Apache-2.0", "dependencies": { - "@img/sharp-darwin-arm64": "^0.33.5", - "@img/sharp-darwin-x64": "^0.33.5", - "@img/sharp-linux-arm": "^0.33.5", - "@img/sharp-linux-arm64": "^0.33.5", - "@img/sharp-linux-x64": "^0.33.5", - "@img/sharp-win32-x64": "^0.33.5", "@sentry/profiling-node": "^9.43.0" }, "bin": { diff --git a/extensions/cli/spec/bash-mode.md b/extensions/cli/spec/bash-mode.md new file mode 100644 index 000000000..cbf99c9fe --- /dev/null +++ b/extensions/cli/spec/bash-mode.md @@ -0,0 +1,64 @@ +Bash Mode (CLI TUI) + +Overview +- Bash mode lets users run shell commands directly from the chat input by starting their input with an exclamation mark (!). +- It is intended for quick terminal command execution without leaving the TUI. + +Activation +- Bash mode is activated when the current input (trimmed) starts with ! + - Example: "!git status" or " !ls -la" both activate Bash mode. +- Visual indicator: + - Input border color changes to yellow. + - The input prompt indicator changes to a yellow "$". + - The input placeholder includes "! for bash mode". + +Deactivation / Exiting Bash Mode +- Pressing Enter to submit the input exits bash mode immediately after submission, regardless of the command result. +- Pressing Esc when the input (trimmed) is exactly ! clears the input and exits bash mode. +- Editing the input so it no longer starts with ! also exits bash mode and restores normal input behavior. + +Interaction with other input helpers +- When in bash mode (input starts with !): + - "@" file search suggestions are disabled. + - "/" slash command UI is disabled. +- When in slash command mode (input starts with /): + - "@" file search suggestions are disabled. + +Submission behavior +- On submit (Enter) with a bash-mode input: + - The leading ! is removed and the remainder is treated as the shell command to run. + - The TUI immediately appends an assistant message representing a Bash tool call, with status set to calling, so users can see that the command is in progress. + - The bash command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated. + +Execution semantics +- The command is executed from the current working directory of the CLI process. +- The command runs in the user’s shell as a login shell: + - Unix/macOS: SHELL (or /bin/bash) invoked with -l -c "". + - Windows: powershell.exe -NoLogo -ExecutionPolicy Bypass -Command "". +- The child process stdin is detached (not connected to the TTY). This prevents the TUI from being suspended by job control. Consequences: + - Interactive commands that require stdin will not work. +- Environment variables are inherited from the parent process. Aliases/functions availability depends on the user’s shell configuration and is not guaranteed. + +Output handling +- Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success. +- If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown. +- Output is truncated to the first 5000 lines if exceeded. +- Timeout behavior: If no output is received for 30 seconds (configurable in tests), the process is terminated and the result includes a note like: + "[Command timed out after 30 seconds of no output]". + +Keyboard behaviors (summary) +- Enter: submit input. If in bash mode, exits bash mode after submission and shows the pending Bash tool call immediately. +- Shift+Enter: new line. +- Backslash (\) at end-of-line: inserts a new line (line continuation) as usual. +- Esc: if only ! (trimmed) is present, clears input and exits bash mode; otherwise cancels streaming or closes suggestions depending on context. + +Scope / Modes +- Bash mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing. + +Error handling +- Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available). + +Examples +- "!git status" → shows a Bash tool call immediately, then populates with the git status output. +- "!echo hello" → shows a Bash tool call immediately, then output "hello". +- "!some-unknown-cmd" → shows a Bash tool call immediately, then sets status to error with an error message. diff --git a/extensions/cli/src/slashCommands.ts b/extensions/cli/src/slashCommands.ts index b5dc3d9aa..1c34c58fa 100644 --- a/extensions/cli/src/slashCommands.ts +++ b/extensions/cli/src/slashCommands.ts @@ -28,6 +28,7 @@ async function handleHelp(_args: string[], _assistant: AssistantConfig) { ` ${chalk.cyan("Enter")} Submit message`, ` ${chalk.cyan("Shift+Enter")} New line`, ` ${chalk.cyan("\\")} Line continuation (at end of line)`, + ` ${chalk.cyan("!")} Bash mode - run shell commands`, "", chalk.white("Controls:"), ` ${chalk.cyan("Ctrl+C")} Clear input`, @@ -39,9 +40,11 @@ async function handleHelp(_args: string[], _assistant: AssistantConfig) { chalk.white("Special Characters:"), ` ${chalk.cyan("@")} Search and attach files for context`, ` ${chalk.cyan("/")} Access slash commands`, + ` ${chalk.cyan("!")} Execute bash commands directly`, "", chalk.white("Available Commands:"), ` Type ${chalk.cyan("/")} to see available slash commands`, + ` Type ${chalk.cyan("!")} followed by a command to execute bash directly`, ].join("\n"); posthogService.capture("useSlashCommand", { name: "help" }); return { output: helpMessage }; diff --git a/extensions/cli/src/tools/runTerminalCommand.ts b/extensions/cli/src/tools/runTerminalCommand.ts index 9aefceb9b..242ecdeea 100644 --- a/extensions/cli/src/tools/runTerminalCommand.ts +++ b/extensions/cli/src/tools/runTerminalCommand.ts @@ -17,7 +17,7 @@ function getShellCommand(command: string): { shell: string; args: string[] } { args: ["-NoLogo", "-ExecutionPolicy", "Bypass", "-Command", command], }; } else { - // Unix/macOS: Use login shell to source .bashrc/.zshrc etc. + // Unix/macOS: Just run the user's shell as a login shell const userShell = process.env.SHELL || "/bin/bash"; return { shell: userShell, args: ["-l", "-c", command] }; } @@ -60,7 +60,12 @@ The command will be executed from the current working directory: ${process.cwd() return new Promise((resolve, reject) => { // Use same shell logic as core implementation const { shell, args } = getShellCommand(command); - const child = spawn(shell, args); + const child = spawn(shell, args, { + cwd: process.cwd(), + env: process.env, + stdio: ["ignore", "pipe", "pipe"], // prevent child from reading TTY input + detached: false, + }); let stdout = ""; let stderr = ""; let timeoutId: NodeJS.Timeout; diff --git a/extensions/cli/src/ui/UserInput.tsx b/extensions/cli/src/ui/UserInput.tsx index be24ccb52..e022e3cc3 100644 --- a/extensions/cli/src/ui/UserInput.tsx +++ b/extensions/cli/src/ui/UserInput.tsx @@ -69,6 +69,7 @@ const UserInput: React.FC = ({ const [showSlashCommands, setShowSlashCommands] = useState(false); const [slashCommandFilter, setSlashCommandFilter] = useState(""); const [selectedCommandIndex, setSelectedCommandIndex] = useState(0); + const [showBashMode, setShowBashMode] = useState(false); const [showFileSearch, setShowFileSearch] = useState(false); const [fileSearchFilter, setFileSearchFilter] = useState(""); const [selectedFileIndex, setSelectedFileIndex] = useState(0); @@ -118,6 +119,18 @@ const UserInput: React.FC = ({ return nextMode; }; + // Update bash mode state based on input + const updateBashModeState = (text: string) => { + const trimmed = text.trimStart(); + const isBash = trimmed.startsWith("!"); + setShowBashMode(isBash); + if (isBash) { + // Disable other helpers while in bash mode + setShowSlashCommands(false); + setShowFileSearch(false); + } + }; + // Update slash command UI state based on input const updateSlashCommandState = (text: string, cursor: number) => { // Only show slash commands if slash is the very first character @@ -126,6 +139,9 @@ const UserInput: React.FC = ({ return; } + // When using slash commands, disable file search + setShowFileSearch(false); + const trimmedText = text.trimStart(); const beforeCursor = trimmedText.slice( 0, @@ -188,6 +204,13 @@ const UserInput: React.FC = ({ return; } + // Disable file search if we're in bash mode or slash command mode + const trimmed = text.trimStart(); + if (trimmed.startsWith("!") || trimmed.startsWith("/")) { + setShowFileSearch(false); + return; + } + // Check if we're in a file search context const beforeCursor = text.slice(0, cursor); const lastAtIndex = beforeCursor.lastIndexOf("@"); @@ -226,6 +249,7 @@ const UserInput: React.FC = ({ setFileSearchFilter(afterAt); setSelectedFileIndex(0); setShowSlashCommands(false); + setShowBashMode(false); } } }; @@ -270,6 +294,7 @@ const UserInput: React.FC = ({ setInputText(newText); setCursorPosition(newCursorPos); setShowSlashCommands(false); + setShowBashMode(false); } }; @@ -429,6 +454,7 @@ const UserInput: React.FC = ({ setInputText(""); setCursorPosition(0); setShowSlashCommands(false); + setShowBashMode(false); } return true; } @@ -454,6 +480,15 @@ const UserInput: React.FC = ({ const handleEscapeKey = (key: any): boolean => { if (!key.escape) return false; + // If only "!" is present, clear bash mode + if (inputMode && showBashMode && inputText.trim() === "!") { + textBuffer.clear(); + setInputText(""); + setCursorPosition(0); + setShowBashMode(false); + return true; + } + // Handle escape key to interrupt streaming if (isWaitingForResponse && onInterrupt) { onInterrupt(); @@ -482,6 +517,7 @@ const UserInput: React.FC = ({ setCursorPosition(0); setShowSlashCommands(false); setShowFileSearch(false); + setShowBashMode(false); inputHistory.resetNavigation(); }; @@ -493,6 +529,7 @@ const UserInput: React.FC = ({ setCursorPosition(newCursor); updateSlashCommandState(newText, newCursor); updateFileSearchState(newText, newCursor); + updateBashModeState(newText); inputHistory.resetNavigation(); }; @@ -573,14 +610,15 @@ const UserInput: React.FC = ({ setCursorPosition, updateSlashCommandState, updateFileSearchState, + updateBashModeState, inputHistory, }); }); const renderInputText = () => { const placeholderText = isRemoteMode - ? "Ask anything, / for slash commands" - : placeholder || "Ask anything, @ for context, / for slash commands"; + ? "Ask anything, / for slash commands, ! for bash mode" + : placeholder || "Ask anything, @ for context, / for slash commands, ! for bash mode"; if (inputText.length === 0) { return ( <> @@ -677,10 +715,10 @@ const UserInput: React.FC = ({ borderStyle="round" borderTop={true} paddingX={1} - borderColor={isRemoteMode ? "cyan" : "gray"} + borderColor={showBashMode ? "yellow" : isRemoteMode ? "cyan" : "gray"} > - - {isRemoteMode ? "◉" : "●"}{" "} + + {showBashMode ? "$" : isRemoteMode ? "◉" : "●"} {renderInputText()} diff --git a/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts b/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts new file mode 100644 index 000000000..89105cd4e --- /dev/null +++ b/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts @@ -0,0 +1,108 @@ +import { describe, it, expect, vi, beforeEach } from "vitest"; +import { act } from "@testing-library/react"; + +import { createMinimalTestContext } from "../../test-helpers/ui-test-context.js"; + +// Mock the runTerminalCommandTool +vi.mock("../../tools/runTerminalCommand.js", () => ({ + runTerminalCommandTool: { + run: vi.fn(), + }, +})); + +import { useChat } from "./useChat.js"; +import { runTerminalCommandTool } from "../../tools/runTerminalCommand.js"; + +describe("useChat - Bash Mode", () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + it("should detect bash mode when message starts with !", async () => { + const mockRun = vi.mocked(runTerminalCommandTool.run); + mockRun.mockResolvedValue("total 5\ndrwxr-xr-x 2 user user 4096 Jan 1 12:00 .\ndrwxr-xr-x 3 user user 4096 Jan 1 12:00 .."); + + const ctx = createMinimalTestContext(); + const chat = useChat({ + assistant: { name: "test" } as any, + model: { name: "test-model" } as any, + llmApi: {} as any, + } as any); + + await act(async () => { + await chat.handleUserMessage("!ls -la"); + }); + + expect(mockRun).toHaveBeenCalledWith({ command: "ls -la" }); + + // Since history is managed by service, we just verify no exception and tool called + ctx.cleanup(); + }); + + it("should handle bash command errors", async () => { + const mockRun = vi.mocked(runTerminalCommandTool.run); + mockRun.mockRejectedValue(new Error("Command not found")); + + const chat = useChat({ + assistant: { name: "test" } as any, + model: { name: "test-model" } as any, + llmApi: {} as any, + } as any); + + await act(async () => { + await chat.handleUserMessage("!invalidcommand"); + }); + + expect(mockRun).toHaveBeenCalledWith({ command: "invalidcommand" }); + }); + + it("should not trigger bash mode for regular messages", async () => { + const mockRun = vi.mocked(runTerminalCommandTool.run); + + const chat = useChat({ + assistant: { name: "test" } as any, + model: { name: "test-model" } as any, + llmApi: {} as any, + } as any); + + await act(async () => { + await chat.handleUserMessage("Hello! How are you?"); + }); + + expect(mockRun).not.toHaveBeenCalled(); + }); + + it("should handle empty bash command", async () => { + const mockRun = vi.mocked(runTerminalCommandTool.run); + + const chat = useChat({ + assistant: { name: "test" } as any, + model: { name: "test-model" } as any, + llmApi: {} as any, + } as any); + + await act(async () => { + await chat.handleUserMessage("!"); + }); + + // Should not call the tool for empty command + expect(mockRun).not.toHaveBeenCalled(); + }); + + it("should handle bash command with leading whitespace", async () => { + const mockRun = vi.mocked(runTerminalCommandTool.run); + mockRun.mockResolvedValue("echo test output"); + + const chat = useChat({ + assistant: { name: "test" } as any, + model: { name: "test-model" } as any, + llmApi: {} as any, + } as any); + + await act(async () => { + await chat.handleUserMessage(" !echo hello"); + }); + + expect(mockRun).toHaveBeenCalledWith({ command: "echo hello" }); + }); +}); \ No newline at end of file diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index c62854ed4..4c6876629 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -339,6 +339,52 @@ export function useChat({ return false; }; + const handleBashModeProcessing = async ( + message: string, + ): Promise => { + // Handle bash mode commands (starting with !) + if (!message.trimStart().startsWith("!")) { + return message; + } + + // Extract the command after the ! + const bashCommand = message.trimStart().slice(1).trim(); + + if (!bashCommand) { + return message; // No command provided, treat as regular message + } + + // Show tool call immediately, then run asynchronously and populate result + const toolCallId = `bash-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; + const toolCall = { + id: toolCallId, + type: "function" as const, + function: { + name: "Bash", + arguments: JSON.stringify({ command: bashCommand }), + }, + }; + + // Add assistant message with tool call immediately + services.chatHistory.addAssistantMessage("", [toolCall as any]); + // Mark as calling for immediate UI feedback + services.chatHistory.updateToolStatus(toolCallId, "calling"); + + // Execute the bash command asynchronously - don't block UI + (async () => { + try { + const { runTerminalCommandTool } = await import("../../tools/runTerminalCommand.js"); + const result = await runTerminalCommandTool.run({ command: bashCommand }); + services.chatHistory.addToolResult(toolCallId, result, "done"); + } catch (error: any) { + const errorMessage = `Bash command failed: ${error?.message || String(error)}`; + services.chatHistory.addToolResult(toolCallId, errorMessage, "error"); + } + })(); + + return null; // Processed, no further message handling needed + }; + const handleSlashCommandProcessing = async ( message: string, ): Promise => { @@ -423,6 +469,13 @@ export function useChat({ if (handled) return; + // Handle bash mode commands (before slash commands) + const bashProcessedMessage = await handleBashModeProcessing(message); + if (bashProcessedMessage === null) { + return; // Bash command was handled and no further processing needed + } + message = bashProcessedMessage; + // Handle slash commands const processedMessage = await handleSlashCommandProcessing(message); if (processedMessage === null) { diff --git a/extensions/cli/src/ui/hooks/useUserInput.ts b/extensions/cli/src/ui/hooks/useUserInput.ts index aa99c421e..983a17d09 100644 --- a/extensions/cli/src/ui/hooks/useUserInput.ts +++ b/extensions/cli/src/ui/hooks/useUserInput.ts @@ -189,6 +189,7 @@ interface TextBufferStateOptions { setCursorPosition: (pos: number) => void; updateSlashCommandState: (text: string, cursor: number) => void; updateFileSearchState: (text: string, cursor: number) => void; + updateBashModeState: (text: string) => void; inputHistory: any; } @@ -200,6 +201,7 @@ export function updateTextBufferState(options: TextBufferStateOptions) { setCursorPosition, updateSlashCommandState, updateFileSearchState, + updateBashModeState, inputHistory, } = options; @@ -211,6 +213,7 @@ export function updateTextBufferState(options: TextBufferStateOptions) { setCursorPosition(newCursor); updateSlashCommandState(newText, newCursor); updateFileSearchState(newText, newCursor); + updateBashModeState(newText); inputHistory.resetNavigation(); } } From 684b072cbb0523a04ff9999f506c6819cc471345 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 2 Sep 2025 19:20:32 -0700 Subject: [PATCH 04/31] chore: prettier --- extensions/cli/spec/bash-mode.md | 13 ++++++++++++- extensions/cli/src/ui/UserInput.tsx | 10 +++++++--- .../cli/src/ui/hooks/useChat.bashMode.test.ts | 6 ++++-- extensions/cli/src/ui/hooks/useChat.ts | 10 +++++++--- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/extensions/cli/spec/bash-mode.md b/extensions/cli/spec/bash-mode.md index cbf99c9fe..18957e0b7 100644 --- a/extensions/cli/spec/bash-mode.md +++ b/extensions/cli/spec/bash-mode.md @@ -1,23 +1,27 @@ Bash Mode (CLI TUI) Overview + - Bash mode lets users run shell commands directly from the chat input by starting their input with an exclamation mark (!). - It is intended for quick terminal command execution without leaving the TUI. Activation + - Bash mode is activated when the current input (trimmed) starts with ! - - Example: "!git status" or " !ls -la" both activate Bash mode. + - Example: "!git status" or " !ls -la" both activate Bash mode. - Visual indicator: - Input border color changes to yellow. - The input prompt indicator changes to a yellow "$". - The input placeholder includes "! for bash mode". Deactivation / Exiting Bash Mode + - Pressing Enter to submit the input exits bash mode immediately after submission, regardless of the command result. - Pressing Esc when the input (trimmed) is exactly ! clears the input and exits bash mode. - Editing the input so it no longer starts with ! also exits bash mode and restores normal input behavior. Interaction with other input helpers + - When in bash mode (input starts with !): - "@" file search suggestions are disabled. - "/" slash command UI is disabled. @@ -25,12 +29,14 @@ Interaction with other input helpers - "@" file search suggestions are disabled. Submission behavior + - On submit (Enter) with a bash-mode input: - The leading ! is removed and the remainder is treated as the shell command to run. - The TUI immediately appends an assistant message representing a Bash tool call, with status set to calling, so users can see that the command is in progress. - The bash command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated. Execution semantics + - The command is executed from the current working directory of the CLI process. - The command runs in the user’s shell as a login shell: - Unix/macOS: SHELL (or /bin/bash) invoked with -l -c "". @@ -40,6 +46,7 @@ Execution semantics - Environment variables are inherited from the parent process. Aliases/functions availability depends on the user’s shell configuration and is not guaranteed. Output handling + - Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success. - If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown. - Output is truncated to the first 5000 lines if exceeded. @@ -47,18 +54,22 @@ Output handling "[Command timed out after 30 seconds of no output]". Keyboard behaviors (summary) + - Enter: submit input. If in bash mode, exits bash mode after submission and shows the pending Bash tool call immediately. - Shift+Enter: new line. - Backslash (\) at end-of-line: inserts a new line (line continuation) as usual. - Esc: if only ! (trimmed) is present, clears input and exits bash mode; otherwise cancels streaming or closes suggestions depending on context. Scope / Modes + - Bash mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing. Error handling + - Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available). Examples + - "!git status" → shows a Bash tool call immediately, then populates with the git status output. - "!echo hello" → shows a Bash tool call immediately, then output "hello". - "!some-unknown-cmd" → shows a Bash tool call immediately, then sets status to error with an error message. diff --git a/extensions/cli/src/ui/UserInput.tsx b/extensions/cli/src/ui/UserInput.tsx index e022e3cc3..3f9339fda 100644 --- a/extensions/cli/src/ui/UserInput.tsx +++ b/extensions/cli/src/ui/UserInput.tsx @@ -618,7 +618,8 @@ const UserInput: React.FC = ({ const renderInputText = () => { const placeholderText = isRemoteMode ? "Ask anything, / for slash commands, ! for bash mode" - : placeholder || "Ask anything, @ for context, / for slash commands, ! for bash mode"; + : placeholder || + "Ask anything, @ for context, / for slash commands, ! for bash mode"; if (inputText.length === 0) { return ( <> @@ -717,8 +718,11 @@ const UserInput: React.FC = ({ paddingX={1} borderColor={showBashMode ? "yellow" : isRemoteMode ? "cyan" : "gray"} > - - {showBashMode ? "$" : isRemoteMode ? "◉" : "●"} + + {showBashMode ? "$" : isRemoteMode ? "◉" : "●"} {renderInputText()} diff --git a/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts b/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts index 89105cd4e..717033a04 100644 --- a/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts +++ b/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts @@ -20,7 +20,9 @@ describe("useChat - Bash Mode", () => { it("should detect bash mode when message starts with !", async () => { const mockRun = vi.mocked(runTerminalCommandTool.run); - mockRun.mockResolvedValue("total 5\ndrwxr-xr-x 2 user user 4096 Jan 1 12:00 .\ndrwxr-xr-x 3 user user 4096 Jan 1 12:00 .."); + mockRun.mockResolvedValue( + "total 5\ndrwxr-xr-x 2 user user 4096 Jan 1 12:00 .\ndrwxr-xr-x 3 user user 4096 Jan 1 12:00 ..", + ); const ctx = createMinimalTestContext(); const chat = useChat({ @@ -105,4 +107,4 @@ describe("useChat - Bash Mode", () => { expect(mockRun).toHaveBeenCalledWith({ command: "echo hello" }); }); -}); \ No newline at end of file +}); diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index 4c6876629..5fcba19fd 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -349,7 +349,7 @@ export function useChat({ // Extract the command after the ! const bashCommand = message.trimStart().slice(1).trim(); - + if (!bashCommand) { return message; // No command provided, treat as regular message } @@ -373,8 +373,12 @@ export function useChat({ // Execute the bash command asynchronously - don't block UI (async () => { try { - const { runTerminalCommandTool } = await import("../../tools/runTerminalCommand.js"); - const result = await runTerminalCommandTool.run({ command: bashCommand }); + const { runTerminalCommandTool } = await import( + "../../tools/runTerminalCommand.js" + ); + const result = await runTerminalCommandTool.run({ + command: bashCommand, + }); services.chatHistory.addToolResult(toolCallId, result, "done"); } catch (error: any) { const errorMessage = `Bash command failed: ${error?.message || String(error)}`; From ac9a6f8ee41049043d853b0746646f9bb5b21f05 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 2 Sep 2025 19:32:58 -0700 Subject: [PATCH 05/31] fix: eslint requirements --- extensions/cli/AGENTS.md | 5 - .../CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md | 1 - extensions/cli/spec/config-loading.md | 2 - extensions/cli/spec/onboarding.md | 1 - extensions/cli/src/ui/UserInput.tsx | 120 +++++++++++++----- .../cli/src/ui/hooks/useChat.bashMode.test.ts | 8 +- .../cli/src/ui/hooks/useChat.bashMode.ts | 51 ++++++++ extensions/cli/src/ui/hooks/useChat.ts | 51 +------- 8 files changed, 147 insertions(+), 92 deletions(-) create mode 100644 extensions/cli/src/ui/hooks/useChat.bashMode.ts diff --git a/extensions/cli/AGENTS.md b/extensions/cli/AGENTS.md index 6fe536a46..bfe1f0d39 100644 --- a/extensions/cli/AGENTS.md +++ b/extensions/cli/AGENTS.md @@ -18,30 +18,25 @@ This is a CLI tool for Continue Dev that provides an interactive AI-assisted dev ### Core Components 1. **Entry Point** (`src/index.ts`): Main CLI logic with two modes: - - **Headless mode**: Non-interactive mode for automation/CI - **TUI mode**: Terminal User Interface using Ink/React - **Standard mode**: Traditional readline-based chat interface 2. **Authentication** (`src/auth/`): WorkOS-based authentication system - - `ensureAuth.ts`: Handles authentication flow - `workos.ts`: WorkOS configuration and token management 3. **Continue SDK Integration** (`src/continueSDK.ts`): Initializes the Continue SDK client with: - - API key authentication - Assistant configuration (slug-based) - Organization support 4. **Terminal UI** (`src/ui/`): React/Ink-based TUI components - - `TUIChat.tsx`: Main chat interface component - `UserInput.tsx`: Input handling with multi-line support - `TextBuffer.ts`: Text display utilities 5. **Tools System** (`src/tools/`): Built-in development tools including: - - File operations (read, write, list) - Code search functionality - Terminal command execution diff --git a/extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md b/extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md index 566ebe5aa..7b9d508f5 100644 --- a/extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md +++ b/extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md @@ -299,7 +299,6 @@ If issues arise during migration: 1. **Streaming integration**: Most complex change - Mitigation: Extensive testing, gradual rollout 2. **Remote mode**: Different state management - - Mitigation: Test thoroughly, maintain compatibility 3. **Performance**: Large histories might cause issues diff --git a/extensions/cli/spec/config-loading.md b/extensions/cli/spec/config-loading.md index 0f474b5a7..384b19809 100644 --- a/extensions/cli/spec/config-loading.md +++ b/extensions/cli/spec/config-loading.md @@ -23,13 +23,11 @@ This document specifies the behavior of the CLI's configuration loading system, **When CLI is invoked, config source is determined in this order:** 1. **CLI `--config` Flag** (highest priority) - - File path (starts with `.`, `/`, `~`): Loads local YAML file - Assistant slug (`owner/package`): Fetches from Continue platform - Overrides any saved preferences 2. **Saved Config URI** (if no `--config` flag) - - Retrieved from authentication config - Converts `file://` URIs back to file paths - Converts `slug://` URIs back to assistant slugs diff --git a/extensions/cli/spec/onboarding.md b/extensions/cli/spec/onboarding.md index 523b9067e..9b3eaf22e 100644 --- a/extensions/cli/spec/onboarding.md +++ b/extensions/cli/spec/onboarding.md @@ -8,7 +8,6 @@ When a user first runs `cn` in interactive mode, they will be taken through "onb 1. If the --config flag is provided, load this config 2. Otherwise, we will present the user with two options: - - Log in with Continue: log them in, which will automatically create their assistant and then we can load the first assistant from the first org - Enter your Anthropic API key: let them enter the key, and then either create a ~/.continue/config.yaml with the following contents OR update the existing config.yaml to add the model diff --git a/extensions/cli/src/ui/UserInput.tsx b/extensions/cli/src/ui/UserInput.tsx index 3f9339fda..1f85011d7 100644 --- a/extensions/cli/src/ui/UserInput.tsx +++ b/extensions/cli/src/ui/UserInput.tsx @@ -19,6 +19,77 @@ import { import { SlashCommandUI } from "./SlashCommandUI.js"; import { TextBuffer } from "./TextBuffer.js"; +// Small presentational helpers to reduce cyclomatic complexity in UserInput +const InterruptedBanner: React.FC<{ wasInterrupted: boolean }> = ({ + wasInterrupted, +}) => { + if (!wasInterrupted) return null; + return ( + + ⚠ Interrupted by user - Press enter to resume + + ); +}; + +const SlashCommandsMaybe: React.FC<{ + show: boolean; + inputMode: boolean; + hideNormalUI: boolean; + isRemoteMode: boolean; + assistant?: AssistantConfig; + filter: string; + selectedIndex: number; +}> = ({ + show, + inputMode, + hideNormalUI, + isRemoteMode, + assistant, + filter, + selectedIndex, +}) => { + if (!show || !inputMode || hideNormalUI || !(isRemoteMode || assistant)) + return null; + return ( + + ); +}; + +const FileSearchMaybe: React.FC<{ + show: boolean; + inputMode: boolean; + hideNormalUI: boolean; + isRemoteMode: boolean; + filter: string; + selectedIndex: number; + onSelect: (path: string) => void | Promise; + onFilesUpdated: (files: Array<{ path: string; displayName: string }>) => void; +}> = ({ + show, + inputMode, + hideNormalUI, + isRemoteMode, + filter, + selectedIndex, + onSelect, + onFilesUpdated, +}) => { + if (!show || !inputMode || hideNormalUI || isRemoteMode) return null; + return ( + + ); +}; + interface UserInputProps { onSubmit: (message: string, imageMap?: Map) => void; isWaitingForResponse: boolean; @@ -702,14 +773,7 @@ const UserInput: React.FC = ({ return ( - {/* Interruption message - shown just above the input box */} - {wasInterrupted && ( - - - ⚠ Interrupted by user - Press enter to resume - - - )} + {/* Input box */} = ({ {renderInputText()} - {/* Slash command UI - show in remote mode OR when assistant is available */} - {showSlashCommands && - inputMode && - !hideNormalUI && - (isRemoteMode || assistant) && ( - - )} + - {/* File search UI - only show in local mode */} - {showFileSearch && inputMode && !hideNormalUI && !isRemoteMode && ( - - )} + ); }; diff --git a/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts b/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts index 717033a04..43726bf09 100644 --- a/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts +++ b/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts @@ -1,7 +1,10 @@ -import { describe, it, expect, vi, beforeEach } from "vitest"; import { act } from "@testing-library/react"; +import { describe, it, expect, vi, beforeEach } from "vitest"; import { createMinimalTestContext } from "../../test-helpers/ui-test-context.js"; +import { runTerminalCommandTool } from "../../tools/runTerminalCommand.js"; + +import { useChat } from "./useChat.js"; // Mock the runTerminalCommandTool vi.mock("../../tools/runTerminalCommand.js", () => ({ @@ -10,9 +13,6 @@ vi.mock("../../tools/runTerminalCommand.js", () => ({ }, })); -import { useChat } from "./useChat.js"; -import { runTerminalCommandTool } from "../../tools/runTerminalCommand.js"; - describe("useChat - Bash Mode", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/extensions/cli/src/ui/hooks/useChat.bashMode.ts b/extensions/cli/src/ui/hooks/useChat.bashMode.ts new file mode 100644 index 000000000..534f0b3b7 --- /dev/null +++ b/extensions/cli/src/ui/hooks/useChat.bashMode.ts @@ -0,0 +1,51 @@ +import { services } from "../../services/index.js"; + +export const handleBashModeProcessing = async ( + message: string, +): Promise => { + // Handle bash mode commands (starting with !) + if (!message.trimStart().startsWith("!")) { + return message; + } + + // Extract the command after the ! + const bashCommand = message.trimStart().slice(1).trim(); + + if (!bashCommand) { + return message; // No command provided, treat as regular message + } + + // Show tool call immediately, then run asynchronously and populate result + const toolCallId = `bash-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; + const toolCall = { + id: toolCallId, + type: "function" as const, + function: { + name: "Bash", + arguments: JSON.stringify({ command: bashCommand }), + }, + }; + + // Add assistant message with tool call immediately + services.chatHistory.addAssistantMessage("", [toolCall as any]); + // Mark as calling for immediate UI feedback + services.chatHistory.updateToolStatus(toolCallId, "calling"); + + // Execute the bash command asynchronously - don't block UI + (async () => { + try { + const { runTerminalCommandTool } = await import( + "../../tools/runTerminalCommand.js" + ); + const result = await runTerminalCommandTool.run({ + command: bashCommand, + }); + services.chatHistory.addToolResult(toolCallId, result, "done"); + } catch (error: any) { + const errorMessage = `Bash command failed: ${error?.message || String(error)}`; + services.chatHistory.addToolResult(toolCallId, errorMessage, "errored"); + } + })(); + + return null; // Processed, no further message handling needed +}; diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index 5fcba19fd..cc86d61fe 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -15,6 +15,7 @@ import { telemetryService } from "../../telemetry/telemetryService.js"; import { formatError } from "../../util/formatError.js"; import { logger } from "../../util/logger.js"; +import { handleBashModeProcessing } from "./useChat.bashMode.js"; import { handleAutoCompaction, handleCompactCommand, @@ -339,56 +340,6 @@ export function useChat({ return false; }; - const handleBashModeProcessing = async ( - message: string, - ): Promise => { - // Handle bash mode commands (starting with !) - if (!message.trimStart().startsWith("!")) { - return message; - } - - // Extract the command after the ! - const bashCommand = message.trimStart().slice(1).trim(); - - if (!bashCommand) { - return message; // No command provided, treat as regular message - } - - // Show tool call immediately, then run asynchronously and populate result - const toolCallId = `bash-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; - const toolCall = { - id: toolCallId, - type: "function" as const, - function: { - name: "Bash", - arguments: JSON.stringify({ command: bashCommand }), - }, - }; - - // Add assistant message with tool call immediately - services.chatHistory.addAssistantMessage("", [toolCall as any]); - // Mark as calling for immediate UI feedback - services.chatHistory.updateToolStatus(toolCallId, "calling"); - - // Execute the bash command asynchronously - don't block UI - (async () => { - try { - const { runTerminalCommandTool } = await import( - "../../tools/runTerminalCommand.js" - ); - const result = await runTerminalCommandTool.run({ - command: bashCommand, - }); - services.chatHistory.addToolResult(toolCallId, result, "done"); - } catch (error: any) { - const errorMessage = `Bash command failed: ${error?.message || String(error)}`; - services.chatHistory.addToolResult(toolCallId, errorMessage, "error"); - } - })(); - - return null; // Processed, no further message handling needed - }; - const handleSlashCommandProcessing = async ( message: string, ): Promise => { From 08f4b865fb027ca06199b5a42a36f21144ed4c7a Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 2 Sep 2025 19:57:08 -0700 Subject: [PATCH 06/31] fix: prettier --- extensions/cli/AGENTS.md | 5 +++++ extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md | 1 + extensions/cli/spec/config-loading.md | 2 ++ extensions/cli/spec/onboarding.md | 1 + 4 files changed, 9 insertions(+) diff --git a/extensions/cli/AGENTS.md b/extensions/cli/AGENTS.md index bfe1f0d39..6fe536a46 100644 --- a/extensions/cli/AGENTS.md +++ b/extensions/cli/AGENTS.md @@ -18,25 +18,30 @@ This is a CLI tool for Continue Dev that provides an interactive AI-assisted dev ### Core Components 1. **Entry Point** (`src/index.ts`): Main CLI logic with two modes: + - **Headless mode**: Non-interactive mode for automation/CI - **TUI mode**: Terminal User Interface using Ink/React - **Standard mode**: Traditional readline-based chat interface 2. **Authentication** (`src/auth/`): WorkOS-based authentication system + - `ensureAuth.ts`: Handles authentication flow - `workos.ts`: WorkOS configuration and token management 3. **Continue SDK Integration** (`src/continueSDK.ts`): Initializes the Continue SDK client with: + - API key authentication - Assistant configuration (slug-based) - Organization support 4. **Terminal UI** (`src/ui/`): React/Ink-based TUI components + - `TUIChat.tsx`: Main chat interface component - `UserInput.tsx`: Input handling with multi-line support - `TextBuffer.ts`: Text display utilities 5. **Tools System** (`src/tools/`): Built-in development tools including: + - File operations (read, write, list) - Code search functionality - Terminal command execution diff --git a/extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md b/extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md index 7b9d508f5..566ebe5aa 100644 --- a/extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md +++ b/extensions/cli/CHAT_HISTORY_SERVICE_MIGRATION_PLAN.md @@ -299,6 +299,7 @@ If issues arise during migration: 1. **Streaming integration**: Most complex change - Mitigation: Extensive testing, gradual rollout 2. **Remote mode**: Different state management + - Mitigation: Test thoroughly, maintain compatibility 3. **Performance**: Large histories might cause issues diff --git a/extensions/cli/spec/config-loading.md b/extensions/cli/spec/config-loading.md index 384b19809..0f474b5a7 100644 --- a/extensions/cli/spec/config-loading.md +++ b/extensions/cli/spec/config-loading.md @@ -23,11 +23,13 @@ This document specifies the behavior of the CLI's configuration loading system, **When CLI is invoked, config source is determined in this order:** 1. **CLI `--config` Flag** (highest priority) + - File path (starts with `.`, `/`, `~`): Loads local YAML file - Assistant slug (`owner/package`): Fetches from Continue platform - Overrides any saved preferences 2. **Saved Config URI** (if no `--config` flag) + - Retrieved from authentication config - Converts `file://` URIs back to file paths - Converts `slug://` URIs back to assistant slugs diff --git a/extensions/cli/spec/onboarding.md b/extensions/cli/spec/onboarding.md index 9b3eaf22e..523b9067e 100644 --- a/extensions/cli/spec/onboarding.md +++ b/extensions/cli/spec/onboarding.md @@ -8,6 +8,7 @@ When a user first runs `cn` in interactive mode, they will be taken through "onb 1. If the --config flag is provided, load this config 2. Otherwise, we will present the user with two options: + - Log in with Continue: log them in, which will automatically create their assistant and then we can load the first assistant from the first org - Enter your Anthropic API key: let them enter the key, and then either create a ~/.continue/config.yaml with the following contents OR update the existing config.yaml to add the model From b7ff51e49c295828c047c38e434d1f48eea0e321 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 2 Sep 2025 21:07:37 -0700 Subject: [PATCH 07/31] chore: cleanup shell mode --- extensions/cli/spec/bash-mode.md | 75 ---------- extensions/cli/spec/shell-mode.md | 138 ++++++++++++++++++ extensions/cli/src/slashCommands.ts | 2 +- .../cli/src/tools/runTerminalCommand.ts | 9 +- extensions/cli/src/ui/UserInput.tsx | 12 +- ...Mode.test.ts => useChat.shellMode.test.ts} | 2 +- ...eChat.bashMode.ts => useChat.shellMode.ts} | 29 ++-- extensions/cli/src/ui/hooks/useChat.ts | 4 +- 8 files changed, 164 insertions(+), 107 deletions(-) delete mode 100644 extensions/cli/spec/bash-mode.md create mode 100644 extensions/cli/spec/shell-mode.md rename extensions/cli/src/ui/hooks/{useChat.bashMode.test.ts => useChat.shellMode.test.ts} (98%) rename extensions/cli/src/ui/hooks/{useChat.bashMode.ts => useChat.shellMode.ts} (66%) diff --git a/extensions/cli/spec/bash-mode.md b/extensions/cli/spec/bash-mode.md deleted file mode 100644 index 18957e0b7..000000000 --- a/extensions/cli/spec/bash-mode.md +++ /dev/null @@ -1,75 +0,0 @@ -Bash Mode (CLI TUI) - -Overview - -- Bash mode lets users run shell commands directly from the chat input by starting their input with an exclamation mark (!). -- It is intended for quick terminal command execution without leaving the TUI. - -Activation - -- Bash mode is activated when the current input (trimmed) starts with ! - - Example: "!git status" or " !ls -la" both activate Bash mode. -- Visual indicator: - - Input border color changes to yellow. - - The input prompt indicator changes to a yellow "$". - - The input placeholder includes "! for bash mode". - -Deactivation / Exiting Bash Mode - -- Pressing Enter to submit the input exits bash mode immediately after submission, regardless of the command result. -- Pressing Esc when the input (trimmed) is exactly ! clears the input and exits bash mode. -- Editing the input so it no longer starts with ! also exits bash mode and restores normal input behavior. - -Interaction with other input helpers - -- When in bash mode (input starts with !): - - "@" file search suggestions are disabled. - - "/" slash command UI is disabled. -- When in slash command mode (input starts with /): - - "@" file search suggestions are disabled. - -Submission behavior - -- On submit (Enter) with a bash-mode input: - - The leading ! is removed and the remainder is treated as the shell command to run. - - The TUI immediately appends an assistant message representing a Bash tool call, with status set to calling, so users can see that the command is in progress. - - The bash command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated. - -Execution semantics - -- The command is executed from the current working directory of the CLI process. -- The command runs in the user’s shell as a login shell: - - Unix/macOS: SHELL (or /bin/bash) invoked with -l -c "". - - Windows: powershell.exe -NoLogo -ExecutionPolicy Bypass -Command "". -- The child process stdin is detached (not connected to the TTY). This prevents the TUI from being suspended by job control. Consequences: - - Interactive commands that require stdin will not work. -- Environment variables are inherited from the parent process. Aliases/functions availability depends on the user’s shell configuration and is not guaranteed. - -Output handling - -- Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success. -- If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown. -- Output is truncated to the first 5000 lines if exceeded. -- Timeout behavior: If no output is received for 30 seconds (configurable in tests), the process is terminated and the result includes a note like: - "[Command timed out after 30 seconds of no output]". - -Keyboard behaviors (summary) - -- Enter: submit input. If in bash mode, exits bash mode after submission and shows the pending Bash tool call immediately. -- Shift+Enter: new line. -- Backslash (\) at end-of-line: inserts a new line (line continuation) as usual. -- Esc: if only ! (trimmed) is present, clears input and exits bash mode; otherwise cancels streaming or closes suggestions depending on context. - -Scope / Modes - -- Bash mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing. - -Error handling - -- Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available). - -Examples - -- "!git status" → shows a Bash tool call immediately, then populates with the git status output. -- "!echo hello" → shows a Bash tool call immediately, then output "hello". -- "!some-unknown-cmd" → shows a Bash tool call immediately, then sets status to error with an error message. diff --git a/extensions/cli/spec/shell-mode.md b/extensions/cli/spec/shell-mode.md new file mode 100644 index 000000000..a3bdd6cf4 --- /dev/null +++ b/extensions/cli/spec/shell-mode.md @@ -0,0 +1,138 @@ +shell Mode (CLI TUI) + +Overview + +- shell mode lets users run shell commands directly from the chat input by starting their input with an exclamation mark (!). +- It is intended for quick terminal command execution without leaving the TUI. + +Activation + +- shell mode is activated when the current input (trimmed) starts with ! + - Example: "!git status" or " !ls -la" both activate shell mode. +- Visual indicator: + - Input border color changes to yellow. + - The input prompt indicator changes to a yellow "$". + - The input placeholder includes "! for shell mode". + +Deactivation / Exiting shell Mode + +- Pressing Enter to submit the input exits shell mode immediately after submission, regardless of the command result. +- Pressing Esc when the input (trimmed) is exactly ! clears the input and exits shell mode. +- Editing the input so it no longer starts with ! also exits shell mode and restores normal input behavior. + +Interaction with other input helpers + +- When in shell mode (input starts with !): + - "@" file search suggestions are disabled. + - "/" slash command UI is disabled. +- When in slash command mode (input starts with /): + - "@" file search suggestions are disabled. + +Submission behavior + +- On submit (Enter) with a shell-mode input: + - The leading ! is removed and the remainder is treated as the shell command to run. + - The TUI immediately appends an assistant message representing a shell tool call, with status set to calling, so users can see that the command is in progress. + - The shell command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated. + +Execution semantics + +- The command is executed in the same way as terminal tool commands, minus permissions + +Output handling + +- Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success. +- If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown. +- Output is truncated to the first 5000 lines if exceeded. +- Timeout behavior: If no output is received for 30 seconds (configurable in tests), the process is terminated and the result includes a note like: + "[Command timed out after 30 seconds of no output]". + +Keyboard behaviors (summary) + +- Enter: submit input. If in shell mode, exits shell mode after submission and shows the pending shell tool call immediately. +- Shift+Enter: new line. +- Backslash (\) at end-of-line: inserts a new line (line continuation) as usual. +- Esc: if only ! (trimmed) is present, clears input and exits shell mode; otherwise cancels streaming or closes suggestions depending on context. + +Scope / Modes + +- shell mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing. + +Error handling + +- Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available). + +Examples + +- "!git status" → shows a shell tool call immediately, then populates with the git status output. +- "!echo hello" → shows a shell tool call immediately, then output "hello". +- "!some-unknown-cmd" → shows a shell tool call immediately, then sets status to error with an error message. + Shell Mode (CLI TUI) + +Overview + +- Shell mode lets users run shell commands directly from the chat input by starting their input with an exclamation mark (!). +- It is intended for quick terminal command execution without leaving the TUI. + +Activation + +- Shell mode is activated when the current input (trimmed) starts with ! + - Example: "!git status" or " !ls -la" both activate Shell mode. +- Visual indicator: + - Input border color changes to yellow. + - The input prompt indicator changes to a yellow "$". + - The input placeholder includes "! for shell mode". + +Deactivation / Exiting Shell Mode + +- Pressing Enter to submit the input exits shell mode immediately after submission, regardless of the command result. +- Pressing Esc when the input (trimmed) is exactly ! clears the input and exits shell mode. +- Editing the input so it no longer starts with ! also exits shell mode and restores normal input behavior. + +Interaction with other input helpers + +- When in shell mode (input starts with !): + - "@" file search suggestions are disabled. + - "/" slash command UI is disabled. +- When in slash command mode (input starts with /): + - "@" file search suggestions are disabled. + +Submission behavior + +- On submit (Enter) with a shell-mode input: + - The leading ! is removed and the remainder is treated as the shell command to run. + - The TUI immediately appends an assistant message representing a Shell tool call, with status set to calling, so users can see that the command is in progress. + - The shell command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated. + +Execution semantics + +- The command is executed in the same way as terminal tool commands, minus permissions, and inserted into the chat history the same. + +Output handling + +- Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success. +- If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown. +- Output is truncated to the first 5000 lines if exceeded. +- Timeout behavior: If no output is received for 30 seconds (configurable in tests), the process is terminated and the result includes a note like: + "[Command timed out after 30 seconds of no output]". + +Keyboard behaviors (summary) + +- Enter: submit input. If in shell mode, exits shell mode after submission and shows the pending Shell tool call immediately. +- Shift+Enter: new line. +- Backslash (\) at end-of-line: inserts a new line (line continuation) as usual. +- Esc: if only ! (trimmed) is present, clears input and exits shell mode; otherwise cancels streaming or closes suggestions depending on context. + +Scope / Modes + +- Shell mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing. + +Error handling + +- Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available). + +Examples + +- "!git status" → shows a Shell tool call immediately, then populates with the git status output. +- "!echo hello" → shows a Shell tool call immediately, then output "hello". +- "!some-unknown-cmd" → shows a Shell tool call immediately, then sets status to error with an error message. diff --git a/extensions/cli/src/slashCommands.ts b/extensions/cli/src/slashCommands.ts index 1c34c58fa..509ce8f61 100644 --- a/extensions/cli/src/slashCommands.ts +++ b/extensions/cli/src/slashCommands.ts @@ -28,7 +28,7 @@ async function handleHelp(_args: string[], _assistant: AssistantConfig) { ` ${chalk.cyan("Enter")} Submit message`, ` ${chalk.cyan("Shift+Enter")} New line`, ` ${chalk.cyan("\\")} Line continuation (at end of line)`, - ` ${chalk.cyan("!")} Bash mode - run shell commands`, + ` ${chalk.cyan("!")} Shell mode - run shell commands`, "", chalk.white("Controls:"), ` ${chalk.cyan("Ctrl+C")} Clear input`, diff --git a/extensions/cli/src/tools/runTerminalCommand.ts b/extensions/cli/src/tools/runTerminalCommand.ts index 242ecdeea..9aefceb9b 100644 --- a/extensions/cli/src/tools/runTerminalCommand.ts +++ b/extensions/cli/src/tools/runTerminalCommand.ts @@ -17,7 +17,7 @@ function getShellCommand(command: string): { shell: string; args: string[] } { args: ["-NoLogo", "-ExecutionPolicy", "Bypass", "-Command", command], }; } else { - // Unix/macOS: Just run the user's shell as a login shell + // Unix/macOS: Use login shell to source .bashrc/.zshrc etc. const userShell = process.env.SHELL || "/bin/bash"; return { shell: userShell, args: ["-l", "-c", command] }; } @@ -60,12 +60,7 @@ The command will be executed from the current working directory: ${process.cwd() return new Promise((resolve, reject) => { // Use same shell logic as core implementation const { shell, args } = getShellCommand(command); - const child = spawn(shell, args, { - cwd: process.cwd(), - env: process.env, - stdio: ["ignore", "pipe", "pipe"], // prevent child from reading TTY input - detached: false, - }); + const child = spawn(shell, args); let stdout = ""; let stderr = ""; let timeoutId: NodeJS.Timeout; diff --git a/extensions/cli/src/ui/UserInput.tsx b/extensions/cli/src/ui/UserInput.tsx index 1f85011d7..1c916e9d0 100644 --- a/extensions/cli/src/ui/UserInput.tsx +++ b/extensions/cli/src/ui/UserInput.tsx @@ -190,13 +190,13 @@ const UserInput: React.FC = ({ return nextMode; }; - // Update bash mode state based on input + // Update shell mode state based on input const updateBashModeState = (text: string) => { const trimmed = text.trimStart(); const isBash = trimmed.startsWith("!"); setShowBashMode(isBash); if (isBash) { - // Disable other helpers while in bash mode + // Disable other helpers while in shell mode setShowSlashCommands(false); setShowFileSearch(false); } @@ -275,7 +275,7 @@ const UserInput: React.FC = ({ return; } - // Disable file search if we're in bash mode or slash command mode + // Disable file search if we're in shell mode or slash command mode const trimmed = text.trimStart(); if (trimmed.startsWith("!") || trimmed.startsWith("/")) { setShowFileSearch(false); @@ -551,7 +551,7 @@ const UserInput: React.FC = ({ const handleEscapeKey = (key: any): boolean => { if (!key.escape) return false; - // If only "!" is present, clear bash mode + // If only "!" is present, clear shell mode if (inputMode && showBashMode && inputText.trim() === "!") { textBuffer.clear(); setInputText(""); @@ -688,9 +688,9 @@ const UserInput: React.FC = ({ const renderInputText = () => { const placeholderText = isRemoteMode - ? "Ask anything, / for slash commands, ! for bash mode" + ? "Ask anything, / for slash commands, ! for shell mode" : placeholder || - "Ask anything, @ for context, / for slash commands, ! for bash mode"; + "Ask anything, @ for context, / for slash commands, ! for shell mode"; if (inputText.length === 0) { return ( <> diff --git a/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts b/extensions/cli/src/ui/hooks/useChat.shellMode.test.ts similarity index 98% rename from extensions/cli/src/ui/hooks/useChat.bashMode.test.ts rename to extensions/cli/src/ui/hooks/useChat.shellMode.test.ts index 43726bf09..5afed14bf 100644 --- a/extensions/cli/src/ui/hooks/useChat.bashMode.test.ts +++ b/extensions/cli/src/ui/hooks/useChat.shellMode.test.ts @@ -1,5 +1,5 @@ import { act } from "@testing-library/react"; -import { describe, it, expect, vi, beforeEach } from "vitest"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { createMinimalTestContext } from "../../test-helpers/ui-test-context.js"; import { runTerminalCommandTool } from "../../tools/runTerminalCommand.js"; diff --git a/extensions/cli/src/ui/hooks/useChat.bashMode.ts b/extensions/cli/src/ui/hooks/useChat.shellMode.ts similarity index 66% rename from extensions/cli/src/ui/hooks/useChat.bashMode.ts rename to extensions/cli/src/ui/hooks/useChat.shellMode.ts index 534f0b3b7..18cac2d43 100644 --- a/extensions/cli/src/ui/hooks/useChat.bashMode.ts +++ b/extensions/cli/src/ui/hooks/useChat.shellMode.ts @@ -1,9 +1,11 @@ +import { runTerminalCommandTool } from "src/tools/runTerminalCommand.js"; +import { getErrorString } from "src/util/error.js"; import { services } from "../../services/index.js"; export const handleBashModeProcessing = async ( message: string, ): Promise => { - // Handle bash mode commands (starting with !) + // Handle shell mode commands (starting with !) if (!message.trimStart().startsWith("!")) { return message; } @@ -16,7 +18,7 @@ export const handleBashModeProcessing = async ( } // Show tool call immediately, then run asynchronously and populate result - const toolCallId = `bash-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; + const toolCallId = `shell-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; const toolCall = { id: toolCallId, type: "function" as const, @@ -27,25 +29,22 @@ export const handleBashModeProcessing = async ( }; // Add assistant message with tool call immediately - services.chatHistory.addAssistantMessage("", [toolCall as any]); + services.chatHistory.addAssistantMessage("", [toolCall]); // Mark as calling for immediate UI feedback services.chatHistory.updateToolStatus(toolCallId, "calling"); // Execute the bash command asynchronously - don't block UI - (async () => { - try { - const { runTerminalCommandTool } = await import( - "../../tools/runTerminalCommand.js" - ); - const result = await runTerminalCommandTool.run({ - command: bashCommand, - }); + void runTerminalCommandTool + .run({ + command: bashCommand, + }) + .then((result) => { services.chatHistory.addToolResult(toolCallId, result, "done"); - } catch (error: any) { - const errorMessage = `Bash command failed: ${error?.message || String(error)}`; + }) + .catch((error) => { + const errorMessage = `Bash command failed: ${getErrorString(error)}`; services.chatHistory.addToolResult(toolCallId, errorMessage, "errored"); - } - })(); + }); return null; // Processed, no further message handling needed }; diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index cc86d61fe..c2f1e0130 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -15,7 +15,6 @@ import { telemetryService } from "../../telemetry/telemetryService.js"; import { formatError } from "../../util/formatError.js"; import { logger } from "../../util/logger.js"; -import { handleBashModeProcessing } from "./useChat.bashMode.js"; import { handleAutoCompaction, handleCompactCommand, @@ -31,6 +30,7 @@ import { handleRemoteMessage, setupRemotePolling, } from "./useChat.remote.helpers.js"; +import { handleBashModeProcessing } from "./useChat.shellMode.js"; import { createStreamCallbacks, executeStreaming, @@ -424,7 +424,7 @@ export function useChat({ if (handled) return; - // Handle bash mode commands (before slash commands) + // Handle shell mode commands (before slash commands) const bashProcessedMessage = await handleBashModeProcessing(message); if (bashProcessedMessage === null) { return; // Bash command was handled and no further processing needed From afede3f89dd66c8dcb61a4bc3f716791c1ca12e1 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 2 Sep 2025 21:08:26 -0700 Subject: [PATCH 08/31] chore: cleanup shell mode --- extensions/cli/src/ui/hooks/useChat.shellMode.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/cli/src/ui/hooks/useChat.shellMode.ts b/extensions/cli/src/ui/hooks/useChat.shellMode.ts index 18cac2d43..9c441310f 100644 --- a/extensions/cli/src/ui/hooks/useChat.shellMode.ts +++ b/extensions/cli/src/ui/hooks/useChat.shellMode.ts @@ -1,5 +1,6 @@ import { runTerminalCommandTool } from "src/tools/runTerminalCommand.js"; import { getErrorString } from "src/util/error.js"; + import { services } from "../../services/index.js"; export const handleBashModeProcessing = async ( From 530e0374d5c6d7198e4d4db46f5f43edd8eba760 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 2 Sep 2025 22:40:32 -0700 Subject: [PATCH 09/31] fix: shell mode tests --- .../src/ui/hooks/useChat.shellMode.test.ts | 149 +++++++++++------- 1 file changed, 93 insertions(+), 56 deletions(-) diff --git a/extensions/cli/src/ui/hooks/useChat.shellMode.test.ts b/extensions/cli/src/ui/hooks/useChat.shellMode.test.ts index 5afed14bf..da65c1a70 100644 --- a/extensions/cli/src/ui/hooks/useChat.shellMode.test.ts +++ b/extensions/cli/src/ui/hooks/useChat.shellMode.test.ts @@ -1,19 +1,29 @@ -import { act } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { createMinimalTestContext } from "../../test-helpers/ui-test-context.js"; -import { runTerminalCommandTool } from "../../tools/runTerminalCommand.js"; +import { runTerminalCommandTool } from "src/tools/runTerminalCommand.js"; +import { services } from "../../services/index.js"; -import { useChat } from "./useChat.js"; +import { handleBashModeProcessing } from "./useChat.shellMode.js"; -// Mock the runTerminalCommandTool -vi.mock("../../tools/runTerminalCommand.js", () => ({ +// Mock the runTerminalCommandTool with the correct path for the import in shellMode.ts +vi.mock("src/tools/runTerminalCommand.js", () => ({ runTerminalCommandTool: { run: vi.fn(), }, })); -describe("useChat - Bash Mode", () => { +// Mock the services +vi.mock("../../services/index.js", () => ({ + services: { + chatHistory: { + addAssistantMessage: vi.fn(), + updateToolStatus: vi.fn(), + addToolResult: vi.fn(), + }, + }, +})); + +describe("handleBashModeProcessing", () => { beforeEach(() => { vi.clearAllMocks(); }); @@ -24,87 +34,114 @@ describe("useChat - Bash Mode", () => { "total 5\ndrwxr-xr-x 2 user user 4096 Jan 1 12:00 .\ndrwxr-xr-x 3 user user 4096 Jan 1 12:00 ..", ); - const ctx = createMinimalTestContext(); - const chat = useChat({ - assistant: { name: "test" } as any, - model: { name: "test-model" } as any, - llmApi: {} as any, - } as any); + const result = await handleBashModeProcessing("!ls -la"); - await act(async () => { - await chat.handleUserMessage("!ls -la"); - }); + expect(result).toBe(null); // Processed, no further handling needed + expect(services.chatHistory.addAssistantMessage).toHaveBeenCalled(); + expect(services.chatHistory.updateToolStatus).toHaveBeenCalledWith( + expect.any(String), + "calling", + ); - expect(mockRun).toHaveBeenCalledWith({ command: "ls -la" }); + // Use vi.waitFor to wait for async operations in the void expression + await vi.waitFor( + () => { + expect(mockRun).toHaveBeenCalledWith({ command: "ls -la" }); + }, + { timeout: 1000 }, + ); - // Since history is managed by service, we just verify no exception and tool called - ctx.cleanup(); + await vi.waitFor( + () => { + expect(services.chatHistory.addToolResult).toHaveBeenCalledWith( + expect.any(String), + "total 5\ndrwxr-xr-x 2 user user 4096 Jan 1 12:00 .\ndrwxr-xr-x 3 user user 4096 Jan 1 12:00 ..", + "done", + ); + }, + { timeout: 1000 }, + ); }); it("should handle bash command errors", async () => { const mockRun = vi.mocked(runTerminalCommandTool.run); mockRun.mockRejectedValue(new Error("Command not found")); - const chat = useChat({ - assistant: { name: "test" } as any, - model: { name: "test-model" } as any, - llmApi: {} as any, - } as any); + const result = await handleBashModeProcessing("!invalidcommand"); - await act(async () => { - await chat.handleUserMessage("!invalidcommand"); - }); + expect(result).toBe(null); // Processed, no further handling needed + expect(services.chatHistory.addAssistantMessage).toHaveBeenCalled(); + expect(services.chatHistory.updateToolStatus).toHaveBeenCalledWith( + expect.any(String), + "calling", + ); - expect(mockRun).toHaveBeenCalledWith({ command: "invalidcommand" }); + // Use vi.waitFor to wait for async operations in the void expression + await vi.waitFor( + () => { + expect(mockRun).toHaveBeenCalledWith({ command: "invalidcommand" }); + }, + { timeout: 1000 }, + ); + + await vi.waitFor( + () => { + expect(services.chatHistory.addToolResult).toHaveBeenCalledWith( + expect.any(String), + "Bash command failed: Command not found", + "errored", + ); + }, + { timeout: 1000 }, + ); }); it("should not trigger bash mode for regular messages", async () => { const mockRun = vi.mocked(runTerminalCommandTool.run); - const chat = useChat({ - assistant: { name: "test" } as any, - model: { name: "test-model" } as any, - llmApi: {} as any, - } as any); - - await act(async () => { - await chat.handleUserMessage("Hello! How are you?"); - }); + const result = await handleBashModeProcessing("Hello! How are you?"); + expect(result).toBe("Hello! How are you?"); // Pass through unchanged expect(mockRun).not.toHaveBeenCalled(); + expect(services.chatHistory.addAssistantMessage).not.toHaveBeenCalled(); }); it("should handle empty bash command", async () => { const mockRun = vi.mocked(runTerminalCommandTool.run); - const chat = useChat({ - assistant: { name: "test" } as any, - model: { name: "test-model" } as any, - llmApi: {} as any, - } as any); + const result = await handleBashModeProcessing("!"); - await act(async () => { - await chat.handleUserMessage("!"); - }); - - // Should not call the tool for empty command + expect(result).toBe("!"); // Pass through unchanged for empty command expect(mockRun).not.toHaveBeenCalled(); + expect(services.chatHistory.addAssistantMessage).not.toHaveBeenCalled(); }); it("should handle bash command with leading whitespace", async () => { const mockRun = vi.mocked(runTerminalCommandTool.run); mockRun.mockResolvedValue("echo test output"); - const chat = useChat({ - assistant: { name: "test" } as any, - model: { name: "test-model" } as any, - llmApi: {} as any, - } as any); + const result = await handleBashModeProcessing(" !echo hello"); - await act(async () => { - await chat.handleUserMessage(" !echo hello"); - }); + expect(result).toBe(null); // Processed, no further handling needed + expect(services.chatHistory.addAssistantMessage).toHaveBeenCalled(); - expect(mockRun).toHaveBeenCalledWith({ command: "echo hello" }); + // Use vi.waitFor to wait for async operations in the void expression + await vi.waitFor( + () => { + expect(mockRun).toHaveBeenCalledWith({ command: "echo hello" }); + }, + { timeout: 1000 }, + ); + + await vi.waitFor( + () => { + expect(services.chatHistory.addToolResult).toHaveBeenCalledWith( + expect.any(String), + "echo test output", + "done", + ); + }, + { timeout: 1000 }, + ); }); }); From 898fc440ca165e6d459b3b9ad8ef29954b80a6b6 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 2 Sep 2025 22:44:40 -0700 Subject: [PATCH 10/31] fix: eslint --- extensions/cli/src/ui/hooks/useChat.shellMode.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/cli/src/ui/hooks/useChat.shellMode.test.ts b/extensions/cli/src/ui/hooks/useChat.shellMode.test.ts index da65c1a70..3308fdde5 100644 --- a/extensions/cli/src/ui/hooks/useChat.shellMode.test.ts +++ b/extensions/cli/src/ui/hooks/useChat.shellMode.test.ts @@ -1,6 +1,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { runTerminalCommandTool } from "src/tools/runTerminalCommand.js"; + import { services } from "../../services/index.js"; import { handleBashModeProcessing } from "./useChat.shellMode.js"; From 87b19acfe9d8a7c995374fd3ddda8835339dfb4a Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 3 Sep 2025 17:17:40 -0700 Subject: [PATCH 11/31] fix: don't show unchanged diff sections in extension UI --- .../pages/gui/ToolCallDiv/FindAndReplace.tsx | 116 +++++++++++++++++- 1 file changed, 114 insertions(+), 2 deletions(-) diff --git a/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx b/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx index ec0d9d8b9..f2f029595 100644 --- a/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx +++ b/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx @@ -3,7 +3,7 @@ import { ApplyState } from "core"; import { EditOperation } from "core/tools/definitions/multiEdit"; import { renderContextItems } from "core/util/messageContent"; import { getLastNPathParts, getUriPathBasename } from "core/util/uri"; -import { diffLines } from "diff"; +import { ChangeObject, diffLines } from "diff"; import { useContext, useMemo, useState } from "react"; import { ApplyActions } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ApplyActions"; import { FileInfo } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/FileInfo"; @@ -122,6 +122,107 @@ export function FindAndReplaceDisplay({ } }, [toolCallState?.status, toolCallState?.output]); + const processedDiff: (ChangeObject | { ellipsis: true })[] = + useMemo(() => { + if (!diffResult?.diff) return []; + + const MAX_CONTEXT_LINES = 2; + const processed: (ChangeObject | { ellipsis: true })[] = []; + + for (let i = 0; i < diffResult.diff.length; i++) { + const part = diffResult.diff[i]; + + if (part.added || part.removed) { + processed.push(part); + } else { + // This is an unchanged part + const lines = part.value.split("\n"); + // Remove empty line at the end if it exists + if (lines[lines.length - 1] === "") { + lines.pop(); + } + + const isFirstPart = i === 0; + const isLastPart = i === diffResult.diff.length - 1; + const hasChangesAfter = + i < diffResult.diff.length - 1 && + diffResult.diff.slice(i + 1).some((p) => p.added || p.removed); + const hasChangesBefore = + i > 0 && + diffResult.diff.slice(0, i).some((p) => p.added || p.removed); + + let startIndex = 0; + let endIndex = lines.length; + let addEllipsisAtStart = false; + let addEllipsisAtEnd = false; + + if (isFirstPart && hasChangesAfter) { + // Show only last MAX_CONTEXT_LINES lines + const newStartIndex = Math.max(0, lines.length - MAX_CONTEXT_LINES); + if (newStartIndex > 0) { + addEllipsisAtStart = true; + } + startIndex = newStartIndex; + } else if (isLastPart && hasChangesBefore) { + // Show only first MAX_CONTEXT_LINES lines + const newEndIndex = Math.min(lines.length, MAX_CONTEXT_LINES); + if (newEndIndex < lines.length) { + addEllipsisAtEnd = true; + } + endIndex = newEndIndex; + } else if ( + !isFirstPart && + !isLastPart && + (hasChangesBefore || hasChangesAfter) + ) { + // Show MAX_CONTEXT_LINES at start and end + if (lines.length > MAX_CONTEXT_LINES * 2) { + const contextLines = [ + ...lines.slice(0, MAX_CONTEXT_LINES), + ...lines.slice(-MAX_CONTEXT_LINES), + ]; + processed.push({ + ...part, + value: + contextLines.slice(0, MAX_CONTEXT_LINES).join("\n") + "\n", + }); + + // Add ellipsis indicator + processed.push({ + ellipsis: true, + }); + + processed.push({ + ...part, + value: contextLines.slice(MAX_CONTEXT_LINES).join("\n") + "\n", + }); + continue; + } + } + + if (startIndex < endIndex) { + const visibleLines = lines.slice(startIndex, endIndex); + if (visibleLines.length > 0) { + if (addEllipsisAtStart) { + processed.unshift({ ellipsis: true }); + } + + processed.push({ + ...part, + value: visibleLines.join("\n") + "\n", + }); + + if (addEllipsisAtEnd) { + processed.push({ ellipsis: true }); + } + } + } + } + } + + return processed; + }, [diffResult?.diff]); + // Unified container component that always renders the same structure const renderContainer = (content: React.ReactNode) => (
@@ -200,7 +301,18 @@ export function FindAndReplaceDisplay({
-        {diffResult.diff.map((part, index) => {
+        {processedDiff.map((part, index) => {
+          if ("ellipsis" in part) {
+            return (
+              
+ ⋯ +
+ ); + } + if (part.removed) { return (
Date: Thu, 4 Sep 2025 18:52:55 +0530 Subject: [PATCH 12/31] fix: abort2error during stream fim --- core/llm/index.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/core/llm/index.ts b/core/llm/index.ts index 6602be1f1..f8fefd381 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -370,8 +370,17 @@ export abstract class BaseLLM implements ILLM { }, }); - if (error !== undefined) { - if (error === "cancel" || error.name === "AbortError") { + if (typeof error === "undefined") { + interaction?.logItem({ + kind: "success", + promptTokens, + generatedTokens, + thinkingTokens, + usage, + }); + return "success"; + } else { + if (error === "cancel" || error?.name?.includes("AbortError")) { interaction?.logItem({ kind: "cancel", promptTokens, @@ -393,15 +402,6 @@ export abstract class BaseLLM implements ILLM { }); return "error"; } - } else { - interaction?.logItem({ - kind: "success", - promptTokens, - generatedTokens, - thinkingTokens, - usage, - }); - return "success"; } } @@ -615,6 +615,7 @@ export abstract class BaseLLM implements ILLM { kind: "chunk", chunk: formattedContent, }); + completion += formattedContent; yield content; } @@ -630,6 +631,7 @@ export abstract class BaseLLM implements ILLM { kind: "chunk", chunk, }); + completion += chunk; yield chunk; } From 1525047e3c07b7fdf0b973d198c7f9acc0330371 Mon Sep 17 00:00:00 2001 From: Jakub Blach Date: Thu, 4 Sep 2025 19:19:34 +0200 Subject: [PATCH 13/31] fix: open file on EDT Solves CON-3809 --- .../continueintellijextension/continue/IntelliJIde.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 9affb4c2d..ba1f4a571 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -199,7 +199,9 @@ class IntelliJIDE( } override suspend fun openFile(path: String) = - fileUtils.openFile(path) + withContext(Dispatchers.EDT) { + fileUtils.openFile(path) + } override suspend fun openUrl(url: String) { withContext(Dispatchers.IO) { From 082af0f3dd4ce4db4a5aa5622e8c60c649374b51 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 4 Sep 2025 14:22:31 -0700 Subject: [PATCH 14/31] fix: clean up diff viewer --- .../pages/gui/ToolCallDiv/FindAndReplace.tsx | 243 ++++++------------ 1 file changed, 77 insertions(+), 166 deletions(-) diff --git a/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx b/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx index f2f029595..8d226dc58 100644 --- a/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx +++ b/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx @@ -3,7 +3,7 @@ import { ApplyState } from "core"; import { EditOperation } from "core/tools/definitions/multiEdit"; import { renderContextItems } from "core/util/messageContent"; import { getLastNPathParts, getUriPathBasename } from "core/util/uri"; -import { ChangeObject, diffLines } from "diff"; +import { diffLines } from "diff"; import { useContext, useMemo, useState } from "react"; import { ApplyActions } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ApplyActions"; import { FileInfo } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/FileInfo"; @@ -14,6 +14,7 @@ import { selectToolCallById, } from "../../../redux/selectors/selectToolCalls"; import { performFindAndReplace } from "../../../util/clientTools/findAndReplaceUtils"; +import { cn } from "../../../util/cn"; import { getStatusIcon } from "./utils"; interface FindAndReplaceDisplayProps { @@ -25,6 +26,48 @@ interface FindAndReplaceDisplayProps { historyIndex: number; } +const MAX_SAME_LINES = 2; + +function EllipsisLine() { + return ( +
+ ⋯ +
+ ); +} + +function DiffLines({ + lines, + className = "", + diffChar = " ", + diffCharClass = "text-description-muted", +}: { + lines: string[]; + diffChar?: string; + diffCharClass?: string; + className?: string; +}) { + return ( + <> + {lines.map((line, lineIndex) => { + const isLastPartLine = lineIndex === lines.length - 1; + if (line === "" && isLastPartLine) return null; + return ( +
+ + {diffChar} + + {line} +
+ ); + })} + + ); +} + export function FindAndReplaceDisplay({ fileUri, relativeFilePath, @@ -122,107 +165,6 @@ export function FindAndReplaceDisplay({ } }, [toolCallState?.status, toolCallState?.output]); - const processedDiff: (ChangeObject | { ellipsis: true })[] = - useMemo(() => { - if (!diffResult?.diff) return []; - - const MAX_CONTEXT_LINES = 2; - const processed: (ChangeObject | { ellipsis: true })[] = []; - - for (let i = 0; i < diffResult.diff.length; i++) { - const part = diffResult.diff[i]; - - if (part.added || part.removed) { - processed.push(part); - } else { - // This is an unchanged part - const lines = part.value.split("\n"); - // Remove empty line at the end if it exists - if (lines[lines.length - 1] === "") { - lines.pop(); - } - - const isFirstPart = i === 0; - const isLastPart = i === diffResult.diff.length - 1; - const hasChangesAfter = - i < diffResult.diff.length - 1 && - diffResult.diff.slice(i + 1).some((p) => p.added || p.removed); - const hasChangesBefore = - i > 0 && - diffResult.diff.slice(0, i).some((p) => p.added || p.removed); - - let startIndex = 0; - let endIndex = lines.length; - let addEllipsisAtStart = false; - let addEllipsisAtEnd = false; - - if (isFirstPart && hasChangesAfter) { - // Show only last MAX_CONTEXT_LINES lines - const newStartIndex = Math.max(0, lines.length - MAX_CONTEXT_LINES); - if (newStartIndex > 0) { - addEllipsisAtStart = true; - } - startIndex = newStartIndex; - } else if (isLastPart && hasChangesBefore) { - // Show only first MAX_CONTEXT_LINES lines - const newEndIndex = Math.min(lines.length, MAX_CONTEXT_LINES); - if (newEndIndex < lines.length) { - addEllipsisAtEnd = true; - } - endIndex = newEndIndex; - } else if ( - !isFirstPart && - !isLastPart && - (hasChangesBefore || hasChangesAfter) - ) { - // Show MAX_CONTEXT_LINES at start and end - if (lines.length > MAX_CONTEXT_LINES * 2) { - const contextLines = [ - ...lines.slice(0, MAX_CONTEXT_LINES), - ...lines.slice(-MAX_CONTEXT_LINES), - ]; - processed.push({ - ...part, - value: - contextLines.slice(0, MAX_CONTEXT_LINES).join("\n") + "\n", - }); - - // Add ellipsis indicator - processed.push({ - ellipsis: true, - }); - - processed.push({ - ...part, - value: contextLines.slice(MAX_CONTEXT_LINES).join("\n") + "\n", - }); - continue; - } - } - - if (startIndex < endIndex) { - const visibleLines = lines.slice(startIndex, endIndex); - if (visibleLines.length > 0) { - if (addEllipsisAtStart) { - processed.unshift({ ellipsis: true }); - } - - processed.push({ - ...part, - value: visibleLines.join("\n") + "\n", - }); - - if (addEllipsisAtEnd) { - processed.push({ ellipsis: true }); - } - } - } - } - } - - return processed; - }, [diffResult?.diff]); - // Unified container component that always renders the same structure const renderContainer = (content: React.ReactNode) => (
@@ -301,81 +243,50 @@ export function FindAndReplaceDisplay({
-        {processedDiff.map((part, index) => {
-          if ("ellipsis" in part) {
-            return (
-              
- ⋯ -
- ); - } - + {diffResult.diff?.map((part, index) => { if (part.removed) { return ( -
- {part.value.split("\n").map((line, lineIndex) => { - if ( - line === "" && - lineIndex === part.value.split("\n").length - 1 - ) - return null; - return ( -
- - - {line} -
- ); - })} -
+ lines={part.value.split("\n")} + className="border-l-4 border-red-900 bg-red-900/30" + diffCharClass="text-red-600" + /> ); } else if (part.added) { return ( -
- {part.value.split("\n").map((line, lineIndex) => { - if ( - line === "" && - lineIndex === part.value.split("\n").length - 1 - ) - return null; - return ( -
- + - {line} -
- ); - })} -
+ lines={part.value.split("\n")} + diffCharClass="text-green-600" + className="border-l-4 border-green-600 bg-green-600/20" + /> ); } else { + const isFirst = index === 0; + const isLast = index === diffResult.diff.length - 1; + const lines = part.value.split("\n"); + const showStartEllipsis = isFirst && lines.length > MAX_SAME_LINES; + const showEndEllipsis = isLast && lines.length > MAX_SAME_LINES; + const showMiddleEllipses = + !isFirst && !isLast && lines.length > MAX_SAME_LINES * 2 + 1; + + const startLines = showStartEllipsis + ? lines.slice(-MAX_SAME_LINES) + : showMiddleEllipses || showEndEllipsis + ? lines.slice(0, MAX_SAME_LINES) + : lines; + const endLines = showMiddleEllipses + ? lines.slice(-MAX_SAME_LINES) + : []; + return (
- {part.value.split("\n").map((line, lineIndex) => { - if ( - line === "" && - lineIndex === part.value.split("\n").length - 1 - ) - return null; - return ( -
- - {" "} - - {line} -
- ); - })} + {showStartEllipsis && } + + {showMiddleEllipses && } + + {showEndEllipsis && }
); } From e31833160579e753919fc5c9d9eb504882b4da84 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 4 Sep 2025 14:53:16 -0700 Subject: [PATCH 15/31] fix: show added/removed diff chars --- gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx b/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx index 8d226dc58..ae1b3d5c9 100644 --- a/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx +++ b/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx @@ -251,6 +251,7 @@ export function FindAndReplaceDisplay({ lines={part.value.split("\n")} className="border-l-4 border-red-900 bg-red-900/30" diffCharClass="text-red-600" + diffChar="-" /> ); } else if (part.added) { @@ -260,6 +261,7 @@ export function FindAndReplaceDisplay({ lines={part.value.split("\n")} diffCharClass="text-green-600" className="border-l-4 border-green-600 bg-green-600/20" + diffChar="+" /> ); } else { From 06574b506b306cf978eab092e907a10d0d3c46e2 Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Thu, 4 Sep 2025 17:09:40 -0700 Subject: [PATCH 16/31] chore: disable fail-fast for cli workflow There's some flakey tests in cli test suite, let's not fail fast so one failed matrix won't immediately stop all other running matrixes. --- .github/workflows/cli-pr-checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cli-pr-checks.yml b/.github/workflows/cli-pr-checks.yml index 43a78d06e..94987f57b 100644 --- a/.github/workflows/cli-pr-checks.yml +++ b/.github/workflows/cli-pr-checks.yml @@ -59,6 +59,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] node-version: [18, 20, 22, 24] + fail-fast: false runs-on: ${{ matrix.os }} steps: From 3ca8a7b6369c3f1ac863cc180ef01f5ab1bb0dd4 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 4 Sep 2025 20:31:48 -0700 Subject: [PATCH 17/31] Handle review comment threads in GitHub workflow --- .github/workflows/respond-to-cubic.yaml | 41 +++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/.github/workflows/respond-to-cubic.yaml b/.github/workflows/respond-to-cubic.yaml index 4be94e462..2f3da84bc 100644 --- a/.github/workflows/respond-to-cubic.yaml +++ b/.github/workflows/respond-to-cubic.yaml @@ -172,6 +172,40 @@ jobs: if: steps.check-mention.outputs.contains_mention == 'true' run: npm i -g @continuedev/cli + - name: Get review context + if: steps.check-mention.outputs.contains_mention == 'true' + id: review-context + uses: actions/github-script@v7 + with: + script: | + let reviewContext = ''; + + // Check if this comment is a reply to another review comment + if (context.payload.comment.in_reply_to_id) { + try { + const { data: originalComment } = await github.rest.pulls.getReviewComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: context.payload.comment.in_reply_to_id + }); + + reviewContext = `**Original review comment by @${originalComment.user.login}:** + ${originalComment.body} + + **Reply by @${{ github.event.comment.user.login }}:** + ${{ github.event.comment.body }}`; + } catch (error) { + console.log('Could not fetch original comment, using current comment only'); + reviewContext = `**Review comment by @${{ github.event.comment.user.login }}:** + ${{ github.event.comment.body }}`; + } + } else { + reviewContext = `**Review comment by @${{ github.event.comment.user.login }}:** + ${{ github.event.comment.body }}`; + } + + core.setOutput('context', reviewContext); + - name: Start remote session if: steps.check-mention.outputs.contains_mention == 'true' id: remote-session @@ -180,13 +214,14 @@ jobs: run: | # Create a temporary file for the prompt to handle special characters and newlines properly cat > /tmp/prompt.txt << 'PROMPT_EOF' - Please help with the following code review comment from @${{ github.event.comment.user.login }} on PR #${{ github.event.pull_request.number }}: + Please help with the following code review discussion from PR #${{ github.event.pull_request.number }}: **File:** ${{ github.event.comment.path }} **Line:** ${{ github.event.comment.line || github.event.comment.original_line || 'N/A' }} - **Comment:** ${{ github.event.comment.body }} - Please analyze the specific file and line mentioned, understand the review feedback, implement the necessary changes, and commit them to this branch. + ${{ steps.review-context.outputs.context }} + + Please analyze the specific file and line mentioned, understand the review feedback and any discussion context, implement the necessary changes, and commit them to this branch. PROMPT_EOF # Debug output From 212cad2e351e789bffa23ca9a1ec90c6448a5f03 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 4 Sep 2025 20:34:13 -0700 Subject: [PATCH 18/31] echo branch for debuggng --- .github/workflows/respond-to-cubic.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/respond-to-cubic.yaml b/.github/workflows/respond-to-cubic.yaml index 2f3da84bc..d462b26ba 100644 --- a/.github/workflows/respond-to-cubic.yaml +++ b/.github/workflows/respond-to-cubic.yaml @@ -212,6 +212,9 @@ jobs: env: CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }} run: | + # Debug: Echo the branch we're starting the session on + echo "Starting remote session on branch: ${{ github.event.pull_request.head.ref }}" + # Create a temporary file for the prompt to handle special characters and newlines properly cat > /tmp/prompt.txt << 'PROMPT_EOF' Please help with the following code review discussion from PR #${{ github.event.pull_request.number }}: From 261d181362e53dfa32dd5a1aa719a33500c1d674 Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Fri, 5 Sep 2025 00:32:50 -0700 Subject: [PATCH 19/31] fix gemini tests --- packages/openai-adapters/src/apis/Gemini.ts | 7 ++----- packages/openai-adapters/src/apis/Relace.ts | 7 ++----- packages/openai-adapters/src/test/util.ts | 14 +++++++++++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/openai-adapters/src/apis/Gemini.ts b/packages/openai-adapters/src/apis/Gemini.ts index 2f2446414..f0cab7693 100644 --- a/packages/openai-adapters/src/apis/Gemini.ts +++ b/packages/openai-adapters/src/apis/Gemini.ts @@ -10,6 +10,7 @@ import { Completion, CompletionCreateParamsNonStreaming, CompletionCreateParamsStreaming, + CompletionUsage, CreateEmbeddingResponse, EmbeddingCreateParams, Model, @@ -38,11 +39,7 @@ import { RerankCreateParams, } from "./base.js"; -type UsageInfo = { - total_tokens: number; - completion_tokens: number; - prompt_tokens: number; -}; +type UsageInfo = Pick; export class GeminiApi implements BaseLlmApi { apiBase: string = "https://generativelanguage.googleapis.com/v1beta/"; diff --git a/packages/openai-adapters/src/apis/Relace.ts b/packages/openai-adapters/src/apis/Relace.ts index c2799d376..37b92b1eb 100644 --- a/packages/openai-adapters/src/apis/Relace.ts +++ b/packages/openai-adapters/src/apis/Relace.ts @@ -2,6 +2,7 @@ import { Completion, CompletionCreateParamsNonStreaming, CompletionCreateParamsStreaming, + CompletionUsage, } from "openai/resources/completions.mjs"; import { CreateEmbeddingResponse, @@ -29,11 +30,7 @@ import { RerankCreateParams, } from "./base.js"; -type UsageInfo = { - total_tokens: number; - completion_tokens: number; - prompt_tokens: number; -}; +type UsageInfo = Pick; // Relace only supports apply through a /v1/apply endpoint export class RelaceApi implements BaseLlmApi { diff --git a/packages/openai-adapters/src/test/util.ts b/packages/openai-adapters/src/test/util.ts index 5c751e792..fbcf51932 100644 --- a/packages/openai-adapters/src/test/util.ts +++ b/packages/openai-adapters/src/test/util.ts @@ -106,9 +106,17 @@ export function testChat( expect(usage).toBeDefined(); expect(usage!.completion_tokens).toBeGreaterThan(0); expect(usage!.prompt_tokens).toBeGreaterThan(0); - expect(usage!.total_tokens).toEqual( - usage!.prompt_tokens + usage!.completion_tokens, - ); + // Gemini 2.5 models have thinking tokens, so total_tokens >= prompt + completion + // Other models should have total_tokens = prompt + completion + if (model.includes('gemini-2.5') || model.includes('gemini-2.0')) { + expect(usage!.total_tokens).toBeGreaterThanOrEqual( + usage!.prompt_tokens + usage!.completion_tokens, + ); + } else { + expect(usage!.total_tokens).toEqual( + usage!.prompt_tokens + usage!.completion_tokens, + ); + } } }); From cbbebe276bc33fecc027e8278d385f7c14038505 Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Fri, 5 Sep 2025 00:33:02 -0700 Subject: [PATCH 20/31] openai stream include_usage=true --- packages/openai-adapters/src/apis/OpenAI.ts | 5 +++++ packages/openai-adapters/src/test/adapter-test-utils.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/packages/openai-adapters/src/apis/OpenAI.ts b/packages/openai-adapters/src/apis/OpenAI.ts index 714ce67fd..20c914318 100644 --- a/packages/openai-adapters/src/apis/OpenAI.ts +++ b/packages/openai-adapters/src/apis/OpenAI.ts @@ -35,6 +35,11 @@ export class OpenAIApi implements BaseLlmApi { }); } modifyChatBody(body: T): T { + // Add stream_options to include usage in streaming responses + if (body.stream) { + (body as any).stream_options = { include_usage: true }; + } + // o-series models - only apply for official OpenAI API const isOfficialOpenAIAPI = this.apiBase === "https://api.openai.com/v1/"; if (isOfficialOpenAIAPI) { diff --git a/packages/openai-adapters/src/test/adapter-test-utils.ts b/packages/openai-adapters/src/test/adapter-test-utils.ts index e08cb6d09..6c125abf3 100644 --- a/packages/openai-adapters/src/test/adapter-test-utils.ts +++ b/packages/openai-adapters/src/test/adapter-test-utils.ts @@ -258,6 +258,7 @@ export const createAdapterTests = (testConfig: AdapterTestConfig) => { model: "gpt-4", messages: [{ role: "user", content: "hello" }], stream: true, + stream_options: { include_usage: true }, ...testConfig.customBodyOptions, }, }, From 99e2148f1d908b78531e4d3dac9ed34deafa60b4 Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Fri, 5 Sep 2025 00:59:25 -0700 Subject: [PATCH 21/31] lint --- packages/openai-adapters/src/apis/Gemini.ts | 5 ++++- packages/openai-adapters/src/apis/OpenAI.ts | 2 +- packages/openai-adapters/src/apis/Relace.ts | 5 ++++- packages/openai-adapters/src/test/util.ts | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/openai-adapters/src/apis/Gemini.ts b/packages/openai-adapters/src/apis/Gemini.ts index f0cab7693..b0f32ad46 100644 --- a/packages/openai-adapters/src/apis/Gemini.ts +++ b/packages/openai-adapters/src/apis/Gemini.ts @@ -39,7 +39,10 @@ import { RerankCreateParams, } from "./base.js"; -type UsageInfo = Pick; +type UsageInfo = Pick< + CompletionUsage, + "total_tokens" | "completion_tokens" | "prompt_tokens" +>; export class GeminiApi implements BaseLlmApi { apiBase: string = "https://generativelanguage.googleapis.com/v1beta/"; diff --git a/packages/openai-adapters/src/apis/OpenAI.ts b/packages/openai-adapters/src/apis/OpenAI.ts index 20c914318..310e5ef40 100644 --- a/packages/openai-adapters/src/apis/OpenAI.ts +++ b/packages/openai-adapters/src/apis/OpenAI.ts @@ -39,7 +39,7 @@ export class OpenAIApi implements BaseLlmApi { if (body.stream) { (body as any).stream_options = { include_usage: true }; } - + // o-series models - only apply for official OpenAI API const isOfficialOpenAIAPI = this.apiBase === "https://api.openai.com/v1/"; if (isOfficialOpenAIAPI) { diff --git a/packages/openai-adapters/src/apis/Relace.ts b/packages/openai-adapters/src/apis/Relace.ts index 37b92b1eb..febe38f1c 100644 --- a/packages/openai-adapters/src/apis/Relace.ts +++ b/packages/openai-adapters/src/apis/Relace.ts @@ -30,7 +30,10 @@ import { RerankCreateParams, } from "./base.js"; -type UsageInfo = Pick; +type UsageInfo = Pick< + CompletionUsage, + "total_tokens" | "completion_tokens" | "prompt_tokens" +>; // Relace only supports apply through a /v1/apply endpoint export class RelaceApi implements BaseLlmApi { diff --git a/packages/openai-adapters/src/test/util.ts b/packages/openai-adapters/src/test/util.ts index fbcf51932..f637dec7e 100644 --- a/packages/openai-adapters/src/test/util.ts +++ b/packages/openai-adapters/src/test/util.ts @@ -108,7 +108,7 @@ export function testChat( expect(usage!.prompt_tokens).toBeGreaterThan(0); // Gemini 2.5 models have thinking tokens, so total_tokens >= prompt + completion // Other models should have total_tokens = prompt + completion - if (model.includes('gemini-2.5') || model.includes('gemini-2.0')) { + if (model.includes("gemini-2.5") || model.includes("gemini-2.0")) { expect(usage!.total_tokens).toBeGreaterThanOrEqual( usage!.prompt_tokens + usage!.completion_tokens, ); From 9d2a4819c7d214119358ee70f4a1ab01029c0470 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Sep 2025 09:08:10 +0000 Subject: [PATCH 22/31] build(deps): bump actions/github-script from 7 to 8 Bumps [actions/github-script](https://github.com/actions/github-script) from 7 to 8. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v7...v8) --- updated-dependencies: - dependency-name: actions/github-script dependency-version: '8' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/compliance.yaml | 2 +- .github/workflows/label-merged-prs.yml | 2 +- .github/workflows/respond-to-cubic.yaml | 10 +++++----- .github/workflows/similar-issues.yml | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/compliance.yaml b/.github/workflows/compliance.yaml index 76c21d6b1..0e4a04e02 100644 --- a/.github/workflows/compliance.yaml +++ b/.github/workflows/compliance.yaml @@ -41,7 +41,7 @@ jobs: - name: Add PR title guidance comment if: always() && steps.pr-title-check.outputs.valid == 'false' - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | const { data: comments } = await github.rest.issues.listComments({ diff --git a/.github/workflows/label-merged-prs.yml b/.github/workflows/label-merged-prs.yml index d6f83eba8..b434d07fd 100644 --- a/.github/workflows/label-merged-prs.yml +++ b/.github/workflows/label-merged-prs.yml @@ -44,7 +44,7 @@ jobs: - name: Determine and apply tier label if: steps.check-author.outputs.should_label == 'true' - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | const pr = context.payload.pull_request; diff --git a/.github/workflows/respond-to-cubic.yaml b/.github/workflows/respond-to-cubic.yaml index 4be94e462..d683bd883 100644 --- a/.github/workflows/respond-to-cubic.yaml +++ b/.github/workflows/respond-to-cubic.yaml @@ -29,7 +29,7 @@ jobs: - name: Add eyes reaction to comment if: steps.check-mention.outputs.contains_mention == 'true' - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | await github.rest.reactions.createForIssueComment({ @@ -49,7 +49,7 @@ jobs: - name: Get PR information if: steps.check-mention.outputs.contains_mention == 'true' id: pr-info - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | const { data: pr } = await github.rest.pulls.get({ @@ -107,7 +107,7 @@ jobs: - name: Comment with session URL if: steps.check-mention.outputs.contains_mention == 'true' && steps.remote-session.outputs.session_url - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | const commentBody = `I've started [a remote session](${{ steps.remote-session.outputs.session_url }}) to help with your request: @@ -144,7 +144,7 @@ jobs: - name: Add eyes reaction to comment if: steps.check-mention.outputs.contains_mention == 'true' - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | await github.rest.reactions.createForPullRequestReviewComment({ @@ -211,7 +211,7 @@ jobs: - name: Comment with session URL if: steps.check-mention.outputs.contains_mention == 'true' && steps.remote-session.outputs.session_url - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | const commentBody = `I've started [a remote session](${{ steps.remote-session.outputs.session_url }}) to help with your request: diff --git a/.github/workflows/similar-issues.yml b/.github/workflows/similar-issues.yml index 9873a0585..4abf1cdd3 100644 --- a/.github/workflows/similar-issues.yml +++ b/.github/workflows/similar-issues.yml @@ -190,7 +190,7 @@ jobs: echo "confidence=$CONFIDENCE" >> $GITHUB_OUTPUT - name: Comment with analysis - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | let comment = ''; @@ -307,7 +307,7 @@ jobs: - name: Add labels if: github.event_name == 'issues' - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | const labels = []; From 50c6f90633b51025b9a82d7b6bd4b412dc56eb9c Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 5 Sep 2025 11:36:31 -0700 Subject: [PATCH 23/31] update Bash tool instructions --- extensions/cli/src/tools/runTerminalCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cli/src/tools/runTerminalCommand.ts b/extensions/cli/src/tools/runTerminalCommand.ts index 58d3939e5..726c86501 100644 --- a/extensions/cli/src/tools/runTerminalCommand.ts +++ b/extensions/cli/src/tools/runTerminalCommand.ts @@ -33,7 +33,7 @@ export const runTerminalCommandTool: Tool = { displayName: "Bash", description: `Executes a terminal command and returns the output -The command will be executed from the current working directory: ${process.cwd()} +Commands are automatically executed from the current working directory (${process.cwd()}), so there's no need to change directories with 'cd' commands. `, parameters: { command: { From 6789833a77eb57e6a06d2578d2497fc17751e191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20B=C5=82ach?= Date: Fri, 5 Sep 2025 21:35:16 +0200 Subject: [PATCH 24/31] fix: ignore Stream closed exceptions on flush (#7610) Solves: CON-3587 This exception occurs if continue-binary is killed or throws some unexpected error, but in the previous version, the exception would bubble up and be logged as an IDE error (visible for users). After this change, we catch this exception and only log it, because there's no point in throwing it. The handler still recognizes this invalid state and gracefully restarts the binary. --- .../continue/process/ContinueProcessHandler.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueProcessHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueProcessHandler.kt index 04e4d3d2e..9e269226b 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueProcessHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueProcessHandler.kt @@ -43,10 +43,14 @@ class ContinueProcessHandler( } scope.launch(Dispatchers.IO) { for (message in pendingWrites) { - log.debug("Write: $message") - writer.write(message) - writer.write("\r\n") - writer.flush() + try { + log.debug("Write: $message") + writer.write(message) + writer.write("\r\n") + writer.flush() + } catch (e: IOException) { + log.warn(e) + } } } } From 18ec563762fdb45635c9e4da10f3664a95e1e2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20B=C5=82ach?= Date: Fri, 5 Sep 2025 21:36:17 +0200 Subject: [PATCH 25/31] fix: don't use override-only actionPerformed to invoke action (#7608) It's resolving one of problems during plugin verification. I manually tested this feature to make sure there are no regressions. Solves error: Override-only method AddLicenseKey.actionPerformed(AnActionEvent) is invoked in AddLicenseKey.createErrorAction$1.invoke(...). This method is marked with @ApiStatus.OverrideOnly annotation, which indicates that the method must be only overridden but not invoked by client code. See documentation of the @ApiStatus.OverrideOnly for more info. --- .../error/ContinueErrorSubmitter.kt | 1 + .../license/AddLicenseKey.kt | 29 ++++++++----------- .../license/AddLicenseKeyDialog.kt | 4 +-- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/error/ContinueErrorSubmitter.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/error/ContinueErrorSubmitter.kt index 69ea9b911..9d806ee66 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/error/ContinueErrorSubmitter.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/error/ContinueErrorSubmitter.kt @@ -21,6 +21,7 @@ class ContinueErrorSubmitter : ErrorReportSubmitter() { consumer: Consumer ): Boolean { try { + // todo: IdeaReportingEvent is deprecated; migrate to IdeaLoggingEvent + figure out how to read attachments val event = events.filterIsInstance() .firstOrNull() ?: return false service().report( diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/license/AddLicenseKey.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/license/AddLicenseKey.kt index 2402ff6c4..66a096f5e 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/license/AddLicenseKey.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/license/AddLicenseKey.kt @@ -5,22 +5,27 @@ import com.github.continuedev.continueintellijextension.utils.castNestedOrNull import com.intellij.notification.NotificationAction import com.intellij.notification.NotificationGroupManager import com.intellij.notification.NotificationType -import com.intellij.openapi.actionSystem.ActionManager -import com.intellij.openapi.actionSystem.ActionPlaces import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.service +import com.intellij.openapi.project.Project import com.intellij.openapi.ui.DialogWrapper class AddLicenseKey : AnAction() { override fun actionPerformed(e: AnActionEvent) { - val dialog = AddLicenseKeyDialog(e.project) + performAddLicenseKey(e.project) + } + + private fun performAddLicenseKey(project: Project?) { + if (project == null) + return + val dialog = AddLicenseKeyDialog(project) dialog.show() if (dialog.exitCode != DialogWrapper.OK_EXIT_CODE) return - val messenger = e.project?.service()?.coreMessenger + val messenger = project.service().coreMessenger ?: return messenger.request("mdm/setLicenseKey", mapOf("licenseKey" to dialog.licenseKey), null) { response -> val isValid = response.castNestedOrNull("content") ?: false @@ -28,7 +33,7 @@ class AddLicenseKey : AnAction() { createSuccessAction() else createErrorAction() - notification.notify(e.project) + notification.notify(project) } } @@ -37,7 +42,7 @@ class AddLicenseKey : AnAction() { "License key is valid. A restart is required for it to take effect.", NotificationType.INFORMATION ).addAction( - NotificationAction.create("Restart IDE") { event, notification -> + NotificationAction.create("Restart IDE") { _, _ -> ApplicationManager.getApplication().restart() } ) @@ -49,17 +54,7 @@ class AddLicenseKey : AnAction() { ).addAction( NotificationAction.create("Try again") { event, notification -> notification.expire() - val action = this@AddLicenseKey - action.actionPerformed( - AnActionEvent( - null, - event.dataContext, - ActionPlaces.UNKNOWN, - action.templatePresentation.clone(), - ActionManager.getInstance(), - 0 - ) - ) + performAddLicenseKey(event.project) } ) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/license/AddLicenseKeyDialog.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/license/AddLicenseKeyDialog.kt index 4ba6f2e21..af8763a21 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/license/AddLicenseKeyDialog.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/license/AddLicenseKeyDialog.kt @@ -3,9 +3,9 @@ package com.github.continuedev.continueintellijextension.license import com.intellij.openapi.project.Project import com.intellij.openapi.ui.DialogWrapper import com.intellij.openapi.ui.ValidationInfo +import com.intellij.ui.dsl.builder.AlignX import com.intellij.ui.dsl.builder.bindText import com.intellij.ui.dsl.builder.panel -import com.intellij.ui.dsl.gridLayout.HorizontalAlign import javax.swing.JComponent class AddLicenseKeyDialog(project: Project?) : DialogWrapper(project) { @@ -22,7 +22,7 @@ class AddLicenseKeyDialog(project: Project?) : DialogWrapper(project) { panel { row { textField().bindText(::licenseKey) - .horizontalAlign(HorizontalAlign.FILL) + .align(AlignX.FILL) .focused() .validationOnApply { if (it.text.isBlank()) From b290e5b4dc13ef25bb233b3ef7b7cdd2bea6c6a8 Mon Sep 17 00:00:00 2001 From: Aditya Mitra <61635505+uinstinct@users.noreply.github.com> Date: Sat, 6 Sep 2025 01:09:12 +0530 Subject: [PATCH 26/31] fix(docs): broken settings page links (#7598) * fix(docs): broken settings page links * undo minor changes --- docs/features/autocomplete/how-to-customize.mdx | 2 +- docs/reference/deprecated-docs.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/features/autocomplete/how-to-customize.mdx b/docs/features/autocomplete/how-to-customize.mdx index 854be157e..4fab64383 100644 --- a/docs/features/autocomplete/how-to-customize.mdx +++ b/docs/features/autocomplete/how-to-customize.mdx @@ -3,6 +3,6 @@ title: “Customize Autocomplete Settings in Continue” description: “Learn how to customize autocomplete behavior in Continue, including user settings, configuration options, and adjustments to improve AI code suggestions in your IDE.” --- -Continue offers a handful of settings to customize autocomplete behavior. Visit the [User Settings Page](/customize/settings) to manage these settings. +Continue offers a handful of settings to customize autocomplete behavior. Visit the User Settings Page (Gear Icon) to manage these settings. For a comprehensive guide on all configuration options and their impacts, see the [Autocomplete deep dive](/customize/deep-dives/autocomplete). diff --git a/docs/reference/deprecated-docs.mdx b/docs/reference/deprecated-docs.mdx index c972db7fa..a62e88b49 100644 --- a/docs/reference/deprecated-docs.mdx +++ b/docs/reference/deprecated-docs.mdx @@ -408,4 +408,4 @@ The following configuration example includes: -This setup could also involve enabling Chromium as a backup for local documentation through the [User Settings Page](../customize/settings). \ No newline at end of file +This setup could also involve enabling Chromium as a backup for local documentation through the User Settings Page (Gear Icon). \ No newline at end of file From a698049b3a6654a0c72a3c525e9c8d11a885b8be Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Fri, 5 Sep 2025 15:22:50 -0700 Subject: [PATCH 27/31] chore: bump package.json --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index ee1649b03..6e9c5b01a 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.3.3", + "version": "1.3.4", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 1218c14f895b00252130b21a26abb90dd201be04 Mon Sep 17 00:00:00 2001 From: Aditya Mitra <61635505+uinstinct@users.noreply.github.com> Date: Sat, 6 Sep 2025 04:20:50 +0530 Subject: [PATCH 28/31] feat: add tooltips to user settings page (#7597) --- gui/src/components/gui/Switch.tsx | 13 ++++++- gui/src/pages/config/UserSettingsForm.tsx | 46 ++++++++++++++++++++--- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/gui/src/components/gui/Switch.tsx b/gui/src/components/gui/Switch.tsx index 0af15f8eb..23d232124 100644 --- a/gui/src/components/gui/Switch.tsx +++ b/gui/src/components/gui/Switch.tsx @@ -1,5 +1,7 @@ +import { InformationCircleIcon } from "@heroicons/react/24/outline"; import React, { ReactNode } from "react"; import { vscButtonBackground } from ".."; +import { ToolTip } from "./Tooltip"; type ToggleSwitchProps = { isToggled: boolean; @@ -8,6 +10,7 @@ type ToggleSwitchProps = { size?: number; showIfToggled?: ReactNode; disabled?: boolean; + tooltip?: string; }; const ToggleSwitch: React.FC = ({ @@ -17,12 +20,20 @@ const ToggleSwitch: React.FC = ({ size = 16, showIfToggled, disabled = false, + tooltip, }) => { return (
- {text} + + {text}{" "} + {tooltip && ( + + + + )} +
{isToggled && !!showIfToggled && showIfToggled}
{/* */}