Fix stacked PR reviews to use PR base, not main - #59
Conversation
Compare baseRefOid..headRefOid for the diff and run codex in a detached head worktree so file reads match stacked branches. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Request baseRefOid/baseRefName from gh pr view, and only prepare a head worktree when cwd is the target repo. Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
||
| // Fetch the diff once, here in the runner — codex reviews it from the prompt with no network/gh of its own. | ||
| const read = getDiff(cfg, pr.number) | ||
| const read = getDiff(cfg, pr) |
There was a problem hiding this comment.
🔴 src/sweep/sweep.ts:121 · bug · conf 0.98
The diff now depends on baseRefOid, but dedup/failure state is still keyed only by headRefOid; when a stacked base advances without changing this PR's head, the sweep skips the changed compare entirely.
→ Fix: key the existing review marker and local attempt state by the base+head compare identity, not head alone.
| rmSync(dir, { recursive: true, force: true }) | ||
| exec('git', ['worktree', 'prune'], { cwd: repoDir }) | ||
| if ( | ||
| !exec('git', ['fetch', '-q', 'origin', pr.baseRefOid, pr.headRefOid], { cwd: repoDir }).ok || |
There was a problem hiding this comment.
🟠 src/sweep/worktree.ts:20 · footgun · conf 0.93
Default pool workers call git fetch concurrently against the same checkout, contending on shared fetch metadata such as FETCH_HEAD; one preparation can fail and throttle an otherwise valid PR.
→ Fix: pass Git's existing --no-write-fetch-head flag, or perform the fetches in the existing serial candidate-collection phase.
Summary
baseRefOid...headRefOid) instead ofgh pr diffagainst the default-branch checkout.~/.stupify/worktreesin Codex config during VM setup so sandbox reads work outside the main repo checkout.Test plan
bun run typecheckbun testMade with Cursor