Desktop app shows stale PR link after branch switch (polling cache not invalidated)
Description
When switching branches in a git repo, the Claude Code desktop app continues to display a stale PR link from the previous branch for up to ~60 seconds. The session-pr-store cache in Electron Local Storage is not invalidated on branch switch — it waits for the next gh pr view background poll cycle to update.
Steps to Reproduce
- Have a repo with a feature branch (e.g.,
dev) that has a merged PR (e.g., PR #122 targetingmain) - Start Claude Code desktop while on the
devbranch — the footer correctly showsmain ← devwith a "View PR" link to PR #122 - Switch to
mainin your terminal/IDE - Immediately open a new Claude Code conversation
Expected: No PR link shown (since main has no associated PR — gh pr view returns "no pull requests found for branch main")
Actual: The footer still shows the old PR link (displayed as main ← main with PR #122) for up to ~60 seconds until the next background gh pr view poll fires and clears it
Evidence
- Running
gh pr viewmanually onmainimmediately returns "no pull requests found for branch main" - Running
gh pr viewondevreturns the merged PR #122 - The Electron Local Storage leveldb (
~/Library/Application Support/Claude/Local Storage/leveldb/) contains asession-pr-storethat caches branch→PR mappings and is not cleared on branch switch - The stale PR persists long enough that a user can switch branches, open a new conversation, type a message, take a screenshot, and share it — all while seeing the wrong PR
Environment
- Claude Code Desktop v2.1.51
- macOS (Darwin 24.6.0, arm64)
ghCLI installed and authenticated
Suggested Fix
Invalidate the session-pr-store cache entry immediately when the detected git branch changes, rather than waiting for the next 60-second gh pr view poll cycle. A branch switch event should trigger an immediate re-poll or cache clear.
Related Issues
- #23580 —
gh pr viewpolling bypasses permission system and cannot be disabled - #11176 — PR metadata is immutable once set in a conversation
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