The best way to control Claude Code, Codex and more from any computer or phone
fix(server): threads show the new branch's pull request after a branch switch (#32042)
Julius Marminge committed
Nov 14, 2026 at 18:47 UTC
2c5013d153f4775954a514e5a6612c2f1ec19791
2 files changed
+28
-1
apps/server/src/orchestration-v2/Orchestrator.ts
+2
-1
@@ -4325,7 +4325,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
4325
Option.isNone(project) ||
4326
project.value.deletedAt !== null ||
4327
project.value.workspaceRoot !== command.expected.workspaceRoot ||
4328
- currentSequence > command.snapshotSequence ||
4328
+ // A replacement rewrites pullRequests, which the expected fields do not capture.
4329
+ (command.linkedPullRequest !== undefined && currentSequence > command.snapshotSequence) ||
4330
thread.projectId !== command.projectId ||
4331
thread.branch !== command.expected.branch ||
4332
thread.worktreePath !== command.expected.worktreePath ||
apps/server/src/orchestration-v2/runtimeLayer.test.ts
+26
@@ -3240,6 +3240,13 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
3240
.pipe(Effect.flip);
3241
assert.instanceOf(staleProjectWorkspace, Orchestrator.OrchestratorDispatchError);
3242
yield* moveProject(projectId, project.workspaceRoot, "2026-09-07T00:02:00.000Z");
3243
+ // An unrelated thread event during discovery must not drop the branch pull request.
3244
+ yield* orchestrator.dispatch({
3245
+ type: "thread.visit",
3246
+ commandId: CommandId.make("runtime-layer-lifecycle-visit-during-pr-sync"),
3247
+ threadId,
3248
+ visitedAt: "2026-09-07T00:02:30.000Z",
3249
+ });
3250
yield* orchestrator.dispatch({
3251
type: "thread.pull-request.sync",
3252
commandId: CommandId.make("runtime-layer-lifecycle-pr-sync"),
@@ -3277,6 +3284,25 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
3284
})
3285
.pipe(Effect.flip);
3286
assert.instanceOf(stalePullRequestSync, Orchestrator.OrchestratorDispatchError);
3287
+ const staleLinkedPullRequestReplacement = yield* orchestrator
3288
+ .dispatch({
3289
+ type: "thread.pull-request.sync",
3290
+ commandId: CommandId.make("runtime-layer-lifecycle-pr-sync-stale-replacement"),
3291
+ threadId,
3292
+ projectId,
3293
+ snapshotSequence: pullRequestSnapshot.snapshotSequence,
3294
+ expected: {
3295
+ workspaceRoot: "/workspace/project",
3296
+ branch: "feature/v2",
3297
+ worktreePath: "/tmp/t3-v2-worktree",
3298
+ linkedPullRequest: null,
3299
+ branchPullRequest: pullRequest,
3300
+ },
3301
+ branchPullRequest: pullRequest,
3302
+ linkedPullRequest: pullRequest,
3303
+ })
3304
+ .pipe(Effect.flip);
3305
+ assert.instanceOf(staleLinkedPullRequestReplacement, Orchestrator.OrchestratorDispatchError);
3306
yield* orchestrator.dispatch({
3307
type: "thread.runtime-mode.set",
3308
commandId: CommandId.make("runtime-layer-lifecycle-runtime"),