@devries-cameron20 / t3code Mirror · read-only / commits / d015325b76
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 03:00 UTC

fix(mobile): avoid nested dropdowns for single tools (#15674)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Wout Stiens committed Oct 18, 2026 at 22:05 UTC d015325b7637c5923cbf3bde016495556277914e
4 files changed +168 -37
apps/mobile/src/features/threads/ThreadFeed.tsx
+15 -9
@@ -987,7 +987,7 @@ function renderFeedEntry(
987 readonly failedRunIds: ReadonlySet<RunId>;
988 readonly onCopyWorkRow: (rowId: string, value: string) => void;
989 readonly onToggleWorkGroup: (groupId: string, anchorKey?: string) => void;
990 - readonly onToggleWorkRow: (rowId: string, anchorKey?: string) => void;
990 + readonly onToggleWorkRow: (rowId: string, anchorKey?: string, groupId?: string) => void;
991 readonly onToggleTurnFold: (runId: RunId) => void;
992 readonly onPressPreview: (source: FilePreviewSource) => void;
993 readonly onPressVideo: (attachment: ChatFileAttachment, sourceIdentifier: string) => void;
@@ -2344,16 +2344,22 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2344 [suspendEndScrollMaintenanceForDisclosure],
2345 );
2346
2347 + // A lone call's row stands in for its group header, so both disclosures move
2348 + // together. Details the reader opened stay open when a second call turns the
2349 + // row into a group.
2350 const onToggleWorkRow = useCallback(
2348 - (rowId: string, anchorKey?: string) => {
2351 + (rowId: string, anchorKey?: string, groupId?: string) => {
2352 suspendEndScrollMaintenanceForDisclosure(anchorKey ?? null);
2350 - setInteractionState((current) => ({
2351 - ...current,
2352 - expandedWorkRows: {
2353 - ...current.expandedWorkRows,
2354 - [rowId]: !(current.expandedWorkRows[rowId] ?? false),
2355 - },
2356 - }));
2353 + setInteractionState((current) => {
2354 + const expanded = !(current.expandedWorkRows[rowId] ?? false);
2355 + return {
2356 + ...current,
2357 + expandedWorkRows: { ...current.expandedWorkRows, [rowId]: expanded },
2358 + ...(groupId === undefined
2359 + ? {}
2360 + : { expandedWorkGroups: { ...current.expandedWorkGroups, [groupId]: expanded } }),
2361 + };
2362 + });
2363 },
2364 [suspendEndScrollMaintenanceForDisclosure],
2365 );
apps/mobile/src/features/threads/thread-work-log.tsx
+5 -4
@@ -485,7 +485,8 @@ interface ThreadWorkLogProps {
485 readonly edgeFadeColor: string;
486 readonly themeAppearance: "light" | "dark";
487 readonly onCopyRow: (rowId: string, value: string) => void;
488 - readonly onToggleRow: (rowId: string, anchorKey: string) => void;
488 + /** `groupId` is the group a lone call stands in for; it opens and closes with the row. */
489 + readonly onToggleRow: (rowId: string, anchorKey: string, groupId?: string) => void;
490 readonly renderImage: MarkdownImageRenderer;
491 readonly renderReasoning: (text: string) => ReactNode;
492 readonly onPressPreview: (source: FilePreviewSource) => void;
@@ -1030,12 +1031,12 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
1031 </Text>
1032 );
1033 const toolPresentation = resolveWorkEntryToolPresentation(row.workEntry);
1033 - const previewText = workEntryRowLabel(row.workEntry);
1034 + const previewText = row.groupStandIn?.label ?? workEntryRowLabel(row.workEntry);
1035 const answerPreview = row.workEntry.questionAnswer
1036 ? getQuestionAnswerPreview(row.workEntry.questionAnswer)
1037 : null;
1038 const accessiblePreview = [previewText, answerPreview].filter(Boolean).join(": ");
1038 - const displayText = workEntryRowLabel(row.workEntry, expanded);
1039 + const displayText = row.groupStandIn?.label ?? workEntryRowLabel(row.workEntry, expanded);
1040 const isSystemNotice = row.projectedItem.item.type === "system_notice";
1041 const isUsageLimit =
1042 row.projectedItem.item.type === "error" &&
@@ -1080,7 +1081,7 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
1081 }
1082 if (canExpand) {
1083 void Haptics.selectionAsync();
1083 - props.onToggleRow(row.id, props.anchorKey);
1084 + props.onToggleRow(row.id, props.anchorKey, row.groupStandIn?.groupId);
1085 }
1086 }}
1087 onLongPress={() => props.onCopyRow(row.id, row.getCopyText())}
apps/mobile/src/lib/threadActivity.test.ts
+123 -17
@@ -887,7 +887,7 @@ describe("buildThreadFeed", () => {
887 "message",
888 "message",
889 "run-fold",
890 - "work-toggle",
890 + "activity-group",
891 "message",
892 "message",
893 ]);
@@ -1080,7 +1080,7 @@ describe("buildThreadFeed", () => {
1080 expect(expanded.map((entry) => entry.type)).toEqual([
1081 "message",
1082 "run-fold",
1083 - "work-toggle",
1083 + "activity-group",
1084 "message",
1085 ]);
1086 });
@@ -1103,11 +1103,8 @@ describe("buildThreadFeed", () => {
1103 );
1104
1105 expect(presented.some((entry) => entry.type === "run-fold")).toBe(false);
1106 - expect(presented.find((entry) => entry.type === "work-toggle")).toMatchObject({
1107 - summary: "vp check",
1108 - hiddenCount: 1,
1109 - hasFailure: true,
1110 - live: false,
1106 + expect(presented.find((entry) => entry.type === "activity-group")).toMatchObject({
1107 + activities: [{ status: "failure", live: false, groupStandIn: { label: "vp check" } }],
1108 });
1109 });
1110
@@ -1169,7 +1166,7 @@ describe("buildThreadFeed", () => {
1166 ).toEqual([
1167 "user:launch",
1168 "fold:Worked for 8.0s",
1172 - "work-toggle",
1169 + "activity-group",
1170 "assistant:launch-answer",
1171 "user:resume",
1172 "fold:Worked for 8.0s",
@@ -1192,7 +1189,7 @@ describe("buildThreadFeed", () => {
1189 "fold:Worked for 8.0s",
1190 "assistant:launch-answer",
1191 "user:resume",
1195 - "work-toggle",
1192 + "activity-group",
1193 ]);
1194 });
1195
@@ -1274,10 +1271,9 @@ describe("buildThreadFeed", () => {
1271 startedAt,
1272 true,
1273 );
1277 - expect(presented.find((entry) => entry.type === "work-toggle")).toMatchObject({
1278 - summary: "Running vp",
1279 - live: true,
1280 - shimmer: true,
1274 + expect(presented.find((entry) => entry.type === "activity-group")).toMatchObject({
1275 + id: "live-activity-row",
1276 + activities: [{ live: true, groupStandIn: { label: "Running vp" } }],
1277 });
1278 expect(presented.some((entry) => entry.type === "thinking")).toBe(false);
1279 });
@@ -1412,6 +1408,112 @@ describe("buildThreadFeed", () => {
1408 });
1409 });
1410
1411 + describe("a lone call", () => {
1412 + const wait = (overrides: Partial<OrchestrationV2TurnItem> = {}) =>
1413 + ({
1414 + ...base("wait", "2026-06-20T00:00:02.000Z", 1),
1415 + type: "dynamic_tool",
1416 + toolName: "t3-code.t3_thread_wait",
1417 + input: { threadId: "thread-child", timeoutMs: 50_000 },
1418 + output: { threadId: "thread-child", status: "timeout" },
1419 + ...overrides,
1420 + }) as OrchestrationV2TurnItem;
1421 + const read = (overrides: Partial<OrchestrationV2TurnItem> = {}) =>
1422 + ({
1423 + ...base("read", "2026-06-20T00:00:03.000Z", 2),
1424 + type: "dynamic_tool",
1425 + toolName: "t3-code.t3_thread_read",
1426 + input: { threadId: "thread-child" },
1427 + output: { messages: [] },
1428 + ...overrides,
1429 + }) as OrchestrationV2TurnItem;
1430 + const running = { status: "running", completedAt: null, output: null } as const;
1431 + const startedAt = "2026-06-20T00:00:01.000Z";
1432 + const liveRows = (items: ReadonlyArray<OrchestrationV2TurnItem>, groupIds: string[] = []) =>
1433 + deriveThreadFeedPresentation(
1434 + buildThreadFeed(items.map((item, position) => projected(item, position))),
1435 + { runId, status: "running", startedAt, completedAt: null },
1436 + new Set(),
1437 + new Set(groupIds),
1438 + startedAt,
1439 + );
1440 + const standIn = (rows: ReadonlyArray<ThreadFeedEntry>) => {
1441 + const row = rows.find((entry) => entry.type === "activity-group");
1442 + if (row?.type !== "activity-group") throw new Error("Expected the call's own row");
1443 + return row.activities[0]?.groupStandIn;
1444 + };
1445 +
1446 + it("is its own row, with no group header to open first", () => {
1447 + // The second call never finished, so only one call is visible.
1448 + for (const items of [[wait()], [wait(), read(running)]]) {
1449 + const feed = buildThreadFeed(
1450 + [userMessage(), ...items, assistantMessage("2026-06-20T00:00:04.000Z")].map(
1451 + (item, position) => projected(item, position),
1452 + ),
1453 + );
1454 + const rows = deriveThreadFeedPresentation(feed, null, new Set([runId]));
1455 + expect(rows.map((entry) => entry.type)).toEqual([
1456 + "message",
1457 + "run-fold",
1458 + "activity-group",
1459 + "message",
1460 + ]);
1461 + expect(rows[2]).toMatchObject({
1462 + activities: [{ canExpand: true, groupStandIn: { label: "Waited for a T3 thread" } }],
1463 + });
1464 + expect(rows[2]).not.toMatchObject({ activities: [{ groupedToolDetail: true }] });
1465 + // The group's own disclosure adds nothing while the call is alone.
1466 + expect(
1467 + deriveThreadFeedPresentation(
1468 + feed,
1469 + null,
1470 + new Set([runId]),
1471 + new Set([standIn(rows)!.groupId]),
1472 + ).map((entry) => entry.id),
1473 + ).toEqual(rows.map((entry) => entry.id));
1474 + }
1475 + });
1476 +
1477 + it("offers no disclosure when it has nothing to show", () => {
1478 + const rows = deriveThreadFeedPresentation(
1479 + buildThreadFeed([projected(wait({ toolName: "example", input: {}, output: null }), 0)]),
1480 + null,
1481 + new Set([runId]),
1482 + );
1483 + expect(rows.map((entry) => entry.type)).toEqual(["run-fold", "activity-group"]);
1484 + expect(rows[1]).toMatchObject({ activities: [{ canExpand: false }] });
1485 + });
1486 +
1487 + it("holds the live slot until a second call makes it a group", () => {
1488 + for (const item of [wait(running), wait()]) {
1489 + const rows = liveRows([item]);
1490 + expect(rows.map((entry) => entry.type)).toEqual(["activity-group"]);
1491 + expect(rows[0]).toMatchObject({
1492 + id: "live-activity-row",
1493 + activities: [{ live: true, groupStandIn: { label: "Waiting for a T3 thread" } }],
1494 + });
1495 + }
1496 +
1497 + const groupId = standIn(liveRows([wait()]))!.groupId;
1498 + const grouped = liveRows([wait(), read(running)], [groupId]);
1499 + expect(grouped.map((entry) => entry.type)).toEqual(["work-toggle", "activity-group"]);
1500 + expect(grouped[0]).toMatchObject({
1501 + id: "live-activity-row",
1502 + groupId,
1503 + hiddenCount: 2,
1504 + expanded: true,
1505 + summary: "Reading a T3 thread",
1506 + });
1507 + expect(grouped[1]).toMatchObject({
1508 + activities: [
1509 + { groupedToolDetail: true, live: false },
1510 + { groupedToolDetail: true, live: true },
1511 + ],
1512 + });
1513 + expect(standIn(grouped)).toBeUndefined();
1514 + });
1515 + });
1516 +
1517 it("retains Claude Read image previews without tool output", () => {
1518 const item = {
1519 ...base("image-read", "2026-06-20T00:00:04.000Z", 3),
@@ -1818,11 +1920,11 @@ describe("retained v2 feed presentation", () => {
1920 });
1921
1922 it.each([
1821 - ["failed", "Failed to click in the preview browser", true],
1822 - ["cancelled", "Stopped clicking in the preview browser", false],
1923 + ["failed", "Failed to click in the preview browser", "failure"],
1924 + ["cancelled", "Stopped clicking in the preview browser", "neutral"],
1925 ] as const)(
1926 "keeps %s calls terminal while the parent run remains live",
1825 - (status, summary, hasFailure) => {
1927 + (status, label, activityStatus) => {
1928 const feed = buildThreadFeed([
1929 projected(
1930 {
@@ -1843,7 +1945,11 @@ describe("retained v2 feed presentation", () => {
1945 new Set(),
1946 "2026-06-20T00:00:01.000Z",
1947 );
1846 - expect(rows[0]).toMatchObject({ type: "work-toggle", summary, hasFailure, shimmer: false });
1948 + expect(rows[0]).toMatchObject({
1949 + type: "activity-group",
1950 + activities: [{ status: activityStatus, live: false, groupStandIn: { label } }],
1951 + });
1952 + expect(rows.at(-1)?.type).toBe("thinking");
1953 },
1954 );
1955
apps/mobile/src/lib/threadActivity.ts
+25 -7
@@ -119,6 +119,11 @@ export interface ThreadFeedActivity {
119 readonly workEntry: WorkLogPresentationEntry;
120 readonly groupedToolDetail?: boolean;
121 readonly live?: boolean;
122 + /**
123 + * Set on a lone call shown in place of its group header. Carries the header's
124 + * label and the group that takes over once a second call joins it.
125 + */
126 + readonly groupStandIn?: { readonly groupId: string; readonly label: string };
127 readonly projectedItem: OrchestrationV2ProjectedTurnItem;
128 }
129
@@ -1340,7 +1345,7 @@ export function deriveThreadFeedPresentation(
1345 activeWorkStartedAt !== null &&
1346 !result.some(
1347 (row) =>
1343 - (row.type === "work-toggle" && row.shimmer) ||
1348 + row.id === LIVE_ACTIVITY_ROW_ID ||
1349 (row.type === "activity-group" &&
1350 isContextCompactionActivityGroup(row) &&
1351 row.runId === activeRunId &&
@@ -1535,6 +1540,23 @@ function appendToolGroupRows(
1540 : singleActivity !== null && !singleActivity.toolLike
1541 ? singleActivity.workEntry.label
1542 : groupSummary.summary;
1543 + const id = shimmer ? LIVE_ACTIVITY_ROW_ID : `${live ? "work-live" : "work-toggle"}:${groupId}`;
1544 + // A lone call needs no header. Its own row takes the header's place, label
1545 + // and identity, and discloses its details directly. A lone thought keeps the
1546 + // header, whose expansion already shows the text itself.
1547 + if (singleActivity !== null && singleActivity.workEntry.itemType !== "reasoning") {
1548 + result.push({
1549 + type: "activity-group",
1550 + id,
1551 + createdAt: singleActivity.createdAt,
1552 + runId: singleActivity.runId,
1553 + activities: [{ ...singleActivity, live: shimmer, groupStandIn: { groupId, label: summary } }],
1554 + // Like the header, the row has no trailing margin, so the Thinking
1555 + // fallback and a growing group swap in without shifting the feed.
1556 + continuesWorkLog: true,
1557 + });
1558 + return;
1559 + }
1560 const primarySourceActivity = activities.find(
1561 (activity) => activity.workEntry.toolSource !== undefined,
1562 );
@@ -1558,14 +1580,10 @@ function appendToolGroupRows(
1580 .toolIcon;
1581 const summaryToolIcon = live
1582 ? resolveWorkEntryToolPresentation(latestActivity.workEntry)?.icon
1561 - : singleActivity !== null &&
1562 - singleActivity.toolLike &&
1563 - toolGroupAction(singleActivity.workEntry) !== "edit"
1564 - ? resolveWorkEntryToolPresentation(singleActivity.workEntry, "completed")?.icon
1565 - : undefined;
1583 + : undefined;
1584 result.push({
1585 type: "work-toggle",
1568 - id: shimmer ? LIVE_ACTIVITY_ROW_ID : `${live ? "work-live" : "work-toggle"}:${groupId}`,
1586 + id,
1587 createdAt: sourceGroup.createdAt,
1588 runId: sourceGroup.runId,
1589 groupId,