Elffuss BraidHub

kikocis/continue public

Merge pull request #7537 from continuedev/dallin/con-3345

feat: CLI shell mode
Changesetaf695458de9dac865a7252688b8bb58337134e005e76885708b75182eac2997a
AuthorTing-Wai <40179554+tingwai@users.noreply.github.com> · 2025-09-05 13:40 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-05 13:40 -07:00
Parentsef50d56d248f, 3f8d78b26826

Browse the files at this changeset

7 files changed

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/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 };
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 }