Skip to content
TypeScript

fix: show computer-use action titles and align app icons (#18865)

Yash Singh5d6e4192bfcf
diff --git a/apps/mobile/src/components/BrowserAppIcon.tsx b/apps/mobile/src/components/BrowserAppIcon.tsx
new file mode 100644
index 00000000000..8c09e8e77a5
--- /dev/null
+++ b/apps/mobile/src/components/BrowserAppIcon.tsx
@@ -0,0 +1,33 @@
+import type { ColorValue } from "react-native";
+import Svg, { Circle, Path } from "react-native-svg";
+import { withUniwind } from "uniwind";
+
+const ThemedSvg = withUniwind(Svg);
+
+/** Matches the window-and-pointer icon used by the web work log. */
+export function BrowserAppIcon(props: {
+ readonly size: number;
+ readonly color?: ColorValue;
+ readonly colorClassName?: string;
+}) {
+ return (
+ <ThemedSvg
+ width={props.size}
+ height={props.size}
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={1.9}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ color={props.color}
+ colorClassName={props.colorClassName}
+ accessible={false}
+ >
+ <Path d="M8.5 19H7.2C4.4 19 3 17.5 3 14.6V7.4C3 4.5 4.5 3 7.4 3h8.2C18.5 3 20 4.5 20 7.4v2.4" />
+ <Circle cx={7.4} cy={7.2} r={0.75} fill="currentColor" stroke="none" />
+ <Path d="M11.2 7.2h4.3" />
+ <Path d="m12.4 11.4 7.5 2.6-3.4 1.6-1.5 3.6z" fill="currentColor" stroke="none" />
+ </ThemedSvg>
+ );
+}
diff --git a/apps/mobile/src/features/threads/thread-work-log.tsx b/apps/mobile/src/features/threads/thread-work-log.tsx
index 1df6d6780e1..a5e00b6336e 100644
--- a/apps/mobile/src/features/threads/thread-work-log.tsx
+++ b/apps/mobile/src/features/threads/thread-work-log.tsx
@@ -53,9 +53,12 @@ import { scopeThreadRef } from "@t3tools/client-runtime/environment";
import { environmentThreadDetails, threadEnvironment } from "../../state/threads";
import { useAtomCommand } from "../../state/use-atom-command";
import { toolActivityFaviconUrl } from "@t3tools/shared/favicon";
+import { isJavaScriptReplTool } from "@t3tools/shared/toolActivity";
+import { useMarkdownCodeHighlight } from "./markdownCodeHighlightState";
import { AppText as Text } from "../../components/AppText";
import { T3Wordmark } from "../../components/T3Wordmark";
+import { BrowserAppIcon } from "../../components/BrowserAppIcon";
import { cn } from "../../lib/cn";
import { THREAD_WORK_ROW_MIN_HEIGHT, type deriveThreadWorkLogSizing } from "../../lib/layout";
import {
@@ -111,7 +114,13 @@ export const THREAD_DISCLOSURE_TRANSITION_MS = 180;
const WORK_LOG_LAYOUT_TRANSITION = LinearTransition.duration(THREAD_DISCLOSURE_TRANSITION_MS);
const WORK_LOG_DETAIL_ENTER_TRANSITION = FadeIn.duration(140);
const WORK_LOG_DETAIL_EXIT_TRANSITION = FadeOut.duration(120);
-type WorkContentIcon = AppSymbolName | "browser" | "device" | "t3-code" | "pull-request";
+type WorkContentIcon =
+ | AppSymbolName
+ | "browser"
+ | "computer"
+ | "device"
+ | "t3-code"
+ | "pull-request";
function WorkLogIcon(props: {
readonly icon: WorkContentIcon;
@@ -125,6 +134,14 @@ function WorkLogIcon(props: {
<T3Wordmark height={10} {...(colorClassName ? { colorClassName } : { color: props.color })} />
);
}
+ if (props.icon === "computer") {
+ return (
+ <BrowserAppIcon
+ size={14}
+ {...(colorClassName ? { colorClassName } : { color: props.color })}
+ />
+ );
+ }
return (
<SymbolView
name={
@@ -372,7 +389,7 @@ export function ShimmeringWorkContent(props: {
);
}
-function workRowSymbolName(icon: ThreadFeedActivity["icon"]): AppSymbolName {
+function workRowSymbolName(icon: ThreadFeedActivity["icon"]): WorkContentIcon {
switch (icon) {
case "agent":
return { ios: "sparkles", android: "auto_awesome" };
@@ -385,7 +402,9 @@ function workRowSymbolName(icon: ThreadFeedActivity["icon"]): AppSymbolName {
case "command":
return { ios: "terminal", android: "terminal" };
case "computer":
- return { ios: "desktopcomputer", android: "desktop_windows" };
+ return "computer";
+ case "code":
+ return "chevron.left.forwardslash.chevron.right";
case "edit":
return { ios: "square.and.pencil", android: "edit" };
case "eye":
@@ -832,6 +851,38 @@ function WorkspacePreparationRetryButton(props: {
);
}
+function ReplCodeText({
+ code,
+ theme,
+}: {
+ readonly code: string;
+ readonly theme: "light" | "dark";
+}) {
+ const lines = useMarkdownCodeHighlight({ code, language: "typescript", theme, enabled: true });
+ let offset = 0;
+ const highlighted = lines?.flatMap((line, lineIndex) => {
+ const separator = lineIndex > 0 ? "\n" : "";
+ offset += separator.length;
+ return [
+ separator,
+ ...line.map((token) => {
+ const start = offset;
+ offset += token.content.length;
+ return (
+ <Text key={start} style={token.color ? { color: token.color } : undefined}>
+ {token.content}
+ </Text>
+ );
+ }),
+ ];
+ });
+ return (
+ <Text selectable className="font-mono text-2xs leading-normal text-foreground">
+ {highlighted ?? code}
+ </Text>
+ );
+}
+
const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
props: Omit<
ThreadWorkLogProps,
@@ -1177,19 +1228,36 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
) : call ? (
[
call.command,
- ...(call.args ?? []).map(([key, value]) => `${key} ${value}`),
+ ...(call.args ?? []).map(([key, value]) =>
+ key === "code" &&
+ shownItem.type === "dynamic_tool" &&
+ isJavaScriptReplTool(shownItem.toolName) ? (
+ <View key={key}>
+ <Text className="font-mono text-2xs leading-normal text-foreground-muted">
+ {key}
+ </Text>
+ <ReplCodeText code={value} theme={props.themeAppearance} />
+ </View>
+ ) : (
+ `${key} ${value}`
+ ),
+ ),
call.argsText,
]
- .filter((line): line is string => Boolean(line))
- .map((line, index) => (
- <Text
- key={`${index}:${line}`}
- selectable
- className="font-mono text-2xs leading-normal text-foreground"
- >
- {line}
- </Text>
- ))
+ .filter((line) => Boolean(line))
+ .map((line, index) =>
+ typeof line === "string" ? (
+ <Text
+ key={`${index}:${line}`}
+ selectable
+ className="font-mono text-2xs leading-normal text-foreground"
+ >
+ {line}
+ </Text>
+ ) : (
+ line
+ ),
+ )
) : fullDetail ? (
<Text selectable className="font-mono text-2xs leading-normal text-foreground-muted">
{fullDetail}
diff --git a/apps/mobile/src/lib/threadActivity.test.ts b/apps/mobile/src/lib/threadActivity.test.ts
index fca9430b3df..95cf9fdd6ed 100644
--- a/apps/mobile/src/lib/threadActivity.test.ts
+++ b/apps/mobile/src/lib/threadActivity.test.ts
@@ -1450,16 +1450,54 @@ describe("buildThreadFeed", () => {
expect(activity?.getCopyText().split("\n")[0]).toBe("Read a T3 thread");
});
- it("uses the CUA action title in the mobile feed", () => {
+ it.each(["cua_repl.js", "node_repl.js", "js"])(
+ "uses the %s action title in the mobile feed",
+ (toolName) => {
+ const item: OrchestrationV2TurnItem = {
+ ...base("cua", "2026-09-23T20:20:00.000Z", 1),
+ type: "dynamic_tool",
+ toolName,
+ input: {
+ code: "await game.getAXStateAndScreenshot();",
+ title: "Inspect Saga music screen",
+ },
+ };
+ const feed = buildThreadFeed([projected(item, 0)]);
+ const activity = feed[0]?.type === "activity-group" ? feed[0].activities[0] : null;
+ expect(activity?.summary).toBe("Inspect Saga music screen");
+ },
+ );
+
+ it.each([
+ [
+ "failed",
+ "await sky.type_text({app:'T3 Code (Nightly)',text:'debug(ga.run)'});",
+ "Restrict the breakpoint to Git actions",
+ "computer",
+ ],
+ [
+ "completed",
+ "await fetch('http://127.0.0.1/json/list');",
+ "Discover the live Electron debugging endpoint",
+ "code",
+ ],
+ ] as const)("recovers the retained js title and %s call icon", (status, code, title, icon) => {
const item: OrchestrationV2TurnItem = {
- ...base("cua", "2026-09-23T20:20:00.000Z", 1),
+ ...base("retained-js", "2026-09-23T20:20:00.000Z", 1),
type: "dynamic_tool",
- toolName: "cua_repl.js",
- input: { code: "await game.getAXStateAndScreenshot();", title: "Inspect Saga music screen" },
+ status,
+ title: "js",
+ toolName: "node_repl.js",
+ toolSource: { key: "mcp:node_repl", name: "node repl", kind: "integration" },
+ input: { code, title },
};
const feed = buildThreadFeed([projected(item, 0)]);
const activity = feed[0]?.type === "activity-group" ? feed[0].activities[0] : null;
- expect(activity?.summary).toBe("Inspect Saga music screen");
+ expect(activity?.summary).toBe(title);
+ expect(activity?.icon).toBe(icon);
+ expect(activity?.workEntry.toolSource?.kind).toBe(
+ icon === "computer" ? "computer" : "integration",
+ );
});
it("uses canonical T3 orchestration summaries in compact work groups", () => {
diff --git a/apps/mobile/src/lib/threadActivity.ts b/apps/mobile/src/lib/threadActivity.ts
index edaaf2b0fab..25d102d16d0 100644
--- a/apps/mobile/src/lib/threadActivity.ts
+++ b/apps/mobile/src/lib/threadActivity.ts
@@ -57,6 +57,7 @@ import {
classifyToolActivity,
collectToolFilePaths,
dynamicToolTitle,
+ isJavaScriptReplTool,
formatReadToolLabel,
formatSearchToolLabel,
} from "@t3tools/shared/toolActivity";
@@ -97,6 +98,7 @@ export interface ThreadFeedActivity {
| "alert"
| "browser"
| "computer"
+ | "code"
| "check"
| "command"
| "edit"
@@ -556,7 +558,7 @@ function itemIcon(item: OrchestrationV2TurnItem): ThreadFeedActivity["icon"] {
case "assistant_message":
return "message";
case "dynamic_tool":
- return "wrench";
+ return isJavaScriptReplTool(item.toolName) ? "code" : "wrench";
case "subagent":
return "hammer";
case "run_interrupt_request":
@@ -598,8 +600,9 @@ function itemSummary(
if (item.type === "system_notice") return item.message;
if (item.type === "compaction") return contextCompactionLabel(item);
const title =
- (item.type === "dynamic_tool" ? dynamicToolTitle(item.toolName, item.input) : undefined) ??
- item.title?.trim();
+ (item.type === "dynamic_tool"
+ ? dynamicToolTitle(item.toolName, item.input, item.title)
+ : undefined) ?? item.title?.trim();
if (item.type === "subagent") return formatSubagentDisplayTitle(title || "Subagent");
if (title) return toolPresentation?.displayName ?? capitalizePhrase(title);
switch (item.type) {
diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
index 9a1c8f6c900..14bb6a03d81 100644
--- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
@@ -827,36 +827,82 @@ describe("CodexAdapterV2 process spawning", () => {
});
describe("CodexAdapterV2 dynamic tool projection", () => {
- it.effect("uses the CUA call title while leaving other MCP titles as tool arguments", () =>
+ it.effect("keeps a failed Sky MCP call in Computer Use when its error has no metadata", () =>
Effect.gen(function* () {
- const call = {
- type: "mcpToolCall" as const,
- id: "inspect",
- server: "cua_repl",
+ const projection = yield* CodexAdapterV2.projectCodexDynamicToolItem({
+ type: "mcpToolCall",
+ id: "failed-sky-js",
+ server: "node_repl",
tool: "js",
- status: "completed" as const,
+ status: "failed",
arguments: {
- code: "await game.getAXStateAndScreenshot();",
- title: "Inspect Saga music screen",
+ title: "Restrict the breakpoint to Git actions",
+ code: "await sky.type_text({app:'T3 Code (Nightly)',text:'debug(ga.run)'});",
},
- result: { content: [] },
- };
- assert.equal(
- (yield* CodexAdapterV2.projectCodexDynamicToolItem(call)).title,
- "Inspect Saga music screen",
- );
- assert.equal(
- (yield* CodexAdapterV2.projectCodexDynamicToolItem({ ...call, arguments: { title: " " } }))
- .title,
- "js",
- );
- assert.equal(
- (yield* CodexAdapterV2.projectCodexDynamicToolItem({ ...call, server: "github" })).title,
- "js",
- );
+ result: { content: [{ type: "text", text: "Illegal Unicode escape sequence" }] },
+ });
+ assert.equal(projection.title, "Restrict the breakpoint to Git actions");
+ assert.equal(projection.toolSurface, "computer");
+ assert.deepEqual(projection.toolSource, {
+ key: "computer-use",
+ name: "Computer Use",
+ kind: "computer",
+ });
}).pipe(Effect.provide(NodeServices.layer)),
);
+ it.effect.each(["inProgress", "completed", "failed"] as const)(
+ "preserves a bare js action's title and computer surface when %s without result metadata",
+ (status) =>
+ Effect.gen(function* () {
+ const projection = yield* CodexAdapterV2.projectCodexDynamicToolItem({
+ type: "dynamicToolCall",
+ id: "bare-js",
+ tool: "js",
+ status,
+ arguments: { code: "await sky.get_app_state(app);", title: "Read the desktop window" },
+ contentItems: [],
+ success: status !== "failed",
+ });
+ assert.equal(projection.title, "Read the desktop window");
+ assert.equal(projection.toolSurface, "computer");
+ }).pipe(Effect.provide(NodeServices.layer)),
+ );
+
+ it.effect.each(["cua_repl", "node_repl"])(
+ "uses the %s call title while leaving other MCP titles as tool arguments",
+ (server) =>
+ Effect.gen(function* () {
+ const call = {
+ type: "mcpToolCall" as const,
+ id: "inspect",
+ server,
+ tool: "js",
+ status: "completed" as const,
+ arguments: {
+ code: "await game.getAXStateAndScreenshot();",
+ title: "Inspect Saga music screen",
+ },
+ result: { content: [] },
+ };
+ assert.equal(
+ (yield* CodexAdapterV2.projectCodexDynamicToolItem(call)).title,
+ "Inspect Saga music screen",
+ );
+ assert.equal(
+ (yield* CodexAdapterV2.projectCodexDynamicToolItem({
+ ...call,
+ arguments: { title: " " },
+ })).title,
+ server === "cua_repl" ? "Computer use" : "Run JavaScript",
+ );
+ assert.equal(
+ (yield* CodexAdapterV2.projectCodexDynamicToolItem({ ...call, server: "github" })).title,
+ "js",
+ );
+ }).pipe(Effect.provide(NodeServices.layer)),
+ );
+
it.effect.each(["inProgress", "completed", "failed"] as const)(
"presents ordinary MCP calls when %s",
(status) =>
diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
index d8ef1461ef7..5a51136396a 100644
--- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
@@ -35,7 +35,11 @@ import {
import { SKILL_MENTION_PATTERN } from "@t3tools/shared/composerInlineTokens";
import { AgentScope } from "@t3tools/shared/AgentScope";
import * as HostProcess from "@t3tools/shared/HostProcess";
-import { dynamicToolTitle } from "@t3tools/shared/toolActivity";
+import {
+ COMPUTER_USE_TOOL_SOURCE,
+ dynamicToolSurface,
+ dynamicToolTitle,
+} from "@t3tools/shared/toolActivity";
import { getModelSelectionStringOptionValue, modelSelectionsEqual } from "@t3tools/shared/model";
import { resolveSpawnCommand } from "@t3tools/shared/shell";
import type {
@@ -497,9 +501,17 @@ export const projectCodexDynamicToolItem = Effect.fn("CodexAdapterV2.projectDyna
: [trimText(item.namespace), item.tool].filter(Boolean).join(".");
const presentation: McpToolPresentation =
item.type === "mcpToolCall" ? yield* mcpToolPresentation(item) : {};
- const title = dynamicToolTitle(toolName, item.arguments) ?? presentation.title;
+ const title =
+ dynamicToolTitle(toolName, item.arguments, presentation.title) ?? presentation.title;
+ const toolSurface = presentation.toolSurface ?? dynamicToolSurface(toolName, item.arguments);
+ const toolSource =
+ toolSurface === "computer" && presentation.toolSource?.kind !== "computer"
+ ? COMPUTER_USE_TOOL_SOURCE
+ : presentation.toolSource;
const projection: CodexDynamicToolProjection = {
...presentation,
+ ...(toolSurface ? { toolSurface } : {}),
+ ...(toolSource ? { toolSource } : {}),
toolName,
...(title ? { title } : {}),
input: item.arguments,
diff --git a/apps/web/src/components/Icons.tsx b/apps/web/src/components/Icons.tsx
index 909b9c7456f..4e64cd251ea 100644
--- a/apps/web/src/components/Icons.tsx
+++ b/apps/web/src/components/Icons.tsx
@@ -760,28 +760,3 @@ export const MacAccessibilityIcon: Icon = (props) => {
</svg>
);
};
-
-// Codex's Computer Use app mark, shown on computer-use rows in the work log.
-export const ComputerUseAppIcon: Icon = (props) => {
- const gradientId = `${useId().replaceAll(":", "")}-computer-use-app-gradient`;
- return (
- <svg viewBox="0 0 24 24" aria-hidden="true" {...props}>
- <defs>
- <linearGradient id={gradientId} x1="2" y1="2" x2="22" y2="22">
- <stop offset="0" stopColor="#00dff0" />
- <stop offset="0.42" stopColor="#3b9cff" />
- <stop offset="0.72" stopColor="#b044f5" />
- <stop offset="1" stopColor="#ff78b6" />
- </linearGradient>
- </defs>
- <rect x="1" y="1" width="22" height="22" rx="5" fill={`url(#${gradientId})`} />
- <path
- d="m7.2 6.2 10.5 4.1-4.2 2.1-2 4.7z"
- fill="white"
- stroke="#315cff"
- strokeWidth="1.1"
- strokeLinejoin="round"
- />
- </svg>
- );
-};
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
index 45613d72aac..68930da0252 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
@@ -746,34 +746,70 @@ describe("deriveMessagesTimelineRows", () => {
expect(first.kind === "work" && first.entry.toolLifecycleStatus).toBe("inProgress");
});
- it("shows the CUA action title for a retained tool item", () => {
+ it.each(["cua_repl.js", "node_repl.js", "js"])(
+ "shows the %s action title for a retained tool item",
+ (toolName) => {
+ const fixture = makeStreamingTimelineFixture();
+ const source = fixture.visibleTurnItems.find((row) => row.item.type === "dynamic_tool")!;
+ if (source.item.type !== "dynamic_tool") throw new Error("Expected tool fixture");
+ const item = {
+ ...source.item,
+ title: null,
+ toolName,
+ input: {
+ code: "await game.getAXStateAndScreenshot();",
+ title: "Inspect Saga music screen",
+ },
+ };
+ const entries = deriveTimelineEntriesFromVisibleTurnItems({
+ visibleTurnItems: [{ ...source, item }],
+ optimisticMessages: [],
+ });
+ const work = entries.find((entry) => entry.kind === "work");
+ expect(work?.kind === "work" && workEntryDisplayLabel(work.entry, undefined)).toBe(
+ "Inspect Saga music screen",
+ );
+ const rows = deriveMessagesTimelineRows({
+ timelineEntries: entries,
+ isWorking: false,
+ runningRunId: fixture.runId,
+ activeTurnStartedAt: fixture.time(0),
+ turnDiffSummaries: [],
+ supportsConversationRollback: false,
+ });
+ expect(rows.find((row) => row.kind === "work")).toMatchObject({
+ displayLabel: "Inspect Saga music screen",
+ });
+ },
+ );
+
+ it("recovers the failed Sky call stored as a generic js integration", () => {
const fixture = makeStreamingTimelineFixture();
const source = fixture.visibleTurnItems.find((row) => row.item.type === "dynamic_tool")!;
if (source.item.type !== "dynamic_tool") throw new Error("Expected tool fixture");
const item = {
...source.item,
- title: null,
- toolName: "cua_repl.js",
- input: { code: "await game.getAXStateAndScreenshot();", title: "Inspect Saga music screen" },
+ type: "dynamic_tool" as const,
+ status: "failed" as const,
+ title: "js",
+ toolName: "node_repl.js",
+ toolSource: { key: "mcp:node_repl", name: "node repl", kind: "integration" as const },
+ input: {
+ title: "Restrict the breakpoint to Git actions",
+ code: "await sky.type_text({app:'T3 Code (Nightly)',text:'debug(ga.run)'});",
+ },
};
const entries = deriveTimelineEntriesFromVisibleTurnItems({
visibleTurnItems: [{ ...source, item }],
optimisticMessages: [],
});
- const work = entries.find((entry) => entry.kind === "work");
- expect(work?.kind === "work" && workEntryDisplayLabel(work.entry, undefined)).toBe(
- "Inspect Saga music screen",
+ const entry = entries.find((row) => row.kind === "work");
+ expect(entry?.kind === "work" && workEntryDisplayLabel(entry.entry, undefined)).toBe(
+ "Restrict the breakpoint to Git actions",
);
- const rows = deriveMessagesTimelineRows({
- timelineEntries: entries,
- isWorking: false,
- runningRunId: fixture.runId,
- activeTurnStartedAt: fixture.time(0),
- turnDiffSummaries: [],
- supportsConversationRollback: false,
- });
- expect(rows.find((row) => row.kind === "work")).toMatchObject({
- displayLabel: "Inspect Saga music screen",
+ expect(entry?.kind === "work" && entry.entry).toMatchObject({
+ toolSurface: "computer",
+ toolSource: { key: "computer-use", kind: "computer" },
});
});
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts
index 684b0e641f8..6eeda65512c 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts
@@ -97,7 +97,8 @@ function singleToolCallLabel(entry: WorkLogEntry): string {
const toolPresentation = resolveWorkEntryToolPresentation(entry, "completed");
if (toolPresentation) return toolPresentation.displayName;
const item = entry.structuredPayload;
- const title = item?.type === "dynamic_tool" ? dynamicToolTitle(item.toolName, item.input) : null;
+ const title =
+ item?.type === "dynamic_tool" ? dynamicToolTitle(item.toolName, item.input, item.title) : null;
if (title) return title;
// A lone web search keeps its heading; the query stays in its detail.
if (entry.itemType === "web_search") return entry.toolTitle ?? "Web search";
@@ -157,7 +158,8 @@ export function workEntryDisplayLabel(entry: WorkLogEntry, workspaceRoot: string
const providerRetry =
entry.projectedItem?.item.type === "error" && entry.projectedItem.item.retry !== undefined;
const item = entry.structuredPayload;
- const title = item?.type === "dynamic_tool" ? dynamicToolTitle(item.toolName, item.input) : null;
+ const title =
+ item?.type === "dynamic_tool" ? dynamicToolTitle(item.toolName, item.input, item.title) : null;
if (title) return title;
const compactDetail = entry.detail?.trim();
const detailIsSearchOutput =
diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx
index bac737b66ba..d0b259d8f02 100644
--- a/apps/web/src/components/chat/MessagesTimeline.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.tsx
@@ -1,7 +1,6 @@
import { ThreadFindTimelineContext } from "./ThreadFindProvider";
import { shouldPreserveAssistantLineBreaks } from "@t3tools/shared/markdownPipeline";
import { MarkdownFindContext, useFindRevealRef } from "./markdownFindContext";
-import { ComputerUseAppIcon } from "~/components/Icons";
import { useChatCanvas } from "./ChatCanvasContext";
import { WorkLogBlock, WorkLogButton, WorkLogDetails, WorkLogList, WorkLogRow } from "./WorkLog";
import { PullRequestGlyph } from "../pullRequest/pullRequestIcons";
@@ -67,7 +66,7 @@ import { resolveChatListAnchoredEndSpace } from "@t3tools/shared/chatList";
import { toolActivityFaviconUrl } from "@t3tools/shared/favicon";
import { formatDuration } from "@t3tools/shared/orchestrationTiming";
import { getProjectFaviconCacheKey } from "@t3tools/shared/projectFavicon";
-import { claudeSkillInvocation } from "@t3tools/shared/toolActivity";
+import { claudeSkillInvocation, isJavaScriptReplTool } from "@t3tools/shared/toolActivity";
import { observeVisibleAnimation } from "../../lib/visibleAnimation";
import {
createContext,
@@ -148,6 +147,7 @@ import {
Undo2Icon,
HammerIcon,
WrenchIcon,
+ Code2Icon,
XIcon,
ZapIcon,
RotateCcwIcon,
@@ -3779,13 +3779,9 @@ 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";
+/** Image icons cannot take a currentColor tint, so failed rows get a trailing x. */
+function toolIconAcceptsTint(toolIcon: ToolActivityIcon | undefined): boolean {
+ return toolIcon === undefined;
}
function WorkingTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "working" }> }) {
@@ -3951,7 +3947,7 @@ function LiveActivityContent({
highlighted?: boolean;
}) {
const showTrailingFailureMark =
- failed && iconName !== undefined && !toolIconAcceptsTint(iconName, toolIcon);
+ failed && iconName !== undefined && !toolIconAcceptsTint(toolIcon);
return (
<WorkLogRow
@@ -5030,6 +5026,7 @@ type WorkEntryIconName =
| "check"
| "circle-alert"
| "computer"
+ | "code"
| "device"
| "eye"
| "globe"
@@ -5226,9 +5223,10 @@ function WorkEntryIcon({ name, className }: { name: WorkEntryIconName; className
case "brain":
return <BrainIcon className={className} aria-hidden />;
case "browser":
- return <BrowserAppIcon className={className} />;
case "computer":
- return <ComputerUseAppIcon className={className} />;
+ return <BrowserAppIcon className={className} />;
+ case "code":
+ return <Code2Icon className={className} aria-hidden />;
case "device":
return <SmartphoneIcon className={className} aria-hidden />;
case "t3-code":
@@ -5382,6 +5380,11 @@ function workEntryIconName(workEntry: TimelineWorkEntry): WorkEntryIconName {
return "message-circle";
}
if (workEntry.toolSurface) return workEntry.toolSurface;
+ if (
+ workEntry.structuredPayload?.type === "dynamic_tool" &&
+ isJavaScriptReplTool(workEntry.structuredPayload.toolName)
+ )
+ return "code";
const toolPresentation = resolveWorkEntryToolPresentation(workEntry);
if (toolPresentation) return toolPresentation.icon;
const action = toolGroupAction(workEntry);
@@ -5794,7 +5797,7 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
) : null}
{showFailedIndicator &&
!showDestructiveRowStyle &&
- !toolIconAcceptsTint(entryIconName, entryToolIcon) ? (
+ !toolIconAcceptsTint(entryToolIcon) ? (
<XIcon aria-hidden className={cn("size-3 shrink-0", failedToolIconClassName)} />
) : null}
<TimelineRowTimestamp createdAt={workEntry.createdAt} timestampFormat={timestampFormat} />
diff --git a/apps/web/src/components/chat/V2ItemInspector.tsx b/apps/web/src/components/chat/V2ItemInspector.tsx
index 93befc5c75a..2bc30383254 100644
--- a/apps/web/src/components/chat/V2ItemInspector.tsx
+++ b/apps/web/src/components/chat/V2ItemInspector.tsx
@@ -12,6 +12,7 @@ import {
turnItemOutputText,
} from "@t3tools/client-runtime/work-log/item-detail";
import { formatDiffCount } from "@t3tools/client-runtime/diff-count";
+import { isJavaScriptReplTool } from "@t3tools/shared/toolActivity";
import { ExternalLinkIcon, GitBranchIcon, RotateCcwIcon } from "lucide-react";
import { memo, Suspense, use, useMemo } from "react";
@@ -43,13 +44,22 @@ interface V2ItemInspectorProps {
readonly onImageExpand?: ((preview: ExpandedImagePreview) => void) | undefined;
}
-function JsonTokens({ text }: { readonly text: string }) {
+function SyntaxTokens({
+ text,
+ language,
+}: {
+ readonly text: string;
+ readonly language: "json" | "typescript";
+}) {
const { resolvedTheme } = useTheme();
- const highlighter = use(getSyntaxHighlighterPromise("json"));
+ const highlighter = use(getSyntaxHighlighterPromise(language));
const { tokens } = useMemo(
() =>
- highlighter.codeToTokens(text, { lang: "json", theme: resolveDiffThemeName(resolvedTheme) }),
- [highlighter, text, resolvedTheme],
+ highlighter.codeToTokens(text, {
+ lang: language,
+ theme: resolveDiffThemeName(resolvedTheme),
+ }),
+ [highlighter, text, language, resolvedTheme],
);
return tokens.flatMap((line, lineIndex) => [
lineIndex > 0 ? "\n" : "",
@@ -67,9 +77,11 @@ const monoClassName =
function StructuredValue({
value,
highlightJson = false,
+ language,
}: {
readonly value: unknown;
readonly highlightJson?: boolean;
+ readonly language?: "typescript";
}) {
const text = typeof value === "string" ? value : JSON.stringify(value, null, 2);
const isJson = useMemo(() => {
@@ -84,10 +96,10 @@ function StructuredValue({
if (!text) return null;
return (
<pre className={cn("max-h-80 overflow-auto text-muted-foreground", monoClassName)}>
- {isJson ? (
+ {language || isJson ? (
<RenderErrorBoundary fallback={text}>
<Suspense fallback={text}>
- <JsonTokens text={text} />
+ <SyntaxTokens text={text} language={language ?? "json"} />
</Suspense>
</RenderErrorBoundary>
) : (
@@ -194,6 +206,7 @@ function ToolCallBody(
props: ToolOutputState & {
readonly command?: string;
readonly args?: unknown;
+ readonly toolName?: string | null;
readonly exitCode?: number | undefined;
},
) {
@@ -206,7 +219,11 @@ function ToolCallBody(
{call.args.map(([key, value]) => (
<div key={key}>
<span className="text-muted-foreground">{key} </span>
- {value}
+ {key === "code" && isJavaScriptReplTool(props.toolName) ? (
+ <StructuredValue value={value} language="typescript" />
+ ) : (
+ value
+ )}
</div>
))}
</div>
@@ -349,7 +366,12 @@ export const V2ItemInspector = memo(function V2ItemInspector(props: V2ItemInspec
) : null}
{item.type === "dynamic_tool" ? (
- <ToolCallBody args={item.input} {...outputState} onImageExpand={props.onImageExpand} />
+ <ToolCallBody
+ toolName={item.toolName}
+ args={item.input}
+ {...outputState}
+ onImageExpand={props.onImageExpand}
+ />
) : null}
{item.type === "approval_request" ? <StructuredValue value={item.prompt} /> : null}
diff --git a/apps/web/src/components/chat/WorkLog.tsx b/apps/web/src/components/chat/WorkLog.tsx
index 1c588937813..378387c4261 100644
--- a/apps/web/src/components/chat/WorkLog.tsx
+++ b/apps/web/src/components/chat/WorkLog.tsx
@@ -49,20 +49,27 @@ function WorkLogLine({ icon, label, trailing, wrapLabel }: RowContent) {
<div
className={cn(
"flex min-h-6 min-w-0 gap-1.5 text-sm leading-relaxed select-none [&_*]:select-none",
- // A wrapped label keeps its icon beside the first line.
wrapLabel ? "items-start" : "items-center",
)}
>
- {icon ? (
- <span className="relative flex size-6 shrink-0 items-center justify-center">{icon}</span>
- ) : null}
- <div
- className={cn(
- "min-w-0 flex-1 text-secondary-label",
- !wrapLabel && "truncate [&_*]:whitespace-nowrap",
- )}
- >
- {label}
+ <div className="flex min-w-0 flex-1 items-baseline gap-1.5">
+ {icon ? (
+ // Align with the first line's capital letters. Centering line boxes drifts
+ // when font ascent/descent rounding changes at fractional browser zoom.
+ <span className="relative w-6 shrink-0 leading-0">
+ <span className="inline-block size-6 overflow-hidden align-[calc(0.5cap_-_0.75rem)]">
+ <span className="flex size-full items-center justify-center">{icon}</span>
+ </span>
+ </span>
+ ) : null}
+ <div
+ className={cn(
+ "min-w-0 flex-1 text-secondary-label",
+ !wrapLabel && "truncate [&_*]:whitespace-nowrap",
+ )}
+ >
+ {label}
+ </div>
</div>
{trailing}
</div>
diff --git a/packages/client-runtime/src/work-log/presentation.test.ts b/packages/client-runtime/src/work-log/presentation.test.ts
index 241215310aa..4b0078fdb73 100644
--- a/packages/client-runtime/src/work-log/presentation.test.ts
+++ b/packages/client-runtime/src/work-log/presentation.test.ts
@@ -253,6 +253,28 @@ describe("summarizeToolGroup", () => {
).toBe("Used Chrome integration and ran 1 command");
});
+ it.each([
+ [["Foo", "Foo"], "Used Foo integration and ran 1 command"],
+ [["Foo", "Bar", "Foo"], "Used Foo and Bar integrations and ran 1 command"],
+ ] as const)(
+ "uses the displayed source names for integration plurality: %j",
+ (names, expected) => {
+ expect(
+ summarizeToolGroup([
+ ...names.map((name, index) =>
+ entry(`integration-${index}`, {
+ toolSource: { key: `integration-${index}`, name, kind: "integration" },
+ }),
+ ),
+ entry("command", {
+ itemType: "command_execution",
+ command: "git status",
+ }),
+ ]).summary,
+ ).toBe(expected);
+ },
+ );
+
it("omits the integration suffix for special browser and computer sources", () => {
expect(
summarizeToolGroup([
@@ -267,6 +289,25 @@ describe("summarizeToolGroup", () => {
]).summary,
).toBe("Used Browser and Computer Use");
});
+
+ it("names Computer Use once when native-app and fallback sources share its label", () => {
+ expect(
+ summarizeToolGroup([
+ entry("inspect-app", {
+ label: "Inspect app",
+ toolSource: {
+ key: "native-app:com.t3tools.t3code",
+ name: "Computer Use",
+ kind: "computer",
+ },
+ }),
+ entry("failed-sky", {
+ label: "Restrict the breakpoint to Git actions",
+ toolSource: { key: "computer-use", name: "Computer Use", kind: "computer" },
+ }),
+ ]).summary,
+ ).toBe("Used Computer Use");
+ });
});
describe("resolveWorkEntryToolPresentation", () => {
diff --git a/packages/client-runtime/src/work-log/presentation.ts b/packages/client-runtime/src/work-log/presentation.ts
index 90c33b789a6..cb5ac00b0e9 100644
--- a/packages/client-runtime/src/work-log/presentation.ts
+++ b/packages/client-runtime/src/work-log/presentation.ts
@@ -697,7 +697,7 @@ export function summarizeToolGroup(entries: ReadonlyArray<WorkLogPresentationEnt
const labels = selected.map(({ label }) => label);
if (sources.size > 0) {
const sourceValues = [...sources.values()];
- const sourceNames = sourceValues.map((source) => source.name);
+ const sourceNames = [...new Set(sourceValues.map((source) => source.name))];
const formattedNames =
sourceNames.length < 2
? sourceNames[0]!
@@ -706,7 +706,7 @@ export function summarizeToolGroup(entries: ReadonlyArray<WorkLogPresentationEnt
: `${sourceNames.slice(0, -1).join(", ")}, and ${sourceNames.at(-1)}`;
const allIntegrations = sourceValues.every((source) => source.kind === "integration");
labels.unshift(
- `Used ${formattedNames}${allIntegrations ? ` ${sources.size === 1 ? "integration" : "integrations"}` : ""}`,
+ `Used ${formattedNames}${allIntegrations ? ` ${sourceNames.length === 1 ? "integration" : "integrations"}` : ""}`,
);
}
const sourcedCount = entries.filter(
diff --git a/packages/client-runtime/src/work-log/toolPresentation.test.ts b/packages/client-runtime/src/work-log/toolPresentation.test.ts
index a794678a372..37733eca4c8 100644
--- a/packages/client-runtime/src/work-log/toolPresentation.test.ts
+++ b/packages/client-runtime/src/work-log/toolPresentation.test.ts
@@ -3,6 +3,49 @@ import { describe, expect, it } from "@effect/vitest";
import { extractToolActivityPresentation } from "./toolPresentation.ts";
describe("extractToolActivityPresentation", () => {
+ it("recovers computer-use presentation for retained calls without result metadata", () => {
+ const item = {
+ type: "dynamic_tool",
+ toolName: "js",
+ input: { code: "await sky.get_app_state(app);" },
+ };
+ expect(extractToolActivityPresentation(item)).toEqual({
+ toolSurface: "computer",
+ toolSource: { key: "computer-use", name: "Computer Use", kind: "computer" },
+ });
+ expect(extractToolActivityPresentation({ ...item, toolSurface: "browser" })).toEqual({
+ toolSurface: "browser",
+ });
+ expect(
+ extractToolActivityPresentation({ ...item, input: { code: "await fs.readFile(path);" } }),
+ ).toEqual({});
+ });
+
+ it("replaces a failed Sky call's generic node REPL source", () => {
+ const source = { key: "mcp:node_repl", name: "node repl", kind: "integration" };
+ const item = {
+ type: "dynamic_tool",
+ toolName: "node_repl.js",
+ title: "js",
+ status: "failed",
+ toolSource: source,
+ input: {
+ title: "Restrict the breakpoint to Git actions",
+ code: "await sky.type_text({app:'T3 Code (Nightly)',text:'debug(ga.run)'});",
+ },
+ };
+ expect(extractToolActivityPresentation(item)).toEqual({
+ toolSurface: "computer",
+ toolSource: { key: "computer-use", name: "Computer Use", kind: "computer" },
+ });
+ expect(
+ extractToolActivityPresentation({
+ ...item,
+ input: { code: "await fetch('http://127.0.0.1/json/list');" },
+ }),
+ ).toEqual({ toolSource: source });
+ });
+
it("retains valid image paths independently of redacted output", () => {
expect(
extractToolActivityPresentation({ viewedImagePath: " /workspace/reference.webp " }),
diff --git a/packages/client-runtime/src/work-log/toolPresentation.ts b/packages/client-runtime/src/work-log/toolPresentation.ts
index 95ad72cfcca..f69ddbd3c65 100644
--- a/packages/client-runtime/src/work-log/toolPresentation.ts
+++ b/packages/client-runtime/src/work-log/toolPresentation.ts
@@ -1,4 +1,5 @@
import { isWorkspaceImagePreviewPath } from "@t3tools/shared/filePreview";
+import { COMPUTER_USE_TOOL_SOURCE, dynamicToolSurface } from "@t3tools/shared/toolActivity";
import type {
ToolActivityIcon,
ToolActivityNativeAppReference,
@@ -111,12 +112,23 @@ export function extractToolActivityPresentation(
payloadValue: unknown,
): ExtractedToolActivityPresentation {
const payload = asRecord(payloadValue);
+ const retainedSource = activitySource(payload?.toolSource);
const toolSurface =
payload?.toolSurface === "browser" || payload?.toolSurface === "computer"
? payload.toolSurface
- : undefined;
+ : retainedSource?.kind === "computer" || retainedSource?.kind === "browser"
+ ? retainedSource.kind
+ : payload?.type === "dynamic_tool"
+ ? dynamicToolSurface(
+ typeof payload.toolName === "string" ? payload.toolName : undefined,
+ payload.input,
+ )
+ : undefined;
+ const toolSource =
+ toolSurface === "computer" && retainedSource?.kind !== "computer"
+ ? COMPUTER_USE_TOOL_SOURCE
+ : retainedSource;
const toolIcon = activityIcon(payload?.toolIcon);
- const toolSource = activitySource(payload?.toolSource);
const viewedImagePath = trimmedString(payload?.viewedImagePath, 4096);
return {
...(toolSurface ? { toolSurface } : {}),
diff --git a/packages/shared/src/toolActivity.test.ts b/packages/shared/src/toolActivity.test.ts
index fe19052fa5b..e18eeda8ca8 100644
--- a/packages/shared/src/toolActivity.test.ts
+++ b/packages/shared/src/toolActivity.test.ts
@@ -6,6 +6,7 @@ import {
collectToolFilePaths,
deriveToolActivityPresentation,
dynamicToolTitle,
+ dynamicToolSurface,
formatReadToolLabel,
formatSearchToolLabel,
mergeToolActivityData,
@@ -123,6 +124,44 @@ describe("toolActivity", () => {
).toEqual({ rawInput: { path: "src/a.ts", startLine: 4 } });
});
+ it.each(["cua_repl.js", "node_repl.js", "js"])("uses the action title for %s", (toolName) => {
+ expect(dynamicToolTitle(toolName, { title: " Read the current T3 desktop window " })).toBe(
+ "Read the current T3 desktop window",
+ );
+ const fallback = toolName === "cua_repl.js" ? "Computer use" : "Run JavaScript";
+ expect(dynamicToolTitle(toolName, { title: " " })).toBe(fallback);
+ expect(dynamicToolTitle(toolName, { title: 123 })).toBe(fallback);
+ expect(dynamicToolTitle(toolName, {})).toBe(fallback);
+ expect(dynamicToolTitle(toolName, { code: "await sky.get_app_state(app);" })).toBe(
+ "Computer use",
+ );
+ });
+
+ it("keeps a retained action title but replaces raw REPL names", () => {
+ expect(dynamicToolTitle("js", {}, "Read the window")).toBe("Read the window");
+ expect(dynamicToolTitle("js", { title: "Inspect the window" }, "Read the window")).toBe(
+ "Inspect the window",
+ );
+ expect(dynamicToolTitle("js", { code: "await sky.click(app);" }, "Js")).toBe("Computer use");
+ expect(dynamicToolTitle("node_repl.js", {}, "Node_repl.js")).toBe("Run JavaScript");
+ });
+
+ it("recognizes computer-use REPL calls before result metadata exists", () => {
+ expect(dynamicToolSurface("cua_repl.js", {})).toBe("computer");
+ for (const name of ["node_repl.js", "js"]) {
+ expect(dynamicToolSurface(name, { code: "await sky.get_app_state(app);" })).toBe("computer");
+ expect(dynamicToolSurface(name, { code: "const sky = await import('@oai/sky');" })).toBe(
+ "computer",
+ );
+ expect(dynamicToolSurface(name, { code: "await fs.readFile(path);" })).toBeUndefined();
+ }
+ expect(dynamicToolSurface("github.js", { code: "await sky.click(app);" })).toBeUndefined();
+ });
+
+ it("leaves ordinary tool titles in their arguments", () => {
+ expect(dynamicToolTitle("github.create_issue", { title: "Issue title" })).toBeUndefined();
+ });
+
it("titles Claude skill calls with the skill they load", () => {
expect(dynamicToolTitle("Skill", { skill: "full-send" })).toBe("Skill: full-send");
expect(claudeSkillInvocation("Skill", { skill: "claude-api", args: " pricing " })).toEqual({
diff --git a/packages/shared/src/toolActivity.ts b/packages/shared/src/toolActivity.ts
index d281462cb08..d93c5fd3e1b 100644
--- a/packages/shared/src/toolActivity.ts
+++ b/packages/shared/src/toolActivity.ts
@@ -25,15 +25,48 @@ export function claudeSkillInvocation(
return name === undefined ? undefined : { name, args: asTrimmedString(record?.args) };
}
+export function isJavaScriptReplTool(toolName: string | null | undefined): boolean {
+ return toolName === "js" || toolName === "cua_repl.js" || toolName === "node_repl.js";
+}
+
+export const COMPUTER_USE_TOOL_SOURCE = {
+ key: "computer-use",
+ name: "Computer Use",
+ kind: "computer",
+} as const;
+
+/** Computer-use calls may fail or still be running before result metadata is available. */
+export function dynamicToolSurface(toolName: string | null | undefined, input: unknown) {
+ if (toolName === "cua_repl.js") return "computer" as const;
+ const code = asRecord(input)?.code;
+ return isJavaScriptReplTool(toolName) &&
+ typeof code === "string" &&
+ (/\bsky\s*\./u.test(code) || /["']@oai\/sky["']/u.test(code))
+ ? ("computer" as const)
+ : undefined;
+}
+
/**
- * Activity log heading a dynamic tool derives from its input: CUA's `title`,
+ * Activity log heading a dynamic tool derives from its input: a REPL's `title`,
* or the skill a Claude `Skill` call loads.
*/
export function dynamicToolTitle(
toolName: string | null | undefined,
input: unknown,
+ retainedTitle?: string | null,
): string | undefined {
- if (toolName === "cua_repl.js") return asTrimmedString(asRecord(input)?.title);
+ if (isJavaScriptReplTool(toolName)) {
+ const title = asTrimmedString(retainedTitle);
+ const meaningfulTitle =
+ title && title.toLowerCase() !== "js" && title.toLowerCase() !== toolName?.toLowerCase()
+ ? title
+ : undefined;
+ return (
+ asTrimmedString(asRecord(input)?.title) ??
+ meaningfulTitle ??
+ (dynamicToolSurface(toolName, input) === "computer" ? "Computer use" : "Run JavaScript")
+ );
+ }
const skill = claudeSkillInvocation(toolName, input);
return skill === undefined ? undefined : `Skill: ${skill.name}`;
}