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 plans and fold settled progress notes (#21393)
maria committed
Oct 21, 2026 at 00:04 UTC
77e4f561f58b8539f0e37deb32eb2ba56912a140
5 files changed
+209
-30
apps/mobile/src/features/threads/ProposedPlanCard.tsx
new
+85
@@ -0,0 +1,85 @@
1
+import { useAtomValue } from "@effect/atom-react";
2
+import {
3
+ isAtomCommandInterrupted,
4
+ squashAtomCommandFailure,
5
+} from "@t3tools/client-runtime/state/runtime";
6
+import type { EnvironmentId } from "@t3tools/contracts";
7
+import { proposedPlanTitle, stripDisplayedPlanMarkdown } from "@t3tools/shared/proposedPlanText";
8
+import { useRef, useState, type ReactNode } from "react";
9
+import { View } from "react-native";
10
+
11
+import { AppText as Text } from "../../components/ui/AppText";
12
+import { Button } from "../../components/ui/Button";
13
+import * as Dialog from "../../components/ui/Dialog";
14
+import { projectEnvironment } from "../../state/projects";
15
+import { useAtomCommand } from "../../state/use-atom-command";
16
+import { CopyTextButton } from "./CopyTextButton";
17
+
18
+export function ProposedPlanCard(props: {
19
+ readonly environmentId: EnvironmentId;
20
+ readonly workspaceRoot: string | null | undefined;
21
+ readonly markdown: string;
22
+ readonly renderMarkdown: (text: string) => ReactNode;
23
+}) {
24
+ const canWrite = useAtomValue(projectEnvironment.writeFile.permissionAtom(props.environmentId));
25
+ const writeFile = useAtomCommand(projectEnvironment.writeFile, { reportFailure: false });
26
+ const inFlight = useRef(false);
27
+ const [saving, setSaving] = useState(false);
28
+ const [lastPath, setLastPath] = useState("plan.md");
29
+ const contents = `${props.markdown.trimEnd()}\n`;
30
+
31
+ const save = async (path: string) => {
32
+ const relativePath = path.trim();
33
+ if (!canWrite || !props.workspaceRoot || inFlight.current) return;
34
+ if (!relativePath) {
35
+ Dialog.alert("Enter a workspace path");
36
+ return;
37
+ }
38
+ inFlight.current = true;
39
+ setSaving(true);
40
+ setLastPath(relativePath);
41
+ const result = await writeFile({
42
+ environmentId: props.environmentId,
43
+ input: { cwd: props.workspaceRoot, relativePath, contents },
44
+ }).finally(() => {
45
+ inFlight.current = false;
46
+ setSaving(false);
47
+ });
48
+ if (result._tag === "Success") {
49
+ Dialog.alert("Plan saved to workspace", result.value.relativePath);
50
+ } else if (!isAtomCommandInterrupted(result)) {
51
+ const error = squashAtomCommandFailure(result);
52
+ Dialog.alert("Could not save plan", error instanceof Error ? error.message : String(error));
53
+ }
54
+ };
55
+
56
+ return (
57
+ <View className="mb-3 gap-3 rounded-[20px] border border-border bg-card-alt p-4">
58
+ <View className="flex-row items-center gap-2">
59
+ <Text accessibilityRole="header" className="flex-1 font-t3-bold text-base text-foreground">
60
+ {proposedPlanTitle(props.markdown) ?? "Proposed plan"}
61
+ </Text>
62
+ <CopyTextButton accessibilityLabel="Copy plan" text={contents} />
63
+ </View>
64
+ {props.renderMarkdown(stripDisplayedPlanMarkdown(props.markdown))}
65
+ <View className="flex-row">
66
+ <Button
67
+ label={saving ? "Saving..." : "Save to workspace"}
68
+ tone="secondary"
69
+ disabled={!canWrite || !props.workspaceRoot || saving}
70
+ onPress={() =>
71
+ Dialog.prompt({
72
+ title: "Save plan to workspace",
73
+ // The write replaces an existing file, and the RPC has no create-only mode.
74
+ message:
75
+ "Enter a path relative to the thread's workspace. A file already at that path is replaced.",
76
+ initialValue: lastPath,
77
+ confirmText: "Save",
78
+ onConfirm: (path) => void save(path),
79
+ })
80
+ }
81
+ />
82
+ </View>
83
+ </View>
84
+ );
85
+}
apps/mobile/src/features/threads/ThreadFeed.tsx
+1
@@ -1445,6 +1445,7 @@ function renderFeedEntry(
1445
activities={entry.activities}
1446
continuesWorkLog={entry.continuesWorkLog}
1447
environmentId={props.environmentId}
1448
+ workspaceRoot={props.workspaceRoot}
1449
anchorKey={entry.id}
1450
copiedRowId={props.copiedRowId}
1451
expandedRows={props.expandedWorkRows}
apps/mobile/src/features/threads/thread-work-log.tsx
+14
@@ -1,6 +1,7 @@
1
import { Button } from "../../components/ui/Button";
2
import { SubagentStatusDot } from "./SubagentStatusDot";
3
import { ThreadSubagentGroup } from "./thread-subagent-group";
4
+import { ProposedPlanCard } from "./ProposedPlanCard";
5
import {
6
WorkLogLabel,
7
WorkLogBlock,
@@ -483,6 +484,7 @@ interface ThreadWorkLogProps {
484
readonly activities: ReadonlyArray<ThreadFeedActivity>;
485
readonly anchorKey: string;
486
readonly environmentId: EnvironmentId;
487
+ readonly workspaceRoot?: string | null | undefined;
488
readonly copiedRowId: string | null;
489
readonly expandedRows: Readonly<Record<string, boolean>>;
490
readonly rowSizing: ReturnType<typeof deriveThreadWorkLogSizing>;
@@ -521,6 +523,18 @@ export function ThreadWorkLog(props: ThreadWorkLogProps) {
523
return null;
524
}
525
526
+ const plan = props.activities[0]?.projectedItem.item;
527
+ if (plan?.type === "proposed_plan") {
528
+ return (
529
+ <ProposedPlanCard
530
+ environmentId={props.environmentId}
531
+ workspaceRoot={props.workspaceRoot}
532
+ markdown={plan.markdown}
533
+ renderMarkdown={props.renderReasoning}
534
+ />
535
+ );
536
+ }
537
+
538
if (props.activities[0]?.projectedItem.item.type === "subagent") {
539
return <ThreadSubagentGroup {...props} />;
540
}
apps/mobile/src/lib/threadActivity.test.ts
+91
-13
@@ -60,7 +60,26 @@ it("keeps historical plan detail accessible from its paged turn item", () => {
60
entry.type === "activity-group" ? entry.activities : [],
61
)[0];
62
expect(activity?.detail).toBe("Full historical plan text");
63
- expect(activity?.getFullDetail()).toContain("Full historical plan text");
63
+ expect(activity?.getFullDetail()).toBe("Full historical plan text");
64
+ expect(activity?.getCopyText()).toBe("Full historical plan text\n");
65
+ expect(activity?.prominent).toBe(true);
66
+ const presented = deriveThreadFeedPresentation(
67
+ buildThreadFeed([
68
+ projected(userMessage(), 0),
69
+ projected(command(), 1),
70
+ projected(item, 2),
71
+ projected(assistantMessage(), 3),
72
+ ]),
73
+ null,
74
+ new Set(),
75
+ );
76
+ expect(presented.map((entry) => entry.type)).toEqual([
77
+ "message",
78
+ "run-fold",
79
+ "activity-group",
80
+ "message",
81
+ ]);
82
+ expect(presented[2]).toMatchObject({ activities: [{ projectedItem: { item } }] });
83
});
84
85
it("shows only the structured path in expanded mobile read details", () => {
@@ -245,6 +264,56 @@ describe("buildThreadFeed", () => {
264
expect(buildThreadFeed([projected(reply, 0)])[0]?.type).toBe("message");
265
});
266
267
+ it.each([false, true])(
268
+ "keeps answered questions outside settled work (attachments only: %s)",
269
+ (attachmentsOnly) => {
270
+ const requestId = RuntimeRequestId.make("answered-question");
271
+ const question: OrchestrationV2TurnItem = {
272
+ ...base("answered-question", "2026-06-20T00:00:02.500Z", 2),
273
+ type: "user_input_request",
274
+ requestId,
275
+ questions: [],
276
+ questionAnswer: {
277
+ requestId,
278
+ questionTextById: { color: "Which color?" },
279
+ answers: { color: attachmentsOnly ? "" : "Blue" },
280
+ attachmentsByQuestionId: attachmentsOnly
281
+ ? {
282
+ color: [
283
+ {
284
+ type: "file",
285
+ id: "color-file",
286
+ name: "color.txt",
287
+ mimeType: "text/plain",
288
+ sizeBytes: 4,
289
+ },
290
+ ],
291
+ }
292
+ : {},
293
+ },
294
+ };
295
+ const feed = buildThreadFeed([
296
+ projected(userMessage(), 0),
297
+ projected(command(), 1),
298
+ projected(question, 2),
299
+ projected(assistantMessage(), 3),
300
+ ]);
301
+ const presented = deriveThreadFeedPresentation(feed, null, new Set());
302
+ expect(presented.map((entry) => entry.type)).toEqual([
303
+ "message",
304
+ "run-fold",
305
+ "activity-group",
306
+ "message",
307
+ ]);
308
+ expect(presented[2]).toMatchObject({
309
+ activities: [{ workEntry: { questionAnswer: question.questionAnswer } }],
310
+ });
311
+ expect(
312
+ deriveThreadFeedPresentation(feed, null, new Set([runId])).map((entry) => entry.type),
313
+ ).toEqual(["message", "run-fold", "activity-group", "activity-group", "message"]);
314
+ },
315
+ );
316
+
317
it("does not create a work group for a message and checkpoint", () => {
318
const checkpoint: OrchestrationV2TurnItem = {
319
...base("checkpoint", "2026-06-20T00:00:04.000Z", 3),
@@ -844,7 +913,7 @@ describe("buildThreadFeed", () => {
913
).toBe(false);
914
});
915
847
- it("keeps opening and final assistant messages around the first hidden work", () => {
916
+ it("folds progress messages while keeping the final assistant answer visible", () => {
917
const opening = {
918
...assistantMessage("2026-06-20T00:00:01.500Z"),
919
id: TurnItemId.make("item-opening"),
@@ -874,30 +943,40 @@ describe("buildThreadFeed", () => {
943
const collapsed = deriveThreadFeedPresentation(feed, latestRun, new Set());
944
expect(collapsed.map((entry) => entry.id)).toEqual([
945
"message-user",
877
- "message-opening",
946
"run-fold:run-1",
947
"message-assistant",
948
]);
881
- expect(collapsed[1]).toMatchObject({ message: { text: opening.text } });
882
- expect(collapsed[2]).toMatchObject({
949
+ expect(collapsed[1]).toMatchObject({
950
type: "run-fold",
884
- createdAt: "2026-06-20T00:00:02.000Z",
951
+ createdAt: "2026-06-20T00:00:01.500Z",
952
label: "Worked for 2.0s",
953
});
954
955
const expanded = deriveThreadFeedPresentation(feed, latestRun, new Set([runId]));
956
expect(expanded.map((entry) => entry.type)).toEqual([
890
- "message",
957
"message",
958
"run-fold",
959
+ "message",
960
"activity-group",
961
"message",
962
"message",
963
]);
964
expect(expanded[4]).toMatchObject({ message: { id: middle.messageId, text: middle.text } });
965
+
966
+ const active = deriveThreadFeedPresentation(
967
+ feed,
968
+ { ...latestRun, status: "running", completedAt: null },
969
+ new Set(),
970
+ );
971
+ expect(active.filter((entry) => entry.type === "message").map((entry) => entry.id)).toEqual([
972
+ "message-user",
973
+ "message-opening",
974
+ "message-middle",
975
+ "message-assistant",
976
+ ]);
977
});
978
900
- it("does not fold a response that only has opening and final messages", () => {
979
+ it("folds progress even when a response has no tool calls", () => {
980
const feed = buildThreadFeed([
981
projected(userMessage(), 0),
982
projected(
@@ -915,7 +994,7 @@ describe("buildThreadFeed", () => {
994
const presented = deriveThreadFeedPresentation(feed, null, new Set());
995
expect(presented.map((entry) => entry.id)).toEqual([
996
"message-user",
918
- "message-opening",
997
+ "run-fold:run-1",
998
"message-assistant",
999
]);
1000
});
@@ -1230,7 +1309,7 @@ describe("buildThreadFeed", () => {
1309
new Set(),
1310
"2026-06-20T00:01:00.000Z",
1311
)
1233
- .slice(0, 4)
1312
+ .slice(0, 3)
1313
.map((entry) => (entry.type === "message" ? entry.message.role : entry.type));
1314
1315
expect(
@@ -1239,7 +1318,7 @@ describe("buildThreadFeed", () => {
1318
id: TurnItemId.make("new-prompt"),
1319
messageId: MessageId.make("new-prompt"),
1320
}),
1242
- ).toEqual(["user", "assistant", "run-fold", "assistant"]);
1321
+ ).toEqual(["user", "run-fold", "assistant"]);
1322
expect(
1323
presented({
1324
...base("wake", "2026-06-20T00:01:00.000Z", 4),
@@ -1248,7 +1327,7 @@ describe("buildThreadFeed", () => {
1327
outcome: "completed",
1328
summary: "Background task finished",
1329
}),
1251
- ).toEqual(["user", "assistant", "run-fold", "assistant"]);
1330
+ ).toEqual(["user", "run-fold", "assistant"]);
1331
});
1332
1333
it("keeps a provider-native subagent's runless tool call live while it works", () => {
@@ -2247,7 +2326,6 @@ describe("subagent continued by a later turn", () => {
2326
"answer-1",
2327
"prompt-2",
2328
`run-fold:${run2}`,
2250
- "answer-2",
2329
"closing-2",
2330
]);
2331
});
apps/mobile/src/lib/threadActivity.ts
+18
-17
@@ -467,6 +467,7 @@ function itemIsProminent(item: OrchestrationV2TurnItem): boolean {
467
item.type === "fork" ||
468
item.type === "thread_created" ||
469
item.type === "system_notice" ||
470
+ item.type === "proposed_plan" ||
471
item.type === "secret_request"
472
);
473
}
@@ -823,19 +824,23 @@ function toFeedActivity(
824
? collectToolFilePaths(item)
825
: null;
826
const getFullDetail = memoizeValue(() =>
826
- readPaths
827
- ? readPaths.join("\n") || null
828
- : item.type === "notification"
829
- ? item.detail?.trim() || null
830
- : formatItemFullDetail(row, item),
827
+ item.type === "proposed_plan"
828
+ ? item.markdown
829
+ : readPaths
830
+ ? readPaths.join("\n") || null
831
+ : item.type === "notification"
832
+ ? item.detail?.trim() || null
833
+ : formatItemFullDetail(row, item),
834
);
835
const getCopyText = memoizeValue(() =>
833
- [summary, detail, getFullDetail()]
834
- .filter(
835
- (value, index, values): value is string =>
836
- Boolean(value) && values.indexOf(value) === index,
837
- )
838
- .join("\n"),
836
+ item.type === "proposed_plan"
837
+ ? `${item.markdown.trimEnd()}\n`
838
+ : [summary, detail, getFullDetail()]
839
+ .filter(
840
+ (value, index, values): value is string =>
841
+ Boolean(value) && values.indexOf(value) === index,
842
+ )
843
+ .join("\n"),
844
);
845
return {
846
id: `${row.visibility}:${row.sourceThreadId}:${row.sourceItemId}`,
@@ -955,6 +960,7 @@ function groupAdjacentActivities(
960
}
961
962
const isStandaloneActivity =
963
+ entry.activity.workEntry.questionAnswer !== undefined ||
964
entry.activity.projectedItem.item.type === "compaction" ||
965
entry.activity.projectedItem.item.type === "handoff" ||
966
entry.activity.projectedItem.item.type === "notification";
@@ -1059,7 +1065,6 @@ function deriveThreadFeedRunFolds(
1065
runlessWorkActive: boolean,
1066
feedFailedRunIds: ReadonlySet<RunId>,
1067
): ReadonlyMap<string, ThreadFeedRunFold> {
1062
- const firstAssistantMessageIdByRun = new Map<RunId, string>();
1068
const terminalAssistantMessageIdByRun = new Map<RunId, string>();
1069
const interruptedRunIds = new Set<RunId>();
1070
const failedRunIds = new Set(feedFailedRunIds);
@@ -1114,9 +1119,6 @@ function deriveThreadFeedRunFolds(
1119
}
1120
group.entries.push(entry);
1121
if (entry.type === "message") {
1117
- if (!firstAssistantMessageIdByRun.has(runId)) {
1118
- firstAssistantMessageIdByRun.set(runId, entry.id);
1119
- }
1122
terminalAssistantMessageIdByRun.set(runId, entry.id);
1123
}
1124
if (entry.type !== "activity-group") continue;
@@ -1146,13 +1148,11 @@ function deriveThreadFeedRunFolds(
1148
) {
1149
continue;
1150
}
1149
- const firstAssistantId = firstAssistantMessageIdByRun.get(runId);
1151
const terminalAssistantId = terminalAssistantMessageIdByRun.get(runId);
1152
const hiddenEntryIds = new Set(
1153
group.entries
1154
.filter(
1155
(entry) =>
1155
- entry.id !== firstAssistantId &&
1156
entry.id !== terminalAssistantId &&
1157
entry.type !== "html-render" &&
1158
entry.type !== "mcp-app" &&
@@ -1161,6 +1161,7 @@ function deriveThreadFeedRunFolds(
1161
entry.activities.some(
1162
(activity) =>
1163
activity.prominent ||
1164
+ activity.workEntry.questionAnswer !== undefined ||
1165
activity.projectedItem.item.type === "notification" ||
1166
activity.projectedItem.item.type === "handoff" ||
1167
// A child still working outlives its settled launching run;