@devries-cameron20 / t3code Mirror · read-only / commits / 8bbb85c902
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 22, 20:45 UTC

fix(mobile): show each turn's diffstat on its work row (#21392)

maria committed Oct 21, 2026 at 02:16 UTC 8bbb85c9023aebd63a2cc266e8d9a170a0a79d43
6 files changed +351 -66
apps/mobile/src/features/threads/ThreadFeed.tsx
+91 -23
@@ -26,6 +26,8 @@ import { scopeThreadRef } from "@t3tools/client-runtime/environment";
26 import type { HandoffEndpoints } from "@t3tools/client-runtime/handoff";
27 import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message";
28 import { canForkProjectedAssistantItem } from "@t3tools/client-runtime/state/thread-workflows";
29 +import type { ThreadCheckpointSummary } from "@t3tools/client-runtime/state/thread-checkpoints";
30 +import { formatDiffCount } from "@t3tools/client-runtime/diff-count";
31 import type { WorkflowOpening } from "@t3tools/client-runtime/state/subagentRuntime";
32 import {
33 AuthFilesystemReadScope,
@@ -153,6 +155,8 @@ import {
155 type MediaVideoPreviewSource,
156 } from "../../lib/videoPreviewSource";
157 import { CopyTextButton } from "./CopyTextButton";
158 +import { getReviewSectionIdForCheckpoint } from "../review/reviewModel";
159 +import { setReviewSelectedSectionId } from "../review/reviewState";
160 import { Menu } from "../../components/ui/Menu";
161 import { copyPromptLink } from "../prompt-links/prompt-link-actions";
162 import { parseReviewCommentMessageSegments } from "../review/reviewCommentSelection";
@@ -1002,6 +1006,7 @@ function renderFeedEntry(
1006 readonly onToggleWorkGroup: (groupId: string, anchorKey?: string) => void;
1007 readonly onToggleWorkRow: (rowId: string, anchorKey?: string, groupId?: string) => void;
1008 readonly onToggleTurnFold: (runId: RunId) => void;
1009 + readonly onOpenTurnDiff: (checkpoint: ThreadCheckpointSummary) => void;
1010 readonly onPressPreview: (source: FilePreviewSource) => void;
1011 readonly onPressVideo: (attachment: ChatFileAttachment, sourceIdentifier: string) => void;
1012 readonly markdownLinkHandlers: MarkdownLinkHandlers;
@@ -1028,29 +1033,38 @@ function renderFeedEntry(
1033
1034 if (entry.type === "run-fold") {
1035 return (
1031 - <Pressable
1032 - accessibilityRole="button"
1033 - accessibilityState={{ expanded: entry.expanded }}
1034 - onPress={() => props.onToggleTurnFold(entry.runId)}
1035 - hitSlop={4}
1036 - className="mb-1 min-h-11 flex-row items-center gap-2 border-b border-border-subtle px-2"
1037 - style={{
1038 - minHeight: Math.max(TURN_FOLD_HEIGHT - 3.5, props.workRowSizing.estimatedRowHeight),
1039 - }}
1040 - >
1041 - <Text
1042 - key={props.workRowSizing.textSizeKey}
1043 - className="font-t3-medium text-sm tabular-nums text-foreground-muted"
1036 + <View className="mb-1 flex-row items-center border-b border-border-subtle px-2">
1037 + <Pressable
1038 + accessibilityRole="button"
1039 + accessibilityState={{ expanded: entry.expanded }}
1040 + onPress={() => props.onToggleTurnFold(entry.runId)}
1041 + hitSlop={4}
1042 + className="min-h-11 min-w-0 flex-1 flex-row items-center gap-2"
1043 + style={{
1044 + minHeight: Math.max(TURN_FOLD_HEIGHT - 3.5, props.workRowSizing.estimatedRowHeight),
1045 + }}
1046 >
1045 - {entry.label}
1046 - </Text>
1047 - <ThreadDisclosureChevron
1048 - expanded={entry.expanded}
1049 - collapsedDirection="right"
1050 - size={15}
1051 - tintColor={iconSubtleColor}
1052 - />
1053 - </Pressable>
1047 + <Text
1048 + key={props.workRowSizing.textSizeKey}
1049 + numberOfLines={1}
1050 + className="shrink font-t3-medium text-sm tabular-nums text-foreground-muted"
1051 + >
1052 + {entry.label}
1053 + </Text>
1054 + <ThreadDisclosureChevron
1055 + expanded={entry.expanded}
1056 + collapsedDirection="right"
1057 + size={15}
1058 + tintColor={iconSubtleColor}
1059 + />
1060 + </Pressable>
1061 + {entry.checkpointSummary ? (
1062 + <TurnDiffStat
1063 + checkpoint={entry.checkpointSummary}
1064 + onOpenTurnDiff={props.onOpenTurnDiff}
1065 + />
1066 + ) : null}
1067 + </View>
1068 );
1069 }
1070
@@ -1102,6 +1116,14 @@ function renderFeedEntry(
1116 hasFailure={entry.hasFailure}
1117 shimmer={entry.shimmer}
1118 thought={entry.thought}
1119 + trailing={
1120 + entry.checkpointSummary ? (
1121 + <TurnDiffStat
1122 + checkpoint={entry.checkpointSummary}
1123 + onOpenTurnDiff={props.onOpenTurnDiff}
1124 + />
1125 + ) : null
1126 + }
1127 onToggle={() => props.onToggleWorkGroup(entry.groupId, entry.id)}
1128 />
1129 );
@@ -1425,6 +1447,12 @@ function renderFeedEntry(
1447 <MessageAttachmentUnknown key={attachment.id} name={attachment.name} />
1448 );
1449 })}
1450 + {showAssistantMeta && message.checkpointSummary ? (
1451 + <TurnDiffStat
1452 + checkpoint={message.checkpointSummary}
1453 + onOpenTurnDiff={props.onOpenTurnDiff}
1454 + />
1455 + ) : null}
1456 {showAssistantMeta ? (
1457 <View className="mt-1 flex-row items-center gap-1">
1458 <CopyTextButton
@@ -1475,6 +1503,32 @@ function renderFeedEntry(
1503 );
1504 }
1505
1506 +function TurnDiffStat(props: {
1507 + readonly checkpoint: ThreadCheckpointSummary;
1508 + readonly onOpenTurnDiff: (checkpoint: ThreadCheckpointSummary) => void;
1509 +}) {
1510 + const { files } = props.checkpoint;
1511 + const additions = files.reduce((total, file) => total + file.additions, 0);
1512 + const deletions = files.reduce((total, file) => total + file.deletions, 0);
1513 + const fileCountLabel = `${files.length} file${files.length === 1 ? "" : "s"} changed`;
1514 + return (
1515 + <Pressable
1516 + accessibilityRole="button"
1517 + accessibilityLabel={`Review ${fileCountLabel}, ${additions} additions, ${deletions} deletions`}
1518 + onPress={() => props.onOpenTurnDiff(props.checkpoint)}
1519 + className="min-h-11 shrink-0 flex-row items-center gap-2 px-2 active:bg-subtle"
1520 + >
1521 + <Text className="font-t3-medium text-xs tabular-nums text-adaptive-emerald-700-300">
1522 + +{formatDiffCount(additions)}
1523 + </Text>
1524 + <Text className="font-t3-medium text-xs tabular-nums text-adaptive-rose-700-300">
1525 + −{formatDiffCount(deletions)}
1526 + </Text>
1527 + <SymbolView name="chevron.right" size={12} tintColorClassName="accent-foreground-muted" />
1528 + </Pressable>
1529 + );
1530 +}
1531 +
1532 type UserMessageContentProps = {
1533 readonly text: string;
1534 readonly environmentId: EnvironmentId;
@@ -1687,6 +1741,19 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
1741 const duoColumns = useNativeWorkspaceColumnsSupported() && isDuoDevice(deviceType);
1742 const openPullRequest = useOpenPullRequest();
1743 const navigation = useNavigation();
1744 + const onOpenTurnDiff = useCallback(
1745 + (checkpoint: ThreadCheckpointSummary) => {
1746 + setReviewSelectedSectionId(
1747 + scopedThreadKey(props.environmentId, props.threadId),
1748 + getReviewSectionIdForCheckpoint(checkpoint),
1749 + );
1750 + navigation.navigate("ThreadReview", {
1751 + environmentId: props.environmentId,
1752 + threadId: props.threadId,
1753 + });
1754 + },
1755 + [navigation, props.environmentId, props.threadId],
1756 + );
1757 const { themeAppearance } = useAppearancePreferences();
1758 const copyFeedbackTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
1759 const disclosureSettleFrameRef = useRef<number | null>(null);
@@ -2469,7 +2536,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2536 if (entry.type === "html-render") {
2537 return htmlRenderRowHeight(htmlRenderFrameHeight(entry.render, contentWidth));
2538 }
2472 - if (workRowSizing.fixedRowHeight === undefined) {
2539 + if (workRowSizing.fixedRowHeight === undefined || entry.checkpointSummary) {
2540 return undefined;
2541 }
2542 switch (entry.type) {
@@ -2546,6 +2613,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2613 onToggleWorkGroup,
2614 onToggleWorkRow,
2615 onToggleTurnFold,
2616 + onOpenTurnDiff,
2617 onPressPreview,
2618 onPressVideo,
2619 markdownLinkHandlers,
apps/mobile/src/features/threads/thread-work-log.tsx
+46 -40
@@ -1303,6 +1303,7 @@ export function ThreadWorkGroupToggle(props: {
1303 readonly hasFailure: boolean;
1304 readonly shimmer: boolean;
1305 readonly thought?: string | undefined;
1306 + readonly trailing?: ReactNode;
1307 readonly onToggle: () => void;
1308 }) {
1309 const statusLabel = props.hasFailure ? `${props.summary}, tool call failed` : props.summary;
@@ -1335,49 +1336,54 @@ export function ThreadWorkGroupToggle(props: {
1336 </Text>
1337 </Pressable>
1338 ) : null}
1338 - <WorkLogPressable
1339 - accessibilityRole="button"
1340 - accessibilityState={{ expanded: props.expanded }}
1341 - accessibilityLabel={accessibilityLabel}
1342 - accessibilityHint={`Double tap to ${props.expanded ? "hide" : "show"} ${props.hiddenCount} tool ${props.hiddenCount === 1 ? "call" : "calls"}.`}
1343 - onPress={() => {
1344 - void Haptics.selectionAsync();
1345 - props.onToggle();
1346 - }}
1347 - rowSizing={props.rowSizing}
1348 - >
1349 - {props.shimmer ? (
1350 - <ShimmeringWorkContent
1351 - key={props.rowSizing.textSizeKey}
1352 - environmentId={props.environmentId}
1353 - icon={icon}
1354 - iconSubtleColor={props.iconSubtleColor}
1355 - label={props.summary}
1356 - showIcon
1357 - themeAppearance={props.themeAppearance}
1358 - toolIcon={props.toolIcon}
1359 - />
1360 - ) : (
1361 - <>
1362 - <WorkLogIconSlot>
1363 - <ToolActivityIconView
1339 + <View className="flex-row items-center">
1340 + <View className="min-w-0 flex-1">
1341 + <WorkLogPressable
1342 + accessibilityRole="button"
1343 + accessibilityState={{ expanded: props.expanded }}
1344 + accessibilityLabel={accessibilityLabel}
1345 + accessibilityHint={`Double tap to ${props.expanded ? "hide" : "show"} ${props.hiddenCount} tool ${props.hiddenCount === 1 ? "call" : "calls"}.`}
1346 + onPress={() => {
1347 + void Haptics.selectionAsync();
1348 + props.onToggle();
1349 + }}
1350 + rowSizing={props.rowSizing}
1351 + >
1352 + {props.shimmer ? (
1353 + <ShimmeringWorkContent
1354 + key={props.rowSizing.textSizeKey}
1355 environmentId={props.environmentId}
1365 - icon={props.toolIcon}
1366 - fallback={icon}
1367 - fallbackColor={props.iconSubtleColor}
1356 + icon={icon}
1357 + iconSubtleColor={props.iconSubtleColor}
1358 + label={props.summary}
1359 + showIcon
1360 themeAppearance={props.themeAppearance}
1361 + toolIcon={props.toolIcon}
1362 />
1370 - </WorkLogIconSlot>
1371 - <WorkLogLabel key={props.rowSizing.textSizeKey}>{props.summary}</WorkLogLabel>
1372 - </>
1373 - )}
1374 - <ThreadDisclosureChevron
1375 - expanded={props.expanded}
1376 - collapsedDirection="down"
1377 - size={11}
1378 - tintColor={props.iconSubtleColor}
1379 - />
1380 - </WorkLogPressable>
1363 + ) : (
1364 + <>
1365 + <WorkLogIconSlot>
1366 + <ToolActivityIconView
1367 + environmentId={props.environmentId}
1368 + icon={props.toolIcon}
1369 + fallback={icon}
1370 + fallbackColor={props.iconSubtleColor}
1371 + themeAppearance={props.themeAppearance}
1372 + />
1373 + </WorkLogIconSlot>
1374 + <WorkLogLabel key={props.rowSizing.textSizeKey}>{props.summary}</WorkLogLabel>
1375 + </>
1376 + )}
1377 + <ThreadDisclosureChevron
1378 + expanded={props.expanded}
1379 + collapsedDirection="down"
1380 + size={11}
1381 + tintColor={props.iconSubtleColor}
1382 + />
1383 + </WorkLogPressable>
1384 + </View>
1385 + {props.trailing}
1386 + </View>
1387 </WorkLogBlock>
1388 );
1389 }
apps/mobile/src/lib/threadActivity.test.ts
+124
@@ -1,5 +1,8 @@
1 import {
2 MessageId,
3 + CheckpointId,
4 + CheckpointRef,
5 + CheckpointScopeId,
6 RuntimeRequestId,
7 NodeId,
8 ProviderInstanceId,
@@ -14,6 +17,8 @@ import {
17 type OrchestrationV2ProjectedTurnItem,
18 type OrchestrationV2TurnItem,
19 } from "@t3tools/contracts";
20 +import { deriveThreadCheckpointSummaries } from "@t3tools/client-runtime/state/thread-checkpoints";
21 +import { getReviewSectionIdForCheckpoint } from "../features/review/reviewModel";
22 import * as DateTime from "effect/DateTime";
23 import { describe, expect, it } from "vite-plus/test";
24
@@ -211,6 +216,125 @@ describe("buildThreadFeed", () => {
216 },
217 );
218
219 + it.each([false, true])(
220 + "carries a late checkpoint to only the final answer without changing cached messages (cache: %s)",
221 + (cached) => {
222 + const cache = cached ? createThreadFeedCache() : undefined;
223 + const earlier = {
224 + ...assistantMessage(),
225 + id: TurnItemId.make("earlier-item"),
226 + messageId: MessageId.make("earlier-message"),
227 + text: "Working on the files",
228 + };
229 + const final = assistantMessage("2026-06-20T00:00:04.000Z");
230 + const rows = [projected(earlier, 0), projected(final, 1)];
231 + const before = buildThreadFeed(rows, { cache });
232 + const [summary] = deriveThreadCheckpointSummaries({
233 + messages: [earlier, final].map((message) => ({
234 + ...message,
235 + id: message.messageId,
236 + role: "assistant",
237 + createdBy: "agent",
238 + creationSource: "provider",
239 + attachments: [],
240 + createdAt: message.startedAt,
241 + })),
242 + checkpoints: [
243 + {
244 + id: CheckpointId.make("checkpoint-final"),
245 + threadId,
246 + scopeId: CheckpointScopeId.make("scope"),
247 + runId,
248 + nodeId: NodeId.make("node"),
249 + parentCheckpointId: null,
250 + ordinalWithinScope: 1,
251 + appRunOrdinal: 2,
252 + ref: CheckpointRef.make("checkpoint-ref"),
253 + status: "ready",
254 + capturedAt: final.updatedAt,
255 + files: [
256 + { path: "src/one.ts", kind: "modified", additions: 10, deletions: 2 },
257 + { path: "src/two.ts", kind: "added", additions: 5, deletions: 0 },
258 + ],
259 + },
260 + ],
261 + });
262 + expect(summary).toBeDefined();
263 + if (!summary) return;
264 + const after = buildThreadFeed(rows, { checkpointSummaries: [summary], cache });
265 + expect(after[0]).toBe(before[0]);
266 + expect(after[1]).toMatchObject({
267 + type: "message",
268 + message: { id: final.messageId, checkpointSummary: summary },
269 + });
270 + expect(before[1]).not.toHaveProperty("message.checkpointSummary");
271 + expect(getReviewSectionIdForCheckpoint(summary)).toBe("turn:2");
272 + const fallback = deriveThreadFeedPresentation(
273 + [after.at(-1)!],
274 + null,
275 + new Set(),
276 + new Set(),
277 + null,
278 + false,
279 + cache,
280 + );
281 + expect(fallback.at(-1)).toMatchObject({ message: { checkpointSummary: summary } });
282 + const workRows = [
283 + projected(userMessage(), 0),
284 + projected(command(), 1),
285 + projected({ ...command(), id: TurnItemId.make("second-command") }, 2),
286 + projected(final, 3),
287 + ];
288 + const workBefore = buildThreadFeed(workRows, { cache });
289 + deriveThreadFeedPresentation(workBefore, null, new Set(), new Set(), null, false, cache);
290 + const workAfter = buildThreadFeed(workRows, { checkpointSummaries: [summary], cache });
291 + for (const expanded of [new Set<RunId>(), new Set([runId])]) {
292 + const presented = deriveThreadFeedPresentation(
293 + workAfter,
294 + null,
295 + expanded,
296 + new Set(),
297 + null,
298 + false,
299 + cache,
300 + );
301 + expect(presented.find((entry) => entry.type === "run-fold")).toMatchObject({
302 + checkpointSummary: summary,
303 + });
304 + expect(presented.at(-1)).not.toHaveProperty("message.checkpointSummary");
305 + }
306 + const active = deriveThreadFeedPresentation(
307 + workAfter,
308 + {
309 + runId,
310 + status: "running",
311 + startedAt: "2026-06-20T00:00:00.000Z",
312 + completedAt: null,
313 + },
314 + new Set(),
315 + new Set(),
316 + null,
317 + false,
318 + cache,
319 + );
320 + expect(active.find((entry) => entry.type === "work-toggle")).toMatchObject({
321 + checkpointSummary: summary,
322 + });
323 + expect(active.at(-1)).not.toHaveProperty("message.checkpointSummary");
324 + expect(workBefore.at(-1)).not.toHaveProperty("message.checkpointSummary");
325 +
326 + for (const checkpoint of [
327 + { ...summary, files: [] },
328 + ...(["missing", "error", "stale"] as const).map((status) => ({ ...summary, status })),
329 + { ...summary, runId: RunId.make("another-run") },
330 + { ...summary, assistantMessageId: MessageId.make("unloaded-message") },
331 + ]) {
332 + expect(buildThreadFeed(rows, { checkpointSummaries: [checkpoint], cache })).toEqual(before);
333 + }
334 + expect(buildThreadFeed(rows, { cache })).toEqual(before);
335 + },
336 + );
337 +
338 it("omits cached tool output and patch bodies from expanded and copied activity", () => {
339 const rawOutput = "RAW_TOOL_OUTPUT";
340 const items: OrchestrationV2TurnItem[] = [
apps/mobile/src/lib/threadActivity.ts
+78 -2
@@ -4,6 +4,7 @@ import type {
4 ThreadUserInputQuestion,
5 } from "@t3tools/client-runtime/state/thread-requests";
6 import { turnItemIsWorkspacePreparation } from "@t3tools/client-runtime/state/turn-item-presentation";
7 +import type { ThreadCheckpointSummary } from "@t3tools/client-runtime/state/thread-checkpoints";
8 import { formatSubagentDisplayTitle } from "@t3tools/client-runtime/state/subagent-display";
9 import { isLiveSubagentTurnItem } from "@t3tools/client-runtime/state/subagentRuntime";
10 import { extractToolActivityPresentation } from "@t3tools/client-runtime/work-log/tool-presentation";
@@ -145,6 +146,7 @@ export interface ThreadFeedMessage {
146 readonly createdAt: string;
147 readonly updatedAt: string;
148 readonly projectedItem?: OrchestrationV2ProjectedTurnItem;
149 + readonly checkpointSummary?: ThreadCheckpointSummary;
150 }
151
152 export interface LocalThreadMessage {
@@ -191,7 +193,10 @@ type RawThreadFeedEntry =
193 readonly app: McpAppReference;
194 };
195
194 -export type ThreadFeedEntry = ThreadFeedEntryContent & { readonly continuesWorkLog?: boolean };
196 +export type ThreadFeedEntry = ThreadFeedEntryContent & {
197 + readonly continuesWorkLog?: boolean;
198 + readonly checkpointSummary?: ThreadCheckpointSummary;
199 +};
200
201 type ThreadFeedEntryContent =
202 | Extract<RawThreadFeedEntry, { type: "message" | "html-render" | "mcp-app" }>
@@ -1471,6 +1476,39 @@ export function deriveThreadFeedPresentation(
1476 ) {
1477 result.push(thinkingRow(activeWorkStartedAt, activeRunId));
1478 }
1479 + const checkpointByRunId = new Map<RunId, ThreadCheckpointSummary>();
1480 + for (const entry of sourceFeed) {
1481 + if (entry.type === "message" && entry.message.checkpointSummary) {
1482 + checkpointByRunId.set(entry.message.checkpointSummary.runId, entry.message.checkpointSummary);
1483 + }
1484 + }
1485 + const workRowByRunId = new Map<RunId, number>();
1486 + for (let index = tailStart; index < result.length; index += 1) {
1487 + const row = result[index]!;
1488 + if (
1489 + (row.type === "run-fold" || row.type === "work-toggle") &&
1490 + row.runId !== null &&
1491 + checkpointByRunId.has(row.runId) &&
1492 + (row.type === "run-fold" || !workRowByRunId.has(row.runId))
1493 + ) {
1494 + workRowByRunId.set(row.runId, index);
1495 + }
1496 + }
1497 + for (const [runId, index] of workRowByRunId) {
1498 + result[index] = { ...result[index]!, checkpointSummary: checkpointByRunId.get(runId)! };
1499 + }
1500 + for (let index = tailStart; index < result.length; index += 1) {
1501 + const row = result[index]!;
1502 + if (
1503 + row.type !== "message" ||
1504 + !row.message.checkpointSummary ||
1505 + !workRowByRunId.has(row.message.checkpointSummary.runId)
1506 + )
1507 + continue;
1508 + const message = { ...row.message };
1509 + delete message.checkpointSummary;
1510 + result[index] = { ...row, message };
1511 + }
1512 // Reused rows are final: the user message after them never continues a work log.
1513 for (let index = tailStart; index < result.length; index += 1) {
1514 const row = result[index]!;
@@ -1899,6 +1937,7 @@ interface ThreadFeedBuild {
1937 readonly rows: ReadonlyArray<OrchestrationV2ProjectedTurnItem>;
1938 readonly attempts: ReadonlyArray<OrchestrationV2RunAttempt> | undefined;
1939 readonly nodes: ReadonlyArray<OrchestrationV2ExecutionNode> | undefined;
1940 + readonly checkpointSummaries: ReadonlyArray<ThreadCheckpointSummary> | undefined;
1941 readonly foldedAnswerMessageIds: ReadonlySet<string>;
1942 readonly delegatedChildrenByRun: ReadonlyMap<RunId, ReadonlySet<string>>;
1943 readonly feed: ReadonlyArray<ThreadFeedEntry>;
@@ -1928,6 +1967,30 @@ function setsEqual<T>(left: ReadonlySet<T>, right: ReadonlySet<T>): boolean {
1967 return true;
1968 }
1969
1970 +// Summaries are re-derived whenever messages change, including streamed text,
1971 +// so a new array often holds the same checkpoints.
1972 +function checkpointSummariesEqual(
1973 + left: ReadonlyArray<ThreadCheckpointSummary> | undefined,
1974 + right: ReadonlyArray<ThreadCheckpointSummary> | undefined,
1975 +): boolean {
1976 + if (left === right) return true;
1977 + if (left === undefined || right === undefined || left.length !== right.length) return false;
1978 + return left.every((summary, index) => {
1979 + const other = right[index]!;
1980 + return (
1981 + summary.checkpointId === other.checkpointId &&
1982 + summary.scopeId === other.scopeId &&
1983 + summary.runId === other.runId &&
1984 + summary.checkpointTurnCount === other.checkpointTurnCount &&
1985 + summary.checkpointRef === other.checkpointRef &&
1986 + summary.completedAt === other.completedAt &&
1987 + summary.status === other.status &&
1988 + summary.files === other.files &&
1989 + summary.assistantMessageId === other.assistantMessageId
1990 + );
1991 + });
1992 +}
1993 +
1994 function setMapsEqual<K, V>(
1995 left: ReadonlyMap<K, ReadonlySet<V>>,
1996 right: ReadonlyMap<K, ReadonlySet<V>>,
@@ -1954,6 +2017,7 @@ export function buildThreadFeed(
2017 readonly anchoredMessages?: ReadonlyArray<LocalThreadMessage>;
2018 readonly attempts?: ReadonlyArray<OrchestrationV2RunAttempt>;
2019 readonly nodes?: ReadonlyArray<OrchestrationV2ExecutionNode>;
2020 + readonly checkpointSummaries?: ReadonlyArray<ThreadCheckpointSummary>;
2021 readonly cache?: ThreadFeedCache;
2022 },
2023 ): ThreadFeedEntry[] {
@@ -2000,6 +2064,7 @@ export function buildThreadFeed(
2064 anchoredMessages.length === 0 &&
2065 previous.attempts === options?.attempts &&
2066 previous.nodes === options?.nodes &&
2067 + checkpointSummariesEqual(previous.checkpointSummaries, options?.checkpointSummaries) &&
2068 setsEqual(previous.foldedAnswerMessageIds, foldedAnswerMessageIds) &&
2069 setMapsEqual(previous.delegatedChildrenByRun, delegatedChildrenByRun)
2070 ) {
@@ -2154,8 +2219,18 @@ export function buildThreadFeed(
2219 if (insertionIndex === -1) entries.push(entry);
2220 else entries.splice(insertionIndex, 0, entry);
2221 }
2222 + const checkpointByMessageId = new Map(
2223 + (options?.checkpointSummaries ?? [])
2224 + .filter((checkpoint) => checkpoint.status === "ready" && checkpoint.files.length > 0)
2225 + .map((checkpoint) => [checkpoint.assistantMessageId, checkpoint]),
2226 + );
2227 const grouped = groupAdjacentActivities(
2158 - entries,
2228 + entries.map((entry) => {
2229 + if (entry.type !== "message" || entry.message.role !== "assistant") return entry;
2230 + const checkpointSummary = checkpointByMessageId.get(entry.message.id);
2231 + if (!checkpointSummary || checkpointSummary.runId !== entry.message.runId) return entry;
2232 + return { ...entry, message: { ...entry.message, checkpointSummary } };
2233 + }),
2234 delegatedChildrenByRun,
2235 // Anchored messages shift entries away from their rows; such a build is not reused.
2236 anchoredMessages.length > 0
@@ -2175,6 +2250,7 @@ export function buildThreadFeed(
2250 rows: visibleTurnItems,
2251 attempts: options?.attempts,
2252 nodes: options?.nodes,
2253 + checkpointSummaries: options?.checkpointSummaries,
2254 foldedAnswerMessageIds,
2255 delegatedChildrenByRun,
2256 feed,
apps/mobile/src/state/thread-task-permissions.test.ts
+4 -1
@@ -108,7 +108,10 @@ vi.mock("./use-atom-command", () => ({ useAtomCommand: <A>(command: A) => comman
108 vi.mock("./threads", async () => {
109 const { Atom } = await import("effect/reactivity");
110 return {
111 - environmentThreadDetails: { queueWorkflowAtom: () => Atom.make(null) },
111 + environmentThreadDetails: {
112 + queueWorkflowAtom: () => Atom.make(null),
113 + checkpointSummariesAtom: () => Atom.make([]),
114 + },
115 threadEnvironment: {
116 respondToApproval: state.approve,
117 respondToUserInput: state.answer,
apps/mobile/src/state/use-thread-composer-state.ts
+8
@@ -4,6 +4,7 @@ import { readEnvironmentScope } from "./session";
4 import type { ComposerTextPaste } from "../native/T3ComposerEditor.types";
5 import { useAtomValue } from "@effect/atom-react";
6 import { threadRuntimeIsActive } from "@t3tools/client-runtime/state/shell";
7 +import type { ThreadCheckpointSummary } from "@t3tools/client-runtime/state/thread-checkpoints";
8 import { resolvePendingHandoff } from "@t3tools/client-runtime/handoff";
9 import {
10 deriveProviderSubagentStatus,
@@ -117,6 +118,7 @@ import { useAtomCommand } from "./use-atom-command";
118 const EMPTY_QUEUE_WORKFLOW_ATOM = Atom.make<null>(null).pipe(
119 Atom.withLabel("mobile-thread-queue-workflow:empty"),
120 );
121 +const EMPTY_CHECKPOINT_SUMMARIES_ATOM = Atom.make<ReadonlyArray<ThreadCheckpointSummary>>([]);
122
123 export function appendReviewCommentToDraft(input: {
124 readonly environmentId: EnvironmentId;
@@ -240,6 +242,11 @@ export function useThreadComposerState() {
242 const selectedThreadMessages = selectedThreadProjection?.projection.messages;
243 const selectedThreadAttempts = selectedThreadProjection?.projection.attempts;
244 const selectedThreadNodes = selectedThreadProjection?.projection.nodes;
245 + const checkpointSummaries = useAtomValue(
246 + selectedThreadDetailRef === null
247 + ? EMPTY_CHECKPOINT_SUMMARIES_ATOM
248 + : environmentThreadDetails.checkpointSummariesAtom(selectedThreadDetailRef),
249 + );
250 // A thread whose creation has not delivered its turn yet: the prompt only
251 // exists in the outbox, so it is appended to whatever the server has. The
252 // detail is usually present but empty during a worktree checkout, so this
@@ -256,6 +263,7 @@ export function useThreadComposerState() {
263 anchoredMessages: pendingCreation,
264 attempts: selectedThreadAttempts,
265 nodes: selectedThreadNodes,
266 + checkpointSummaries,
267 cache: feedCache,
268 });
269 const pendingAcknowledgments = acknowledgedMessages.filter(