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 21, 12:15 UTC
fix(client): avoid worktree setup flash after editing first message (#31738)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Amine Ilidrissi committed
Nov 15, 2026 at 12:04 UTC
eb8b1f5246a493d55962423ae4db8c053edd6b54
5 files changed
+19
-11
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+1
-1
@@ -859,7 +859,7 @@ function ThreadRouteContent(
859
selectedThread?.worktreePath != null ||
860
(selectedThreadCreation?.message.creation?.workspaceMode === "worktree" &&
861
selectedThreadCreation.outcome == null),
862
- turnStarted: setupTurnStartedAt !== null,
862
+ runs: selectedThreadDetail?.runs ?? [],
863
followUpSent:
864
composer.selectedThreadFeed.filter(
865
(entry) => entry.type === "message" && entry.message.role === "user",
apps/mobile/src/features/threads/use-worktree-setup.ts
+2
-2
@@ -9,7 +9,7 @@ export function useWorktreeSetup(input: {
9
environmentId: EnvironmentId | null;
10
threadId: ThreadId | null;
11
preparing: boolean;
12
- turnStarted: boolean;
12
+ runs: Parameters<typeof resolveVisibleWorktreeSetup>[0]["runs"];
13
followUpSent: boolean;
14
}) {
15
const key = JSON.stringify([input.environmentId, input.threadId]);
@@ -35,7 +35,7 @@ export function useWorktreeSetup(input: {
35
visible: resolveVisibleWorktreeSetup({
36
live: snapshot,
37
recorded: null,
38
- turnStarted: input.turnStarted,
38
+ runs: input.runs,
39
followUpSent: input.followUpSent,
40
}),
41
};
apps/mobile/src/features/threads/worktree-setup-state.test.ts
+12
-4
@@ -1,6 +1,7 @@
1
import { ThreadId, type WorktreeSetupSnapshot } from "@t3tools/contracts";
2
import { resolveVisibleWorktreeSetup } from "@t3tools/client-runtime/worktree-setup";
3
import { describe, expect, it } from "vite-plus/test";
4
+import * as DateTime from "effect/DateTime";
5
import { resolveWorktreeSetupSnapshot } from "./worktree-setup-state";
6
7
const threadId = ThreadId.make("setup-thread");
@@ -27,7 +28,7 @@ describe("mobile worktree setup handoff", () => {
28
resolveVisibleWorktreeSetup({
29
live: held,
30
recorded: null,
30
- turnStarted: false,
31
+ runs: [],
32
followUpSent: false,
33
}),
34
).toBe(done);
@@ -35,10 +36,17 @@ describe("mobile worktree setup handoff", () => {
36
resolveVisibleWorktreeSetup({
37
live: held,
38
recorded: null,
38
- turnStarted: true,
39
+ runs: [{ startedAt: DateTime.makeUnsafe(running.startedAt) }],
40
followUpSent: false,
41
}),
42
).toBeNull();
43
+ const afterFirstMessageEdit = {
44
+ live: held,
45
+ recorded: null,
46
+ followUpSent: false,
47
+ runs: [{ startedAt: DateTime.makeUnsafe(running.startedAt) }, { startedAt: null }],
48
+ };
49
+ expect(resolveVisibleWorktreeSetup(afterFirstMessageEdit)).toBeNull();
50
expect(resolveWorktreeSetupSnapshot(threadId, undefined, held)).toBe(done);
51
});
52
@@ -53,7 +61,7 @@ describe("mobile worktree setup handoff", () => {
61
resolveVisibleWorktreeSetup({
62
live: held,
63
recorded: null,
56
- turnStarted: false,
64
+ runs: [],
65
followUpSent: false,
66
}),
67
).toBe(settled);
@@ -61,7 +69,7 @@ describe("mobile worktree setup handoff", () => {
69
resolveVisibleWorktreeSetup({
70
live: held,
71
recorded: null,
64
- turnStarted: false,
72
+ runs: [],
73
followUpSent: true,
74
}),
75
).toBeNull();
apps/web/src/components/chat/useWorktreeSetup.ts
+1
-1
@@ -100,7 +100,7 @@ export function useWorktreeSetup(input: {
100
const worktreeSetup = resolveVisibleWorktreeSetup({
101
live: liveSnapshot,
102
recorded: null,
103
- turnStarted: activityRun?.startedAt != null,
103
+ runs: serverProjection?.runs ?? [],
104
followUpSent,
105
});
106
// After agent handoff, sends queue behind setup without awaiting its scripts.
packages/client-runtime/src/worktreeSetup.ts
+3
-3
@@ -1,9 +1,9 @@
1
-import type { WorktreeSetupSnapshot } from "@t3tools/contracts";
1
+import type { OrchestrationV2Run, WorktreeSetupSnapshot } from "@t3tools/contracts";
2
3
export function resolveVisibleWorktreeSetup(input: {
4
live: WorktreeSetupSnapshot | null;
5
recorded: WorktreeSetupSnapshot | null;
6
- turnStarted: boolean;
6
+ runs: ReadonlyArray<Pick<OrchestrationV2Run, "startedAt">>;
7
followUpSent: boolean;
8
}): WorktreeSetupSnapshot | null {
9
const snapshot =
@@ -14,7 +14,7 @@ export function resolveVisibleWorktreeSetup(input: {
14
if (snapshot.phase === "running") return snapshot;
15
if (input.followUpSent) return null;
16
if (snapshot.phase !== "done") return snapshot;
17
- if (!input.turnStarted) return snapshot;
17
+ if (!input.runs.some((run) => run.startedAt !== null)) return snapshot;
18
return snapshot.stages.some((stage) => stage.status === "failed") ? snapshot : null;
19
}
20