Skip to content

Show merged PR status from merge commits#6470

Open
brennanb2025 wants to merge 9 commits into
mainfrom
brennanb2025/fix-pr-status-sidebar-flicker
Open

Show merged PR status from merge commits#6470
brennanb2025 wants to merge 9 commits into
mainfrom
brennanb2025/fix-pr-status-sidebar-flicker

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Resolve GitHub PRs from the checked-out merge commit when branch/upstream/fallback PR lookup misses, so merged detached worktrees keep PR context in the left sidebar and Checks tab.
  • Scope branchless/detached PR and hosted-review cache entries by the checked-out HEAD instead of the empty branch string, preventing stale PRs from leaking between detached worktrees.
  • Thread currentHeadOid / worktreeHead through renderer, IPC, runtime RPC, refresh coordinator aliases, queued/manual refreshes, right-sidebar refreshes, entry refreshes, and async cache keys so detached merged worktrees refresh under the same identity everywhere.
  • Update the left sidebar card, folder/import aggregate card, and Checks panel to read/use detached-HEAD PR/hosted-review cache keys, including imported/folder and legacy local cache-key shapes.
  • Add detached-only suffix fallback for PR cache owner-prefix mismatches observed on Windows, while keeping normal branch cards and hosted-review lookups on exact-key subscriptions.
  • Fix the latest Windows repro shape: when a detached card has no linkedPR, a hosted review entry with linkedReviewHintKey: github:<n>, and a matching detached PR-cache entry, the card now shows the PR instead of the raw detached badge.
  • Keep the stale linked-review guard: linked-hint detached hosted reviews are only shown unlinked when corroborated by the HEAD-scoped PR cache.
  • Include detached worktrees in visible PR refresh reporting when head is present; branch worktrees remain branch-scoped so ordinary HEAD movement does not trigger extra visible PR refresh churn.
  • Add short-lived commit-associated PR caching, in-flight dedupe, hydration dedupe, and bounded perf accounting for the extra merge-commit probe.

Manual validation

  • Created a throwaway PR in stablyai/demo-project, merged it, then opened a detached worktree at the resulting merged commit.
  • Verified the app saw the detached worktree with empty branch and the merge commit HEAD.
  • Verified the right sidebar Checks panel rendered the merged PR instead of “No pull request found”.
  • Verified PR/hosted-review cache entries were written under the detached HEAD key, not the empty branch key.
  • Windows validation through commit 1b3961128 confirmed no crash and correct right-sidebar/cache behavior, but the active left sidebar detached card still rendered raw detached status.
  • Windows retest on 9a2d8b6a7fb0190c8890894d7c0bdb30e4285962 passed for both repro shapes:
    • direct imported detached folder showed Linked PR #24 in the active left sidebar card, not Detached HEAD @ 67c9b95;
    • parent repo with external worktrees visible also showed Linked PR #24 on the active detached child row;
    • right Checks panel stayed on stablyai/demo-project#24, title Validate Orca PR status fallback 20260626214121, merged state, and check status;
    • switching away/back and closing/reopening Checks stayed stable with no “No PR”, stale detached PR, or raw detached status after refresh settled;
    • logs showed no git/worktree/HEAD/path stack traces, crashes, fatal errors, or unhandled exceptions; only Chromium cache warnings.
  • Local repro test for the Windows store shape failed before the display fix and now passes.
  • Review-code loop on the latest diff found and fixed two issues before push:
    • normal branch visible-refresh identity briefly included head, which could cause extra refresh churn; now branch rows use branch identity and detached rows use head identity;
    • detached hosted-review hints were briefly neutralized too broadly; now they require HEAD-scoped PR-cache proof or the PR-cache display path.
  • CodeRabbit follow-up found that Checks-panel tab-entry refresh still had a !branch guard; 9a2d8b6a7 changes GitHub entry refresh to use detached head identity while keeping GitLab branch-scoped.
  • Internal perf skill review found the hosted-review suffix fallback could scan the whole cache per detached card on unrelated store updates; 9a2d8b6a7 removes that scan and relies on exact hosted-review keys plus the detached PR-cache fallback.

