Desktop app shows stale PR link after branch switch (polling cache not invalidated)

Resolved 💬 2 comments Opened Mar 4, 2026 by ohcedar Closed Apr 1, 2026

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

  1. Have a repo with a feature branch (e.g., dev) that has a merged PR (e.g., PR #122 targeting main)
  2. Start Claude Code desktop while on the dev branch — the footer correctly shows main ← dev with a "View PR" link to PR #122
  3. Switch to main in your terminal/IDE
  4. 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 view manually on main immediately returns "no pull requests found for branch main"
  • Running gh pr view on dev returns the merged PR #122
  • The Electron Local Storage leveldb (~/Library/Application Support/Claude/Local Storage/leveldb/) contains a session-pr-store that 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)
  • gh CLI 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 view polling bypasses permission system and cannot be disabled
  • #11176 — PR metadata is immutable once set in a conversation

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