|
5 | 5 | import { atom } from "jotai" |
6 | 6 | import { addMessageAtom, inputModeAtom, type InputMode } from "./ui.js" |
7 | 7 | import { exec } from "child_process" |
8 | | -import { chatMessagesAtom } from "./extension.js" |
9 | 8 | import { clearTextAtom, setTextAtom, textBufferIsEmptyAtom } from "./textBuffer.js" |
10 | 9 |
|
11 | 10 | // ============================================================================ |
@@ -170,53 +169,31 @@ export const executeShellCommandAtom = atom(null, async (get, set, command: stri |
170 | 169 |
|
171 | 170 | const output = stdout || stderr || "Command executed successfully" |
172 | 171 |
|
173 | | - // Display as system message for visibility |
| 172 | + // Display as system message for visibility in CLI |
174 | 173 | const systemMessage = { |
175 | 174 | id: `shell-${Date.now()}`, |
176 | 175 | type: "system" as const, |
177 | 176 | ts: Date.now(), |
178 | 177 | content: `$ ${command}\n${output}`, |
179 | 178 | partial: false, |
180 | 179 | } |
181 | | - set(addMessageAtom, systemMessage) |
182 | | - |
183 | | - // Add to chat messages for agent context |
184 | | - const chatMessage = { |
185 | | - ts: Date.now(), |
186 | | - type: "say" as const, |
187 | | - say: "shell_command", |
188 | | - text: `Shell command executed:\n$ ${command}\n${output}`, |
189 | | - partial: false, |
190 | | - } |
191 | 180 |
|
192 | | - const currentMessages = get(chatMessagesAtom) |
193 | | - set(chatMessagesAtom, [...currentMessages, chatMessage]) |
| 181 | + set(addMessageAtom, systemMessage) |
194 | 182 | } catch (error: unknown) { |
195 | 183 | // Handle errors and display them in the message system |
196 | 184 |
|
197 | 185 | const errorOutput = `❌ Error: ${error instanceof Error ? error.message : error}` |
198 | 186 |
|
199 | | - // Display as error message for visibility |
| 187 | + // Display as error message for visibility in CLI |
200 | 188 | const errorMessage = { |
201 | 189 | id: `shell-error-${Date.now()}`, |
202 | 190 | type: "error" as const, |
203 | 191 | ts: Date.now(), |
204 | 192 | content: `$ ${command}\n${errorOutput}`, |
205 | 193 | partial: false, |
206 | 194 | } |
207 | | - set(addMessageAtom, errorMessage) |
208 | | - |
209 | | - // Add to chat messages for agent context |
210 | | - const chatErrorMessage = { |
211 | | - ts: Date.now(), |
212 | | - type: "say" as const, |
213 | | - say: "shell_command_error", |
214 | | - text: `Shell command failed:\n$ ${command}\n${errorOutput}`, |
215 | | - partial: false, |
216 | | - } |
217 | 195 |
|
218 | | - const currentMessages = get(chatMessagesAtom) |
219 | | - set(chatMessagesAtom, [...currentMessages, chatErrorMessage]) |
| 196 | + set(addMessageAtom, errorMessage) |
220 | 197 | } |
221 | 198 |
|
222 | 199 | // Reset history navigation index |
|
0 commit comments