Skip to content

Commit 0be86ee

Browse files
StiensWoutclaude
andcommitted
fix(mobile): a lone tool call opens its details in one tap
A group with one visible tool call rendered a group header, and opening it revealed a second disclosure for the same call. Reading the details took two taps on two identical labels. The feed presenter now shows a lone call as its own row. The row keeps the header's label, list identity and height, so the live slot still swaps in place with Thinking and with a growing group. Its disclosure opens the details directly, and a call with nothing to show gets no chevron. Lone thoughts keep their header, which already expands to the text. Groups of two or more calls are unchanged. Toggling a lone row also sets its group's disclosure, so details that are open stay open when a second call turns the row into a group. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 4ee6bfd commit 0be86ee

4 files changed

Lines changed: 168 additions & 37 deletions

File tree

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ function renderFeedEntry(
15291529
readonly failedRunIds: ReadonlySet<RunId>;
15301530
readonly onCopyWorkRow: (rowId: string, value: string) => void;
15311531
readonly onToggleWorkGroup: (groupId: string, anchorKey?: string) => void;
1532-
readonly onToggleWorkRow: (rowId: string, anchorKey?: string) => void;
1532+
readonly onToggleWorkRow: (rowId: string, anchorKey?: string, groupId?: string) => void;
15331533
readonly onToggleTurnFold: (runId: RunId) => void;
15341534
readonly onPressPreview: (source: FilePreviewSource) => void;
15351535
readonly onPressVideo: (attachment: ChatFileAttachment, sourceIdentifier: string) => void;
@@ -2826,16 +2826,22 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
28262826
[suspendEndScrollMaintenanceForDisclosure],
28272827
);
28282828

2829+
// A lone call's row stands in for its group header, so both disclosures move
2830+
// together. Details the reader opened stay open when a second call turns the
2831+
// row into a group.
28292832
const onToggleWorkRow = useCallback(
2830-
(rowId: string, anchorKey?: string) => {
2833+
(rowId: string, anchorKey?: string, groupId?: string) => {
28312834
suspendEndScrollMaintenanceForDisclosure(anchorKey ?? null);
2832-
setInteractionState((current) => ({
2833-
...current,
2834-
expandedWorkRows: {
2835-
...current.expandedWorkRows,
2836-
[rowId]: !(current.expandedWorkRows[rowId] ?? false),
2837-
},
2838-
}));
2835+
setInteractionState((current) => {
2836+
const expanded = !(current.expandedWorkRows[rowId] ?? false);
2837+
return {
2838+
...current,
2839+
expandedWorkRows: { ...current.expandedWorkRows, [rowId]: expanded },
2840+
...(groupId === undefined
2841+
? {}
2842+
: { expandedWorkGroups: { ...current.expandedWorkGroups, [groupId]: expanded } }),
2843+
};
2844+
});
28392845
},
28402846
[suspendEndScrollMaintenanceForDisclosure],
28412847
);

‎apps/mobile/src/features/threads/thread-work-log.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ interface ThreadWorkLogProps {
459459
readonly edgeFadeColor: string;
460460
readonly themeAppearance: "light" | "dark";
461461
readonly onCopyRow: (rowId: string, value: string) => void;
462-
readonly onToggleRow: (rowId: string, anchorKey: string) => void;
462+
/** `groupId` is the group a lone call stands in for; it opens and closes with the row. */
463+
readonly onToggleRow: (rowId: string, anchorKey: string, groupId?: string) => void;
463464
readonly renderImage: MarkdownImageRenderer;
464465
readonly renderReasoning: (text: string) => ReactNode;
465466
}
@@ -966,12 +967,12 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
966967
: null;
967968
const viewedImagePath = workEntryViewedImagePath(row.workEntry);
968969
const toolPresentation = resolveWorkEntryToolPresentation(row.workEntry);
969-
const previewText = workEntryRowLabel(row.workEntry);
970+
const previewText = row.groupStandIn?.label ?? workEntryRowLabel(row.workEntry);
970971
const answerPreview = row.workEntry.questionAnswer
971972
? getQuestionAnswerPreview(row.workEntry.questionAnswer)
972973
: null;
973974
const accessiblePreview = [previewText, answerPreview].filter(Boolean).join(": ");
974-
const displayText = workEntryRowLabel(row.workEntry, expanded);
975+
const displayText = row.groupStandIn?.label ?? workEntryRowLabel(row.workEntry, expanded);
975976
const isSystemNotice = row.projectedItem.item.type === "system_notice";
976977
const isUsageLimit =
977978
row.projectedItem.item.type === "error" &&
@@ -1012,7 +1013,7 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
10121013
}
10131014
if (canExpand) {
10141015
void Haptics.selectionAsync();
1015-
props.onToggleRow(row.id, props.anchorKey);
1016+
props.onToggleRow(row.id, props.anchorKey, row.groupStandIn?.groupId);
10161017
}
10171018
}}
10181019
onLongPress={() => props.onCopyRow(row.id, row.getCopyText())}

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

