TypeScript
fix(web): stop showing red x summaries for ordinary tool failures (#8395)
Theo Brownef1e6f0c9bbe5
diff --git a/apps/mobile/src/features/threads/thread-work-log.tsx b/apps/mobile/src/features/threads/thread-work-log.tsxindex a5adacb8d19..9b8bef79445 100644--- a/apps/mobile/src/features/threads/thread-work-log.tsx+++ b/apps/mobile/src/features/threads/thread-work-log.tsx@@ -239,7 +239,7 @@ export function ThreadWorkLog(props: {: { ios: "minus", android: "remove" }}size={11}- tintColor={row.status === "failure" ? "#e11d48" : props.iconSubtleColor}+ tintColor={props.iconSubtleColor}type="monochrome"/>) : null}diff --git a/apps/mobile/src/lib/threadActivity.test.ts b/apps/mobile/src/lib/threadActivity.test.tsindex e2943ebc1a0..19194ea3a57 100644--- a/apps/mobile/src/lib/threadActivity.test.ts+++ b/apps/mobile/src/lib/threadActivity.test.ts@@ -324,6 +324,38 @@ describe("buildThreadFeed", () => {]);});+ it("drops runtime warnings with no displayable content", () => {+ const thread = makeThread({+ id: ThreadId.make("thread-noise"),+ projectId: ProjectId.make("project-1"),+ title: "Warning noise thread",+ activities: [+ makeActivity({+ id: EventId.make("activity-noise"),+ kind: "runtime.warning",+ summary: "Claude system message 'background_tasks_changed' (no displayable text content)",+ createdAt: "2026-04-01T00:00:02.000Z",+ turnId: TurnId.make("turn-1"),+ }),+ makeActivity({+ id: EventId.make("activity-signal"),+ kind: "runtime.warning",+ summary: "Reconnecting... 2/5",+ createdAt: "2026-04-01T00:00:03.000Z",+ turnId: TurnId.make("turn-1"),+ }),+ ],+ });++ const feed = buildThreadFeed(thread);+ expect(feed).toMatchObject([+ {+ type: "activity-group",+ activities: [{ id: "activity-signal" }],+ },+ ]);+ });+it("collapses matching tool lifecycle rows like desktop", () => {const thread = makeThread({id: ThreadId.make("thread-2"),diff --git a/apps/mobile/src/lib/threadActivity.ts b/apps/mobile/src/lib/threadActivity.tsindex 9e0cb64ae8b..6dd8230307a 100644--- a/apps/mobile/src/lib/threadActivity.ts+++ b/apps/mobile/src/lib/threadActivity.ts@@ -338,6 +338,7 @@ function deriveWorkLogEntries(if (activity.kind === "tool.progress") continue;if (activity.kind === "context-window.updated") continue;if (activity.summary === "Checkpoint captured") continue;+ if (isNoContentRuntimeWarning(activity)) continue;if (isPlanBoundaryToolActivity(activity)) continue;if (isAgentInternalActivity(activity)) continue;entries.push(toDerivedWorkLogEntry(activity));@@ -345,6 +346,17 @@ function deriveWorkLogEntries(return collapseDerivedWorkLogEntries(entries);}+/** Adapters forward unknown wire-only SDK messages (background_tasks_changed,+ * commands_changed, ...) as runtime warnings. The suffix comes from+ * describeUnknownSdkMessage in the Claude adapter; a row with no displayable+ * text carries nothing a user can act on, so it does not render. */+function isNoContentRuntimeWarning(activity: OrchestrationThreadActivity): boolean {+ return (+ activity.kind === "runtime.warning" &&+ activity.summary.endsWith("(no displayable text content)")+ );+}+function isPlanBoundaryToolActivity(activity: OrchestrationThreadActivity): boolean {if (activity.kind !== "tool.updated" && activity.kind !== "tool.completed") {return false;diff --git a/apps/web/src/components/chat/MessagesTimeline.test.tsx b/apps/web/src/components/chat/MessagesTimeline.test.tsxindex 7ee4514c370..de94a7cd3cb 100644--- a/apps/web/src/components/chat/MessagesTimeline.test.tsx+++ b/apps/web/src/components/chat/MessagesTimeline.test.tsx@@ -973,6 +973,49 @@ describe("MessagesTimeline", () => {expect(markup).not.toContain('aria-label="Tool call failed"');});+ it("keeps the collapsed summary icon neutral when the group ends in a failure", () => {+ const markup = renderToStaticMarkup(+ <MessagesTimeline+ {...buildProps()}+ timelineEntries={[+ {+ id: "entry-completed",+ kind: "work",+ createdAt: "2026-03-17T19:12:28.000Z",+ entry: {+ id: "work-completed",+ createdAt: "2026-03-17T19:12:28.000Z",+ label: "Run tests",+ tone: "tool",+ itemType: "command_execution",+ toolLifecycleStatus: "completed",+ },+ },+ {+ id: "entry-failed",+ kind: "work",+ createdAt: "2026-03-17T19:12:29.000Z",+ entry: {+ id: "work-failed",+ createdAt: "2026-03-17T19:12:29.000Z",+ label: "Run lint",+ tone: "tool",+ itemType: "command_execution",+ toolLifecycleStatus: "failed",+ },+ },+ ]}+ />,+ );++ expect(markup).toContain("Ran 2 commands");+ expect(markup).toContain("lucide-terminal");+ expect(markup).not.toContain("lucide-x");+ expect(markup).not.toContain("text-destructive");+ // The failure stays discoverable for screen readers.+ expect(markup).toContain("tool call failed");+ });+it("keeps mixed work logs neutral after a later tool call succeeds", () => {const markup = renderToStaticMarkup(<MessagesTimeline@@ -1249,11 +1292,22 @@ describe("MessagesTimeline", () => {expect(markup).not.toContain('data-testid="file-diff"');});- it("renders a failure marker for failed tool lifecycle entries", () => {+ it("renders a muted failure marker for failed tool lifecycle entries", () => {const markup = renderToStaticMarkup(<MessagesTimeline{...buildProps()}timelineEntries={[+ {+ id: "entry-info",+ kind: "work",+ createdAt: "2026-03-17T19:12:27.000Z",+ entry: {+ id: "work-info",+ createdAt: "2026-03-17T19:12:27.000Z",+ label: "Status updated",+ tone: "info",+ },+ },{id: "entry-1",kind: "work",@@ -1273,5 +1327,43 @@ describe("MessagesTimeline", () => {expect(markup).toContain("lucide-x");expect(markup).toContain('aria-label="Tool call failed"');+ // Ordinary tool failures render muted, not red.+ expect(markup).not.toContain("text-destructive");+ });++ it("keeps the red treatment for severe orchestration failures", () => {+ const markup = renderToStaticMarkup(+ <MessagesTimeline+ {...buildProps()}+ timelineEntries={[+ {+ id: "entry-info",+ kind: "work",+ createdAt: "2026-03-17T19:12:27.000Z",+ entry: {+ id: "work-info",+ createdAt: "2026-03-17T19:12:27.000Z",+ label: "Status updated",+ tone: "info",+ },+ },+ {+ id: "entry-turn-failed",+ kind: "work",+ createdAt: "2026-03-17T19:12:28.000Z",+ entry: {+ id: "work-turn-failed",+ createdAt: "2026-03-17T19:12:28.000Z",+ label: "Provider turn start failed",+ tone: "error",+ sourceActivityKind: "provider.turn.start.failed",+ },+ },+ ]}+ />,+ );++ expect(markup).toContain("lucide-x");+ expect(markup).toContain("text-destructive");});});diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsxindex af920c0d615..7c31fb6207b 100644--- a/apps/web/src/components/chat/MessagesTimeline.tsx+++ b/apps/web/src/components/chat/MessagesTimeline.tsx@@ -35,6 +35,7 @@ import { FileDiff } from "@pierre/diffs/react";import {deriveTimelineEntries,workEntryDisplayIndicatesToolFailure,+ workEntrySignalsSevereFailure,workLogEntryIsToolLike,} from "../../session-logic";import { type TurnDiffSummary } from "../../types";@@ -1479,7 +1480,7 @@ function LiveActivityContent({<spanclassName={cn("flex size-6 shrink-0 items-center justify-center",- failed ? "text-destructive" : highlighted ? "text-foreground" : "text-icon-muted",+ highlighted ? "text-foreground" : "text-icon-muted",)}role={announceFailure ? "img" : undefined}aria-label={announceFailure ? "Tool call failed" : undefined}@@ -1556,16 +1557,9 @@ function WorkGroupToggleTimelineRow({aria-expanded={row.expanded}onClick={() => ctx.onToggleWorkGroup(row.groupId, row.id)}>- <span- className={cn(- "flex size-6 shrink-0 items-center justify-center",- row.hasFailure ? "text-destructive" : "text-icon-muted",- )}- role={row.hasFailure ? "img" : undefined}- aria-label={row.hasFailure ? "Tool call failed" : undefined}- >+ <span className="flex size-6 shrink-0 items-center justify-center text-icon-muted"><WorkEntryIconSvg- name={row.hasFailure ? "x" : toolGroupSummaryIconName(row.summaryKind)}+ name={toolGroupSummaryIconName(row.summaryKind)}className="size-4 shrink-0 stroke-[1.8] opacity-70"/></span>@@ -1580,33 +1574,25 @@ function WorkGroupToggleTimelineRow({: row.hiddenCount === 1? "log entry": "log entries";- const showHiddenFailure = row.hasFailure && !row.expanded;-return (<buttontype="button"className="flex min-h-6 w-full cursor-pointer items-center gap-1.5 rounded-md px-0.5 py-0.5 text-left text-sm leading-relaxed transition-colors duration-150 hover:bg-accent/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70"+ aria-label={+ row.hasFailure && !row.expanded+ ? `+${row.hiddenCount} previous ${labelNoun}, includes a failure`+ : undefined+ }aria-expanded={row.expanded}onClick={() => ctx.onToggleWorkGroup(row.groupId, row.id)}>- <span- className={cn(- "flex size-6 shrink-0 items-center justify-center",- showHiddenFailure ? "text-destructive" : "text-icon-muted",- )}- role={showHiddenFailure ? "img" : undefined}- aria-label={showHiddenFailure ? "Hidden work includes a failure" : undefined}- >- {showHiddenFailure ? (- <WorkEntryIconSvg name="x" className="size-4 shrink-0 stroke-[1.8] opacity-70" />- ) : (- <ChevronDownIcon- className={cn(- "size-4 shrink-0 opacity-70 transition-transform duration-200",- row.expanded && "rotate-180",- )}- />- )}+ <span className="flex size-6 shrink-0 items-center justify-center text-icon-muted">+ <ChevronDownIcon+ className={cn(+ "size-4 shrink-0 opacity-70 transition-transform duration-200",+ row.expanded && "rotate-180",+ )}+ /></span>{row.expanded ? (<span className="font-medium text-foreground">@@ -2631,11 +2617,13 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: {const canExpand = expandedBody !== null;const showDestructiveRowStyle =showFailedIndicator &&- (workEntry.sourceActivityKind === "runtime.error" || !workLogEntryIsToolLike(workEntry));+ (workEntrySignalsSevereFailure(workEntry) || !workLogEntryIsToolLike(workEntry));+ // Ordinary tool failures stay muted; only runtime errors and warnings get+ // color. The red treatment is reserved for severe failures.const iconWrapperClass = cn("flex size-6 shrink-0 items-center justify-center",- showWarningIndicator || showFailedIndicator- ? "text-destructive"+ showWarningIndicator+ ? "text-warning": showDestructiveRowStyle? "text-destructive": workEntry.tone === "tool" || showFailedIndicatordiff --git a/apps/web/src/session-logic.test.ts b/apps/web/src/session-logic.test.tsindex 0c07e53db67..05be83a20ca 100644--- a/apps/web/src/session-logic.test.ts+++ b/apps/web/src/session-logic.test.ts@@ -935,6 +935,28 @@ describe("deriveWorkLogEntries", () => {expect(entries.map((entry) => entry.id)).toEqual(["tool-complete"]);});+ it("drops runtime warnings with no displayable content, keeps ones with a preview", () => {+ const activities: OrchestrationThreadActivity[] = [+ makeActivity({+ id: "warning-noise",+ createdAt: "2026-02-23T00:00:01.000Z",+ kind: "runtime.warning",+ summary: "Claude system message 'background_tasks_changed' (no displayable text content)",+ tone: "info",+ }),+ makeActivity({+ id: "warning-signal",+ createdAt: "2026-02-23T00:00:02.000Z",+ kind: "runtime.warning",+ summary: "Reconnecting... 2/5",+ tone: "info",+ }),+ ];++ const entries = deriveWorkLogEntries(activities);+ expect(entries.map((entry) => entry.id)).toEqual(["warning-signal"]);+ });+it("omits task.started but shows task.progress and task.completed", () => {const activities: OrchestrationThreadActivity[] = [makeActivity({diff --git a/apps/web/src/session-logic.ts b/apps/web/src/session-logic.tsindex 59165ec6b72..4b35a6e24cc 100644--- a/apps/web/src/session-logic.ts+++ b/apps/web/src/session-logic.ts@@ -279,6 +279,17 @@ export function workEntryDisplayIndicatesToolFailure(entry: WorkLogEntry): boolereturn workEntryIndicatesToolFailureFromOutput(entry, false);}+/** Severe failures keep the red treatment ordinary tool failures lost: runtime+ * errors and orchestration `*.failed` activities (provider.turn.start.failed,+ * checkpoint.capture.failed, ...) mean the turn or a core side effect broke,+ * not that a command exited nonzero. */+export function workEntrySignalsSevereFailure(entry: WorkLogEntry): boolean {+ return (+ entry.sourceActivityKind === "runtime.error" ||+ entry.sourceActivityKind?.endsWith(".failed") === true+ );+}+/** Tool/command row completed without failure (blue check affordance). */export function workEntryIndicatesToolSuccess(entry: WorkLogEntry): boolean {if (!workLogEntryIsToolLike(entry)) {@@ -870,6 +881,7 @@ export function deriveWorkLogEntries(if (activity.kind === "tool.progress") continue;if (activity.kind === "context-window.updated") continue;if (activity.summary === "Checkpoint captured") continue;+ if (isNoContentRuntimeWarning(activity)) continue;if (isPlanBoundaryToolActivity(activity)) continue;if (isAgentInternalActivity(activity)) continue;entries.push(toDerivedWorkLogEntry(activity));@@ -877,6 +889,17 @@ export function deriveWorkLogEntries(return collapseDerivedWorkLogEntries(entries);}+/** Adapters forward unknown wire-only SDK messages (background_tasks_changed,+ * commands_changed, ...) as runtime warnings. The suffix comes from+ * describeUnknownSdkMessage in the Claude adapter; a row with no displayable+ * text carries nothing a user can act on, so it does not render. */+function isNoContentRuntimeWarning(activity: OrchestrationThreadActivity): boolean {+ return (+ activity.kind === "runtime.warning" &&+ activity.summary.endsWith("(no displayable text content)")+ );+}+function isPlanBoundaryToolActivity(activity: OrchestrationThreadActivity): boolean {if (activity.kind !== "tool.updated" && activity.kind !== "tool.completed") {return false;