Skip to content

fix: retire the pull request badge when the merge lands#97

Merged
omartelo merged 2 commits into
mainfrom
fix/pr-badge-after-merge
Jul 25, 2026
Merged

fix: retire the pull request badge when the merge lands#97
omartelo merged 2 commits into
mainfrom
fix/pr-badge-after-merge

Conversation

@omartelo

Copy link
Copy Markdown
Owner

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 (onMerged refreshes 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 the shared map and notifies. Clearing matters as much as the notify: inside the 2s SHARE_MS window a re-read would otherwise replay the pre-merge answer.
  • onPullRequestInvalidated(reload) returns its unsubscribe; usePullRequest subscribes in the same effect that listens for focus.
  • Pulls.tsx wraps refresh in a reload that 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 gh call; the comment names the ceiling and the way out (key the listeners by path).

Not covered: gh pr merge run 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 check clean (12 pre-existing a11y warnings).
  • tsc -b --noEmit + vite build.
  • gofmt -l . + go vet ./... (no Go touched).
  • By hand in task dev: merge a PR from the Pulls screen, confirm the footer badge, the session card #N and the sidebar's "Open" all clear without touching another window.

omartelo added 2 commits July 25, 2026 19:32
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.
@omartelo
omartelo merged commit c808a2c into main Jul 25, 2026
3 checks passed
@omartelo
omartelo deleted the fix/pr-badge-after-merge branch July 25, 2026 22:40
This was referenced Jul 25, 2026
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