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

Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
mariaandmaria-rcks authored and GitHub committed 2026-09-02 22:39:09 -04:00
1 parent 922bd69225
commit ec44bc56f5
8 files changed
+54 -37

No files matched your search

+8 -6
View File
@@ -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 },
+8 -7
View File
@@ -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"
@@ -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);
},
);
@@ -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"
@@ -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"');
});