guardStaleTerminal
guardStaleTerminal(
git,owns):GitState
Defined in: src/pr-poller.ts:26
gh pr list --head <branch> matches by branch NAME only and --state all
includes history, so a prior, already-merged PR that reused this branch name
surfaces as a terminal hit even though the session opened no PR. Trust a
merged/closed PR only when its head commit is reachable from the session’s
branch tip (owns(headSha) — true/false/null when unknowable); otherwise it’s
a name collision, so drop it to “none” rather than flip the row to a false
MERGED. Open PRs are the inherently-current one and pass through untouched.
Pure + shared so the background poller and the on-demand GET endpoint guard
identically — the list overview and GitRail can’t disagree.
Parameters
Section titled “Parameters”(headSha) => boolean | null