Lines changed: 123 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ describe("buildThreadFeed", () => {
869869
"message",
870870
"message",
871871
"run-fold",
872-
"work-toggle",
872+
"activity-group",
873873
"message",
874874
"message",
875875
]);
@@ -995,7 +995,7 @@ describe("buildThreadFeed", () => {
995995
expect(expanded.map((entry) => entry.type)).toEqual([
996996
"message",
997997
"run-fold",
998-
"work-toggle",
998+
"activity-group",
999999
"message",
10001000
]);
10011001
});
@@ -1018,11 +1018,8 @@ describe("buildThreadFeed", () => {
10181018
);
10191019

10201020
expect(presented.some((entry) => entry.type === "run-fold")).toBe(false);
1021-
expect(presented.find((entry) => entry.type === "work-toggle")).toMatchObject({
1022-
summary: "vp check",
1023-
hiddenCount: 1,
1024-
hasFailure: true,
1025-
live: false,
1021+
expect(presented.find((entry) => entry.type === "activity-group")).toMatchObject({
1022+
activities: [{ status: "failure", live: false, groupStandIn: { label: "vp check" } }],
10261023
});
10271024
});
10281025

@@ -1086,7 +1083,7 @@ describe("buildThreadFeed", () => {
10861083
).toEqual([
10871084
"user:launch",
10881085
"fold:Worked for 8.0s",
1089-
"work-toggle",
1086+
"activity-group",
10901087
"assistant:launch-answer",
10911088
"user:resume",
10921089
"fold:Worked for 8.0s",
@@ -1110,7 +1107,7 @@ describe("buildThreadFeed", () => {
11101107
"fold:Worked for 8.0s",
11111108
"assistant:launch-answer",
11121109
"user:resume",
1113-
"work-toggle",
1110+
"activity-group",
11141111
]);
11151112
});
11161113

@@ -1193,10 +1190,9 @@ describe("buildThreadFeed", () => {
11931190
startedAt,
11941191
true,
11951192
);
1196-
expect(presented.find((entry) => entry.type === "work-toggle")).toMatchObject({
1197-
summary: "Running vp",
1198-
live: true,
1199-
shimmer: true,
1193+
expect(presented.find((entry) => entry.type === "activity-group")).toMatchObject({
1194+
id: "live-activity-row",
1195+
activities: [{ live: true, groupStandIn: { label: "Running vp" } }],
12001196
});
12011197
expect(presented.some((entry) => entry.type === "thinking")).toBe(false);
12021198
});
@@ -1334,6 +1330,112 @@ describe("buildThreadFeed", () => {
13341330
});
13351331
});
13361332

1333+
describe("a lone call", () => {
1334+
const wait = (overrides: Partial<OrchestrationV2TurnItem> = {}) =>
1335+
({
1336+
...base("wait", "2026-06-20T00:00:02.000Z", 1),
1337+
type: "dynamic_tool",
1338+
toolName: "t3-code.t3_thread_wait",
1339+
input: { threadId: "thread-child", timeoutMs: 50_000 },
1340+
output: { threadId: "thread-child", status: "timeout" },
1341+
...overrides,
1342+
}) as OrchestrationV2TurnItem;
1343+
const read = (overrides: Partial<OrchestrationV2TurnItem> = {}) =>
1344+
({
1345+
...base("read", "2026-06-20T00:00:03.000Z", 2),
1346+
type: "dynamic_tool",
1347+
toolName: "t3-code.t3_thread_read",
1348+
input: { threadId: "thread-child" },
1349+
output: { messages: [] },
1350+
...overrides,
1351+
}) as OrchestrationV2TurnItem;
1352+
const running = { status: "running", completedAt: null, output: null } as const;
1353+
const startedAt = "2026-06-20T00:00:01.000Z";
1354+
const liveRows = (items: ReadonlyArray<OrchestrationV2TurnItem>, groupIds: string[] = []) =>
1355+
deriveThreadFeedPresentation(
1356+
buildThreadFeed(items.map((item, position) => projected(item, position))),
1357+
{ runId, status: "running", startedAt, completedAt: null },
1358+
new Set(),
1359+
new Set(groupIds),
1360+
startedAt,
1361+
);
1362+
const standIn = (rows: ReadonlyArray<ThreadFeedEntry>) => {
1363+
const row = rows.find((entry) => entry.type === "activity-group");
1364+
if (row?.type !== "activity-group") throw new Error("Expected the call's own row");
1365+
return row.activities[0]?.groupStandIn;
1366+
};
1367+
1368+
it("is its own row, with no group header to open first", () => {
1369+
// The second call never finished, so only one call is visible.
1370+
for (const items of [[wait()], [wait(), read(running)]]) {
1371+
const feed = buildThreadFeed(
1372+
[userMessage(), ...items, assistantMessage("2026-06-20T00:00:04.000Z")].map(
1373+
(item, position) => projected(item, position),
1374+
),
1375+
);
1376+
const rows = deriveThreadFeedPresentation(feed, null, new Set([runId]));
1377+
expect(rows.map((entry) => entry.type)).toEqual([
1378+
"message",
1379+
"run-fold",
1380+
"activity-group",
1381+
"message",
1382+
]);
1383+
expect(rows[2]).toMatchObject({
1384+
activities: [{ canExpand: true, groupStandIn: { label: "Waited for a T3 thread" } }],
1385+
});
1386+
expect(rows[2]).not.toMatchObject({ activities: [{ groupedToolDetail: true }] });
1387+
// The group's own disclosure adds nothing while the call is alone.
1388+
expect(
1389+
deriveThreadFeedPresentation(
1390+
feed,
1391+
null,
1392+
new Set([runId]),
1393+
new Set([standIn(rows)!.groupId]),
1394+
).map((entry) => entry.id),
1395+
).toEqual(rows.map((entry) => entry.id));
1396+
}
1397+
});
1398+
1399+
it("offers no disclosure when it has nothing to show", () => {
1400+
const rows = deriveThreadFeedPresentation(
1401+
buildThreadFeed([projected(wait({ toolName: "example", input: {}, output: null }), 0)]),
1402+
null,
1403+
new Set([runId]),
1404+
);
1405+
expect(rows.map((entry) => entry.type)).toEqual(["run-fold", "activity-group"]);
1406+
expect(rows[1]).toMatchObject({ activities: [{ canExpand: false }] });
1407+
});
1408+
1409+
it("holds the live slot until a second call makes it a group", () => {
1410+
for (const item of [wait(running), wait()]) {
1411+
const rows = liveRows([item]);
1412+
expect(rows.map((entry) => entry.type)).toEqual(["activity-group"]);
1413+
expect(rows[0]).toMatchObject({
1414+
id: "live-activity-row",
1415+
activities: [{ live: true, groupStandIn: { label: "Waiting for a T3 thread" } }],
1416+
});
1417+
}
1418+
1419+
const groupId = standIn(liveRows([wait()]))!.groupId;
1420+
const grouped = liveRows([wait(), read(running)], [groupId]);
1421+
expect(grouped.map((entry) => entry.type)).toEqual(["work-toggle", "activity-group"]);
1422+
expect(grouped[0]).toMatchObject({
1423+
id: "live-activity-row",
1424+
groupId,
1425+
hiddenCount: 2,
1426+
expanded: true,
1427+
summary: "Reading a T3 thread",
1428+
});
1429+
expect(grouped[1]).toMatchObject({
1430+
activities: [
1431+
{ groupedToolDetail: true, live: false },
1432+
{ groupedToolDetail: true, live: true },
1433+
],
1434+
});
1435+
expect(standIn(grouped)).toBeUndefined();
1436+
});
1437+
});
1438+
13371439
it("retains Claude Read image previews without tool output", () => {
13381440
const item = {
13391441
...base("image-read", "2026-06-20T00:00:04.000Z", 3),
@@ -1702,11 +1804,11 @@ describe("retained v2 feed presentation", () => {
17021804
});
17031805

17041806
it.each([
1705-
["failed", "Failed to click in the preview browser", true],
1706-
["cancelled", "Stopped clicking in the preview browser", false],
1807+
["failed", "Failed to click in the preview browser", "failure"],
1808+
["cancelled", "Stopped clicking in the preview browser", "neutral"],
17071809
] as const)(
17081810
"keeps %s calls terminal while the parent run remains live",
1709-
(status, summary, hasFailure) => {
1811+
(status, label, activityStatus) => {
17101812
const feed = buildThreadFeed([
17111813
projected(
17121814
{
@@ -1727,7 +1829,11 @@ describe("retained v2 feed presentation", () => {
17271829
new Set(),
17281830
"2026-06-20T00:00:01.000Z",
17291831
);
1730-
expect(rows[0]).toMatchObject({ type: "work-toggle", summary, hasFailure, shimmer: false });
1832+
expect(rows[0]).toMatchObject({
1833+
type: "activity-group",
1834+
activities: [{ status: activityStatus, live: false, groupStandIn: { label } }],
1835+
});
1836+
expect(rows.at(-1)?.type).toBe("thinking");
17311837
},
17321838
);
17331839

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ export interface ThreadFeedActivity {
107107
readonly workEntry: WorkLogPresentationEntry;
108108
readonly groupedToolDetail?: boolean;
109109
readonly live?: boolean;
110+
/**
111+
* Set on a lone call shown in place of its group header. Carries the header's
112+
* label and the group that takes over once a second call joins it.
113+
*/
114+
readonly groupStandIn?: { readonly groupId: string; readonly label: string };
110115
readonly projectedItem: OrchestrationV2ProjectedTurnItem;
111116
}
112117

@@ -1265,7 +1270,7 @@ export function deriveThreadFeedPresentation(
12651270
activeWorkStartedAt !== null &&
12661271
!result.some(
12671272
(row) =>
1268-
(row.type === "work-toggle" && row.shimmer) ||
1273+
row.id === LIVE_ACTIVITY_ROW_ID ||
12691274
(row.type === "activity-group" &&
12701275
isContextCompactionActivityGroup(row) &&
12711276
row.runId === activeRunId &&
@@ -1454,6 +1459,23 @@ function appendToolGroupRows(
14541459
: singleActivity !== null && !singleActivity.toolLike
14551460
? singleActivity.workEntry.label
14561461
: groupSummary.summary;
1462+
const id = shimmer ? LIVE_ACTIVITY_ROW_ID : `${live ? "work-live" : "work-toggle"}:${groupId}`;
1463+
// A lone call needs no header. Its own row takes the header's place, label
1464+
// and identity, and discloses its details directly. A lone thought keeps the
1465+
// header, whose expansion already shows the text itself.
1466+
if (singleActivity !== null && singleActivity.workEntry.itemType !== "reasoning") {
1467+
result.push({
1468+
type: "activity-group",
1469+
id,
1470+
createdAt: singleActivity.createdAt,
1471+
runId: singleActivity.runId,
1472+
activities: [{ ...singleActivity, live: shimmer, groupStandIn: { groupId, label: summary } }],
1473+
// Like the header, the row has no trailing margin, so the Thinking
1474+
// fallback and a growing group swap in without shifting the feed.
1475+
continuesWorkLog: true,
1476+
});
1477+
return;
1478+
}
14571479
const primarySourceActivity = activities.find(
14581480
(activity) => activity.workEntry.toolSource !== undefined,
14591481
);
@@ -1477,14 +1499,10 @@ function appendToolGroupRows(
14771499
.toolIcon;
14781500
const summaryToolIcon = live
14791501
? resolveWorkEntryToolPresentation(latestActivity.workEntry)?.icon
1480-
: singleActivity !== null &&
1481-
singleActivity.toolLike &&
1482-
toolGroupAction(singleActivity.workEntry) !== "edit"
1483-
? resolveWorkEntryToolPresentation(singleActivity.workEntry, "completed")?.icon
1484-
: undefined;
1502+
: undefined;
14851503
result.push({
14861504
type: "work-toggle",
1487-
id: shimmer ? LIVE_ACTIVITY_ROW_ID : `${live ? "work-live" : "work-toggle"}:${groupId}`,
1505+
id,
14881506
createdAt: sourceGroup.createdAt,
14891507
runId: sourceGroup.runId,
14901508
groupId,

0 commit comments

Comments
 (0)