Repository navigation
fix(sidebar): keep branch-discovered PR status visible on worktree cards - #9789
Conversation
The sidebar status lane and the right checks panel read the same PR
caches but disagreed for unlinked worktrees: every successful GitHub PR
fetch mirrors the result into hostedReviewCache stamped with a
linked-style hint key ('github:<n>'), and getWorktreeCardPrDisplay
suppresses unlinked reviews with a non-empty hint. The checks panel
renders straight from prCache, so it showed "#9387 OPEN" while the same
worktree's card fell back to the plain branch icon.
Thread the branch-keyed PR cache number into getWorktreeCardPrDisplay as
corroboration: when the branch cache names the same PR the hosted entry
holds, the review provably belongs to this branch and stays visible.
WorktreeCard passes its existing cachedBranchFallbackGitHubPRNumber,
which is already guarded for linked metadata and the merged-head rule.
The hint stamping itself is unchanged on purpose: the 'github:' marker
also flags the entry as GitHub-scoped so neutral lookups still re-run
GitLab MR discovery.
📝 WalkthroughWalkthroughThe worktree PR display options now accept a cached GitHub branch PR number. Unlinked GitHub reviews are displayed when their number matches that cached value, while mismatched reviews and non-GitHub providers retain the existing fallback behavior. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e0a3aeb7-96b6-402b-aa52-941a7e0efe09
📒 Files selected for processing (8)
src/renderer/src/components/sidebar/WorktreeCard.pr-display.test.tsxsrc/renderer/src/components/sidebar/WorktreeCard.tsxsrc/renderer/src/components/sidebar/worktree-card-pr-display.test.tssrc/renderer/src/components/sidebar/worktree-card-pr-display.tssrc/renderer/src/store/slices/github.test.tssrc/renderer/src/store/slices/github.tssrc/renderer/src/store/slices/hosted-review.test.tssrc/renderer/src/store/slices/hosted-review.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/renderer/src/components/sidebar/WorktreeCard.tsx
- src/renderer/src/components/sidebar/worktree-card-pr-display.test.ts
- src/renderer/src/components/sidebar/worktree-card-pr-display.ts
…rds (stablyai#9789) * fix(sidebar): keep branch-discovered PR status visible on worktree cards The sidebar status lane and the right checks panel read the same PR caches but disagreed for unlinked worktrees: every successful GitHub PR fetch mirrors the result into hostedReviewCache stamped with a linked-style hint key ('github:<n>'), and getWorktreeCardPrDisplay suppresses unlinked reviews with a non-empty hint. The checks panel renders straight from prCache, so it showed "stablyai#9387 OPEN" while the same worktree's card fell back to the plain branch icon. Thread the branch-keyed PR cache number into getWorktreeCardPrDisplay as corroboration: when the branch cache names the same PR the hosted entry holds, the review provably belongs to this branch and stays visible. WorktreeCard passes its existing cachedBranchFallbackGitHubPRNumber, which is already guarded for linked metadata and the merged-head rule. The hint stamping itself is unchanged on purpose: the 'github:' marker also flags the entry as GitHub-scoped so neutral lookups still re-run GitLab MR discovery. * fix(sidebar): preserve PR lookup provenance * fix(sidebar): preserve merged PR head guard * test(github): assert exact refresh cache write
Problem
The left sidebar status lane and right checks panel disagree for an unlinked worktree whose branch has an open GitHub PR. The checks panel renders the branch-keyed PR cache, while the sidebar suppresses the mirrored hosted-review entry because GitHub refreshes retain a linked-style request hint.
Root cause
The request hint serves two roles: request identity/provider scoping and display provenance. A GitHub branch refresh can therefore look like a stale exact-linked lookup even though the PR was discovered for the current branch.
Fix
Record branch-lookup provenance on the bounded hosted-review cache entry when either the provider-neutral lookup or GitHub refresh proves the PR belongs to the branch. WorktreeCard trusts that provenance only when:
Exact linked lookups never receive branch provenance. Hosted-review fallbacks inherit it only when the prior entry already proved it, so unlinking cannot resurrect stale PR details. The linked-style request hint remains unchanged, preserving provider-scoped refetch and inflight dedupe behavior.
Performance
The change adds one optional number to a cache already capped at 500 entries and constant-time comparisons on existing cache write/render paths. It adds no I/O, polling, provider fanout, scans, subscriptions, or timers.
Review findings
Testing