TypeScript
fix(server): follow placeholder branches after checkout updates (#10441)
Yash Singh1e740e48a5f9
diff --git a/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts b/apps/server/src/orchestration/Layers/CheckpointReactor.test.tsindex 9e141600713..b88f7f012d4 100644--- a/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts+++ b/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts@@ -1002,23 +1002,22 @@ describe("CheckpointReactor", () => {expect(thread?.branch).toBe("t3code/renamed-by-agent");});- it("does not adopt a drifted checkout when the worktree is shared by another thread", async () => {+ it("follows a checkout from a saved placeholder branch and refreshes its pull request", async () => {const pullRequestRefreshCalls: string[] = [];const harness = await createHarness({seedFilesystemCheckpoints: false,- threadBranch: "t3code/original-branch",- localStatusRefName: "t3code/renamed-by-agent",- secondThreadSharingWorktree: true,+ threadBranch: "t3code/fd9cbe0e",+ localStatusRefName: "fix/mobile-tool-detail-expansion",pullRequestRefreshCalls,});harness.provider.emit({type: "turn.completed",- eventId: EventId.make("evt-turn-completed-branch-drift-shared"),+ eventId: EventId.make("evt-turn-completed-placeholder-drift"),provider: ProviderDriverKind.make("codex"),createdAt: "2026-01-01T00:00:00.000Z",threadId: ThreadId.make("thread-1"),- turnId: asTurnId("turn-branch-drift-shared"),+ turnId: asTurnId("turn-placeholder-drift"),payload: { state: "completed" },});@@ -1026,10 +1025,42 @@ describe("CheckpointReactor", () => {const snapshot = await harness.readModel();const thread = snapshot.threads.find((entry) => entry.id === ThreadId.make("thread-1"));- expect(thread?.branch).toBe("t3code/original-branch");- expect(pullRequestRefreshCalls).toEqual([]);+ expect(thread?.branch).toBe("fix/mobile-tool-detail-expansion");+ expect(thread?.worktreePath).toBe(harness.cwd);+ expect(pullRequestRefreshCalls).toEqual([harness.cwd]);});+ it.each(["t3code/original-branch", "t3code/fd9cbe0e"])(+ "does not adopt a drifted checkout from %s when the worktree is shared by another thread",+ async (threadBranch) => {+ const pullRequestRefreshCalls: string[] = [];+ const harness = await createHarness({+ seedFilesystemCheckpoints: false,+ threadBranch,+ localStatusRefName: "t3code/renamed-by-agent",+ secondThreadSharingWorktree: true,+ pullRequestRefreshCalls,+ });++ harness.provider.emit({+ type: "turn.completed",+ eventId: EventId.make("evt-turn-completed-branch-drift-shared"),+ provider: ProviderDriverKind.make("codex"),+ createdAt: "2026-01-01T00:00:00.000Z",+ threadId: ThreadId.make("thread-1"),+ turnId: asTurnId("turn-branch-drift-shared"),+ payload: { state: "completed" },+ });++ await harness.drain();++ const snapshot = await harness.readModel();+ const thread = snapshot.threads.find((entry) => entry.id === ThreadId.make("thread-1"));+ expect(thread?.branch).toBe(threadBranch);+ expect(pullRequestRefreshCalls).toEqual([]);+ },+ );+it("does not adopt a temporary placeholder checkout as the thread branch", async () => {const harness = await createHarness({seedFilesystemCheckpoints: false,diff --git a/apps/server/src/orchestration/Layers/CheckpointReactor.ts b/apps/server/src/orchestration/Layers/CheckpointReactor.tsindex eb77348180f..d4d6b940980 100644--- a/apps/server/src/orchestration/Layers/CheckpointReactor.ts+++ b/apps/server/src/orchestration/Layers/CheckpointReactor.ts@@ -563,8 +563,7 @@ const make = Effect.gen(function* () {thread.branch === null ||thread.branch === checkedOutBranch ||thread.worktreePath === null ||- thread.worktreePath !== input.cwd ||- isTemporaryWorktreeBranch(thread.branch)+ thread.worktreePath !== input.cwd) {return;}