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

@@ -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", () => {
@@ -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">,