Skip to content

The agent that grows with you

fix(desktop): stop the tool row repeating its command three times

Brooklyn Nicholsonec6719b04e5e
diff --git a/apps/desktop/src/components/assistant-ui/tool/fallback-model.test.ts b/apps/desktop/src/components/assistant-ui/tool/fallback-model.test.ts
index 275cc13fb4f..19a8cd61447 100644
--- a/apps/desktop/src/components/assistant-ui/tool/fallback-model.test.ts
+++ b/apps/desktop/src/components/assistant-ui/tool/fallback-model.test.ts
@@ -340,6 +340,28 @@ describe('buildToolView title actions', () => {
expect(view.titleAction).toEqual({ prefix: '', text: 'Running', suffix: ' pnpm run lint' })
})
+ it('never stutters the verb or echoes the command when the backend context is a phrased label', () => {
+ // Older backends stamped tool.start with a *phrased* label
+ // ("Running sleep 70 + 2 commands") rather than a raw arg preview, and the
+ // desktop merges that into args.context. The row must still prepend its own
+ // verb exactly once, show the real command in the `$` transcript, and not
+ // repeat either string as detail.
+ const command = 'sleep 70; echo "a"; echo "b"'
+
+ const view = buildToolView(
+ part({
+ args: { command, context: 'Running sleep 70 + 2 commands' },
+ result: { exit_code: 0 },
+ toolName: 'terminal'
+ }),
+ ''
+ )
+
+ expect(view.title).toBe('Ran sleep 70 + 2 commands')
+ expect(view.terminalCommand).toBe(command)
+ expect(view.detail).toBe('')
+ })
+
it('uses the runtime locale for title text and action placement', () => {
setRuntimeI18nLocale('ja')
diff --git a/apps/desktop/src/components/assistant-ui/tool/fallback-model/index.ts b/apps/desktop/src/components/assistant-ui/tool/fallback-model/index.ts
index 5c6fd8c9b03..6bcd06a63a9 100644
--- a/apps/desktop/src/components/assistant-ui/tool/fallback-model/index.ts
+++ b/apps/desktop/src/components/assistant-ui/tool/fallback-model/index.ts
@@ -128,9 +128,14 @@ function readFileDisplayTarget(args: Record<string, unknown>, result: Record<str
return [fileEditBasename(path), lineLabel].filter(Boolean).join(' ')
}
+// The real command, preferring the actual argument over the backend's
+// display preview. `context` is a *summarized* preview ("sleep 70 + 2
+// commands") the gateway sends on tool.start before real args arrive — fine
+// as a placeholder for the live title, wrong for the `$` transcript, which
+// must show what actually ran.
function shellCommand(args: Record<string, unknown>): string {
return (
- firstStringField(args, ['context', 'preview']) || firstStringField(args, ['command', 'code']) || contextValue(args)
+ firstStringField(args, ['command', 'code']) || firstStringField(args, ['context', 'preview']) || contextValue(args)
)
}
@@ -1079,6 +1084,13 @@ function toolDetailText(
if (output || lines) {
return [output, lines].filter(Boolean).join('\n')
}
+
+ // A terminal row with no output already shows its command in the `$`
+ // transcript above; the generic fallback would print the same string a
+ // second time. `execute_code` has no transcript, so it keeps the fallback.
+ if (part.toolName === 'terminal') {
+ return ''
+ }
}
if (part.toolName === 'web_extract') {