fix(chat): show single tool calls without summaries (#9267)

Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
mariaandmaria-rcks authored and GitHub committed 2026-09-02 17:21:26 -04:00
1 parent 62c68dc41f
commit 46b5c66406
5 files changed
+104 -38

No files matched your search

+27 -4
View File
@@ -870,6 +870,7 @@ describe("buildThreadFeed", () => {
status: undefined,
displayName: "Click in the preview browser",
liveDisplayName: "Clicking in the preview browser",
settledDisplayName: "Clicked in the preview browser",
icon: "browser",
},
{
@@ -880,11 +881,12 @@ describe("buildThreadFeed", () => {
status: undefined,
displayName: "Get delegated task status",
liveDisplayName: "Getting delegated task status",
settledDisplayName: "Got delegated task status",
icon: "t3-code",
},
])(
"uses friendly row and running labels from $source",
({ label, title, item, status, displayName, liveDisplayName, icon }) => {
({ label, title, item, status, displayName, liveDisplayName, settledDisplayName, icon }) => {
const turnId = TurnId.make("turn-friendly-mcp");
const rawCommand = "node mcp-call.js";
const rawDetail = '{"provider":"raw MCP output"}';
@@ -949,6 +951,23 @@ describe("buildThreadFeed", () => {
live: true,
},
]);
if (settledDisplayName) {
const settledRows = deriveThreadFeedPresentation(
feed,
{
...thread.latestTurn!,
state: "completed",
completedAt: "2026-04-01T00:00:03.000Z",
},
new Set([turnId]),
new Set(),
);
expect(settledRows.find((entry) => entry.type === "work-toggle")).toMatchObject({
summary: settledDisplayName,
summaryToolIcon: icon,
live: false,
});
}
},
);
@@ -1041,7 +1060,7 @@ describe("buildThreadFeed", () => {
hasFailure: true,
},
])(
"keeps a browser group expanded as its action changes from active to $status",
"uses the browser call label once its action settles as $status",
({ status, displayName, detail, hasFailure }) => {
const turnId = TurnId.make("turn-preview-lifecycle");
const toolCallId = "preview-click";
@@ -1176,7 +1195,7 @@ describe("buildThreadFeed", () => {
groupId,
hiddenCount: 1,
expanded: true,
summary: "Used browser 1 time",
summary: displayName,
summaryKind: "browser",
hasFailure,
live: false,
@@ -1762,7 +1781,11 @@ describe("buildThreadFeed", () => {
const stoppedRows = deriveThreadFeedPresentation(feed, latestTurn, new Set());
expect(stoppedRows.filter((entry) => entry.type === "work-toggle")).toMatchObject([
{ live: false, shimmer: false },
{ live: false, shimmer: false },
{
live: false,
shimmer: false,
summary: lifecycleStatus === "inProgress" ? "printf done" : command,
},
]);
const completedRows = deriveThreadFeedPresentation(
+21 -4
View File
@@ -21,6 +21,7 @@ import {
omitSupersededLifecycleMarkers,
resolveWorkEntryToolPresentation,
summarizeToolGroup,
toolGroupAction,
toolGroupSummaryKind,
type ToolGroupSummaryKind,
} from "@t3tools/client-runtime/work-log/presentation";
@@ -837,6 +838,13 @@ function workEntryHeading(workEntry: WorkLogEntry): string {
return capitalizePhrase(normalizeCompactToolLabel(workEntry.toolTitle));
}
function singleToolCallLabel(activity: ThreadFeedActivity): string {
const presentation = resolveWorkEntryToolPresentation(activity.workEntry, "completed");
if (presentation) return presentation.displayName;
const command = activity.workEntry.command?.trim();
return command || activity.summary;
}
function asRecord(value: unknown): Record<string, unknown> | null {
return value && typeof value === "object" ? (value as Record<string, unknown>) : null;
}
@@ -1518,14 +1526,23 @@ function appendToolGroupRows(
const active = latestActiveActivity !== undefined;
const live = activeTail || active;
const latestActivity = latestActiveActivity ?? activities.at(-1)!;
const singleActivity = activities.length === 1 ? latestActivity : null;
const summary = live
? liveToolActivitySummary(latestActivity, active)
: activities.length === 1 && !activities[0]!.toolLike
? activities[0]!.workEntry.label
: summarizeToolGroup(activities.map((activity) => activity.workEntry));
: singleActivity !== null &&
singleActivity.toolLike &&
toolGroupAction(singleActivity.workEntry) !== "edit"
? singleToolCallLabel(singleActivity)
: singleActivity !== null && !singleActivity.toolLike
? singleActivity.workEntry.label
: summarizeToolGroup(activities.map((activity) => activity.workEntry));
const summaryToolIcon = live
? resolveWorkEntryToolPresentation(latestActivity.workEntry)?.icon
: undefined;
: singleActivity !== null &&
singleActivity.toolLike &&
toolGroupAction(singleActivity.workEntry) !== "edit"
? resolveWorkEntryToolPresentation(singleActivity.workEntry, "completed")?.icon
: undefined;
result.push({
type: "work-toggle",
id: `${live ? "work-live" : "work-toggle"}:${groupId}`,
@@ -152,30 +152,35 @@ describe("work entry labels", () => {
},
);
it("gives a completed browser group its own count and summary icon category", () => {
const rows = deriveMessagesTimelineRows({
timelineEntries: [
{
id: "browser-entry",
kind: "work",
createdAt: entry.createdAt,
entry: {
...entry,
itemType: "mcp_tool_call",
toolLifecycleStatus: "completed",
toolData: { server: "t3-code", tool: "preview_click" },
it.each([
["preview_click", "Clicked in the preview browser", "browser"],
["task_status", "Got delegated task status", "t3-code"],
] as const)(
"uses the completed %s call presentation for a settled legacy tool",
(tool, summary, summaryToolIcon) => {
const rows = deriveMessagesTimelineRows({
timelineEntries: [
{
id: "browser-entry",
kind: "work",
createdAt: entry.createdAt,
entry: {
...entry,
itemType: "mcp_tool_call",
toolData: { server: "t3-code", tool },
},
},
},
],
isWorking: false,
activeTurnStartedAt: null,
turnDiffSummaryByAssistantMessageId: new Map(),
revertTurnCountByUserMessageId: new Map(),
});
expect(rows).toMatchObject([
{ kind: "work-toggle", summary: "Used browser 1 time", summaryKind: "browser" },
]);
});
],
isWorking: false,
activeTurnStartedAt: null,
turnDiffSummaryByAssistantMessageId: new Map(),
revertTurnCountByUserMessageId: new Map(),
});
expect(rows).toMatchObject([
{ kind: "work-toggle", hiddenCount: 1, summary, summaryToolIcon },
]);
},
);
});
describe("shouldPreserveAssistantLineBreaks", () => {
@@ -1126,7 +1131,7 @@ describe("deriveMessagesTimelineRows", () => {
});
});
it("summarizes a tool run after commentary starts a new run", () => {
it("labels a single completed tool call without summarizing it", () => {
const rows = deriveMessagesTimelineRows({
timelineEntries: [
{
@@ -1189,7 +1194,7 @@ describe("deriveMessagesTimelineRows", () => {
expect(rows.map((row) => row.kind)).toEqual(["working", "work-toggle", "message", "work-live"]);
expect(rows.find((row) => row.kind === "work-toggle")).toMatchObject({
hiddenCount: 1,
summary: "Ran 1 command",
summary: "rg toolCall",
});
});
@@ -6,6 +6,7 @@ import {
omitSupersededLifecycleMarkers,
resolveWorkEntryToolPresentation,
summarizeToolGroup,
toolGroupAction,
toolGroupSummaryKind,
type ToolGroupSummaryKind,
} from "@t3tools/client-runtime/work-log/presentation";
@@ -34,6 +35,15 @@ export const TIMELINE_MINIMAP_MAX_HEIGHT_CSS = "calc(100vh - 18rem)";
export const TIMELINE_CONTENT_MAX_WIDTH = 768;
export const TIMELINE_MINIMAP_PERSISTENT_GUTTER = 48;
function singleToolCallLabel(entry: WorkLogEntry): string {
const toolPresentation = resolveWorkEntryToolPresentation(entry, "completed");
if (toolPresentation) return toolPresentation.displayName;
const command = entry.command?.trim();
if (command) return command;
const heading = normalizeCompactToolLabel(entry.toolTitle || entry.label);
return `${heading.charAt(0).toUpperCase()}${heading.slice(1)}`;
}
export function workEntryDisplayLabel(entry: WorkLogEntry, workspaceRoot: string | undefined) {
const toolPresentation = resolveWorkEntryToolPresentation(entry);
if (toolPresentation) return toolPresentation.displayName;
@@ -295,6 +305,7 @@ export type MessagesTimelineRow =
expanded: boolean;
summary: string;
summaryKind: ToolGroupSummaryKind;
summaryToolIcon?: "browser" | "t3-code";
hasFailure: boolean;
}
| {
@@ -840,6 +851,15 @@ export function deriveMessagesTimelineRows(input: {
const expanded = input.expandedWorkGroupIds?.has(groupId) ?? false;
const summaryKind = toolGroupSummaryKind(visibleGroupedEntries);
const latestToolEntry = visibleGroupedEntries.findLast(workLogEntryIsToolLike);
const singleEntry =
visibleGroupedEntries.length === 1 ? (visibleGroupedEntries[0] ?? null) : null;
const usesSingleToolCallLabel =
singleEntry !== null &&
workLogEntryIsToolLike(singleEntry) &&
toolGroupAction(singleEntry) !== "edit";
const summaryToolIcon = usesSingleToolCallLabel
? resolveWorkEntryToolPresentation(singleEntry, "completed")?.icon
: undefined;
nextRows.push({
kind: "work-toggle",
id: `work-toggle:${timelineEntry.id}`,
@@ -847,12 +867,13 @@ export function deriveMessagesTimelineRows(input: {
groupId,
hiddenCount: visibleGroupedEntries.length,
expanded,
summary:
visibleGroupedEntries.length === 1 &&
!workLogEntryIsToolLike(visibleGroupedEntries[0]!)
? visibleGroupedEntries[0]!.label
summary: usesSingleToolCallLabel
? singleToolCallLabel(singleEntry)
: singleEntry !== null && !workLogEntryIsToolLike(singleEntry)
? singleEntry.label
: summarizeToolGroup(visibleGroupedEntries),
summaryKind,
...(summaryToolIcon ? { summaryToolIcon } : {}),
hasFailure:
latestToolEntry !== undefined &&
workEntryDisplayIndicatesToolFailure(latestToolEntry),
@@ -1851,7 +1851,7 @@ function WorkGroupToggleTimelineRow({
>
<span className="flex size-6 shrink-0 items-center justify-center text-icon-muted">
<WorkEntryIcon
name={toolGroupSummaryIconName(row.summaryKind)}
name={row.summaryToolIcon ?? toolGroupSummaryIconName(row.summaryKind)}
className="size-4 shrink-0 stroke-[1.8] opacity-70"
/>
</span>