Skip to content

Follow a branch to its newer pull request after the linked one settles - #6684

Merged
ymichael merged 1 commit into
mainfrom
bb/fix-incorrect-thread-association-for-pr6596-thr_su3h8dvui7
Oct 30, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fix-incorrect-thread-association-for-pr6596-thr_su3h8dvui7

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Since #6143, the GitHub PR Status plugin saves a link from each environment to its PR and re-reads that URL on later loads. It only looks up the branch again when the branch name changes. When a PR merged and the thread opened a second PR from the same branch, the environment stayed linked to the merged PR forever. For example, a thread whose branch carried merged #6596 and then open #6613 kept showing #6596. Before #6143 every load ran gh pr view on the current branch, which prefers an open PR.

What changed

  • plugins/github-pr-status/store.ts: adds isSettled(environmentId), which says whether the environment's linked PR is merged or closed. staleAfterMs now uses it.
  • plugins/github-pr-status/server.ts: prepareLoad looks up the branch (url: null) instead of reading the saved URL when the linked PR is settled, just as it already does after a branch change. The branch lookup prefers an open PR and otherwise returns the same settled PR, so this takes one GitHub request per load, not two.

There are no wire, CLI or SDK changes.

Performance, measured against GitHub on the affected branch: a settled link's reload goes from a URL read (~760 ms, 1 rate-limit point) to a branch read (~990 ms, 3 points). Settled PRs are never polled. They reload only when a viewer sees one over an hour old, when a CLI read finds one more than 10 s old, on push, or after a turn that ran gh. App viewers are served the cached row immediately and refreshed in the background.

How you verified

AGENT GENERATED

🤖 Generated with Claude Code

Since #6143 each environment keeps a saved link to its PR and re-reads that
URL, rediscovering only when the branch name changes. A thread that opened a
second PR from the same branch after its first one merged stayed on the
merged PR. Before #6143 every read ran gh pr view, which prefers an open PR.
A saved link to a merged or closed PR now loads by branch instead of by URL,
so the load switches to a newer PR when there is one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 741decd into main Oct 30, 2026
48 checks passed
@ymichael
ymichael deleted the bb/fix-incorrect-thread-association-for-pr6596-thr_su3h8dvui7 branch October 30, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant