Skip to content
TypeScript

fix: preserve tool icons on failed calls (#9606)

Julius Marmingec3b8825bf476
diff --git a/apps/mobile/src/features/threads/thread-work-log.tsx b/apps/mobile/src/features/threads/thread-work-log.tsx
index 431258e0d51..a2e19b9a8c4 100644
--- a/apps/mobile/src/features/threads/thread-work-log.tsx
+++ b/apps/mobile/src/features/threads/thread-work-log.tsx
@@ -76,14 +76,13 @@ type WorkContentIcon = AppSymbolName | "browser" | "t3-code";
function WorkLogIcon(props: {
readonly icon: WorkContentIcon;
readonly color: ColorValue;
+ readonly colorClassName?: string;
readonly highlighted?: boolean;
}) {
+ const colorClassName = props.highlighted ? "accent-foreground" : props.colorClassName;
if (props.icon === "t3-code") {
return (
- <T3Wordmark
- height={10}
- {...(props.highlighted ? { colorClassName: "accent-foreground" } : { color: props.color })}
- />
+ <T3Wordmark height={10} {...(colorClassName ? { colorClassName } : { color: props.color })} />
);
}
return (
@@ -91,9 +90,7 @@ function WorkLogIcon(props: {
name={props.icon === "browser" ? { ios: "globe", android: "public" } : props.icon}
size={14}
weight="medium"
- {...(props.highlighted
- ? { tintColorClassName: "accent-foreground" }
- : { tintColor: props.color })}
+ {...(colorClassName ? { tintColorClassName: colorClassName } : { tintColor: props.color })}
type="monochrome"
/>
);
@@ -707,11 +704,7 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
const iconIsDestructive = row.icon === "alert" || row.icon === "warning";
const failed = row.status === "failure";
const toolIcon = row.workEntry.toolIcon ?? row.workEntry.toolSource?.icon;
- const hasSpecialToolIcon =
- toolPresentation !== null || row.workEntry.toolSurface !== undefined || toolIcon !== undefined;
- const icon =
- toolPresentation?.icon ??
- (failed && !hasSpecialToolIcon ? "xmark" : workRowSymbolName(row.icon));
+ const icon = toolPresentation?.icon ?? workRowSymbolName(row.icon);
return (
<Animated.View
@@ -750,12 +743,7 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
) : (
<>
<View className="h-6 w-6 shrink-0 items-center justify-center">
- {failed && !hasSpecialToolIcon ? (
- <WorkLogIcon
- icon={icon}
- color={iconIsDestructive ? "#e11d48" : props.iconSubtleColor}
- />
- ) : (
+ {toolIcon ? (
<ToolActivityIconView
environmentId={props.environmentId}
icon={toolIcon}
@@ -763,6 +751,18 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
fallbackColor={props.iconSubtleColor}
themeAppearance={props.themeAppearance}
/>
+ ) : (
+ <WorkLogIcon
+ icon={icon}
+ color={props.iconSubtleColor}
+ colorClassName={
+ iconIsDestructive
+ ? "accent-adaptive-rose-600-400"
+ : failed
+ ? "accent-danger-foreground/40"
+ : undefined
+ }
+ />
)}
</View>
<Text
@@ -783,7 +783,7 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
Copied
</Text>
) : null}
- {failed && hasSpecialToolIcon ? (
+ {failed && toolIcon !== undefined ? (
<View
className="h-4 w-4 items-center justify-center"
accessibilityElementsHidden
@@ -792,7 +792,7 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
<SymbolView
name="xmark"
size={11}
- tintColorClassName="accent-adaptive-rose-600-400"
+ tintColorClassName="accent-danger-foreground/40"
type="monochrome"
/>
</View>
diff --git a/apps/web/src/components/chat/MessagesTimeline.test.tsx b/apps/web/src/components/chat/MessagesTimeline.test.tsx
index 3a1337e2e65..bcb4306387c 100644
--- a/apps/web/src/components/chat/MessagesTimeline.test.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.test.tsx
@@ -1471,7 +1471,7 @@ describe("MessagesTimeline", () => {
);
expect(markup).toContain('aria-label="Received 1 update and used 1 tool, tool call failed"');
- // Ordinary tool failures render muted, not red.
+ // Ordinary tool failures do not use destructive row styling.
expect(markup).not.toContain("text-destructive");
});
diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx
index 45c91d7f361..e97f10c3943 100644
--- a/apps/web/src/components/chat/MessagesTimeline.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.tsx
@@ -1893,6 +1893,17 @@ function ActivityShimmerOverlay({ children }: { children: ReactNode }) {
);
}
+const failedToolIconClassName = "text-tool-error-icon/40";
+
+/** Image icons and the gradient computer-use mark cannot take a currentColor
+ * tint, so failed rows using them get a trailing x instead. */
+function toolIconAcceptsTint(
+ iconName: WorkEntryIconName,
+ toolIcon: ToolActivityIcon | undefined,
+): boolean {
+ return toolIcon === undefined && iconName !== "computer";
+}
+
function LiveActivityRow({
label,
iconName,
@@ -1941,37 +1952,41 @@ function LiveActivityContent({
announceFailure?: boolean;
highlighted?: boolean;
}) {
- const isSpecialToolIcon =
- iconName === "browser" || iconName === "computer" || iconName === "t3-code";
- const resolvedIconName = failed && !isSpecialToolIcon ? "circle-alert" : iconName;
+ const showTrailingFailureMark =
+ failed && iconName !== undefined && !toolIconAcceptsTint(iconName, toolIcon);
return (
<span
className={cn(
"flex min-h-6 min-w-0 items-center gap-1.5 py-0.5",
- resolvedIconName ? "px-0.5" : "px-1",
+ iconName ? "px-0.5" : "px-1",
highlighted ? "text-foreground" : "text-secondary-label",
)}
>
- {resolvedIconName ? (
+ {iconName ? (
<span
className={cn(
"flex size-6 shrink-0 items-center justify-center",
- highlighted ? "text-foreground" : "text-icon-muted",
+ highlighted ? "text-foreground" : failed ? failedToolIconClassName : "text-icon-muted",
)}
role={announceFailure ? "img" : undefined}
aria-label={announceFailure ? "Tool call failed" : undefined}
>
<ToolActivityIconView
- icon={failed && !isSpecialToolIcon ? undefined : toolIcon}
- fallbackName={resolvedIconName}
+ icon={toolIcon}
+ fallbackName={iconName}
className="block size-4 shrink-0 stroke-[1.8]"
muted={!highlighted}
/>
</span>
) : null}
<span className="min-w-0 flex-1 truncate">{label}</span>
- {failed && isSpecialToolIcon ? <XIcon aria-hidden className="size-3 shrink-0" /> : null}
+ {showTrailingFailureMark ? (
+ <XIcon
+ aria-hidden
+ className={cn("size-3 shrink-0", !highlighted && failedToolIconClassName)}
+ />
+ ) : null}
</span>
);
}
@@ -3088,12 +3103,15 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: {
const iconConfig = workToneIcon(workEntry.tone);
const showWarningIndicator = workEntry.sourceActivityKind === "runtime.warning";
const showFailedIndicator = workEntryDisplayIndicatesToolFailure(workEntry);
- const toolPresentation = resolveWorkEntryToolPresentation(workEntry);
- const hasSpecialToolIcon = toolPresentation !== null || workEntry.toolSurface !== undefined;
+ const showDestructiveRowStyle =
+ showFailedIndicator &&
+ (workEntrySignalsSevereFailure(workEntry) || !workLogEntryIsToolLike(workEntry));
const entryIconName =
- showWarningIndicator || (showFailedIndicator && !hasSpecialToolIcon)
- ? "circle-alert"
- : workEntryIconName(workEntry);
+ showWarningIndicator || showDestructiveRowStyle ? "circle-alert" : workEntryIconName(workEntry);
+ const entryToolIcon =
+ showWarningIndicator || showDestructiveRowStyle
+ ? undefined
+ : (workEntry.toolIcon ?? workEntry.toolSource?.icon);
const previewText = displayLabel ?? workEntryDisplayLabel(workEntry, workspaceRoot);
const viewedImagePath = workEntryViewedImagePath(workEntry);
const viewedImage =
@@ -3121,20 +3139,18 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: {
viewedImage ? viewedImagePath : null,
)
: null;
- const showDestructiveRowStyle =
- showFailedIndicator &&
- (workEntrySignalsSevereFailure(workEntry) || !workLogEntryIsToolLike(workEntry));
- // Ordinary tool failures stay muted; only runtime errors and warnings get
- // color. The red treatment is reserved for severe failures.
+ // Reserve destructive row styling for severe failures, not routine tool errors.
const iconWrapperClass = cn(
"flex size-6 shrink-0 items-center justify-center",
showWarningIndicator
? "text-warning"
: showDestructiveRowStyle
? "text-destructive"
- : workEntry.tone === "tool" || showFailedIndicator
- ? "text-icon-muted"
- : iconConfig.className,
+ : showFailedIndicator
+ ? failedToolIconClassName
+ : workEntry.tone === "tool"
+ ? "text-icon-muted"
+ : iconConfig.className,
);
const headingClass = showWarningIndicator
? "font-medium text-warning"
@@ -3179,11 +3195,7 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: {
aria-label={showFailedIndicator ? "Tool call failed" : undefined}
>
<ToolActivityIconView
- icon={
- showWarningIndicator || (showFailedIndicator && !hasSpecialToolIcon)
- ? undefined
- : (workEntry.toolIcon ?? workEntry.toolSource?.icon)
- }
+ icon={entryToolIcon}
fallbackName={entryIconName}
className="block size-4 shrink-0 stroke-[1.8]"
muted
@@ -3207,8 +3219,10 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: {
</span>
</p>
</div>
- {showFailedIndicator && hasSpecialToolIcon ? (
- <XIcon aria-hidden className="size-3 shrink-0 text-icon-muted" />
+ {showFailedIndicator &&
+ !showDestructiveRowStyle &&
+ !toolIconAcceptsTint(entryIconName, entryToolIcon) ? (
+ <XIcon aria-hidden className={cn("size-3 shrink-0", failedToolIconClassName)} />
) : null}
<span
className={cn(
diff --git a/apps/web/src/index.css b/apps/web/src/index.css
index 96176611064..63dc9e21c09 100644
--- a/apps/web/src/index.css
+++ b/apps/web/src/index.css
@@ -154,6 +154,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--color-warning: var(--warning);
--color-warning-surface: var(--warning-surface);
--color-error-foreground: var(--error-foreground);
+ --color-tool-error-icon: var(--tool-error-icon);
--color-error: var(--error);
--color-error-surface: var(--error-surface);
--color-update-foreground: var(--update-foreground);
@@ -948,6 +949,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--accent-foreground: var(--color-zinc-900);
--error: var(--color-red-500);
--error-foreground: var(--color-red-700);
+ --tool-error-icon: var(--error);
--error-surface: color-mix(in srgb, var(--error) 8%, transparent);
--destructive: var(--error);
--border: var(--color-zinc-200);
@@ -1002,6 +1004,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--accent-foreground: var(--color-neutral-100);
--error: color-mix(in srgb, var(--color-red-500) 90%, var(--color-white));
--error-foreground: var(--color-red-400);
+ --tool-error-icon: #fca5a5;
--error-surface: color-mix(in srgb, var(--error) 16%, transparent);
--border: --alpha(var(--color-white) / 6%);
--input: --alpha(var(--color-white) / 8%);
@@ -1114,6 +1117,7 @@ html[data-theme-id]:not([data-theme-id=""]) {
--message-action-hover: var(--app-theme-message-action-hover);
--error: var(--app-theme-error);
--error-foreground: var(--app-theme-error-foreground);
+ --tool-error-icon: var(--error-foreground);
--error-surface: var(--app-theme-error-surface);
--destructive: var(--error);
--destructive-foreground: var(--error-foreground);
diff --git a/docs/user/tool-activity.md b/docs/user/tool-activity.md
index 4394e3fc66c..55477f5107d 100644
--- a/docs/user/tool-activity.md
+++ b/docs/user/tool-activity.md
@@ -13,6 +13,10 @@ The latest live activity stays in the present tense while the turn continues, su
Expanded rows follow the call's own state, such as "Clicked" after success.
When a call has not reported a state yet, the label stays in the present tense.
Failed, declined, and stopped calls say what happened without implying success.
+Failed calls keep their tool icon with a muted red tint, so a failed command still
+looks like a command. App logos and other multicolor icons keep their artwork and
+show a small muted red failure mark beside the row. Expand the call to inspect its
+output. Runtime errors and warnings keep their stronger styling.
Preview browser actions use a globe icon. Other T3 tools keep the T3 mark.
Group summaries count browser actions separately, such as "Used browser 18 times" or
"Ran 4 commands and used browser 15 times". Browser-only groups also use a globe icon.