Elffuss BraidHub

kikocis/continue public

Merge branch 'main' into nate/cli-headless-flag
Changeset7d35f41c7d13685e3c130005174b7252dbc370495093c928d7b4f083a6979e58
AuthorNate <sestinj@gmail.com> · 2025-09-08 11:50 -07:00
CommitterNate <sestinj@gmail.com> · 2025-09-08 11:50 -07:00
Parents0054f0ed575b, d96431e8a728

Browse the files at this changeset

40 files changed

modified .github/workflows/cli-pr-checks.yml +1 −0
@@ -59,6 +59,7 @@
5959 matrix:
6060 os: [ubuntu-latest, windows-latest, macos-latest]
6161 node-version: [18, 20, 22, 24]
62+ fail-fast: false
6263 runs-on: ${{ matrix.os }}
6364
6465 steps:
modified .github/workflows/compliance.yaml +1 −1
@@ -41,7 +41,7 @@
4141
4242 - name: Add PR title guidance comment
4343 if: always() && steps.pr-title-check.outputs.valid == 'false'
44- uses: actions/github-script@v7
44+ uses: actions/github-script@v8
4545 with:
4646 script: |
4747 const { data: comments } = await github.rest.issues.listComments({
modified .github/workflows/label-merged-prs.yml +1 −1
@@ -44,7 +44,7 @@
4444
4545 - name: Determine and apply tier label
4646 if: steps.check-author.outputs.should_label == 'true'
47- uses: actions/github-script@v7
47+ uses: actions/github-script@v8
4848 with:
4949 script: |
5050 const pr = context.payload.pull_request;
modified .github/workflows/respond-to-cubic.yaml +46 −8
@@ -29,7 +29,7 @@
2929
3030 - name: Add eyes reaction to comment
3131 if: steps.check-mention.outputs.contains_mention == 'true'
32- uses: actions/github-script@v7
32+ uses: actions/github-script@v8
3333 with:
3434 script: |
3535 await github.rest.reactions.createForIssueComment({
@@ -49,7 +49,7 @@
4949 - name: Get PR information
5050 if: steps.check-mention.outputs.contains_mention == 'true'
5151 id: pr-info
52- uses: actions/github-script@v7
52+ uses: actions/github-script@v8
5353 with:
5454 script: |
5555 const { data: pr } = await github.rest.pulls.get({
@@ -107,7 +107,7 @@
107107
108108 - name: Comment with session URL
109109 if: steps.check-mention.outputs.contains_mention == 'true' && steps.remote-session.outputs.session_url
110- uses: actions/github-script@v7
110+ uses: actions/github-script@v8
111111 with:
112112 script: |
113113 const commentBody = `I've started [a remote session](${{ steps.remote-session.outputs.session_url }}) to help with your request:
@@ -144,7 +144,7 @@
144144
145145 - name: Add eyes reaction to comment
146146 if: steps.check-mention.outputs.contains_mention == 'true'
147- uses: actions/github-script@v7
147+ uses: actions/github-script@v8
148148 with:
149149 script: |
150150 await github.rest.reactions.createForPullRequestReviewComment({
@@ -172,21 +172,59 @@
172172 if: steps.check-mention.outputs.contains_mention == 'true'
173173 run: npm i -g @continuedev/cli
174174
175+ - name: Get review context
176+ if: steps.check-mention.outputs.contains_mention == 'true'
177+ id: review-context
178+ uses: actions/github-script@v7
179+ with:
180+ script: |
181+ let reviewContext = '';
182+
183+ // Check if this comment is a reply to another review comment
184+ if (context.payload.comment.in_reply_to_id) {
185+ try {
186+ const { data: originalComment } = await github.rest.pulls.getReviewComment({
187+ owner: context.repo.owner,
188+ repo: context.repo.repo,
189+ comment_id: context.payload.comment.in_reply_to_id
190+ });
191+
192+ reviewContext = `**Original review comment by @${originalComment.user.login}:**
193+ ${originalComment.body}
194+
195+ **Reply by @${{ github.event.comment.user.login }}:**
196+ ${{ github.event.comment.body }}`;
197+ } catch (error) {
198+ console.log('Could not fetch original comment, using current comment only');
199+ reviewContext = `**Review comment by @${{ github.event.comment.user.login }}:**
200+ ${{ github.event.comment.body }}`;
201+ }
202+ } else {
203+ reviewContext = `**Review comment by @${{ github.event.comment.user.login }}:**
204+ ${{ github.event.comment.body }}`;
205+ }
206+
207+ core.setOutput('context', reviewContext);
208+
175209 - name: Start remote session
176210 if: steps.check-mention.outputs.contains_mention == 'true'
177211 id: remote-session
178212 env:
179213 CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }}
180214 run: |
215+ # Debug: Echo the branch we're starting the session on
216+ echo "Starting remote session on branch: ${{ github.event.pull_request.head.ref }}"
217+
181218 # Create a temporary file for the prompt to handle special characters and newlines properly
182219 cat > /tmp/prompt.txt << 'PROMPT_EOF'
183- Please help with the following code review comment from @${{ github.event.comment.user.login }} on PR #${{ github.event.pull_request.number }}:
220+ Please help with the following code review discussion from PR #${{ github.event.pull_request.number }}:
184221
185222 **File:** ${{ github.event.comment.path }}
186223 **Line:** ${{ github.event.comment.line || github.event.comment.original_line || 'N/A' }}
187- **Comment:** ${{ github.event.comment.body }}
188224
189- Please analyze the specific file and line mentioned, understand the review feedback, implement the necessary changes, and commit them to this branch.
225+ ${{ steps.review-context.outputs.context }}
226+
227+ 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.
190228 PROMPT_EOF
191229
192230 # Debug output
@@ -211,7 +249,7 @@
211249
212250 - name: Comment with session URL
213251 if: steps.check-mention.outputs.contains_mention == 'true' && steps.remote-session.outputs.session_url
214- uses: actions/github-script@v7
252+ uses: actions/github-script@v8
215253 with:
216254 script: |
217255 const commentBody = `I've started [a remote session](${{ steps.remote-session.outputs.session_url }}) to help with your request:
modified .github/workflows/similar-issues.yml +2 −2
@@ -190,7 +190,7 @@
190190 echo "confidence=$CONFIDENCE" >> $GITHUB_OUTPUT
191191
192192 - name: Comment with analysis
193- uses: actions/github-script@v7
193+ uses: actions/github-script@v8
194194 with:
195195 script: |
196196 let comment = '';
@@ -307,7 +307,7 @@
307307
308308 - name: Add labels
309309 if: github.event_name == 'issues'
310- uses: actions/github-script@v7
310+ uses: actions/github-script@v8
311311 with:
312312 script: |
313313 const labels = [];
modified core/llm/index.ts +13 −11
@@ -370,8 +370,17 @@
370370 },
371371 });
372372
373- if (error !== undefined) {
374- if (error === "cancel" || error.name === "AbortError") {
373+ if (typeof error === "undefined") {
374+ interaction?.logItem({
375+ kind: "success",
376+ promptTokens,
377+ generatedTokens,
378+ thinkingTokens,
379+ usage,
380+ });
381+ return "success";
382+ } else {
383+ if (error === "cancel" || error?.name?.includes("AbortError")) {
375384 interaction?.logItem({
376385 kind: "cancel",
377386 promptTokens,
@@ -393,15 +402,6 @@
393402 });
394403 return "error";
395404 }
396- } else {
397- interaction?.logItem({
398- kind: "success",
399- promptTokens,
400- generatedTokens,
401- thinkingTokens,
402- usage,
403- });
404- return "success";
405405 }
406406 }
407407
@@ -615,6 +615,7 @@
615615 kind: "chunk",
616616 chunk: formattedContent,
617617 });
618+
618619 completion += formattedContent;
619620 yield content;
620621 }
@@ -630,6 +631,7 @@
630631 kind: "chunk",
631632 chunk,
632633 });
634+
633635 completion += chunk;
634636 yield chunk;
635637 }
modified core/tools/definitions/editFile.ts +1 −1
@@ -8,7 +8,7 @@
88 }
99
1010 export const NO_PARALLEL_TOOL_CALLING_INTSRUCTION =
11- "Note this tool CANNOT be called in parallel with other tools.";
11+ "This tool CANNOT be called in parallel with other tools.";
1212
1313 const CHANGES_DESCRIPTION =
1414 "Any modifications to the file, showing only needed changes. Do NOT wrap this in a codeblock or write anything besides the code changes. In larger files, use brief language-appropriate placeholders for large unmodified sections, e.g. '// ... existing code ...'";
modified core/tools/definitions/multiEdit.ts +28 −44
@@ -1,6 +1,7 @@
11 import { Tool } from "../..";
22 import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
33 import { NO_PARALLEL_TOOL_CALLING_INTSRUCTION } from "./editFile";
4+import { singleFindAndReplaceTool } from "./singleFindAndReplace";
45
56 export interface EditOperation {
67 old_string: string;
@@ -24,60 +25,41 @@
2425 isInstant: false,
2526 function: {
2627 name: BuiltInToolNames.MultiEdit,
27- description: `This is a tool for making multiple edits to a single file in one operation. It
28-is built on top of the single find and replace tool and allows you to perform multiple
29-find-and-replace operations efficiently. Prefer this tool over the single find and replace tool
30-when you need to make multiple edits to the same file.
31-
32-Before using this tool:
33-
34-1. Use the read_file tool to understand the file's contents and context
35-2. Verify the directory path is correct
36-
37-To make multiple file edits, provide the following:
38-
39-1. filepath: The path to the file to modify (relative to the root of the workspace)
28+ description: `This is a tool for making multiple edits to a single file in one operation. It is built on top of the ${singleFindAndReplaceTool.function.name} and allows you to perform multiple find-and-replace operations efficiently.
29+Prefer this tool over the ${singleFindAndReplaceTool.function.name} tool when you need to make multiple edits to the same file.
30+
31+To make multiple edits to a file, provide the following:
32+1. filepath: The path to the file to modify, RELATIVE to the project/workspace root (verify the directory path is correct)
4033 2. edits: An array of edit operations to perform, where each edit contains:
41- - old_string: The text to replace (must match the file contents exactly, including all whitespace and indentation)
34+ - old_string: The text to replace (must match the old file contents exactly, including all whitespace/indentation)
4235 - new_string: The edited text to replace the old_string
4336 - replace_all: Replace all occurrences of old_string. This parameter is optional and defaults to false.
4437
4538 IMPORTANT:
4639 - All edits are applied in sequence, in the order they are provided
47-- Each edit operates on the result of the previous edit
48-- All edits must be valid for the operation to succeed - if any edit fails,
49-none will be applied
50-- This tool is ideal when you need to make several changes to different parts
51-of the same file
40+- Each edit operates on the result of the previous edit, so plan your edits carefully to avoid conflicts between sequential operations
41+- Edits are atomic - all edits must be valid for the operation to succeed - if any edit fails, none will be applied
42+- This tool is ideal when you need to make several changes to different parts of the same file
5243
5344 CRITICAL REQUIREMENTS:
54-
55-1. All edits follow the same requirements as the single find and replace tool
56-2. The edits are atomic - either all succeed or none are applied
57-3. Plan your edits carefully to avoid conflicts between sequential operations
58-4. ${NO_PARALLEL_TOOL_CALLING_INTSRUCTION}
59-
60-WARNING:
61-
62-- The tool will fail if edits.old_string doesn't match the file contents
63-exactly (including whitespace)
64-- The tool will fail if edits.old_string and edits.new_string are the same
65-- Since edits are applied in sequence, ensure that earlier edits don't affect
66-the text that later edits are trying to find
67-
68-When making edits:
69-
45+1. ALWAYS use the ${BuiltInToolNames.ReadFile} tool just before making edits, to understand the file's up-to-date contents and context. The user can also edit the file while you are working with it.
46+2. ${NO_PARALLEL_TOOL_CALLING_INTSRUCTION}
47+3. When making edits:
7048 - Ensure all edits result in idiomatic, correct code
7149 - Do not leave the code in a broken state
72-- Only use emojis if the user explicitly requests it. Avoid adding emojis to
73-files unless asked.
74-- Use replace_all for replacing and renaming strings across the file. This
75-parameter is useful if you want to rename a variable for instance.
50+- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked
51+- Use replace_all for replacing and renaming all matches for a string across the file. This parameter is useful if you want to rename a variable, for instance
7652
7753 If you want to create a new file, use:
78-- A new file path
54+- A new file path, including new directory if needed
7955 - First edit: empty old_string and the new file's contents as new_string
80-- Subsequent edits are not allowed - there is no need since you are creating`,
56+- Subsequent edits are not allowed - there is no need since you are creating
57+- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required
58+
59+WARNINGS:
60+- If earlier edits affect the text that later edits are trying to find, files can become mangled
61+- The tool will fail if edits.old_string doesn't match the file contents exactly (including whitespace)
62+- The tool will fail if edits.old_string and edits.new_string are the same - they MUST be different`,
8163 parameters: {
8264 type: "object",
8365 required: ["filepath", "edits"],
@@ -97,16 +79,18 @@
9779 properties: {
9880 old_string: {
9981 type: "string",
100- description: "The text to replace",
82+ description:
83+ "The text to replace (exact match including whitespace/indentation)",
10184 },
10285 new_string: {
10386 type: "string",
104- description: "The text to replace it with",
87+ description:
88+ "The text to replace it with. MUST be different than old_string.",
10589 },
10690 replace_all: {
10791 type: "boolean",
10892 description:
109- "Replace all occurrences of old_string (default false)",
93+ "Replace all occurrences of old_string (default false) in the file",
11094 },
11195 },
11296 },
modified core/tools/definitions/singleFindAndReplace.ts +13 −27
@@ -20,33 +20,18 @@
2020 isInstant: false,
2121 function: {
2222 name: BuiltInToolNames.SingleFindAndReplace,
23- description: `Performs exact string replacements in files.
24-
25-Usage:
26-
27-- You must use your \`read_file\` tool at least once in the conversation before
28-editing. This tool will error if you attempt an edit without reading the file.
29-
30-- When editing text from read_file tool output, ensure you preserve the exact
31-indentation (tabs/spaces) as it appears AFTER the line number prefix. The line
32-number prefix format is: spaces + line number + tab. Everything after that tab
33-is the actual file content to match. Never include any part of the line number
34-prefix in the old_string or new_string.
35-
36-- ALWAYS prefer editing existing files in the codebase. NEVER write new files
37-unless explicitly required.
38-
39-- Only use emojis if the user explicitly requests it. Avoid adding emojis to
40-files unless asked.
23+ description: `Performs exact string replacements in a file.
4124
25+IMPORTANT:
26+- ALWAYS use the \`${BuiltInToolNames.ReadFile}\` tool just before making edits, to understand the file's up-to-date contents and context. The user can also edit the file while you are working with it.
4227 - ${NO_PARALLEL_TOOL_CALLING_INTSRUCTION}
43-
44-- The edit will FAIL if \`old_string\` is not unique in the file. Either provide
45-a larger string with more surrounding context to make it unique or use
46-\`replace_all\` to change every instance of \`old_string\`.
47-
48-- Use \`replace_all\` for replacing and renaming strings across the file. This
49-parameter is useful if you want to rename a variable for instance.`,
28+- When editing text from \`${BuiltInToolNames.ReadFile}\` tool output, ensure you preserve exact whitespace/indentation.
29+- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.
30+- Use \`replace_all\` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable, for instance.
31+
32+WARNINGS:
33+- When not using \`replace_all\`, the edit will FAIL if \`old_string\` is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use \`replace_all\` to change every instance of \`old_string\`.
34+- The edit will likely fail if you have not recently used the \`${BuiltInToolNames.ReadFile}\` tool to view up-to-date file contents.`,
5035 parameters: {
5136 type: "object",
5237 required: ["filepath", "old_string", "new_string"],
@@ -58,12 +43,13 @@
5843 },
5944 old_string: {
6045 type: "string",
61- description: "The text to replace",
46+ description:
47+ "The text to replace - must be exact including whitespace/indentation",
6248 },
6349 new_string: {
6450 type: "string",
6551 description:
66- "The text to replace it with (must be different from old_string)",
52+ "The text to replace it with (MUST be different from old_string)",
6753 },
6854 replace_all: {
6955 type: "boolean",
modified docs/features/autocomplete/how-to-customize.mdx +1 −1
@@ -3,6 +3,6 @@
33 description: “Learn how to customize autocomplete behavior in Continue, including user settings, configuration options, and adjustments to improve AI code suggestions in your IDE.”
44 ---
55
6-Continue offers a handful of settings to customize autocomplete behavior. Visit the [User Settings Page](/customize/settings) to manage these settings.
6+Continue offers a handful of settings to customize autocomplete behavior. Visit the User Settings Page (Gear Icon) to manage these settings.
77
88 For a comprehensive guide on all configuration options and their impacts, see the [Autocomplete deep dive](/customize/deep-dives/autocomplete).
modified docs/reference/deprecated-docs.mdx +1 −1
@@ -408,4 +408,4 @@
408408 </Tab>
409409 </Tabs>
410410
411-This setup could also involve enabling Chromium as a backup for local documentation through the [User Settings Page](../customize/settings).
No newline at the end of the file
411+This setup could also involve enabling Chromium as a backup for local documentation through the User Settings Page (Gear Icon).
No newline at the end of the file
added extensions/cli/spec/shell-mode.md +138 −0
@@ -0,0 +1,138 @@
1+shell Mode (CLI TUI)
2+
3+Overview
4+
5+- shell mode lets users run shell commands directly from the chat input by starting their input with an exclamation mark (!).
6+- It is intended for quick terminal command execution without leaving the TUI.
7+
8+Activation
9+
10+- shell mode is activated when the current input (trimmed) starts with !
11+ - Example: "!git status" or " !ls -la" both activate shell mode.
12+- Visual indicator:
13+ - Input border color changes to yellow.
14+ - The input prompt indicator changes to a yellow "$".
15+ - The input placeholder includes "! for shell mode".
16+
17+Deactivation / Exiting shell Mode
18+
19+- Pressing Enter to submit the input exits shell mode immediately after submission, regardless of the command result.
20+- Pressing Esc when the input (trimmed) is exactly ! clears the input and exits shell mode.
21+- Editing the input so it no longer starts with ! also exits shell mode and restores normal input behavior.
22+
23+Interaction with other input helpers
24+
25+- When in shell mode (input starts with !):
26+ - "@" file search suggestions are disabled.
27+ - "/" slash command UI is disabled.
28+- When in slash command mode (input starts with /):
29+ - "@" file search suggestions are disabled.
30+
31+Submission behavior
32+
33+- On submit (Enter) with a shell-mode input:
34+ - The leading ! is removed and the remainder is treated as the shell command to run.
35+ - 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.
36+ - The shell command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated.
37+
38+Execution semantics
39+
40+- The command is executed in the same way as terminal tool commands, minus permissions
41+
42+Output handling
43+
44+- Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success.
45+- If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown.
46+- Output is truncated to the first 5000 lines if exceeded.
47+- Timeout behavior: If no output is received for 30 seconds (configurable in tests), the process is terminated and the result includes a note like:
48+ "[Command timed out after 30 seconds of no output]".
49+
50+Keyboard behaviors (summary)
51+
52+- Enter: submit input. If in shell mode, exits shell mode after submission and shows the pending shell tool call immediately.
53+- Shift+Enter: new line.
54+- Backslash (\) at end-of-line: inserts a new line (line continuation) as usual.
55+- Esc: if only ! (trimmed) is present, clears input and exits shell mode; otherwise cancels streaming or closes suggestions depending on context.
56+
57+Scope / Modes
58+
59+- shell mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing.
60+
61+Error handling
62+
63+- Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available).
64+
65+Examples
66+
67+- "!git status" → shows a shell tool call immediately, then populates with the git status output.
68+- "!echo hello" → shows a shell tool call immediately, then output "hello".
69+- "!some-unknown-cmd" → shows a shell tool call immediately, then sets status to error with an error message.
70+ Shell Mode (CLI TUI)
71+
72+Overview
73+
74+- Shell mode lets users run shell commands directly from the chat input by starting their input with an exclamation mark (!).
75+- It is intended for quick terminal command execution without leaving the TUI.
76+
77+Activation
78+
79+- Shell mode is activated when the current input (trimmed) starts with !
80+ - Example: "!git status" or " !ls -la" both activate Shell mode.
81+- Visual indicator:
82+ - Input border color changes to yellow.
83+ - The input prompt indicator changes to a yellow "$".
84+ - The input placeholder includes "! for shell mode".
85+
86+Deactivation / Exiting Shell Mode
87+
88+- Pressing Enter to submit the input exits shell mode immediately after submission, regardless of the command result.
89+- Pressing Esc when the input (trimmed) is exactly ! clears the input and exits shell mode.
90+- Editing the input so it no longer starts with ! also exits shell mode and restores normal input behavior.
91+
92+Interaction with other input helpers
93+
94+- When in shell mode (input starts with !):
95+ - "@" file search suggestions are disabled.
96+ - "/" slash command UI is disabled.
97+- When in slash command mode (input starts with /):
98+ - "@" file search suggestions are disabled.
99+
100+Submission behavior
101+
102+- On submit (Enter) with a shell-mode input:
103+ - The leading ! is removed and the remainder is treated as the shell command to run.
104+ - 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.
105+ - The shell command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated.
106+
107+Execution semantics
108+
109+- The command is executed in the same way as terminal tool commands, minus permissions, and inserted into the chat history the same.
110+
111+Output handling
112+
113+- Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success.
114+- If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown.
115+- Output is truncated to the first 5000 lines if exceeded.
116+- Timeout behavior: If no output is received for 30 seconds (configurable in tests), the process is terminated and the result includes a note like:
117+ "[Command timed out after 30 seconds of no output]".
118+
119+Keyboard behaviors (summary)
120+
121+- Enter: submit input. If in shell mode, exits shell mode after submission and shows the pending Shell tool call immediately.
122+- Shift+Enter: new line.
123+- Backslash (\) at end-of-line: inserts a new line (line continuation) as usual.
124+- Esc: if only ! (trimmed) is present, clears input and exits shell mode; otherwise cancels streaming or closes suggestions depending on context.
125+
126+Scope / Modes
127+
128+- Shell mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing.
129+
130+Error handling
131+
132+- Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available).
133+
134+Examples
135+
136+- "!git status" → shows a Shell tool call immediately, then populates with the git status output.
137+- "!echo hello" → shows a Shell tool call immediately, then output "hello".
138+- "!some-unknown-cmd" → shows a Shell tool call immediately, then sets status to error with an error message.
modified extensions/cli/src/slashCommands.ts +3 −0
@@ -28,6 +28,7 @@
2828 ` ${chalk.cyan("Enter")} Submit message`,
2929 ` ${chalk.cyan("Shift+Enter")} New line`,
3030 ` ${chalk.cyan("\\")} Line continuation (at end of line)`,
31+ ` ${chalk.cyan("!")} Shell mode - run shell commands`,
3132 "",
3233 chalk.white("Controls:"),
3334 ` ${chalk.cyan("Ctrl+C")} Clear input`,
@@ -39,9 +40,11 @@
3940 chalk.white("Special Characters:"),
4041 ` ${chalk.cyan("@")} Search and attach files for context`,
4142 ` ${chalk.cyan("/")} Access slash commands`,
43+ ` ${chalk.cyan("!")} Execute bash commands directly`,
4244 "",
4345 chalk.white("Available Commands:"),
4446 ` Type ${chalk.cyan("/")} to see available slash commands`,
47+ ` Type ${chalk.cyan("!")} followed by a command to execute bash directly`,
4548 ].join("\n");
4649 posthogService.capture("useSlashCommand", { name: "help" });
4750 return { output: helpMessage };
modified extensions/cli/src/tools/edit.test.ts +8 −5
@@ -1,8 +1,9 @@
11 import * as fs from "fs";
22
3-import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
3+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
44
5-import { editTool, markFileAsRead, readFilesSet } from "./edit.js";
5+import { editTool } from "./edit.js";
6+import { markFileAsRead, readFilesSet } from "./readFile.js";
67
78 // Mock the dependencies
89 vi.mock("../telemetry/telemetryService.js");
@@ -21,6 +22,7 @@
2122 readFileSync: vi.fn(),
2223 writeFileSync: vi.fn(),
2324 unlinkSync: vi.fn(),
25+ realpathSync: vi.fn(),
2426 };
2527 });
2628
@@ -34,6 +36,7 @@
3436 vi.mocked(fs.existsSync).mockReturnValue(true);
3537 vi.mocked(fs.readFileSync).mockReturnValue(originalContent);
3638 vi.mocked(fs.writeFileSync).mockImplementation(() => {});
39+ vi.mocked(fs.realpathSync).mockImplementation((path) => path.toString());
3740 });
3841
3942 afterEach(() => {
@@ -126,7 +129,7 @@
126129 const result = await editTool.preprocess!(args);
127130
128131 expect(result.args).toEqual({
129- file_path: testFilePath,
132+ resolvedPath: testFilePath,
130133 newContent: "Hi there\nThis is a test file\nGoodbye world",
131134 oldContent: originalContent,
132135 });
@@ -163,7 +166,7 @@
163166 it("should successfully write file and return success message", async () => {
164167 const newContent = "Hi there\nThis is a test file\nGoodbye world";
165168 const args = {
166- file_path: testFilePath,
169+ resolvedPath: testFilePath,
167170 newContent,
168171 oldContent: originalContent,
169172 };
@@ -186,7 +189,7 @@
186189 });
187190
188191 const args = {
189- file_path: testFilePath,
192+ resolvedPath: testFilePath,
190193 newContent: "new content",
191194 oldContent: originalContent,
192195 };
modified extensions/cli/src/tools/edit.ts +38 −53
@@ -8,6 +8,7 @@
88 getLanguageFromFilePath,
99 } from "../telemetry/utils.js";
1010
11+import { readFilesSet, readFileTool } from "./readFile.js";
1112 import { Tool } from "./types.js";
1213 import { generateDiff } from "./writeFile.js";
1314
@@ -18,40 +19,23 @@
1819 replace_all?: boolean;
1920 }
2021
21-// Track files that have been read in the current session
22-export const readFilesSet = new Set<string>();
23-
2422 export const editTool: Tool = {
2523 name: "Edit",
2624 displayName: "Edit",
2725 readonly: false,
2826 isBuiltIn: true,
29- description: `Performs exact string replacements in files.
30-
31-
32-Usage:
33-
34-- You must use your \`Read\` tool at least once in the conversation before
35-editing. This tool will error if you attempt an edit without reading the file.
36-
37-- When editing text from Read tool output, ensure you preserve the exact
38-indentation (tabs/spaces) as it appears AFTER the line number prefix. The line
39-number prefix format is: spaces + line number + tab. Everything after that tab
40-is the actual file content to match. Never include any part of the line number
41-prefix in the old_string or new_string.
42-
43-- ALWAYS prefer editing existing files in the codebase. NEVER write new files
44-unless explicitly required.
45-
46-- Only use emojis if the user explicitly requests it. Avoid adding emojis to
47-files unless asked.
48-
49-- The edit will FAIL if \`old_string\` is not unique in the file. Either provide
50-a larger string with more surrounding context to make it unique or use
51-\`replace_all\` to change every instance of \`old_string\`.
52-
53-- Use \`replace_all\` for replacing and renaming strings across the file. This
54-parameter is useful if you want to rename a variable for instance.`,
27+ description: `Performs exact string replacements in a file.
28+
29+USAGE:
30+- ALWAYS use the \`${readFileTool.name}\` tool just before making edits, to understand the file's up-to-date contents and context.
31+- When editing text from ${readFileTool.name} tool output, ensure you preserve exact whitespace/indentation.
32+- Always prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
33+- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.
34+- Use \`replace_all\` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable, for instance.
35+
36+WARNINGS:
37+- When not using \`replace_all\`, the edit will FAIL if \`old_string\` is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use \`replace_all\` to change every instance of \`old_string\`.
38+- The edit will FAIL if you have not recently used the \`${readFileTool.name}\` tool to view up-to-date file contents.`,
5539 parameters: {
5640 file_path: {
5741 type: "string",
@@ -60,13 +44,14 @@
6044 },
6145 old_string: {
6246 type: "string",
63- description: "The text to replace",
47+ description:
48+ "The text to replace - must be exact including whitespace/indentation",
6449 required: true,
6550 },
6651 new_string: {
6752 type: "string",
6853 description:
69- "The text to replace it with (must be different from old_string)",
54+ "The text to replace it with (MUST be different from old_string)",
7055 required: true,
7156 },
7257 replace_all: {
@@ -82,18 +67,12 @@
8267 new_string,
8368 replace_all = false,
8469 } = args as EditArgs;
85- throwIfFileIsSecurityConcern(file_path);
86- // Check if file has been read
87- if (!readFilesSet.has(file_path)) {
88- throw new Error(
89- `You must use the Read tool to read ${file_path} before editing it.`,
90- );
91- }
9270
9371 // Validate arguments
9472 if (!file_path) {
9573 throw new Error("file_path is required");
9674 }
75+
9776 if (!old_string) {
9877 throw new Error("old_string is required");
9978 }
@@ -104,13 +83,24 @@
10483 throw new Error("old_string and new_string must be different");
10584 }
10685
86+ const resolvedPath = fs.realpathSync(file_path);
87+
88+ // Check if file has been read
89+ if (!readFilesSet.has(resolvedPath)) {
90+ throw new Error(
91+ `You must use the ${readFileTool.name} tool to read ${file_path} before editing it.`,
92+ );
93+ }
94+
95+ throwIfFileIsSecurityConcern(resolvedPath);
96+
10797 // Check if file exists
108- if (!fs.existsSync(file_path)) {
98+ if (!fs.existsSync(resolvedPath)) {
10999 throw new Error(`File ${file_path} does not exist`);
110100 }
111101
112102 // Read current file content
113- const oldContent = fs.readFileSync(file_path, "utf-8");
103+ const oldContent = fs.readFileSync(resolvedPath, "utf-8");
114104
115105 // Check if old_string exists in the file
116106 if (!oldContent.includes(old_string)) {
@@ -134,11 +124,11 @@
134124 }
135125
136126 // Generate diff for preview
137- const diff = generateDiff(oldContent, newContent, file_path);
127+ const diff = generateDiff(oldContent, newContent, resolvedPath);
138128
139129 return {
140130 args: {
141- file_path,
131+ resolvedPath,
142132 newContent,
143133 oldContent,
144134 },
@@ -155,19 +145,19 @@
155145 };
156146 },
157147 run: async (args: {
158- file_path: string;
148+ resolvedPath: string;
159149 newContent: string;
160150 oldContent: string;
161151 }) => {
162152 try {
163- fs.writeFileSync(args.file_path, args.newContent, "utf-8");
153+ fs.writeFileSync(args.resolvedPath, args.newContent, "utf-8");
164154
165155 // Get lines for telemetry
166156 const { added, removed } = calculateLinesOfCodeDiff(
167157 args.oldContent,
168158 args.newContent,
169159 );
170- const language = getLanguageFromFilePath(args.file_path);
160+ const language = getLanguageFromFilePath(args.resolvedPath);
171161
172162 if (added > 0) {
173163 telemetryService.recordLinesOfCodeModified("added", added, language);
@@ -184,21 +174,16 @@
184174 const diff = generateDiff(
185175 args.oldContent,
186176 args.newContent,
187- args.file_path,
177+ args.resolvedPath,
188178 );
189179
190- return `Successfully edited ${args.file_path}\nDiff:\n${diff}`;
180+ return `Successfully edited ${args.resolvedPath}\nDiff:\n${diff}`;
191181 } catch (error) {
192182 throw new Error(
193- `Error: failed to edit ${args.file_path}: ${
183+ `Error: failed to edit ${args.resolvedPath}: ${
194184 error instanceof Error ? error.message : String(error)
195185 }`,
196186 );
197187 }
198188 },
199189 };
200-
201-// Function to mark a file as read (to be called from the read tool)
202-export function markFileAsRead(filePath: string) {
203- readFilesSet.add(filePath);
204-}
modified extensions/cli/src/tools/multiEdit.test.ts +5 −2
@@ -1,9 +1,10 @@
11 import * as fs from "fs";
22 import * as path from "path";
33
4-import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
4+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
55
6-import { multiEditTool, markFileAsRead } from "./multiEdit.js";
6+import { multiEditTool } from "./multiEdit.js";
7+import { markFileAsRead } from "./readFile.js";
78
89 // Mock the dependencies
910 vi.mock("../telemetry/telemetryService.js");
@@ -22,6 +23,7 @@
2223 readFileSync: vi.fn(),
2324 writeFileSync: vi.fn(),
2425 unlinkSync: vi.fn(),
26+ realpathSync: vi.fn(),
2527 };
2628 });
2729
@@ -35,6 +37,7 @@
3537 vi.mocked(fs.existsSync).mockReturnValue(true);
3638 vi.mocked(fs.readFileSync).mockReturnValue(originalContent);
3739 vi.mocked(fs.writeFileSync).mockImplementation(() => {});
40+ vi.mocked(fs.realpathSync).mockImplementation((path) => path.toString());
3841 });
3942
4043 afterEach(() => {
modified extensions/cli/src/tools/multiEdit.ts +41 −91
@@ -9,12 +9,11 @@
99 getLanguageFromFilePath,
1010 } from "../telemetry/utils.js";
1111
12-import { markFileAsRead, readFilesSet } from "./edit.js";
12+import { editTool } from "./edit.js";
13+import { readFilesSet, readFileTool } from "./readFile.js";
1314 import { Tool } from "./types.js";
1415 import { generateDiff } from "./writeFile.js";
1516
16-export { markFileAsRead };
17-
1817 export interface EditOperation {
1918 old_string: string;
2019 new_string: string;
@@ -26,15 +25,10 @@
2625 edits: EditOperation[];
2726 }
2827
29-// Function to check if file has been read (shared with edit tool)
30-function hasFileBeenRead(filePath: string): boolean {
31- return readFilesSet.has(filePath);
32-}
33-
3428 // Helper functions for multiEdit validation
3529 function validateMultiEditArgs(args: any): {
3630 original_path: string;
37- file_path: string;
31+ resolved_path: string;
3832 edits: EditOperation[];
3933 } {
4034 const { file_path, edits } = args as MultiEditArgs;
@@ -53,7 +47,9 @@
5347 ? file_path
5448 : path.resolve(process.cwd(), file_path);
5549
56- return { original_path: file_path, file_path: absolutePath, edits };
50+ const resolvedPath = fs.realpathSync(absolutePath);
51+
52+ return { original_path: file_path, resolved_path: resolvedPath, edits };
5753 }
5854
5955 function validateEdits(edits: EditOperation[]): void {
@@ -74,26 +70,25 @@
7470 }
7571
7672 function validateFileAccess(
77- original_path: string,
78- file_path: string,
73+ resolvedPath: string,
7974 isCreatingNewFile: boolean,
8075 ): void {
8176 if (isCreatingNewFile) {
8277 // For new file creation, check if parent directory exists
83- const parentDir = path.dirname(file_path);
78+ const parentDir = path.dirname(resolvedPath);
8479 if (parentDir && !fs.existsSync(parentDir)) {
8580 throw new Error(`Parent directory does not exist: ${parentDir}`);
8681 }
8782 } else {
8883 // For existing files, check if file has been read
8984 // Check with the original path first, then with absolute path
90- if (!hasFileBeenRead(original_path) && !hasFileBeenRead(file_path)) {
85+ if (!readFilesSet.has(resolvedPath)) {
9186 throw new Error(
92- `You must use the Read tool to read ${original_path} before editing it.`,
87+ `You must use the ${readFileTool.name} tool to read ${resolvedPath} before editing it.`,
9388 );
9489 }
95- if (!fs.existsSync(file_path)) {
96- throw new Error(`File ${file_path} does not exist`);
90+ if (!fs.existsSync(resolvedPath)) {
91+ throw new Error(`File ${resolvedPath} does not exist`);
9792 }
9893 }
9994 }
@@ -138,87 +133,42 @@
138133 displayName: "MultiEdit",
139134 readonly: false,
140135 isBuiltIn: true,
141- description: `This is a tool for making multiple edits to a single file in one operation. It
142-is built on top of the Edit tool and allows you to perform multiple
143-find-and-replace operations efficiently. Prefer this tool over the Edit tool
144-when you need to make multiple edits to the same file.
145-
146-
147-Before using this tool:
148-
149-
150-1. Use the Read tool to understand the file's contents and context
151-
152-2. Verify the directory path is correct
153-
154-
155-To make multiple file edits, provide the following:
156-
157-1. file_path: The absolute path to the file to modify (must be absolute, not
158-relative)
159-
136+ description: `This is a tool for making multiple edits to a single file in one operation. It is built on top of the ${editTool.name} tool and allows you to perform multiple find-and-replace operations efficiently.
137+Prefer this tool over the ${editTool.name} tool when you need to make multiple edits to the same file.
138+
139+To make multiple edits to a file, provide the following:
140+1. file_path: The absolute path to the file to modify (must be absolute, not relative)
160141 2. edits: An array of edit operations to perform, where each edit contains:
161- - old_string: The text to replace (must match the file contents exactly, including all whitespace and indentation)
142+ - old_string: The text to replace (must match the file contents exactly, including all whitespace/indentation)
162143 - new_string: The edited text to replace the old_string
163144 - replace_all: Replace all occurences of old_string. This parameter is optional and defaults to false.
164145
165146 IMPORTANT:
166-
167147 - All edits are applied in sequence, in the order they are provided
168-
169-- Each edit operates on the result of the previous edit
170-
171-- All edits must be valid for the operation to succeed - if any edit fails,
172-none will be applied
173-
174-- This tool is ideal when you need to make several changes to different parts
175-of the same file
176-
177-- For Jupyter notebooks (.ipynb files), use the NotebookEdit instead
178-
148+- Each edit operates on the result of the previous edit, so plan your edits carefully to avoid conflicts between sequential operations
149+- Edits are atomic - all edits must be valid for the operation to succeed - if any edit fails, none will be applied
150+- This tool is ideal when you need to make several changes to different parts of the same file
179151
180152 CRITICAL REQUIREMENTS:
181-
182-1. All edits follow the same requirements as the single Edit tool
183-
184-2. The edits are atomic - either all succeed or none are applied
185-
186-3. Plan your edits carefully to avoid conflicts between sequential operations
187-
188-
189-WARNING:
190-
191-- The tool will fail if edits.old_string doesn't match the file contents
192-exactly (including whitespace)
193-
194-- The tool will fail if edits.old_string and edits.new_string are the same
195-
196-- Since edits are applied in sequence, ensure that earlier edits don't affect
197-the text that later edits are trying to find
198-
199-
200-When making edits:
201-
153+1. ALWAYS use the ${readFileTool.name} tool just before making edits, to understand the file's up-to-date contents and context
154+2. When making edits:
202155 - Ensure all edits result in idiomatic, correct code
203-
204156 - Do not leave the code in a broken state
205-
206157 - Always use absolute file paths (starting with /)
207-
208-- Only use emojis if the user explicitly requests it. Avoid adding emojis to
209-files unless asked.
210-
211-- Use replace_all for replacing and renaming strings across the file. This
212-parameter is useful if you want to rename a variable for instance.
213-
158+- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.
159+- Use replace_all for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.
214160
215161 If you want to create a new file, use:
216-
217-- A new file path, including dir name if needed
218-
162+- A new file path, including new directory if needed
219163 - First edit: empty old_string and the new file's contents as new_string
220-
221-- Subsequent edits: normal edit operations on the created content`,
164+- Subsequent edits: normal edit operations on the created content
165+- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required
166+
167+WARNINGS:
168+- If earlier edits affect the text that later edits are trying to find, files can become mangled
169+- The tool will fail if edits.old_string doesn't match the file contents exactly (including whitespace)
170+- The tool will fail if edits.old_string and edits.new_string are the same - they MUST be different
171+- The tool will fail if you have not used the ${readFileTool.name} tool to read the file in this session`,
222172 parameters: {
223173 file_path: {
224174 type: "string",
@@ -237,9 +187,9 @@
237187 },
238188 preprocess: async (args) => {
239189 // Validate and extract arguments
240- const { original_path, file_path, edits } = validateMultiEditArgs(args);
190+ const { resolved_path, edits } = validateMultiEditArgs(args);
241191
242- throwIfFileIsSecurityConcern(file_path);
192+ throwIfFileIsSecurityConcern(resolved_path);
243193
244194 // Validate each edit operation
245195 validateEdits(edits);
@@ -248,12 +198,12 @@
248198 const isCreatingNewFile = edits[0].old_string === "";
249199
250200 // Validate file access
251- validateFileAccess(original_path, file_path, isCreatingNewFile);
201+ validateFileAccess(resolved_path, isCreatingNewFile);
252202
253203 // Read current file content (or start with empty for new files)
254204 let currentContent = "";
255205 if (!isCreatingNewFile) {
256- currentContent = fs.readFileSync(file_path, "utf-8");
206+ currentContent = fs.readFileSync(resolved_path, "utf-8");
257207 }
258208
259209 const originalContent = currentContent;
@@ -266,11 +216,11 @@
266216 }
267217
268218 // Generate diff for preview
269- const diff = generateDiff(originalContent, newContent, file_path);
219+ const diff = generateDiff(originalContent, newContent, resolved_path);
270220
271221 return {
272222 args: {
273- file_path,
223+ file_path: resolved_path,
274224 newContent,
275225 originalContent,
276226 isCreatingNewFile,
@@ -279,7 +229,7 @@
279229 preview: [
280230 {
281231 type: "text",
282- content: `Will apply ${edits.length} edit${edits.length === 1 ? "" : "s"} to ${isCreatingNewFile ? "create" : "modify"} ${file_path}:`,
232+ content: `Will apply ${edits.length} edit${edits.length === 1 ? "" : "s"} to ${isCreatingNewFile ? "create" : "modify"} ${resolved_path}:`,
283233 },
284234 {
285235 type: "diff",
modified extensions/cli/src/tools/readFile.ts +9 −3
@@ -2,10 +2,15 @@
22
33 import { throwIfFileIsSecurityConcern } from "core/indexing/ignore.js";
44
5-import { markFileAsRead } from "./edit.js";
65 import { formatToolArgument } from "./formatters.js";
76 import { Tool } from "./types.js";
87
8+// Track files that have been read in the current session
9+export const readFilesSet = new Set<string>();
10+export function markFileAsRead(filePath: string) {
11+ readFilesSet.add(filePath);
12+}
13+
914 export const readFileTool: Tool = {
1015 name: "Read",
1116 displayName: "Read",
@@ -41,9 +46,10 @@
4146 if (!fs.existsSync(filepath)) {
4247 return `Error: File does not exist: ${filepath}`;
4348 }
44- const content = fs.readFileSync(filepath, "utf-8");
49+ const realPath = fs.realpathSync(filepath);
50+ const content = fs.readFileSync(realPath, "utf-8");
4551 // Mark this file as read for the edit tool
46- markFileAsRead(filepath);
52+ markFileAsRead(realPath);
4753
4854 const lines = content.split("\n");
4955 if (lines.length > 5000) {
modified extensions/cli/src/tools/runTerminalCommand.ts +1 −1
@@ -33,7 +33,7 @@
3333 displayName: "Bash",
3434 description: `Executes a terminal command and returns the output
3535
36-The command will be executed from the current working directory: ${process.cwd()}
36+Commands are automatically executed from the current working directory (${process.cwd()}), so there's no need to change directories with 'cd' commands.
3737 `,
3838 parameters: {
3939 command: {
modified extensions/cli/src/ui/UserInput.tsx +140 −35
@@ -20,6 +20,77 @@
2020 import { SlashCommandUI } from "./SlashCommandUI.js";
2121 import { TextBuffer } from "./TextBuffer.js";
2222
23+// Small presentational helpers to reduce cyclomatic complexity in UserInput
24+const InterruptedBanner: React.FC<{ wasInterrupted: boolean }> = ({
25+ wasInterrupted,
26+}) => {
27+ if (!wasInterrupted) return null;
28+ return (
29+ <Box paddingX={1} marginBottom={0}>
30+ <Text color="yellow">⚠ Interrupted by user - Press enter to resume</Text>
31+ </Box>
32+ );
33+};
34+
35+const SlashCommandsMaybe: React.FC<{
36+ show: boolean;
37+ inputMode: boolean;
38+ hideNormalUI: boolean;
39+ isRemoteMode: boolean;
40+ assistant?: AssistantConfig;
41+ filter: string;
42+ selectedIndex: number;
43+}> = ({
44+ show,
45+ inputMode,
46+ hideNormalUI,
47+ isRemoteMode,
48+ assistant,
49+ filter,
50+ selectedIndex,
51+}) => {
52+ if (!show || !inputMode || hideNormalUI || !(isRemoteMode || assistant))
53+ return null;
54+ return (
55+ <SlashCommandUI
56+ assistant={assistant}
57+ filter={filter}
58+ selectedIndex={selectedIndex}
59+ isRemoteMode={isRemoteMode}
60+ />
61+ );
62+};
63+
64+const FileSearchMaybe: React.FC<{
65+ show: boolean;
66+ inputMode: boolean;
67+ hideNormalUI: boolean;
68+ isRemoteMode: boolean;
69+ filter: string;
70+ selectedIndex: number;
71+ onSelect: (path: string) => void | Promise<void>;
72+ onFilesUpdated: (files: Array<{ path: string; displayName: string }>) => void;
73+}> = ({
74+ show,
75+ inputMode,
76+ hideNormalUI,
77+ isRemoteMode,
78+ filter,
79+ selectedIndex,
80+ onSelect,
81+ onFilesUpdated,
82+}) => {
83+ if (!show || !inputMode || hideNormalUI || isRemoteMode) return null;
84+ return (
85+ <FileSearchUI
86+ filter={filter}
87+ selectedIndex={selectedIndex}
88+ onSelect={onSelect}
89+ onFilesUpdated={onFilesUpdated}
90+ />
91+ );
92+};
93+
2394 interface UserInputProps {
2495 onSubmit: (message: string, imageMap?: Map<string, Buffer>) => void;
2596 isWaitingForResponse: boolean;
@@ -78,10 +149,13 @@
78149 setCursorPosition(0);
79150 setShowSlashCommands(false);
80151 setShowFileSearch(false);
152+ setShowBashMode(false);
81153 inputHistory.resetNavigation();
82154 }, [textBuffer]);
155+
83156 const [slashCommandFilter, setSlashCommandFilter] = useState("");
84157 const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);
158+ const [showBashMode, setShowBashMode] = useState(false);
85159 const [showFileSearch, setShowFileSearch] = useState(false);
86160 const [fileSearchFilter, setFileSearchFilter] = useState("");
87161 const [selectedFileIndex, setSelectedFileIndex] = useState(0);
@@ -131,6 +205,18 @@
131205 return nextMode;
132206 };
133207
208+ // Update shell mode state based on input
209+ const updateBashModeState = (text: string) => {
210+ const trimmed = text.trimStart();
211+ const isBash = trimmed.startsWith("!");
212+ setShowBashMode(isBash);
213+ if (isBash) {
214+ // Disable other helpers while in shell mode
215+ setShowSlashCommands(false);
216+ setShowFileSearch(false);
217+ }
218+ };
219+
134220 // Update slash command UI state based on input
135221 const updateSlashCommandState = (text: string, cursor: number) => {
136222 // Only show slash commands if slash is the very first character
@@ -139,6 +225,9 @@
139225 return;
140226 }
141227
228+ // When using slash commands, disable file search
229+ setShowFileSearch(false);
230+
142231 const trimmedText = text.trimStart();
143232 const beforeCursor = trimmedText.slice(
144233 0,
@@ -196,6 +285,13 @@
196285 return;
197286 }
198287
288+ // Disable file search if we're in shell mode or slash command mode
289+ const trimmed = text.trimStart();
290+ if (trimmed.startsWith("!") || trimmed.startsWith("/")) {
291+ setShowFileSearch(false);
292+ return;
293+ }
294+
199295 // Check if we're in a file search context
200296 const beforeCursor = text.slice(0, cursor);
201297 const lastAtIndex = beforeCursor.lastIndexOf("@");
@@ -234,6 +330,7 @@
234330 setFileSearchFilter(afterAt);
235331 setSelectedFileIndex(0);
236332 setShowSlashCommands(false);
333+ setShowBashMode(false);
237334 }
238335 }
239336 };
@@ -278,6 +375,7 @@
278375 setInputText(newText);
279376 setCursorPosition(newCursorPos);
280377 setShowSlashCommands(false);
378+ setShowBashMode(false);
281379 }
282380 };
283381
@@ -437,6 +535,7 @@
437535 setInputText("");
438536 setCursorPosition(0);
439537 setShowSlashCommands(false);
538+ setShowBashMode(false);
440539 }
441540 return true;
442541 }
@@ -462,6 +561,15 @@
462561 const handleEscapeKey = (key: any): boolean => {
463562 if (!key.escape) return false;
464563
564+ // If only "!" is present, clear shell mode
565+ if (inputMode && showBashMode && inputText.trim() === "!") {
566+ textBuffer.clear();
567+ setInputText("");
568+ setCursorPosition(0);
569+ setShowBashMode(false);
570+ return true;
571+ }
572+
465573 // Handle escape key to interrupt streaming
466574 if (isWaitingForResponse && onInterrupt) {
467575 onInterrupt();
@@ -491,6 +599,7 @@
491599 setCursorPosition(newCursor);
492600 updateSlashCommandState(newText, newCursor);
493601 updateFileSearchState(newText, newCursor);
602+ updateBashModeState(newText);
494603 inputHistory.resetNavigation();
495604 };
496605
@@ -587,14 +696,16 @@
587696 setCursorPosition,
588697 updateSlashCommandState,
589698 updateFileSearchState,
699+ updateBashModeState,
590700 inputHistory,
591701 });
592702 });
593703
594704 const renderInputText = () => {
595705 const placeholderText = isRemoteMode
596- ? "Ask anything, / for slash commands"
597- : placeholder || "Ask anything, @ for context, / for slash commands";
706+ ? "Ask anything, / for slash commands, ! for shell mode"
707+ : placeholder ||
708+ "Ask anything, @ for context, / for slash commands, ! for shell mode";
598709 if (inputText.length === 0) {
599710 return (
600711 <>
@@ -677,50 +788,44 @@
677788
678789 return (
679790 <Box flexDirection="column">
680- {/* Interruption message - shown just above the input box */}
681- {wasInterrupted && (
682- <Box paddingX={1} marginBottom={0}>
683- <Text color="yellow">
684- ⚠ Interrupted by user - Press enter to resume
685- </Text>
686- </Box>
687- )}
791+ <InterruptedBanner wasInterrupted={!!wasInterrupted} />
688792
689793 {/* Input box */}
690794 <Box
691795 borderStyle="round"
692796 borderTop={true}
693797 paddingX={1}
694- borderColor={isRemoteMode ? "cyan" : "gray"}
798+ borderColor={showBashMode ? "yellow" : isRemoteMode ? "cyan" : "gray"}
695799 >
696- <Text color={isRemoteMode ? "cyan" : "blue"} bold>
697- {isRemoteMode ? "◉" : "●"}{" "}
800+ <Text
801+ color={showBashMode ? "yellow" : isRemoteMode ? "cyan" : "blue"}
802+ bold
803+ >
804+ {showBashMode ? "$" : isRemoteMode ? "◉" : "●"}
698805 </Text>
699806 {renderInputText()}
700807 </Box>
701808
702- {/* Slash command UI - show in remote mode OR when assistant is available */}
703- {showSlashCommands &&
704- inputMode &&
705- !hideNormalUI &&
706- (isRemoteMode || assistant) && (
707- <SlashCommandUI
708- assistant={assistant}
709- filter={slashCommandFilter}
710- selectedIndex={selectedCommandIndex}
711- isRemoteMode={isRemoteMode}
712- />
713- )}
714-
715- {/* File search UI - only show in local mode */}
716- {showFileSearch && inputMode && !hideNormalUI && !isRemoteMode && (
717- <FileSearchUI
718- filter={fileSearchFilter}
719- selectedIndex={selectedFileIndex}
720- onSelect={selectFile}
721- onFilesUpdated={setCurrentFiles}
722- />
723- )}
809+ <SlashCommandsMaybe
810+ show={showSlashCommands}
811+ inputMode={inputMode}
812+ hideNormalUI={!!hideNormalUI}
813+ isRemoteMode={!!isRemoteMode}
814+ assistant={assistant}
815+ filter={slashCommandFilter}
816+ selectedIndex={selectedCommandIndex}
817+ />
818+
819+ <FileSearchMaybe
820+ show={showFileSearch}
821+ inputMode={inputMode}
822+ hideNormalUI={!!hideNormalUI}
823+ isRemoteMode={!!isRemoteMode}
824+ filter={fileSearchFilter}
825+ selectedIndex={selectedFileIndex}
826+ onSelect={selectFile}
827+ onFilesUpdated={setCurrentFiles}
828+ />
724829 </Box>
725830 );
726831 };
modified extensions/cli/src/ui/components/StaticChatContent.tsx +15 −38
@@ -74,14 +74,12 @@
7474 }, [chatHistory]);
7575
7676 // Split chat history into stable and pending items
77- // Only put items in pending if they contain tool calls with "calling" status
78- // Everything else goes into static content
77+ // The last two items may have pending tool calls
7978 const { staticItems, pendingItems } = React.useMemo(() => {
80- const items: React.ReactElement[] = [];
81-
8279 // Add intro message as first item if it should be shown
80+ const staticItems: React.ReactElement[] = [];
8381 if (showIntroMessage) {
84- items.push(
82+ staticItems.push(
8583 <IntroMessage
8684 key="intro"
8785 config={config}
@@ -91,48 +89,27 @@
9189 );
9290 }
9391
94- // Helper function to check if an item has pending tool calls
95- const hasPendingToolCalls = (item: ChatHistoryItem): boolean => {
96- return !!(
97- item.toolCallStates &&
98- item.toolCallStates.some(
99- (toolState) =>
100- toolState.status === "calling" ||
101- toolState.status === "generating" ||
102- toolState.status === "generated",
103- )
104- );
105- };
106-
107- // Find the first message with pending tool calls from the end
108- let pendingStartIndex = filteredChatHistory.length;
109- for (let i = filteredChatHistory.length - 1; i >= 0; i--) {
110- if (hasPendingToolCalls(filteredChatHistory[i])) {
111- pendingStartIndex = i;
112- // If there's a message after this one, include it too as it might be related
113- if (i + 1 < filteredChatHistory.length) {
114- // Keep the pending start index as is, so we include the next message
115- }
116- break;
117- }
118- }
119-
120- const stableHistory = filteredChatHistory.slice(0, pendingStartIndex);
121- const pendingHistory = filteredChatHistory.slice(pendingStartIndex);
92+ const PENDING_ITEMS_COUNT = 2;
93+ const stableCount = Math.max(
94+ 0,
95+ filteredChatHistory.length - PENDING_ITEMS_COUNT,
96+ );
97+ const stableHistory = filteredChatHistory.slice(0, stableCount);
98+ const pendingHistory = filteredChatHistory.slice(stableCount);
12299
123100 // Add stable messages to static items
124101 stableHistory.forEach((item, index) => {
125- items.push(renderMessage(item, index));
102+ staticItems.push(renderMessage(item, index));
126103 });
127104
128105 // Pending items will be rendered dynamically outside Static
129- const pendingElements = pendingHistory.map((item, index) =>
130- renderMessage(item, pendingStartIndex + index),
106+ const pendingItems = pendingHistory.map((item, index) =>
107+ renderMessage(item, stableCount + index),
131108 );
132109
133110 return {
134- staticItems: items,
135- pendingItems: pendingElements,
111+ staticItems,
112+ pendingItems,
136113 };
137114 }, [
138115 showIntroMessage,
added extensions/cli/src/ui/hooks/useChat.shellMode.test.ts +148 −0
@@ -0,0 +1,148 @@
1+import { beforeEach, describe, expect, it, vi } from "vitest";
2+
3+import { runTerminalCommandTool } from "src/tools/runTerminalCommand.js";
4+
5+import { services } from "../../services/index.js";
6+
7+import { handleBashModeProcessing } from "./useChat.shellMode.js";
8+
9+// Mock the runTerminalCommandTool with the correct path for the import in shellMode.ts
10+vi.mock("src/tools/runTerminalCommand.js", () => ({
11+ runTerminalCommandTool: {
12+ run: vi.fn(),
13+ },
14+}));
15+
16+// Mock the services
17+vi.mock("../../services/index.js", () => ({
18+ services: {
19+ chatHistory: {
20+ addAssistantMessage: vi.fn(),
21+ updateToolStatus: vi.fn(),
22+ addToolResult: vi.fn(),
23+ },
24+ },
25+}));
26+
27+describe("handleBashModeProcessing", () => {
28+ beforeEach(() => {
29+ vi.clearAllMocks();
30+ });
31+
32+ it("should detect bash mode when message starts with !", async () => {
33+ const mockRun = vi.mocked(runTerminalCommandTool.run);
34+ mockRun.mockResolvedValue(
35+ "total 5\ndrwxr-xr-x 2 user user 4096 Jan 1 12:00 .\ndrwxr-xr-x 3 user user 4096 Jan 1 12:00 ..",
36+ );
37+
38+ const result = await handleBashModeProcessing("!ls -la");
39+
40+ expect(result).toBe(null); // Processed, no further handling needed
41+ expect(services.chatHistory.addAssistantMessage).toHaveBeenCalled();
42+ expect(services.chatHistory.updateToolStatus).toHaveBeenCalledWith(
43+ expect.any(String),
44+ "calling",
45+ );
46+
47+ // Use vi.waitFor to wait for async operations in the void expression
48+ await vi.waitFor(
49+ () => {
50+ expect(mockRun).toHaveBeenCalledWith({ command: "ls -la" });
51+ },
52+ { timeout: 1000 },
53+ );
54+
55+ await vi.waitFor(
56+ () => {
57+ expect(services.chatHistory.addToolResult).toHaveBeenCalledWith(
58+ expect.any(String),
59+ "total 5\ndrwxr-xr-x 2 user user 4096 Jan 1 12:00 .\ndrwxr-xr-x 3 user user 4096 Jan 1 12:00 ..",
60+ "done",
61+ );
62+ },
63+ { timeout: 1000 },
64+ );
65+ });
66+
67+ it("should handle bash command errors", async () => {
68+ const mockRun = vi.mocked(runTerminalCommandTool.run);
69+ mockRun.mockRejectedValue(new Error("Command not found"));
70+
71+ const result = await handleBashModeProcessing("!invalidcommand");
72+
73+ expect(result).toBe(null); // Processed, no further handling needed
74+ expect(services.chatHistory.addAssistantMessage).toHaveBeenCalled();
75+ expect(services.chatHistory.updateToolStatus).toHaveBeenCalledWith(
76+ expect.any(String),
77+ "calling",
78+ );
79+
80+ // Use vi.waitFor to wait for async operations in the void expression
81+ await vi.waitFor(
82+ () => {
83+ expect(mockRun).toHaveBeenCalledWith({ command: "invalidcommand" });
84+ },
85+ { timeout: 1000 },
86+ );
87+
88+ await vi.waitFor(
89+ () => {
90+ expect(services.chatHistory.addToolResult).toHaveBeenCalledWith(
91+ expect.any(String),
92+ "Bash command failed: Command not found",
93+ "errored",
94+ );
95+ },
96+ { timeout: 1000 },
97+ );
98+ });
99+
100+ it("should not trigger bash mode for regular messages", async () => {
101+ const mockRun = vi.mocked(runTerminalCommandTool.run);
102+
103+ const result = await handleBashModeProcessing("Hello! How are you?");
104+
105+ expect(result).toBe("Hello! How are you?"); // Pass through unchanged
106+ expect(mockRun).not.toHaveBeenCalled();
107+ expect(services.chatHistory.addAssistantMessage).not.toHaveBeenCalled();
108+ });
109+
110+ it("should handle empty bash command", async () => {
111+ const mockRun = vi.mocked(runTerminalCommandTool.run);
112+
113+ const result = await handleBashModeProcessing("!");
114+
115+ expect(result).toBe("!"); // Pass through unchanged for empty command
116+ expect(mockRun).not.toHaveBeenCalled();
117+ expect(services.chatHistory.addAssistantMessage).not.toHaveBeenCalled();
118+ });
119+
120+ it("should handle bash command with leading whitespace", async () => {
121+ const mockRun = vi.mocked(runTerminalCommandTool.run);
122+ mockRun.mockResolvedValue("echo test output");
123+
124+ const result = await handleBashModeProcessing(" !echo hello");
125+
126+ expect(result).toBe(null); // Processed, no further handling needed
127+ expect(services.chatHistory.addAssistantMessage).toHaveBeenCalled();
128+
129+ // Use vi.waitFor to wait for async operations in the void expression
130+ await vi.waitFor(
131+ () => {
132+ expect(mockRun).toHaveBeenCalledWith({ command: "echo hello" });
133+ },
134+ { timeout: 1000 },
135+ );
136+
137+ await vi.waitFor(
138+ () => {
139+ expect(services.chatHistory.addToolResult).toHaveBeenCalledWith(
140+ expect.any(String),
141+ "echo test output",
142+ "done",
143+ );
144+ },
145+ { timeout: 1000 },
146+ );
147+ });
148+});
added extensions/cli/src/ui/hooks/useChat.shellMode.ts +51 −0
@@ -0,0 +1,51 @@
1+import { runTerminalCommandTool } from "src/tools/runTerminalCommand.js";
2+import { getErrorString } from "src/util/error.js";
3+
4+import { services } from "../../services/index.js";
5+
6+export const handleBashModeProcessing = async (
7+ message: string,
8+): Promise<string | null> => {
9+ // Handle shell mode commands (starting with !)
10+ if (!message.trimStart().startsWith("!")) {
11+ return message;
12+ }
13+
14+ // Extract the command after the !
15+ const bashCommand = message.trimStart().slice(1).trim();
16+
17+ if (!bashCommand) {
18+ return message; // No command provided, treat as regular message
19+ }
20+
21+ // Show tool call immediately, then run asynchronously and populate result
22+ const toolCallId = `shell-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
23+ const toolCall = {
24+ id: toolCallId,
25+ type: "function" as const,
26+ function: {
27+ name: "Bash",
28+ arguments: JSON.stringify({ command: bashCommand }),
29+ },
30+ };
31+
32+ // Add assistant message with tool call immediately
33+ services.chatHistory.addAssistantMessage("", [toolCall]);
34+ // Mark as calling for immediate UI feedback
35+ services.chatHistory.updateToolStatus(toolCallId, "calling");
36+
37+ // Execute the bash command asynchronously - don't block UI
38+ void runTerminalCommandTool
39+ .run({
40+ command: bashCommand,
41+ })
42+ .then((result) => {
43+ services.chatHistory.addToolResult(toolCallId, result, "done");
44+ })
45+ .catch((error) => {
46+ const errorMessage = `Bash command failed: ${getErrorString(error)}`;
47+ services.chatHistory.addToolResult(toolCallId, errorMessage, "errored");
48+ });
49+
50+ return null; // Processed, no further message handling needed
51+};
modified extensions/cli/src/ui/hooks/useChat.ts +8 −0
@@ -30,6 +30,7 @@
3030 handleRemoteMessage,
3131 setupRemotePolling,
3232 } from "./useChat.remote.helpers.js";
33+import { handleBashModeProcessing } from "./useChat.shellMode.js";
3334 import {
3435 createStreamCallbacks,
3536 executeStreaming,
@@ -423,6 +424,13 @@
423424
424425 if (handled) return;
425426
427+ // Handle shell mode commands (before slash commands)
428+ const bashProcessedMessage = await handleBashModeProcessing(message);
429+ if (bashProcessedMessage === null) {
430+ return; // Bash command was handled and no further processing needed
431+ }
432+ message = bashProcessedMessage;
433+
426434 // Handle slash commands
427435 const processedMessage = await handleSlashCommandProcessing(message);
428436 if (processedMessage === null) {
modified extensions/cli/src/ui/hooks/useUserInput.ts +3 −0
@@ -104,6 +104,7 @@
104104 setCursorPosition: (pos: number) => void;
105105 updateSlashCommandState: (text: string, cursor: number) => void;
106106 updateFileSearchState: (text: string, cursor: number) => void;
107+ updateBashModeState: (text: string) => void;
107108 inputHistory: any;
108109 }
109110
@@ -115,6 +116,7 @@
115116 setCursorPosition,
116117 updateSlashCommandState,
117118 updateFileSearchState,
119+ updateBashModeState,
118120 inputHistory,
119121 } = options;
120122
@@ -126,6 +128,7 @@
126128 setCursorPosition(newCursor);
127129 updateSlashCommandState(newText, newCursor);
128130 updateFileSearchState(newText, newCursor);
131+ updateBashModeState(newText);
129132 inputHistory.resetNavigation();
130133 }
131134 }
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +3 −1
@@ -199,7 +199,9 @@
199199 }
200200
201201 override suspend fun openFile(path: String) =
202- fileUtils.openFile(path)
202+ withContext(Dispatchers.EDT) {
203+ fileUtils.openFile(path)
204+ }
203205
204206 override suspend fun openUrl(url: String) {
205207 withContext(Dispatchers.IO) {
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/process/ContinueProcessHandler.kt +8 −4
@@ -43,10 +43,14 @@
4343 }
4444 scope.launch(Dispatchers.IO) {
4545 for (message in pendingWrites) {
46- log.debug("Write: $message")
47- writer.write(message)
48- writer.write("\r\n")
49- writer.flush()
46+ try {
47+ log.debug("Write: $message")
48+ writer.write(message)
49+ writer.write("\r\n")
50+ writer.flush()
51+ } catch (e: IOException) {
52+ log.warn(e)
53+ }
5054 }
5155 }
5256 }
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/error/ContinueErrorSubmitter.kt +1 −0
@@ -21,6 +21,7 @@
2121 consumer: Consumer<in SubmittedReportInfo>
2222 ): Boolean {
2323 try {
24+ // todo: IdeaReportingEvent is deprecated; migrate to IdeaLoggingEvent + figure out how to read attachments
2425 val event = events.filterIsInstance<IdeaReportingEvent>()
2526 .firstOrNull() ?: return false
2627 service<ContinueSentryService>().report(
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/license/AddLicenseKey.kt +12 −17
@@ -5,22 +5,27 @@
55 import com.intellij.notification.NotificationAction
66 import com.intellij.notification.NotificationGroupManager
77 import com.intellij.notification.NotificationType
8-import com.intellij.openapi.actionSystem.ActionManager
9-import com.intellij.openapi.actionSystem.ActionPlaces
108 import com.intellij.openapi.actionSystem.AnAction
119 import com.intellij.openapi.actionSystem.AnActionEvent
1210 import com.intellij.openapi.application.ApplicationManager
1311 import com.intellij.openapi.components.service
12+import com.intellij.openapi.project.Project
1413 import com.intellij.openapi.ui.DialogWrapper
1514
1615 class AddLicenseKey : AnAction() {
1716
1817 override fun actionPerformed(e: AnActionEvent) {
19- val dialog = AddLicenseKeyDialog(e.project)
18+ performAddLicenseKey(e.project)
19+ }
20+
21+ private fun performAddLicenseKey(project: Project?) {
22+ if (project == null)
23+ return
24+ val dialog = AddLicenseKeyDialog(project)
2025 dialog.show()
2126 if (dialog.exitCode != DialogWrapper.OK_EXIT_CODE)
2227 return
23- val messenger = e.project?.service<ContinuePluginService>()?.coreMessenger
28+ val messenger = project.service<ContinuePluginService>().coreMessenger
2429 ?: return
2530 messenger.request("mdm/setLicenseKey", mapOf("licenseKey" to dialog.licenseKey), null) { response ->
2631 val isValid = response.castNestedOrNull<Boolean>("content") ?: false
@@ -28,7 +33,7 @@
2833 createSuccessAction()
2934 else
3035 createErrorAction()
31- notification.notify(e.project)
36+ notification.notify(project)
3237 }
3338 }
3439
@@ -37,7 +42,7 @@
3742 "License key is valid. A restart is required for it to take effect.",
3843 NotificationType.INFORMATION
3944 ).addAction(
40- NotificationAction.create("Restart IDE") { event, notification ->
45+ NotificationAction.create("Restart IDE") { _, _ ->
4146 ApplicationManager.getApplication().restart()
4247 }
4348 )
@@ -49,17 +54,7 @@
4954 ).addAction(
5055 NotificationAction.create("Try again") { event, notification ->
5156 notification.expire()
52- val action = this@AddLicenseKey
53- action.actionPerformed(
54- AnActionEvent(
55- null,
56- event.dataContext,
57- ActionPlaces.UNKNOWN,
58- action.templatePresentation.clone(),
59- ActionManager.getInstance(),
60- 0
61- )
62- )
57+ performAddLicenseKey(event.project)
6358 }
6459 )
6560
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/license/AddLicenseKeyDialog.kt +2 −2
@@ -3,9 +3,9 @@
33 import com.intellij.openapi.project.Project
44 import com.intellij.openapi.ui.DialogWrapper
55 import com.intellij.openapi.ui.ValidationInfo
6+import com.intellij.ui.dsl.builder.AlignX
67 import com.intellij.ui.dsl.builder.bindText
78 import com.intellij.ui.dsl.builder.panel
8-import com.intellij.ui.dsl.gridLayout.HorizontalAlign
99 import javax.swing.JComponent
1010
1111 class AddLicenseKeyDialog(project: Project?) : DialogWrapper(project) {
@@ -22,7 +22,7 @@
2222 panel {
2323 row {
2424 textField().bindText(::licenseKey)
25- .horizontalAlign(HorizontalAlign.FILL)
25+ .align(AlignX.FILL)
2626 .focused()
2727 .validationOnApply {
2828 if (it.text.isBlank())
modified extensions/vscode/package.json +1 −1
@@ -2,7 +2,7 @@
22 "name": "continue",
33 "icon": "media/icon.png",
44 "author": "Continue Dev, Inc",
5- "version": "1.3.3",
5+ "version": "1.3.4",
66 "repository": {
77 "type": "git",
88 "url": "https://github.com/continuedev/continue"
modified gui/src/components/gui/Switch.tsx +12 −1
@@ -1,5 +1,7 @@
1+import { InformationCircleIcon } from "@heroicons/react/24/outline";
12 import React, { ReactNode } from "react";
23 import { vscButtonBackground } from "..";
4+import { ToolTip } from "./Tooltip";
35
46 type ToggleSwitchProps = {
57 isToggled: boolean;
@@ -8,6 +10,7 @@
810 size?: number;
911 showIfToggled?: ReactNode;
1012 disabled?: boolean;
13+ tooltip?: string;
1114 };
1215
1316 const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
@@ -17,12 +20,20 @@
1720 size = 16,
1821 showIfToggled,
1922 disabled = false,
23+ tooltip,
2024 }) => {
2125 return (
2226 <div
2327 className={`flex select-none items-center justify-between gap-3 ${disabled ? "cursor-not-allowed" : "cursor-pointer"}`}
2428 >
25- <span className="truncate-right">{text}</span>
29+ <span className="truncate-right flex items-center gap-x-1">
30+ {text}{" "}
31+ {tooltip && (
32+ <ToolTip content={tooltip}>
33+ <InformationCircleIcon className="h-3 w-3" />
34+ </ToolTip>
35+ )}
36+ </span>
2637 <div className="flex flex-row items-center gap-1">
2738 {isToggled && !!showIfToggled && showIfToggled}
2839 <div
modified gui/src/pages/config/UserSettingsForm.tsx +41 −5
@@ -2,6 +2,7 @@
22 CheckIcon,
33 ChevronRightIcon,
44 ExclamationTriangleIcon,
5+ InformationCircleIcon,
56 XMarkIcon,
67 } from "@heroicons/react/24/outline";
78 import {
@@ -177,6 +178,7 @@
177178 })
178179 }
179180 text="Show Session Tabs"
181+ tooltip="If on, displays tabs above the chat as an alternative way to organize and access your sessions."
180182 />
181183 <ToggleSwitch
182184 isToggled={codeWrap}
@@ -186,6 +188,7 @@
186188 })
187189 }
188190 text="Wrap Codeblocks"
191+ tooltip="If on, displays tabs above the chat as an alternative way to organize and access your sessions."
189192 />
190193
191194 <ToggleSwitch
@@ -196,6 +199,7 @@
196199 })
197200 }
198201 text="Show Chat Scrollbar"
202+ tooltip="If on, enables a scrollbar in the chat window."
199203 />
200204 <ToggleSwitch
201205 isToggled={readResponseTTS}
@@ -205,6 +209,7 @@
205209 })
206210 }
207211 text="Text-to-Speech Output"
212+ tooltip="If on, reads LLM responses aloud with TTS."
208213 />
209214 {/* <ToggleSwitch
210215 isToggled={useChromiumForDocsCrawling}
@@ -223,6 +228,7 @@
223228 })
224229 }
225230 text="Enable Session Titles"
231+ tooltip="If on, generates summary titles for each chat session after the first message, using the current Chat model."
226232 />
227233 <ToggleSwitch
228234 isToggled={!displayRawMarkdown}
@@ -232,6 +238,7 @@
232238 })
233239 }
234240 text="Format Markdown"
241+ tooltip="If off, shows responses as raw text."
235242 />
236243
237244 <ToggleSwitch
@@ -243,6 +250,7 @@
243250 })
244251 }
245252 text="Allow Anonymous Telemetry"
253+ tooltip="If on, allows Continue to send anonymous telemetry."
246254 />
247255
248256 <ToggleSwitch
@@ -267,7 +275,12 @@
267275 /> */}
268276
269277 <label className="flex items-center justify-between gap-3">
270- <span className="text-left">Font Size</span>
278+ <span className="flex items-center gap-x-1 text-left">
279+ Font Size{" "}
280+ <ToolTip content="Specifies base font size for UI elements">
281+ <InformationCircleIcon className="h-3 w-3" />
282+ </ToolTip>
283+ </span>
271284 <NumberInput
272285 value={fontSize}
273286 onChange={(val) => {
@@ -281,8 +294,11 @@
281294 />
282295 </label>
283296 <label className="flex items-center justify-between gap-3">
284- <span className="lines lines-1 text-left">
297+ <span className="lines lines-1 flex items-center gap-x-1 text-left">
285298 Multiline Autocompletions
299+ <ToolTip content="Controls multiline completions for autocomplete.">
300+ <InformationCircleIcon className="h-3 w-3" />
301+ </ToolTip>
286302 </span>
287303 <Select
288304 value={useAutocompleteMultilineCompletions}
@@ -301,7 +317,12 @@
301317 </Select>
302318 </label>
303319 <label className="flex items-center justify-between gap-3">
304- <span className="text-left">Autocomplete Timeout (ms)</span>
320+ <span className="flex items-center gap-x-1 text-left">
321+ Autocomplete Timeout (ms)
322+ <ToolTip content="Maximum time in milliseconds for autocomplete request/retrieval.">
323+ <InformationCircleIcon className="h-3 w-3" />
324+ </ToolTip>
325+ </span>
305326 <NumberInput
306327 value={modelTimeout}
307328 onChange={(val) =>
@@ -314,7 +335,12 @@
314335 />
315336 </label>
316337 <label className="flex items-center justify-between gap-3">
317- <span className="text-left">Autocomplete Debounce (ms)</span>
338+ <span className="flex items-center gap-x-1 text-left">
339+ Autocomplete Debounce (ms)
340+ <ToolTip content="Minimum time in milliseconds to trigger an autocomplete request after a change.">
341+ <InformationCircleIcon className="h-3 w-3" />
342+ </ToolTip>
343+ </span>
318344 <NumberInput
319345 value={debounceDelay}
320346 onChange={(val) =>
@@ -334,7 +360,12 @@
334360 }}
335361 >
336362 <div className="flex items-center justify-between">
337- <span>Disable autocomplete in files</span>
363+ <span className="flex items-center gap-x-1">
364+ Disable autocomplete in files
365+ <ToolTip content="List of comma-separated glob pattern to disable autocomplete in matching files. E.g., **/*.{txt,md}">
366+ <InformationCircleIcon className="h-3 w-3" />
367+ </ToolTip>
368+ </span>
338369 <div className="flex items-center gap-2">
339370 <Input
340371 value={formDisableAutocomplete}
@@ -401,6 +432,8 @@
401432 })
402433 }
403434 text="Auto-Accept Agent Edits"
435+ tooltip="If on, diffs generated by the edit tool are
436+ automatically accepted and Agent proceeds with the next conversational turn."
404437 showIfToggled={
405438 <>
406439 <ToolTip
@@ -420,6 +453,7 @@
420453 })
421454 }
422455 text="Add Current File by Default"
456+ tooltip="If on, the currently open file is added as context in every new conversation."
423457 />
424458
425459 <ToggleSwitch
@@ -439,6 +473,7 @@
439473 onlyUseSystemMessageTools: !onlyUseSystemMessageTools,
440474 })
441475 }
476+ tooltip="If on, Continue will not attempt to use native tool calling and will only use system message tools."
442477 text="Only use system message tools"
443478 />
444479
@@ -460,6 +495,7 @@
460495 })
461496 }
462497 text="Stream after tool rejection"
498+ tooltip="If on, streaming will continue after the tool call is rejected."
463499 />
464500
465501 {hasContinueEmail && (
modified gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx +78 −53
@@ -14,6 +14,7 @@
1414 selectToolCallById,
1515 } from "../../../redux/selectors/selectToolCalls";
1616 import { performFindAndReplace } from "../../../util/clientTools/findAndReplaceUtils";
17+import { cn } from "../../../util/cn";
1718 import { getStatusIcon } from "./utils";
1819
1920 interface FindAndReplaceDisplayProps {
@@ -25,6 +26,48 @@
2526 historyIndex: number;
2627 }
2728
29+const MAX_SAME_LINES = 2;
30+
31+function EllipsisLine() {
32+ return (
33+ <div className="text-description-muted px-3 py-1 text-center font-mono">
34+ ⋯
35+ </div>
36+ );
37+}
38+
39+function DiffLines({
40+ lines,
41+ className = "",
42+ diffChar = " ",
43+ diffCharClass = "text-description-muted",
44+}: {
45+ lines: string[];
46+ diffChar?: string;
47+ diffCharClass?: string;
48+ className?: string;
49+}) {
50+ return (
51+ <>
52+ {lines.map((line, lineIndex) => {
53+ const isLastPartLine = lineIndex === lines.length - 1;
54+ if (line === "" && isLastPartLine) return null;
55+ return (
56+ <div
57+ key={lineIndex}
58+ className={cn("text-foreground px-3 py-px font-mono", className)}
59+ >
60+ <span className={cn("mr-2 select-none", diffCharClass)}>
61+ {diffChar}
62+ </span>
63+ {line}
64+ </div>
65+ );
66+ })}
67+ </>
68+ );
69+}
70+
2871 export function FindAndReplaceDisplay({
2972 fileUri,
3073 relativeFilePath,
@@ -200,70 +243,52 @@
200243 <pre
201244 className={`bg-editor m-0 w-full text-xs leading-tight ${config?.ui?.codeWrap ? "whitespace-pre-wrap" : "whitespace-pre"}`}
202245 >
203- {diffResult.diff.map((part, index) => {
246+ {diffResult.diff?.map((part, index) => {
204247 if (part.removed) {
205248 return (
206- <div
249+ <DiffLines
207250 key={index}
208- className="text-foreground border-l-4 border-red-900 bg-red-900/30"
209- >
210- {part.value.split("\n").map((line, lineIndex) => {
211- if (
212- line === "" &&
213- lineIndex === part.value.split("\n").length - 1
214- )
215- return null;
216- return (
217- <div key={lineIndex} className="px-3 py-px font-mono">
218- <span className="mr-2 select-none text-red-600">-</span>
219- {line}
220- </div>
221- );
222- })}
223- </div>
251+ lines={part.value.split("\n")}
252+ className="border-l-4 border-red-900 bg-red-900/30"
253+ diffCharClass="text-red-600"
254+ diffChar="-"
255+ />
224256 );
225257 } else if (part.added) {
226258 return (
227- <div
259+ <DiffLines
228260 key={index}
229- className="text-foreground border-l-4 border-green-600 bg-green-600/20"
230- >
231- {part.value.split("\n").map((line, lineIndex) => {
232- if (
233- line === "" &&
234- lineIndex === part.value.split("\n").length - 1
235- )
236- return null;
237- return (
238- <div key={lineIndex} className="px-3 py-px font-mono">
239- <span className="mr-2 select-none text-green-600">+</span>
240- {line}
241- </div>
242- );
243- })}
244- </div>
261+ lines={part.value.split("\n")}
262+ diffCharClass="text-green-600"
263+ className="border-l-4 border-green-600 bg-green-600/20"
264+ diffChar="+"
265+ />
245266 );
246267 } else {
268+ const isFirst = index === 0;
269+ const isLast = index === diffResult.diff.length - 1;
270+ const lines = part.value.split("\n");
271+ const showStartEllipsis = isFirst && lines.length > MAX_SAME_LINES;
272+ const showEndEllipsis = isLast && lines.length > MAX_SAME_LINES;
273+ const showMiddleEllipses =
274+ !isFirst && !isLast && lines.length > MAX_SAME_LINES * 2 + 1;
275+
276+ const startLines = showStartEllipsis
277+ ? lines.slice(-MAX_SAME_LINES)
278+ : showMiddleEllipses || showEndEllipsis
279+ ? lines.slice(0, MAX_SAME_LINES)
280+ : lines;
281+ const endLines = showMiddleEllipses
282+ ? lines.slice(-MAX_SAME_LINES)
283+ : [];
284+
247285 return (
248286 <div key={index}>
249- {part.value.split("\n").map((line, lineIndex) => {
250- if (
251- line === "" &&
252- lineIndex === part.value.split("\n").length - 1
253- )
254- return null;
255- return (
256- <div
257- key={lineIndex}
258- className="text-foreground px-3 py-px font-mono"
259- >
260- <span className="text-description-muted mr-2 select-none">
261- {" "}
262- </span>
263- {line}
264- </div>
265- );
266- })}
287+ {showStartEllipsis && <EllipsisLine />}
288+ <DiffLines lines={startLines} />
289+ {showMiddleEllipses && <EllipsisLine />}
290+ <DiffLines lines={endLines} />
291+ {showEndEllipsis && <EllipsisLine />}
267292 </div>
268293 );
269294 }
modified packages/openai-adapters/src/apis/Gemini.ts +33 −2
@@ -10,6 +10,7 @@
1010 Completion,
1111 CompletionCreateParamsNonStreaming,
1212 CompletionCreateParamsStreaming,
13+ CompletionUsage,
1314 CreateEmbeddingResponse,
1415 EmbeddingCreateParams,
1516 Model,
@@ -22,6 +23,7 @@
2223 chatChunkFromDelta,
2324 customFetch,
2425 embedding,
26+ usageChatChunk,
2527 } from "../util.js";
2628 import {
2729 convertOpenAIToolToGeminiFunction,
@@ -37,6 +39,11 @@
3739 RerankCreateParams,
3840 } from "./base.js";
3941
42+type UsageInfo = Pick<
43+ CompletionUsage,
44+ "total_tokens" | "completion_tokens" | "prompt_tokens"
45+>;
46+
4047 export class GeminiApi implements BaseLlmApi {
4148 apiBase: string = "https://generativelanguage.googleapis.com/v1beta/";
4249
@@ -240,6 +247,7 @@
240247 signal: AbortSignal,
241248 ): Promise<ChatCompletion> {
242249 let completion = "";
250+ let usage: UsageInfo | undefined = undefined;
243251 for await (const chunk of this.chatCompletionStream(
244252 {
245253 ...body,
@@ -247,7 +255,12 @@
247255 },
248256 signal,
249257 )) {
250- completion += chunk.choices[0].delta.content;
258+ if (chunk.choices.length > 0) {
259+ completion += chunk.choices[0].delta.content || "";
260+ }
261+ if (chunk.usage) {
262+ usage = chunk.usage;
263+ }
251264 }
252265 return {
253266 id: "",
@@ -266,12 +279,13 @@
266279 },
267280 },
268281 ],
269- usage: undefined,
282+ usage,
270283 };
271284 }
272285
273286 async *handleStreamResponse(response: any, model: string) {
274287 let buffer = "";
288+ let usage: UsageInfo | undefined = undefined;
275289 for await (const chunk of streamResponse(response as any)) {
276290 buffer += chunk;
277291 if (buffer.startsWith("[")) {
@@ -300,6 +314,15 @@
300314 throw new Error(data.error.message);
301315 }
302316
317+ // Check for usage metadata
318+ if (data.usageMetadata) {
319+ usage = {
320+ prompt_tokens: data.usageMetadata.promptTokenCount || 0,
321+ completion_tokens: data.usageMetadata.candidatesTokenCount || 0,
322+ total_tokens: data.usageMetadata.totalTokenCount || 0,
323+ };
324+ }
325+
303326 // In case of max tokens reached, gemini will sometimes return content with no parts, even though that doesn't match the API spec
304327 const contentParts = data?.candidates?.[0]?.content?.parts;
305328 if (contentParts) {
@@ -338,6 +361,14 @@
338361 buffer = "";
339362 }
340363 }
364+
365+ // Emit usage at the end if we have it
366+ if (usage) {
367+ yield usageChatChunk({
368+ model,
369+ usage,
370+ });
371+ }
341372 }
342373
343374 async *chatCompletionStream(
modified packages/openai-adapters/src/apis/OpenAI.ts +5 −0
@@ -35,6 +35,11 @@
3535 });
3636 }
3737 modifyChatBody<T extends ChatCompletionCreateParams>(body: T): T {
38+ // Add stream_options to include usage in streaming responses
39+ if (body.stream) {
40+ (body as any).stream_options = { include_usage: true };
41+ }
42+
3843 // o-series models - only apply for official OpenAI API
3944 const isOfficialOpenAIAPI = this.apiBase === "https://api.openai.com/v1/";
4045 if (isOfficialOpenAIAPI) {
modified packages/openai-adapters/src/apis/Relace.ts +29 −2
@@ -2,6 +2,7 @@
22 Completion,
33 CompletionCreateParamsNonStreaming,
44 CompletionCreateParamsStreaming,
5+ CompletionUsage,
56 } from "openai/resources/completions.mjs";
67 import {
78 CreateEmbeddingResponse,
@@ -16,7 +17,12 @@
1617 import { Model } from "openai/resources/models.mjs";
1718 import { z } from "zod";
1819 import { OpenAIConfigSchema } from "../types.js";
19-import { chatChunk, chatCompletion, customFetch } from "../util.js";
20+import {
21+ chatChunk,
22+ chatCompletion,
23+ customFetch,
24+ usageChatChunk,
25+} from "../util.js";
2026 import {
2127 BaseLlmApi,
2228 CreateRerankResponse,
@@ -24,6 +30,11 @@
2430 RerankCreateParams,
2531 } from "./base.js";
2632
33+type UsageInfo = Pick<
34+ CompletionUsage,
35+ "total_tokens" | "completion_tokens" | "prompt_tokens"
36+>;
37+
2738 // Relace only supports apply through a /v1/apply endpoint
2839 export class RelaceApi implements BaseLlmApi {
2940 private apiBase = "https://instantapply.endpoint.relace.run/v1/";
@@ -41,6 +52,7 @@
4152 signal: AbortSignal,
4253 ): Promise<ChatCompletion> {
4354 let content = "";
55+ let usage: UsageInfo | undefined = undefined;
4456
4557 // Convert the non-streaming params to streaming params
4658 const streamingBody: ChatCompletionCreateParamsStreaming = {
@@ -52,12 +64,18 @@
5264 streamingBody,
5365 signal,
5466 )) {
55- content += chunk.choices[0]?.delta?.content || "";
67+ if (chunk.choices.length > 0) {
68+ content += chunk.choices[0]?.delta?.content || "";
69+ }
70+ if (chunk.usage) {
71+ usage = chunk.usage;
72+ }
5673 }
5774
5875 return chatCompletion({
5976 content,
6077 model: body.model,
78+ usage,
6179 });
6280 }
6381
@@ -115,6 +133,15 @@
115133 content: mergedCode,
116134 model: body.model,
117135 });
136+
137+ yield usageChatChunk({
138+ model: body.model,
139+ usage: {
140+ prompt_tokens: result.usage.prompt_tokens || 0,
141+ completion_tokens: result.usage.completion_tokens || 0,
142+ total_tokens: result.usage.total_tokens,
143+ },
144+ });
118145 }
119146
120147 completionNonStream(
modified packages/openai-adapters/src/test/adapter-test-utils.ts +1 −0
@@ -258,6 +258,7 @@
258258 model: "gpt-4",
259259 messages: [{ role: "user", content: "hello" }],
260260 stream: true,
261+ stream_options: { include_usage: true },
261262 ...testConfig.customBodyOptions,
262263 },
263264 },
modified packages/openai-adapters/src/test/main.test.ts +58 −7
@@ -51,6 +51,20 @@
5151 model: "gpt-4o",
5252 apiKey: process.env.OPENAI_API_KEY!,
5353 roles: ["chat"],
54+ options: {
55+ skipTools: false,
56+ expectUsage: true,
57+ },
58+ },
59+ {
60+ provider: "openai",
61+ model: "gpt-4o-mini",
62+ apiKey: process.env.OPENAI_API_KEY!,
63+ roles: ["chat"],
64+ options: {
65+ skipTools: false,
66+ expectUsage: true,
67+ },
5468 },
5569 {
5670 provider: "anthropic",
@@ -67,15 +81,32 @@
6781 model: "gemini-1.5-flash-latest",
6882 apiKey: process.env.GEMINI_API_KEY!,
6983 roles: ["chat"],
84+ options: {
85+ skipTools: false,
86+ expectUsage: true,
87+ },
88+ },
89+ {
90+ provider: "gemini",
91+ model: "gemini-2.5-flash",
92+ apiKey: process.env.GEMINI_API_KEY!,
93+ roles: ["chat"],
94+ options: {
95+ skipTools: false,
96+ expectUsage: true,
97+ },
98+ },
99+ {
100+ provider: "mistral",
101+ model: "codestral",
102+ apiKey: process.env.MISTRAL_API_KEY!,
103+ roles: ["chat"],
104+ options: {
105+ skipTools: false,
106+ expectUsage: true,
107+ },
70108 },
71109 // {
72- // provider: "mistral",
73- // model: "codestral-latest",
74- // apiKey: process.env.MISTRAL_API_KEY!,
75- // apiBase: "https://api.mistral.ai/v1",
76- // roles: ["autocomplete"],
77- // },
78- // {
79110 // provider: "deepseek",
80111 // model: "deepseek-coder",
81112 // apiKey: process.env.DEEPSEEK_API_KEY!,
@@ -111,6 +142,26 @@
111142 apiKey: process.env.VOYAGE_API_KEY!,
112143 roles: ["rerank"],
113144 },
145+ {
146+ provider: "relace",
147+ model: "instant-apply",
148+ apiKey: process.env.RELACE_API_KEY!,
149+ roles: ["chat"],
150+ options: {
151+ skipTools: true,
152+ expectUsage: true,
153+ },
154+ },
155+ {
156+ provider: "inception",
157+ model: "mercury-coder",
158+ apiKey: process.env.INCEPTION_API_KEY!,
159+ roles: ["chat"],
160+ options: {
161+ skipTools: false,
162+ expectUsage: true,
163+ },
164+ },
114165 // {
115166 // provider: "cohere",
116167 // model: "rerank-v3.5",
modified packages/openai-adapters/src/test/util.ts +11 −3
@@ -106,9 +106,17 @@
106106 expect(usage).toBeDefined();
107107 expect(usage!.completion_tokens).toBeGreaterThan(0);
108108 expect(usage!.prompt_tokens).toBeGreaterThan(0);
109- expect(usage!.total_tokens).toEqual(
110- usage!.prompt_tokens + usage!.completion_tokens,
111- );
109+ // Gemini 2.5 models have thinking tokens, so total_tokens >= prompt + completion
110+ // Other models should have total_tokens = prompt + completion
111+ if (model.includes("gemini-2.5") || model.includes("gemini-2.0")) {
112+ expect(usage!.total_tokens).toBeGreaterThanOrEqual(
113+ usage!.prompt_tokens + usage!.completion_tokens,
114+ );
115+ } else {
116+ expect(usage!.total_tokens).toEqual(
117+ usage!.prompt_tokens + usage!.completion_tokens,
118+ );
119+ }
112120 }
113121 });
114122