Performance notes

  • The merge-commit lookup only runs after cheaper branch/upstream/fallback paths miss and only when a usable explicit HEAD hint is present.
  • Commit-associated PR probes use short TTLs, a bounded cache, and in-flight coalescing so multiple visible worktrees on the same commit share the same request.
  • Background refresh accounting charges the extra core probe, and tests assert coalescing keeps the latest HEAD hint without merging distinct detached HEADs.
  • Sidebar cache fallback first checks exact keys; suffix fallback is detached-only and only for PR cache after exact detached keys miss. Hosted-review cache lookup stays exact-key only to avoid O(visible detached cards × hosted cache size) selector work.
  • Visible refresh reporting includes branchless worktrees only when head is present; normal branch cards remain branch-scoped.

Automated validation

  • Focused sidebar/status run after the latest fix: pnpm vitest run --config config/vitest.config.ts src/renderer/src/components/right-sidebar/ChecksPanel.review-header.test.tsx src/renderer/src/components/right-sidebar/active-checks-status.test.ts src/renderer/src/components/sidebar/worktree-list-visible-refresh.test.ts src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts src/renderer/src/components/sidebar/WorktreeCard.merged-pr-display.test.tsx src/renderer/src/components/sidebar/WorktreeCard.branch-review-pending.test.tsx src/renderer/src/components/sidebar/WorktreeCard.pr-display.test.tsx — 7 files / 58 tests passed
  • Broader PR-status run after the latest fix: pnpm vitest run --config config/vitest.config.ts src/renderer/src/components/right-sidebar/ChecksPanel.review-header.test.tsx src/renderer/src/components/right-sidebar/active-checks-status.test.ts src/renderer/src/store/slices/github.test.ts src/renderer/src/store/slices/github-pr-refresh-owner-routing.test.ts src/renderer/src/components/sidebar/WorktreeCard.branch-review-pending.test.tsx src/renderer/src/components/sidebar/WorktreeCard.merged-pr-display.test.tsx src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts src/renderer/src/components/sidebar/worktree-list-visible-refresh.test.ts src/main/github/client.test.ts src/main/github/pr-refresh-coordinator.test.ts src/main/runtime/orca-runtime.test.ts src/main/runtime/rpc/methods/github.test.ts src/main/ipc/github.test.ts src/renderer/src/web/web-preload-api.test.ts — 14 files / 894 tests passed
  • Windows focused test command — 7 files / 62 tests passed
  • Windows pnpm run typecheck — passed
  • pnpm run typecheck — passed
  • pnpm run lint — passed with the existing useGitStatusPolling.ts warning
  • git diff --check — passed
  • Local macOS isolated Electron E2E fresh-start smoke with a temporary spec (removed after run) — direct detached import and parent repo with external worktrees visible both showed Linked PR #24 and the Checks panel stayed on demo-project PR Add Ghostty-style drag-to-reorder terminal panes #24; 2 tests passed.
  • Fresh-start Windows smoke at 9a2d8b6a7fb0190c8890894d7c0bdb30e4285962 passed both sidebar shapes: direct imported detached folder and parent repo with external worktrees visible both rendered PR-aware left sidebar rows (PR: Merged... in the fresh default UI), not Detached HEAD @ 67c9b95; backing cache and Checks panel identified demo-project PR Add Ghostty-style drag-to-reorder terminal panes #24, Checks showed #24, MERGED, title Validate Orca PR status fallback 20260626214121, and 1 failing check; closing/reopening Checks and switching away/back stayed stable; stdout/stderr scans found no crash, stack traces, fatal errors, unhandled exceptions, or git/worktree/HEAD/path errors. Focused tests/typecheck were not rerun in this final smoke. Screenshots were left untracked under .visual-evidence/ on the Windows machine.
  • Windows $git-crash-perf audit at 9a2d8b6a7fb0190c8890894d7c0bdb30e4285962: no new spawn/exec/shell: true/git status/git worktree scan path in the PR diff; detached refresh carries worktreeHead through the existing PR refresh coordinator; refresh remains bounded by coordinator concurrency (MAX_CONCURRENT = 4), Orca ghExecFileAsync timeout/retry behavior, commit-associated PR TTL caches capped at 256 entries, and in-flight coalescing; detached renderer suffix fallback scans only bounded prCache after exact detached-key misses and does not scan hostedReviewCache; no lingering git.exe/gh.exe after tests/typecheck; focused regression/perf-ish suite passed (8 files / 163 tests) and Windows pnpm run typecheck passed. Caveats: inactive-workspace cleanup/delete smoke and live SSH/WSL smoke were not rerun because PR Show merged PR status from merge commits #6470 does not touch those paths; the fallback git rev-parse HEAD helper uses the safe gitExecFileAsync wrapper but lacks an explicit timeout, and the detached repro path should not hit it because renderer provides currentHeadOid.

