Skip to content

fix(sidebar): keep branch-discovered PR status visible on worktree cards - #9789

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/fix-sidebar-pr-icon-checks-mismatch
Jul 22, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/fix-sidebar-pr-icon-checks-mismatch

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • the cached review is GitHub,
  • the provenance number matches the review number, and
  • no durable review metadata is linked for any provider.

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

  • Reviewed the prior PR-display work and its regression history, including linked/unlinked review behavior, merged-PR head ownership, checks-panel selection, cache refreshes, and provider precedence.
  • Found and fixed a stale-status regression: branch provenance could otherwise keep showing a cached merged PR after the worktree advanced beyond that PR's head. Merged reviews now retain the existing exact/confirmed-contained head guard.
  • Strengthened the exact-linked refresh test after CodeRabbit correctly noted that the provenance assertion could pass vacuously without proving the cache write occurred.
  • Reviewed all CodeRabbit feedback. The actionable thread is resolved, and the latest review has no remaining actionable findings.
  • No additional performance-sensitive paths, provider fanout, or render-wide subscriptions were introduced.

Testing

  • 474 focused and adjacent tests pass across sidebar display, merged-PR guards, hosted-review cache races, GitHub refreshes, checks selection, parent review rows, and provider precedence.
  • 174 GitHub store tests pass after strengthening the exact-linked cache-write assertion.
  • Full GitHub verification passes, including the complete test suite, app build, and packaged CLI smoke test.
  • Web typecheck, changed-file oxlint, oxfmt, and max-lines ratchet pass.
  • Live-tested with disposable demo-project PR #28 in an isolated Orca dev profile:
    • an unlinked worktree discovered the open PR by branch;
    • sidebar status matched the Checks pane's failing check state;
    • the state survived an app restart/warm cache;
    • the exact merged PR head retained the merged indicator; and
    • advancing the worktree to a new commit immediately removed the stale merged indicator.

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.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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. WorktreeCard passes the cached branch value into the display function, and tests cover cache provenance, exact linked reviews, merged-review head changes, and provider-specific matching.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description covers the fix and testing, but it misses several required template sections, including Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections, including screenshots/no visual change, a structured AI review report, a security audit, and notes.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the main change: keeping branch-discovered PR status visible on worktree cards.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e0a3aeb7-96b6-402b-aa52-941a7e0efe09

📥 Commits

Reviewing files that changed from the base of the PR and between 36f7866 and 9741c21.

📒 Files selected for processing (8)
  • src/renderer/src/components/sidebar/WorktreeCard.pr-display.test.tsx
  • 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
  • src/renderer/src/store/slices/github.test.ts
  • src/renderer/src/store/slices/github.ts
  • src/renderer/src/store/slices/hosted-review.test.ts
  • src/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

@brennanb2025
brennanb2025 merged commit 4d0e3f5 into main Jul 22, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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
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