Skip to content

Commit d8561c5

Browse files
committed
fix(chat): preserve single-call disclosure behavior
1 parent 6c1bb85 commit d8561c5

4 files changed

Lines changed: 48 additions & 59 deletions

File tree

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

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ describe("buildThreadFeed", () => {
10411041
hasFailure: true,
10421042
},
10431043
])(
1044-
"renders a direct browser row once its action settles as $status",
1044+
"uses the browser call label once its action settles as $status",
10451045
({ status, displayName, detail, hasFailure }) => {
10461046
const turnId = TurnId.make("turn-preview-lifecycle");
10471047
const toolCallId = "preview-click";
@@ -1172,10 +1172,18 @@ describe("buildThreadFeed", () => {
11721172
completedAt: "2026-04-01T00:00:04.000Z",
11731173
},
11741174
});
1175-
expect(settledRows.some((entry) => entry.type === "work-toggle")).toBe(false);
1175+
expect(settledRows.find((entry) => entry.type === "work-toggle")).toMatchObject({
1176+
groupId,
1177+
hiddenCount: 1,
1178+
expanded: true,
1179+
summary: displayName,
1180+
summaryKind: "browser",
1181+
hasFailure,
1182+
live: false,
1183+
});
11761184
expect(settledRows.find((entry) => entry.type === "activity-group")).toMatchObject({
1177-
id: "preview-click-started",
1178-
activities: [{ id: "preview-click-started", summary: displayName }],
1185+
id: `work-details:${groupId}`,
1186+
activities: [{ id: "preview-click-started", summary: displayName, live: false }],
11791187
});
11801188
},
11811189
);
@@ -1350,7 +1358,7 @@ describe("buildThreadFeed", () => {
13501358
expect(expanded.map((entry) => entry.id)).toEqual([
13511359
"assistant-first",
13521360
"turn-fold:turn-1",
1353-
"tool-completed",
1361+
"work-toggle:work-group:tool-completed",
13541362
"assistant-final",
13551363
]);
13561364
});
@@ -1734,7 +1742,7 @@ describe("buildThreadFeed", () => {
17341742
latestTurn.startedAt,
17351743
);
17361744
expect(rows.slice(0, 3).map((entry) => [entry.id, entry.type])).toEqual([
1737-
["activity-1", "activity-group"],
1745+
["work-toggle:work-group:activity-1", "work-toggle"],
17381746
["activity-2", "activity-group"],
17391747
["work-live:work-group:activity-3", "work-toggle"],
17401748
]);
@@ -1749,10 +1757,13 @@ describe("buildThreadFeed", () => {
17491757
live: true,
17501758
shimmer,
17511759
});
1752-
expect(rows[0]).toMatchObject({ type: "activity-group" });
1760+
expect(rows[0]).toMatchObject({ live: false, shimmer: false });
17531761

17541762
const stoppedRows = deriveThreadFeedPresentation(feed, latestTurn, new Set());
1755-
expect(stoppedRows.every((entry) => entry.type === "activity-group")).toBe(true);
1763+
expect(stoppedRows.filter((entry) => entry.type === "work-toggle")).toMatchObject([
1764+
{ live: false, shimmer: false },
1765+
{ live: false, shimmer: false },
1766+
]);
17561767

17571768
const completedRows = deriveThreadFeedPresentation(
17581769
feed,
@@ -1761,11 +1772,10 @@ describe("buildThreadFeed", () => {
17611772
new Set(),
17621773
latestTurn.startedAt,
17631774
);
1764-
expect(
1765-
completedRows
1766-
.filter((entry) => entry.type !== "turn-fold")
1767-
.every((entry) => entry.type === "activity-group"),
1768-
).toBe(true);
1775+
expect(completedRows.filter((entry) => entry.type === "work-toggle")).toMatchObject([
1776+
{ live: false, shimmer: false },
1777+
{ live: false, shimmer: false },
1778+
]);
17691779
},
17701780
);
17711781

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

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,26 +1519,16 @@ function appendToolGroupRows(
15191519
const active = latestActiveActivity !== undefined;
15201520
const live = activeTail || active;
15211521
const latestActivity = latestActiveActivity ?? activities.at(-1)!;
1522-
if (
1523-
!live &&
1524-
activities.length === 1 &&
1525-
latestActivity.toolLike &&
1526-
toolGroupAction(latestActivity.workEntry) !== "edit"
1527-
) {
1528-
result.push({
1529-
type: "activity-group",
1530-
id: latestActivity.id,
1531-
createdAt: latestActivity.createdAt,
1532-
turnId: latestActivity.turnId,
1533-
activities,
1534-
});
1535-
return;
1536-
}
1522+
const singleActivity = activities.length === 1 ? latestActivity : null;
15371523
const summary = live
15381524
? liveToolActivitySummary(latestActivity, active)
1539-
: activities.length === 1 && !activities[0]!.toolLike
1540-
? activities[0]!.workEntry.label
1541-
: summarizeToolGroup(activities.map((activity) => activity.workEntry));
1525+
: singleActivity !== null &&
1526+
singleActivity.toolLike &&
1527+
toolGroupAction(singleActivity.workEntry) !== "edit"
1528+
? singleActivity.summary
1529+
: singleActivity !== null && !singleActivity.toolLike
1530+
? singleActivity.workEntry.label
1531+
: summarizeToolGroup(activities.map((activity) => activity.workEntry));
15421532
const summaryToolIcon = live
15431533
? resolveWorkEntryToolPresentation(latestActivity.workEntry)?.icon
15441534
: undefined;

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

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

155-
it("renders one completed browser call without a group summary", () => {
155+
it("uses the completed browser call label instead of a group summary", () => {
156156
const rows = deriveMessagesTimelineRows({
157157
timelineEntries: [
158158
{
@@ -173,11 +173,7 @@ describe("work entry labels", () => {
173173
revertTurnCountByUserMessageId: new Map(),
174174
});
175175
expect(rows).toMatchObject([
176-
{
177-
kind: "work",
178-
groupedEntries: [{ id: "tool-1" }],
179-
isExpandedToolGroup: false,
180-
},
176+
{ kind: "work-toggle", hiddenCount: 1, summary: "Clicked in the preview browser" },
181177
]);
182178
});
183179
});
@@ -736,7 +732,7 @@ describe("deriveMessagesTimelineRows", () => {
736732
"user-entry",
737733
"turn-fold:turn-1",
738734
"assistant-first-entry",
739-
"work-entry-1",
735+
"work-toggle:work-entry-1",
740736
"assistant-final-entry",
741737
]);
742738
expect(
@@ -1130,7 +1126,7 @@ describe("deriveMessagesTimelineRows", () => {
11301126
});
11311127
});
11321128

1133-
it("renders a single completed tool call without summarizing it", () => {
1129+
it("labels a single completed tool call without summarizing it", () => {
11341130
const rows = deriveMessagesTimelineRows({
11351131
timelineEntries: [
11361132
{
@@ -1190,10 +1186,10 @@ describe("deriveMessagesTimelineRows", () => {
11901186
revertTurnCountByUserMessageId: new Map(),
11911187
});
11921188

1193-
expect(rows.map((row) => row.kind)).toEqual(["working", "work", "message", "work-live"]);
1194-
expect(rows.find((row) => row.kind === "work")).toMatchObject({
1195-
groupedEntries: [{ id: "completed-command" }],
1196-
isExpandedToolGroup: false,
1189+
expect(rows.map((row) => row.kind)).toEqual(["working", "work-toggle", "message", "work-live"]);
1190+
expect(rows.find((row) => row.kind === "work-toggle")).toMatchObject({
1191+
hiddenCount: 1,
1192+
summary: "rg toolCall",
11971193
});
11981194
});
11991195

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -836,23 +836,13 @@ export function deriveMessagesTimelineRows(input: {
836836
expandedWorkGroupRow(groupId, timelineEntry.createdAt, visibleGroupedEntries),
837837
);
838838
}
839-
} else if (
840-
visibleGroupedEntries.length === 1 &&
841-
workLogEntryIsToolLike(visibleGroupedEntries[0]!) &&
842-
toolGroupAction(visibleGroupedEntries[0]!) !== "edit"
843-
) {
844-
nextRows.push({
845-
kind: "work",
846-
id: timelineEntry.id,
847-
createdAt: timelineEntry.createdAt,
848-
groupedEntries: visibleGroupedEntries,
849-
isExpandedToolGroup: false,
850-
});
851839
} else {
852840
const groupId = workGroupId(timelineEntry.id, timelineEntry.entry);
853841
const expanded = input.expandedWorkGroupIds?.has(groupId) ?? false;
854842
const summaryKind = toolGroupSummaryKind(visibleGroupedEntries);
855843
const latestToolEntry = visibleGroupedEntries.findLast(workLogEntryIsToolLike);
844+
const singleEntry =
845+
visibleGroupedEntries.length === 1 ? (visibleGroupedEntries[0] ?? null) : null;
856846
nextRows.push({
857847
kind: "work-toggle",
858848
id: `work-toggle:${timelineEntry.id}`,
@@ -861,10 +851,13 @@ export function deriveMessagesTimelineRows(input: {
861851
hiddenCount: visibleGroupedEntries.length,
862852
expanded,
863853
summary:
864-
visibleGroupedEntries.length === 1 &&
865-
!workLogEntryIsToolLike(visibleGroupedEntries[0]!)
866-
? visibleGroupedEntries[0]!.label
867-
: summarizeToolGroup(visibleGroupedEntries),
854+
singleEntry !== null &&
855+
workLogEntryIsToolLike(singleEntry) &&
856+
toolGroupAction(singleEntry) !== "edit"
857+
? workEntryDisplayLabel(singleEntry, undefined)
858+
: singleEntry !== null && !workLogEntryIsToolLike(singleEntry)
859+
? singleEntry.label
860+
: summarizeToolGroup(visibleGroupedEntries),
868861
summaryKind,
869862
hasFailure:
870863
latestToolEntry !== undefined &&

0 commit comments

Comments
 (0)