brennanb2025 and others added 2 commits June 26, 2026 20:33
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds merge-commit-based PR lookup in the GitHub client and forwards current head OIDs through runtime, IPC, preload, and renderer refresh paths. Renderer cache keys now use worktree head data for detached worktrees, and the worktree card and checks panel update pending hosted-review behavior. Tests were added and updated for merge-commit lookup, head-OID propagation, refresh coordination, tracked-upstream probing, and detached-head UI/cache behavior.

🚥 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 summary and testing, but it omits required Screenshots, AI Review Report, Security Audit, and Notes sections from the template. Add the missing template sections, or mark no visual change in Screenshots, and include the AI review, security audit, and notes details.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title succinctly describes the main user-facing change: showing merged PR status from merge commits.
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.
✨ 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: 2

🧹 Nitpick comments (1)
src/renderer/src/components/sidebar/WorktreeCard.branch-review-pending.test.tsx (1)

147-157: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a pathname-based paired-web case.

This suite only covers window.__ORCA_WEB_CLIENT__. The shared web-client contract also treats /web-index.html as web, so this test won't catch future drift from the common detector.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9047182a-2f15-43b5-87dc-2ed05de16e0f

📥 Commits

Reviewing files that changed from the base of the PR and between 360ce67 and 86c70d2.

📒 Files selected for processing (8)
  • src/main/github/client.test.ts
  • src/main/github/client.ts
  • src/main/github/pr-refresh-coordinator.test.ts
  • src/main/github/pr-refresh-coordinator.ts
  • src/renderer/src/components/sidebar/WorktreeCard.branch-review-pending.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/renderer/src/store/slices/github.ts
  • src/shared/types.ts

Comment thread src/main/github/client.ts Outdated
Comment thread src/renderer/src/components/sidebar/WorktreeCard.tsx Outdated

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

🧹 Nitpick comments (1)
src/main/github/pr-refresh-coordinator.ts (1)

239-244: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a short why-comment for the worktree-head fallback.

Letting a branchless candidate pass validation is non-obvious here; a one-line comment would make it clear this exists for detached/merge-commit PR resolution.

