Skip to content
TypeScript

fix(chat): keep live tool labels in present tense (#9316)

mariaec44bc56f598
diff --git a/apps/mobile/src/lib/threadActivity.test.ts b/apps/mobile/src/lib/threadActivity.test.ts
index 47bfe6755db..2ae78e5989f 100644
--- a/apps/mobile/src/lib/threadActivity.test.ts
+++ b/apps/mobile/src/lib/threadActivity.test.ts
@@ -868,7 +868,7 @@ describe("buildThreadFeed", () => {
title: "Call MCP tool",
item: { server: "t3-code", tool: "preview_click" },
status: undefined,
- displayName: "Click in the preview browser",
+ displayName: "Clicking in the preview browser",
liveDisplayName: "Clicking in the preview browser",
settledDisplayName: "Clicked in the preview browser",
icon: "browser",
@@ -879,7 +879,7 @@ describe("buildThreadFeed", () => {
title: "Call MCP tool",
item: { server: "t3-code", tool: "task_status" },
status: undefined,
- displayName: "Get delegated task status",
+ displayName: "Getting delegated task status",
liveDisplayName: "Getting delegated task status",
settledDisplayName: "Got delegated task status",
icon: "t3-code",
@@ -1039,7 +1039,7 @@ describe("buildThreadFeed", () => {
).toMatchObject([
{
type: "work-toggle",
- summary: "Clicked in the preview browser",
+ summary: "Clicking in the preview browser",
summaryToolIcon: "browser",
live: true,
},
@@ -1050,18 +1050,20 @@ describe("buildThreadFeed", () => {
{
status: "completed",
displayName: "Clicked in the preview browser",
+ liveDisplayName: "Clicking in the preview browser",
detail: "Clicked Continue",
hasFailure: false,
},
{
status: "failed",
displayName: "Failed to click in the preview browser",
+ liveDisplayName: "Failed to click in the preview browser",
detail: "Timed out waiting for Continue",
hasFailure: true,
},
])(
"uses the browser call label once its action settles as $status",
- ({ status, displayName, detail, hasFailure }) => {
+ ({ status, displayName, liveDisplayName, detail, hasFailure }) => {
const turnId = TurnId.make("turn-preview-lifecycle");
const toolCallId = "preview-click";
const groupId = `work-group:tool:${turnId}:${toolCallId}`;
@@ -1156,7 +1158,7 @@ describe("buildThreadFeed", () => {
groupId,
hiddenCount: 1,
expanded: true,
- summary: displayName,
+ summary: liveDisplayName,
summaryToolIcon: "browser",
hasFailure,
live: true,
@@ -1677,7 +1679,7 @@ describe("buildThreadFeed", () => {
(
[
{ lifecycleStatus: "inProgress", summary: "Running pnpm", shimmer: true },
- { lifecycleStatus: "completed", summary: "Ran pnpm", shimmer: false },
+ { lifecycleStatus: "completed", summary: "Running pnpm", shimmer: false },
{ lifecycleStatus: "failed", summary: "Failed pnpm", shimmer: false },
{ lifecycleStatus: "declined", summary: "Declined pnpm", shimmer: false },
{ lifecycleStatus: "stopped", summary: "Stopped pnpm", shimmer: false },
diff --git a/apps/mobile/src/lib/threadActivity.ts b/apps/mobile/src/lib/threadActivity.ts
index c98cb40289e..89164c01db3 100644
--- a/apps/mobile/src/lib/threadActivity.ts
+++ b/apps/mobile/src/lib/threadActivity.ts
@@ -17,6 +17,7 @@ import {
commandDetailRepeatsCommand,
extractCommandOutputText,
isWorktreeSetupActivity,
+ liveActivityToolStatus,
normalizeCompactToolLabel,
omitSupersededLifecycleMarkers,
resolveWorkEntryToolPresentation,
@@ -1528,7 +1529,7 @@ function appendToolGroupRows(
const latestActivity = latestActiveActivity ?? activities.at(-1)!;
const singleActivity = activities.length === 1 ? latestActivity : null;
const summary = live
- ? liveToolActivitySummary(latestActivity, active)
+ ? liveToolActivitySummary(latestActivity, live)
: singleActivity !== null &&
singleActivity.toolLike &&
toolGroupAction(singleActivity.workEntry) !== "edit"
@@ -1580,16 +1581,16 @@ function appendToolGroupRows(
});
}
-function liveToolActivitySummary(activity: ThreadFeedActivity, active: boolean): string {
- const presentation = resolveWorkEntryToolPresentation(
- activity.workEntry,
- active ? "inProgress" : "completed",
- );
+function liveToolActivitySummary(activity: ThreadFeedActivity, presentTense: boolean): string {
+ const status = liveActivityToolStatus(activity.lifecycleStatus, presentTense);
+ const presentation = resolveWorkEntryToolPresentation({
+ ...activity.workEntry,
+ toolLifecycleStatus: status,
+ });
if (presentation) return presentation.displayName;
const command = activity.workEntry.command?.trim();
if (command) {
const program = commandProgramName(command);
- const status = activity.lifecycleStatus ?? (active ? "inProgress" : "completed");
const verb =
status === "inProgress"
? "Running"
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
index 08723c7b9fe..f1cd270d7f9 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
@@ -99,13 +99,16 @@ describe("work entry labels", () => {
);
});
- it("does not describe a finished call as still running while the turn continues", () => {
+ it("keeps the latest live activity in the present tense after the call completes", () => {
const browserEntry = {
...entry,
toolTitle: "T3-code.preview_click",
toolLifecycleStatus: "completed" as const,
};
expect(liveWorkEntryLabel(browserEntry, undefined, true)).toBe(
+ "Clicking in the preview browser",
+ );
+ expect(liveWorkEntryLabel(browserEntry, undefined, false)).toBe(
"Clicked in the preview browser",
);
});
@@ -134,21 +137,21 @@ describe("work entry labels", () => {
});
it.each([
- ["inProgress", "Running vp"],
- ["completed", "Ran vp"],
- ["failed", "Failed vp"],
- ["declined", "Declined vp"],
- ["stopped", "Stopped vp"],
+ ["inProgress", "Running vp", "Running vp"],
+ ["completed", "Running vp", "Ran vp"],
+ ["failed", "Failed vp", "Failed vp"],
+ ["declined", "Declined vp", "Declined vp"],
+ ["stopped", "Stopped vp", "Stopped vp"],
] as const)(
- "uses the command's %s outcome even while the turn continues",
- (toolLifecycleStatus, label) => {
+ "uses present tense for a live %s command and the outcome once it is no longer live",
+ (toolLifecycleStatus, liveLabel, settledLabel) => {
const commandEntry = {
...entry,
command: "/bin/bash -lc 'vp test run'",
toolLifecycleStatus,
};
- expect(liveWorkEntryLabel(commandEntry, undefined, true)).toBe(label);
- expect(liveWorkEntryLabel(commandEntry, undefined, false)).toBe(label);
+ expect(liveWorkEntryLabel(commandEntry, undefined, true)).toBe(liveLabel);
+ expect(liveWorkEntryLabel(commandEntry, undefined, false)).toBe(settledLabel);
},
);
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts
index 980a93a59bd..1fa0e7b4fe7 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts
@@ -2,6 +2,7 @@ import * as Equal from "effect/Equal";
import { renderCodexDirectivesForCopy } from "@t3tools/client-runtime/codex-markdown-directives";
import { commandProgramName } from "@t3tools/client-runtime/work-log/command-label";
import {
+ liveActivityToolStatus,
normalizeCompactToolLabel,
omitSupersededLifecycleMarkers,
resolveWorkEntryToolPresentation,
@@ -65,14 +66,14 @@ export function liveWorkEntryLabel(
workspaceRoot: string | undefined,
active: boolean,
) {
- const toolPresentation = resolveWorkEntryToolPresentation(
- entry,
- active ? "inProgress" : "completed",
- );
+ const status = liveActivityToolStatus(entry.toolLifecycleStatus, active);
+ const toolPresentation = resolveWorkEntryToolPresentation({
+ ...entry,
+ toolLifecycleStatus: status,
+ });
if (toolPresentation) return toolPresentation.displayName;
const command = entry.command?.trim();
if (command) {
- const status = entry.toolLifecycleStatus ?? (active ? "inProgress" : "completed");
const verb =
status === "inProgress"
? "Running"
diff --git a/apps/web/src/components/chat/MessagesTimeline.test.tsx b/apps/web/src/components/chat/MessagesTimeline.test.tsx
index 495c38fa321..b8b8cad401c 100644
--- a/apps/web/src/components/chat/MessagesTimeline.test.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.test.tsx
@@ -1224,7 +1224,7 @@ describe("MessagesTimeline", () => {
expect(markup).toContain('data-timeline-row-id="live-activity-row"');
});
- it("keeps the completed command in the shared activity row with a past-tense label", () => {
+ it("keeps the completed command in the shared activity row with a present-tense label", () => {
const turnId = TurnId.make("turn-live");
const markup = renderToStaticMarkup(
<MessagesTimeline
@@ -1259,10 +1259,10 @@ describe("MessagesTimeline", () => {
/>,
);
- expect(markup).toContain("Ran pnpm");
+ expect(markup).toContain("Running pnpm");
expect(markup).toContain("lucide-terminal");
expect(markup).toContain("live-activity-focus");
- expect(markup).not.toContain("Running pnpm");
+ expect(markup).not.toContain("Ran pnpm");
expect(markup).not.toContain("Thinking");
expect(markup).not.toContain('data-timeline-row-kind="thinking"');
});
diff --git a/docs/user/tool-activity.md b/docs/user/tool-activity.md
index 67a3049016e..4394e3fc66c 100644
--- a/docs/user/tool-activity.md
+++ b/docs/user/tool-activity.md
@@ -8,7 +8,10 @@ indicate more calls above or below. Short groups use only the space they need.
Collapsing and reopening a group preserves your reading position and any open call details.
Recognized T3 tools use descriptive labels in both the running summary and individual rows.
-Labels follow the call's state, such as "Clicking" while running and "Clicked" after success.
+The latest live activity stays in the present tense while the turn continues, such as
+"Running vp" or "Clicking in the preview browser", even after that call has completed.
+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.
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
diff --git a/packages/client-runtime/src/work-log/presentation.test.ts b/packages/client-runtime/src/work-log/presentation.test.ts
index deb4d68cf06..2dfc26c36a4 100644
--- a/packages/client-runtime/src/work-log/presentation.test.ts
+++ b/packages/client-runtime/src/work-log/presentation.test.ts
@@ -25,7 +25,7 @@ describe("resolveWorkEntryToolPresentation", () => {
"preview_click",
])("recognizes browser tool names across providers: %s", (label) => {
expect(resolveWorkEntryToolPresentation({ label })).toEqual({
- displayName: "Click in the preview browser",
+ displayName: "Clicking in the preview browser",
icon: "browser",
});
});
@@ -37,7 +37,7 @@ describe("resolveWorkEntryToolPresentation", () => {
toolTitle: "Inspect the current page",
toolData: { server: "t3-code", tool: "preview_snapshot", result: { title: "Example" } },
}),
- ).toEqual({ displayName: "Take a snapshot of the preview page", icon: "browser" });
+ ).toEqual({ displayName: "Taking a snapshot of the preview page", icon: "browser" });
});
it.each([
@@ -46,7 +46,7 @@ describe("resolveWorkEntryToolPresentation", () => {
["failed", "Failed to click in the preview browser"],
["declined", "Declined to click in the preview browser"],
["stopped", "Stopped clicking in the preview browser"],
- ["unknown", "Click in the preview browser"],
+ ["unknown", "Clicking in the preview browser"],
])("describes the tool's own %s state", (toolLifecycleStatus, displayName) => {
expect(
resolveWorkEntryToolPresentation({
@@ -115,7 +115,7 @@ describe("resolveWorkEntryToolPresentation", () => {
label: "mcp__t3_code__task_status",
toolTitle: "Check the child task",
}),
- ).toEqual({ displayName: "Get delegated task status", icon: "t3-code" });
+ ).toEqual({ displayName: "Getting delegated task status", icon: "t3-code" });
});
it("does not brand unknown tools or another server's matching tool name", () => {
diff --git a/packages/client-runtime/src/work-log/presentation.ts b/packages/client-runtime/src/work-log/presentation.ts
index ae208a5bb49..e19d60b1498 100644
--- a/packages/client-runtime/src/work-log/presentation.ts
+++ b/packages/client-runtime/src/work-log/presentation.ts
@@ -113,7 +113,7 @@ function resolveT3McpToolPresentation(value: string | undefined, status: string
? `Declined to ${action.toLowerCase()}`
: status === "stopped"
? `Stopped ${running.toLowerCase()}`
- : action;
+ : running;
return {
displayName: `${verb} ${detail}`,
@@ -121,6 +121,13 @@ function resolveT3McpToolPresentation(value: string | undefined, status: string
};
}
+/** Latest live activity stays present-tense unless the call itself failed, declined, or stopped. */
+export function liveActivityToolStatus(status: string | undefined, presentTense: boolean) {
+ if (status === "failed" || status === "declined" || status === "stopped") return status;
+ if (presentTense || status === "inProgress") return "inProgress";
+ return "completed";
+}
+
/** Resolves tool identity before choosing labels or icons in either client. */
export function resolveWorkEntryToolPresentation(
entry: Pick<WorkLogPresentationEntry, "label" | "toolTitle" | "toolData" | "toolLifecycleStatus">,