Skip to content

Commit b421d21

Browse files
committed
remove extra chat message
1 parent f7a3f2e commit b421d21

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

cli/src/state/atoms/shell.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import { atom } from "jotai"
66
import { addMessageAtom, inputModeAtom, type InputMode } from "./ui.js"
77
import { exec } from "child_process"
8-
import { chatMessagesAtom } from "./extension.js"
98
import { clearTextAtom, setTextAtom, textBufferIsEmptyAtom } from "./textBuffer.js"
109

1110
// ============================================================================
@@ -170,53 +169,31 @@ export const executeShellCommandAtom = atom(null, async (get, set, command: stri
170169

171170
const output = stdout || stderr || "Command executed successfully"
172171

173-
// Display as system message for visibility
172+
// Display as system message for visibility in CLI
174173
const systemMessage = {
175174
id: `shell-${Date.now()}`,
176175
type: "system" as const,
177176
ts: Date.now(),
178177
content: `$ ${command}\n${output}`,
179178
partial: false,
180179
}
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-
}
191180

192-
const currentMessages = get(chatMessagesAtom)
193-
set(chatMessagesAtom, [...currentMessages, chatMessage])
181+
set(addMessageAtom, systemMessage)
194182
} catch (error: unknown) {
195183
// Handle errors and display them in the message system
196184

197185
const errorOutput = `❌ Error: ${error instanceof Error ? error.message : error}`
198186

199-
// Display as error message for visibility
187+
// Display as error message for visibility in CLI
200188
const errorMessage = {
201189
id: `shell-error-${Date.now()}`,
202190
type: "error" as const,
203191
ts: Date.now(),
204192
content: `$ ${command}\n${errorOutput}`,
205193
partial: false,
206194
}
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-
}
217195

218-
const currentMessages = get(chatMessagesAtom)
219-
set(chatMessagesAtom, [...currentMessages, chatErrorMessage])
196+
set(addMessageAtom, errorMessage)
220197
}
221198

222199
// Reset history navigation index

0 commit comments

Comments
 (0)