Suggested change
 function validateCandidate(
   candidate: GitHubPRRefreshCandidate
 ): GitHubPRRefreshSkippedReason | null {
@@
+  // Why: detached worktrees can still resolve a PR from the checked-out merge commit.
   if (
     !candidate.branch &&
     typeof candidate.linkedPRNumber !== 'number' &&
     typeof candidate.fallbackPRNumber !== 'number' &&
     !candidate.worktreeHead
   ) {

As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 730cfb1e-3cc0-4a50-bec9-9c34c2ca6025

📥 Commits

Reviewing files that changed from the base of the PR and between 86c70d2 and 1adc446.

📒 Files selected for processing (4)
  • src/main/github/pr-refresh-coordinator.test.ts
  • src/main/github/pr-refresh-coordinator.ts
  • src/renderer/src/store/slices/github.test.ts
  • src/renderer/src/store/slices/github.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/store/slices/github.ts

Co-authored-by: Orca <help@stably.ai>

@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: 3

🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/github.ts (1)

57-62: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document why branch may be empty.

requiredStringAllowingEmpty('Missing branch') is intentionally unusual here; add a short why-comment so the detached/merge-commit lookup path is preserved.

As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”

Proposed comment
 const PrForBranch = RepoSelector.extend({
+  // Why: detached/merge-commit worktrees have no branch; currentHeadOid can still resolve PR context.
   branch: requiredStringAllowingEmpty('Missing branch'),

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c7ee72b4-b528-486d-a178-3cf55766ef03

📥 Commits

Reviewing files that changed from the base of the PR and between 1adc446 and 955c8d2.

📒 Files selected for processing (20)
  • src/main/github/client.test.ts
  • src/main/github/client.ts
  • src/main/github/pr-refresh-coordinator.test.ts
  • src/main/github/pr-refresh-coordinator.ts
  • src/main/ipc/github.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/right-sidebar/ChecksPanel.tsx
  • src/renderer/src/components/right-sidebar/active-checks-status.test.ts
  • src/renderer/src/components/right-sidebar/active-checks-status.ts
  • src/renderer/src/components/sidebar/WorktreeCard.branch-review-pending.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/renderer/src/store/slices/github-cache-key.ts
  • src/renderer/src/store/slices/github-pr-refresh-owner-routing.test.ts
  • src/renderer/src/store/slices/github.test.ts
  • src/renderer/src/store/slices/github.ts
  • src/renderer/src/web/web-preload-api.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/renderer/src/components/sidebar/WorktreeCard.branch-review-pending.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/main/github/client.ts

Comment thread src/main/github/pr-refresh-coordinator.ts Outdated
Comment thread src/main/ipc/github.ts Outdated
Comment thread src/renderer/src/components/right-sidebar/ChecksPanel.tsx
brennanb2025 and others added 3 commits June 26, 2026 21:57
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/components/sidebar/WorktreeCard.tsx (1)

639-649: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

Don’t start hosted-review polling for branchless detached cards.

For detached cards, hostedReviewCacheKey is now truthy via __detached_head__, so the polling effect below can call fetchHostedReviewForBranch(repo.path, branch, ...) with branch === ''. Gate this pending state/effects to real branches and let the head-scoped PR refresh path own detached lookup.

Suggested fix
   const hostedReviewLookupPending =
     newCardStyle &&
+    branch.length > 0 &&
     shouldRefreshHostedReview &&
     canPassivelyRefreshHostedReview &&
@@
       !repo ||
       isFolder ||
       worktree.isBare ||
+      !branch ||
       !hostedReviewCacheKey ||
@@
       !repo ||
       isFolder ||
       worktree.isBare ||
+      !branch ||
       !hostedReviewCacheKey ||

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fe4f2eb1-4cf2-44bd-acea-b2edefcb6f8d

📥 Commits

Reviewing files that changed from the base of the PR and between 955c8d2 and 27185da.

📒 Files selected for processing (12)
  • src/main/github/client.test.ts
  • src/main/github/client.ts
  • src/main/github/pr-refresh-coordinator.test.ts
  • src/main/github/pr-refresh-coordinator.ts
  • src/main/ipc/github.test.ts
  • src/main/ipc/github.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/renderer/src/components/right-sidebar/ChecksPanel.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.merged-pr-display.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/main/github/pr-refresh-coordinator.test.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/main/ipc/github.ts
  • src/main/github/client.test.ts
  • src/main/github/pr-refresh-coordinator.ts
  • src/main/github/client.ts

Comment thread src/renderer/src/components/right-sidebar/ChecksPanel.tsx
brennanb2025 and others added 3 commits June 26, 2026 22:44
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
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