Skip to content

Commit 71cb61e

Browse files
committed
fix(chat): preserve singleton tool icons
1 parent 5fbd577 commit 71cb61e

5 files changed

Lines changed: 49 additions & 32 deletions

File tree

‎apps/mobile/src/lib/threadActivity.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,7 @@ describe("buildThreadFeed", () => {
964964
);
965965
expect(settledRows.find((entry) => entry.type === "work-toggle")).toMatchObject({
966966
summary: settledDisplayName,
967+
summaryToolIcon: icon,
967968
live: false,
968969
});
969970
}

‎apps/mobile/src/lib/threadActivity.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,11 @@ function appendToolGroupRows(
15381538
: summarizeToolGroup(activities.map((activity) => activity.workEntry));
15391539
const summaryToolIcon = live
15401540
? resolveWorkEntryToolPresentation(latestActivity.workEntry)?.icon
1541-
: undefined;
1541+
: singleActivity !== null &&
1542+
singleActivity.toolLike &&
1543+
toolGroupAction(singleActivity.workEntry) !== "edit"
1544+
? resolveWorkEntryToolPresentation(singleActivity.workEntry, "completed")?.icon
1545+
: undefined;
15421546
result.push({
15431547
type: "work-toggle",
15441548
id: `${live ? "work-live" : "work-toggle"}:${groupId}`,

‎apps/web/src/components/chat/MessagesTimeline.logic.test.ts‎

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -152,29 +152,35 @@ describe("work entry labels", () => {
152152
},
153153
);
154154

155-
it("uses the completed browser call label for a settled legacy tool", () => {
156-
const rows = deriveMessagesTimelineRows({
157-
timelineEntries: [
158-
{
159-
id: "browser-entry",
160-
kind: "work",
161-
createdAt: entry.createdAt,
162-
entry: {
163-
...entry,
164-
itemType: "mcp_tool_call",
165-
toolData: { server: "t3-code", tool: "preview_click" },
155+
it.each([
156+
["preview_click", "Clicked in the preview browser", "browser"],
157+
["task_status", "Got delegated task status", "t3-code"],
158+
] as const)(
159+
"uses the completed %s call presentation for a settled legacy tool",
160+
(tool, summary, summaryToolIcon) => {
161+
const rows = deriveMessagesTimelineRows({
162+
timelineEntries: [
163+
{
164+
id: "browser-entry",
165+
kind: "work",
166+
createdAt: entry.createdAt,
167+
entry: {
168+
...entry,
169+
itemType: "mcp_tool_call",
170+
toolData: { server: "t3-code", tool },
171+
},
166172
},
167-
},
168-
],
169-
isWorking: false,
170-
activeTurnStartedAt: null,
171-
turnDiffSummaryByAssistantMessageId: new Map(),
172-
revertTurnCountByUserMessageId: new Map(),
173-
});
174-
expect(rows).toMatchObject([
175-
{ kind: "work-toggle", hiddenCount: 1, summary: "Clicked in the preview browser" },
176-
]);
177-
});
173+
],
174+
isWorking: false,
175+
activeTurnStartedAt: null,
176+
turnDiffSummaryByAssistantMessageId: new Map(),
177+
revertTurnCountByUserMessageId: new Map(),
178+
});
179+
expect(rows).toMatchObject([
180+
{ kind: "work-toggle", hiddenCount: 1, summary, summaryToolIcon },
181+
]);
182+
},
183+
);
178184
});
179185

180186
describe("shouldPreserveAssistantLineBreaks", () => {

‎apps/web/src/components/chat/MessagesTimeline.logic.ts‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ export type MessagesTimelineRow =
305305
expanded: boolean;
306306
summary: string;
307307
summaryKind: ToolGroupSummaryKind;
308+
summaryToolIcon?: "browser" | "t3-code";
308309
hasFailure: boolean;
309310
}
310311
| {
@@ -852,22 +853,27 @@ export function deriveMessagesTimelineRows(input: {
852853
const latestToolEntry = visibleGroupedEntries.findLast(workLogEntryIsToolLike);
853854
const singleEntry =
854855
visibleGroupedEntries.length === 1 ? (visibleGroupedEntries[0] ?? null) : null;
856+
const usesSingleToolCallLabel =
857+
singleEntry !== null &&
858+
workLogEntryIsToolLike(singleEntry) &&
859+
toolGroupAction(singleEntry) !== "edit";
860+
const summaryToolIcon = usesSingleToolCallLabel
861+
? resolveWorkEntryToolPresentation(singleEntry, "completed")?.icon
862+
: undefined;
855863
nextRows.push({
856864
kind: "work-toggle",
857865
id: `work-toggle:${timelineEntry.id}`,
858866
createdAt: timelineEntry.createdAt,
859867
groupId,
860868
hiddenCount: visibleGroupedEntries.length,
861869
expanded,
862-
summary:
863-
singleEntry !== null &&
864-
workLogEntryIsToolLike(singleEntry) &&
865-
toolGroupAction(singleEntry) !== "edit"
866-
? singleToolCallLabel(singleEntry)
867-
: singleEntry !== null && !workLogEntryIsToolLike(singleEntry)
868-
? singleEntry.label
869-
: summarizeToolGroup(visibleGroupedEntries),
870+
summary: usesSingleToolCallLabel
871+
? singleToolCallLabel(singleEntry)
872+
: singleEntry !== null && !workLogEntryIsToolLike(singleEntry)
873+
? singleEntry.label
874+
: summarizeToolGroup(visibleGroupedEntries),
870875
summaryKind,
876+
...(summaryToolIcon ? { summaryToolIcon } : {}),
871877
hasFailure:
872878
latestToolEntry !== undefined &&
873879
workEntryDisplayIndicatesToolFailure(latestToolEntry),

‎apps/web/src/components/chat/MessagesTimeline.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ function WorkGroupToggleTimelineRow({
18511851
>
18521852
<span className="flex size-6 shrink-0 items-center justify-center text-icon-muted">
18531853
<WorkEntryIcon
1854-
name={toolGroupSummaryIconName(row.summaryKind)}
1854+
name={row.summaryToolIcon ?? toolGroupSummaryIconName(row.summaryKind)}
18551855
className="size-4 shrink-0 stroke-[1.8] opacity-70"
18561856
/>
18571857
</span>

0 commit comments

Comments
 (0)