fix: retire the pull request badge when the merge lands#97
Merged
Conversation
The footer badge, the session cards and the sidebar's "Pull request" entry only looked the pull request up again when the checkout's HEAD moved or the window lost focus and got it back. A merge does neither — the commit lands on the base branch, on the remote — so merging from the Pulls screen emptied that screen while every badge around it went on reading "#N Open" until you clicked away to another window and back. The shared lookup now takes subscribers: invalidatePullRequests drops every cached answer and asks the badges to read again. Merging, opening a pull request and the header's reload button call it alongside the screen's own refresh. The check poll and the focus re-read stay the screen's alone — they change nothing the badges show.
# Conflicts: # CHANGELOG.md
This was referenced Jul 25, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Merging a pull request left every badge around the Pulls screen still reading
#N Open.The footer badge, the session cards and the sidebar's "Pull request" entry only look the pull request up again when the checkout's HEAD moves, or when the window loses focus and gets it back. A merge does neither — the commit lands on the base branch, on the remote, and the worktree's HEAD never budges. So merging from the Pulls screen emptied that screen (
onMergedrefreshes it) while the badges went on showing the merged PR as open until you clicked away to another window and back.How
lib/pulls/pull-request-lookup.ts— the shared lookup takes subscribers:invalidatePullRequests()clears thesharedmap and notifies. Clearing matters as much as the notify: inside the 2sSHARE_MSwindow a re-read would otherwise replay the pre-merge answer.onPullRequestInvalidated(reload)returns its unsubscribe;usePullRequestsubscribes in the same effect that listens for focus.Pulls.tsxwrapsrefreshin areloadthat invalidates first, and wires it to the three moments the state changes with HEAD standing still: the merge, the header's reload button, and a pull request opened from the empty state. The check poll and the focus re-read stay the screen's own — neither changes what a badge shows.Every badge of every checkout is invalidated, not just the one that changed. A merge is rare and deliberate, and the callers of one checkout still collapse into a single
ghcall; the comment names the ceiling and the way out (key the listeners by path).Not covered:
gh pr mergerun from a terminal next door. Nothing announces that, so it still waits for a window focus — same as before.Test plan
vitest— 408 passing, two new cases on the lookup: a re-read after an invalidation inside the share window, and subscribe/unsubscribe notification.biome checkclean (12 pre-existing a11y warnings).tsc -b --noEmit+vite build.gofmt -l .+go vet ./...(no Go touched).task dev: merge a PR from the Pulls screen, confirm the footer badge, the session card#Nand the sidebar's "Open" all clear without touching another window.