The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): reserve red tool rows for clear failures
brooklyn!d3699f2fc108
diff --git a/apps/desktop/DESIGN.md b/apps/desktop/DESIGN.mdindex 9b7e4097a4f..742a7aec0a2 100644--- a/apps/desktop/DESIGN.md+++ b/apps/desktop/DESIGN.md@@ -271,6 +271,10 @@ so glass and message-bubble transparency do not reveal scrolling text.from the chip to the floating pill; leaving both dismisses it.- A tool result may expose an inline action that opens a preview. It must notopen the rail automatically.+- Tool rows reserve destructive red for explicit failures. Missing read paths and+ ambiguous exit-1 results use neutral notices, with details still available.+ Errors described inside returned data are not tool failures. Expanded failures+ show the actual explanation; supporting output keeps its normal text color.- Composer status groups start collapsed except todos. Progress updates and queuepause/resume preserve the user's disclosure choice. Error banners meet thestack's top edge without a blank padding strip. File and preview links remaindiff --git a/apps/desktop/src/components/assistant-ui/tool/fallback-model.test.ts b/apps/desktop/src/components/assistant-ui/tool/fallback-model.test.tsindex 7f74426df77..5e2351a61e5 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@@ -59,10 +59,9 @@ describe('buildToolView terminal exit-code status', () => {expect(terminal({ exit_code: 1, stdout: 'partial results' }).status).toBe('success')})- // No output + non-zero exit is a genuine failure worth flagging.- it('treats non-zero exit with no output as error', () => {+ it('distinguishes a command failure from an empty no-match exit', () => {expect(terminal({ exit_code: 127, output: '' }).status).toBe('error')- expect(terminal({ exit_code: 1 }).status).toBe('error')+ expect(terminal({ exit_code: 1, output: '' }).status).toBe('notice')})it('treats zero exit as success', () => {@@ -92,6 +91,32 @@ describe('buildToolView terminal exit-code status', () => {})})+describe('buildToolView error confidence', () => {+ it('keeps routine misses and returned diagnostic data out of destructive status', () => {+ const cases: Array<[Partial<ToolPart>, ReturnType<typeof buildToolView>['status']]> = [+ [+ {+ toolName: 'read_file',+ result: { error: 'File not found: /repo/session-view.ts', similar_files: ['/repo/session-view.tsx'] }+ },+ 'notice'+ ],+ [{ toolName: 'read_file', isError: true, result: { error: 'File not found: /repo/session-view.ts' } }, 'notice'],+ [{ toolName: 'terminal', result: { exit_code: 0, output: '{"error":"a logged failure"}' } }, 'success'],+ [{ result: { error: 'none', message: 'No changes needed' } }, 'success'],+ [{ result: { status: 'no error', message: 'Ready' } }, 'success'],+ [{ result: { meta: { error: 'a previous attempt' }, data: { count: 1 } } }, 'success'],+ [{ toolName: 'read_file', result: { error: 'Permission denied reading /repo/private.ts' } }, 'error'],+ [{ toolName: 'patch', result: { error: 'File not found: /repo/session-view.ts' } }, 'error'],+ [{ result: { success: false, result: { output: { error: { message: 'Connection refused' } } } } }, 'error']+ ]++ for (const [overrides, status] of cases) {+ expect(buildToolView(part(overrides), '').status, JSON.stringify(overrides)).toBe(status)+ }+ })+})+describe('buildToolView browser_exec step label', () => {const bexec = (code: string) =>buildToolView(part({ args: { code }, result: undefined, toolName: 'browser_exec' }), '')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.tsindex dea05eb8612..9e569a6d41e 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@@ -662,10 +662,6 @@ function toolErrorText(part: ToolPart, result: Record<string, unknown>): stringreturn extractedError || (typeof part.result === 'string' && part.result.trim()) || 'Tool returned an error.'}- if (typeof result.error === 'string' && result.error.trim()) {- return result.error.trim()- }-if (extractedError) {return extractedError}@@ -674,7 +670,7 @@ function toolErrorText(part: ToolPart, result: Record<string, unknown>): stringreturn firstStringField(result, ['message', 'reason', 'detail']) || 'Tool returned success=false.'}- if (typeof result.status === 'string' && /\b(error|failed|failure)\b/i.test(result.status)) {+ if (typeof result.status === 'string' && /^(error|failed|failure|fatal|exception)$/i.test(result.status.trim())) {return firstStringField(result, ['message', 'reason', 'detail']) || `Tool returned status "${result.status}".`}@@ -708,10 +704,23 @@ function toolStatus(part: ToolPart, resultRecord: Record<string, unknown>): Toolreturn 'success'}- if (!toolErrorText(part, resultRecord)) {+ const error = toolErrorText(part, resultRecord)++ if (!error) {return 'success'}+ // A guessed read path missing is routine exploration, not a broken tool.+ // Keep the explanation available without a destructive alarm. Writes and+ // permission failures deliberately do not take this path.+ if (part.toolName === 'read_file' && /^File not found:/i.test(error)) {+ return 'notice'+ }++ if (part.toolName === 'terminal' && error === 'Command failed with exit code 1.') {+ return 'notice'+ }+// A rejected memory write is a budget negotiation, not a failure: the store// refuses an over-limit batch and the agent retries smaller. Soft warning —// never destructive-red beside routine bookkeeping.diff --git a/apps/desktop/src/components/assistant-ui/tool/fallback-model/types.ts b/apps/desktop/src/components/assistant-ui/tool/fallback-model/types.tsindex 844d8069631..9aa5b8dca71 100644--- a/apps/desktop/src/components/assistant-ui/tool/fallback-model/types.ts+++ b/apps/desktop/src/components/assistant-ui/tool/fallback-model/types.ts@@ -1,5 +1,5 @@export type ToolTone = 'agent' | 'browser' | 'default' | 'file' | 'image' | 'terminal' | 'web'-export type ToolStatus = 'error' | 'running' | 'success' | 'warning'+export type ToolStatus = 'error' | 'notice' | 'running' | 'success' | 'warning'export interface ToolPart {args?: unknowndiff --git a/apps/desktop/src/components/assistant-ui/tool/fallback.tsx b/apps/desktop/src/components/assistant-ui/tool/fallback.tsxindex bd8135e047e..527d97206ea 100644--- a/apps/desktop/src/components/assistant-ui/tool/fallback.tsx+++ b/apps/desktop/src/components/assistant-ui/tool/fallback.tsx@@ -45,7 +45,6 @@ import { connectorCalls } from '@/lib/connector-tools'import { PrettyLink, LinkifiedText as SharedLinkifiedText, urlSlugTitleLabel } from '@/lib/external-link'import { AlertCircle, CheckCircle2 } from '@/lib/icons'import { isOnboardingEnabled } from '@/lib/onboarding-enabled'-import { normalize } from '@/lib/text'import { useEnterAnimation } from '@/lib/use-enter-animation'import { cn } from '@/lib/utils'import { recordPreviewArtifact } from '@/store/preview-status'@@ -257,7 +256,7 @@ function leadingStatus(isPending: boolean, status: ToolStatus): ToolStatus | undreturn 'running'}- return status === 'success' ? undefined : status+ return status === 'success' || status === 'notice' ? undefined : status}function SearchResultsList({ hits }: { hits: SearchResultRow[] }) {@@ -433,16 +432,11 @@ function ToolEntry({ part }: ToolEntryProps) {.map(chunk => chunk.trim()).filter(Boolean)+ // The subtitle is not rendered in the header; keep its explanation here.const [summary = '', ...rest] = chunks- const subtitleNorm = normalize(view.subtitle)- const summaryDuplicatesSubtitle = summary && summary.toLowerCase() === subtitleNorm-- if (summaryDuplicatesSubtitle) {- return { body: rest.join('\n\n').trim(), summary: '' }- }return { body: rest.join('\n\n').trim(), summary }- }, [view.detail, view.status, view.subtitle])+ }, [view.detail, view.status])// `looksRedundant` normalizes the FULL (uncapped) detail payload — a// read_file / terminal result can be huge. Memoize on the view fields so it@@ -455,6 +449,7 @@ function ToolEntry({ part }: ToolEntryProps) {!view.inlineDiff &&(Boolean(view.stdout || view.stderr) ||(view.status === 'error' && Boolean(detailSections.summary || detailSections.body)) ||+ (view.status === 'notice' && Boolean(view.detail)) ||(view.status !== 'error' && Boolean(view.detail) && !detailMatchesTitle && !detailMatchesSubtitle))const renderDetailAsCode =@@ -649,7 +644,7 @@ function ToolEntry({ part }: ToolEntryProps) {{detailSections.body && (<preclassName={cn(- 'max-h-56 overflow-auto whitespace-pre-wrap wrap-anywhere font-mono text-[0.7rem] leading-[1.55] text-destructive/90',+ 'max-h-56 overflow-auto whitespace-pre-wrap wrap-anywhere font-mono text-[0.7rem] leading-[1.55] text-(--ui-text-secondary)',detailSections.summary && 'mt-1.5')}>diff --git a/apps/desktop/src/components/assistant-ui/tool/tool-group.test.tsx b/apps/desktop/src/components/assistant-ui/tool/tool-group.test.tsxindex 5d66c9d9d39..9157cfb78e1 100644--- a/apps/desktop/src/components/assistant-ui/tool/tool-group.test.tsx+++ b/apps/desktop/src/components/assistant-ui/tool/tool-group.test.tsx@@ -630,6 +630,34 @@ describe('flat tool list approval surfacing', () => {})})+describe('tool error explanations', () => {+ it('keeps lookup misses neutral and exposes actual failures when expanded', async () => {+ for (const [error, destructive] of [+ ['File not found: /repo/session-view.ts', false],+ ['Permission denied reading /repo/session-view.ts', true]+ ] as const) {+ const message = completedOnlyMessage()+ const part = message.content[0]!++ const { container, unmount } = render(+ <GroupHarness+ message={{+ ...message,+ content: [{ ...part, result: { error }, args: { path: '/repo/session-view.ts' } } as typeof part]+ }}+ />+ )++ fireEvent.click(await screen.findByText('Read session-view.ts'))++ await waitFor(() => expect(container.textContent).toContain(error))+ expect(Boolean(container.querySelector('[data-tool-row] .text-destructive'))).toBe(destructive)+ unmount()+ $toolDisclosureStates.set({})+ }+ })+})+describe('tool lifecycle timestamps', () => {it('shows the precise call and completion times on a settled tool row', async () => {const { container } = render(<GroupHarness message={completedOnlyMessage()} />)