Skip to content

Commit f7617ab

Browse files
Gourav224claude
andcommitted
fix(server): look up the PR for a branch the agent just renamed in the same turn
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 4099f5f commit f7617ab

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎apps/server/src/orchestration-v2/RunFinalizationService.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ it.effect.each(
177177
const threadId = ThreadId.make("thread-branch-drift");
178178
const runId = RunId.make("run-branch-drift");
179179
const scopeId = CheckpointScopeId.make("scope-branch-drift");
180+
let refreshes = 0;
180181
const updates: Array<{
181182
branch: unknown;
182183
expectedBranch: unknown;
@@ -223,7 +224,11 @@ it.effect.each(
223224
}),
224225
}),
225226
Layer.succeed(RunFinalization.RunFinalizationObserver, {
226-
refresh: () => Effect.succeed(scenario.checkedOut),
227+
refresh: () =>
228+
Effect.sync(() => {
229+
refreshes += 1;
230+
return scenario.checkedOut;
231+
}),
227232
refreshAfterTurn: () => Effect.void,
228233
}),
229234
),
@@ -240,5 +245,7 @@ it.effect.each(
240245
expectedWorktreePath: "/repo",
241246
})),
242247
);
248+
// An adopted branch is refreshed again so its PR is found this turn.
249+
assert.equal(refreshes, 1 + scenario.expected.length);
243250
}).pipe(Effect.provide(layer));
244251
});

‎apps/server/src/orchestration-v2/RunFinalizationService.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ const make = Effect.gen(function* () {
9494
expectedBranch: thread.branch,
9595
expectedWorktreePath: input.cwd,
9696
});
97+
// The first refresh skipped the PR lookup because the thread still had the old branch.
98+
yield* observer.refresh({ cwd: input.cwd, threadId: thread.id, runId: input.runId });
9799
},
98100
(effect, input) =>
99101
effect.pipe(

0 commit comments

Comments
 (0)