Repository navigation
fix(checks): keep a merged PR visible when the worktree sits behind its own PR head - #7277
Conversation
A worktree can end up behind its own merged PR's final head — update-branch
merges or web-committed suggestions land on the remote branch and merge
without a local pull. The merged-implicit visibility rule required exact
head equality, so the Checks panel dropped to 'No pull request found —
Create a pull request…' and the sidebar merged badge vanished right after
a successful merge.
Keep the reused-branch guard, but before hiding a merged branch-matched PR
ask GitHub whether the worktree head is one of the PR's own commits
(commits/{sha}/pulls, bounded immutable-friendly cache, core rate-limit
guard, fail-safe to the old hide). Confirmed heads are stamped on PRInfo/
HostedReviewInfo as confirmedContainedHeadOid so the renderer agreement
points (hosted-review staleness, refresh fallback number, no-PR preserve,
sidebar merged badge) accept the same worktrees without refetch loops.
Old main commits carry no association with the PR, so reused branch names
stay hidden; commits never pushed to GitHub fail the probe and stay hidden.
Co-authored-by: Orca <[email protected]>
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds commit-membership awareness for merged pull requests. A new main-process module checks whether a commit belongs to a merged PR and caches the result. That signal is threaded through PR lookup, IPC/runtime request plumbing, shared types, and renderer cache logic via ChangesRelated issues: None Sequence Diagram(s)See the hidden artifact diagram for the PR lookup request flow. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e667c142-1581-4e37-a691-de9038d67679
📒 Files selected for processing (13)
src/main/github/client.test.tssrc/main/github/client.tssrc/main/github/merged-pr-commit-membership.tssrc/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.tssrc/shared/hosted-review-github.tssrc/shared/hosted-review.tssrc/shared/types.ts
A merged PR's commit set is frozen, so a 200 response that lacks the PR is as immutable as one that contains it — only errors (unpushed commits, network) warrant the short retry TTL. Keeps a reused-branch worktree with the checks panel open from re-probing GitHub every five minutes. Also adds the review-requested why comments on the fallback gate and the preservation seam. Co-authored-by: Orca <[email protected]>
…tion is head-gated Live validation caught a self-sustaining loop the unit seams missed: the Checks panel passes its displayed PR number as the refresh fallback, and the candidate path carried no worktree head, so main preserved a merged branch PR head-blind — the merged view survived new local commits instead of yielding to 'No pull request found'. Thread currentHeadOid through GitHubPRRefreshCandidate, both renderer candidate builders, the gh:prForBranch IPC, and the runtime RPC method — the same shape the hosted-review path already used. Main's explicit-head gate (equality or confirmed commit membership) now applies to every renderer-driven lookup; true no-context callers keep the designed deleted-head preservation. Co-authored-by: Orca <[email protected]>
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: 8103510c-8022-449d-9622-0b0c90098bfe
📒 Files selected for processing (10)
src/main/github/pr-refresh-coordinator.test.tssrc/main/github/pr-refresh-coordinator.tssrc/main/ipc/github.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/github.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/store/slices/github.test.tssrc/renderer/src/store/slices/github.tssrc/shared/types.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/shared/types.ts
- src/renderer/src/store/slices/github.test.ts
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
…fix garbled comments (#7322) Quality pass on renderer/shared PRs merged 2026-07-03: - WorktreeTitleInlineRename: skip the truncation measure + ResizeObserver in `wrapTitle` mode, where wrapped titles never truncate — it could only churn unused state (#7307). - editor slice: reuse the `removeEditorStateForReplacedPreview` helper this PR added instead of a hand-rolled copy of the same six-field eviction (drops ~50 lines) (#6476). - useFileExplorerTree: extract `readWorktreeDirectory` so the connectionId/settings assembly for `readRuntimeDirectory` lives in one place, not three (#6321). - comment-markdown-github-attachment-media: extract a shared `AttachmentFallbackLink` for the image/video error-fallback link (#6759). - repository-icon-github: fold the two near-identical live resolvers into one parameterized `resolveRepositoryIdentityLive`; trim a 3-line comment to 2 (#6507). - resource-usage-open-slices: delete the `shouldReadPopoverSlices` identity wrapper and inline `open` at the four call sites (#7275). - BrowserPane: drop the pointerEvents assignment already applied inside `ensureBrowserPageWebview` for the reused-webview path (#6958). - github slice: fix two garbled "…a commit main confirmed…" comments (#7277). - runtime-file-client: trim the binary-file fallback comment to its whys (#6606). - composer-branch-selection: drop the inline comment that restated the JSDoc (#6748). - TabBarQuickCommandsButton: correct the stale "+ Command" comment (button shows no +). No behavior change (the editor-helper reuse is behavior-equivalent, only more conservative on an edge case); typecheck, oxlint, react-doctor, oxfmt, and touched unit suites all pass.
The synchronous fresh-return path guards on `staleMergedHeadRefetch` so a worktree that advanced off a merged PR's head does not reuse the now-stale merged review (added in stablyai#7277). The stale-while-revalidate fast path was missing that same guard, so it served the stale merged card synchronously (and kicked only a background refetch) whenever the parent-PR-checks overview polled with `{ staleWhileRevalidate: true, currentHeadOid }`. Result: a worktree that commits new work on top of a merged branch keeps showing the old "Merged" card instead of going branch-only — persistently while the background revalidation keeps failing (rate limit / gh error). Add `!staleMergedHeadRefetch` to the SWR condition so the read revalidates synchronously, matching the fresh-return path. Adds a regression test that fails without the guard. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ts own PR head (stablyai#7277) Co-authored-by: Orca <[email protected]>
…fix garbled comments (stablyai#7322) Quality pass on renderer/shared PRs merged 2026-07-03: - WorktreeTitleInlineRename: skip the truncation measure + ResizeObserver in `wrapTitle` mode, where wrapped titles never truncate — it could only churn unused state (stablyai#7307). - editor slice: reuse the `removeEditorStateForReplacedPreview` helper this PR added instead of a hand-rolled copy of the same six-field eviction (drops ~50 lines) (stablyai#6476). - useFileExplorerTree: extract `readWorktreeDirectory` so the connectionId/settings assembly for `readRuntimeDirectory` lives in one place, not three (stablyai#6321). - comment-markdown-github-attachment-media: extract a shared `AttachmentFallbackLink` for the image/video error-fallback link (stablyai#6759). - repository-icon-github: fold the two near-identical live resolvers into one parameterized `resolveRepositoryIdentityLive`; trim a 3-line comment to 2 (stablyai#6507). - resource-usage-open-slices: delete the `shouldReadPopoverSlices` identity wrapper and inline `open` at the four call sites (stablyai#7275). - BrowserPane: drop the pointerEvents assignment already applied inside `ensureBrowserPageWebview` for the reused-webview path (stablyai#6958). - github slice: fix two garbled "…a commit main confirmed…" comments (stablyai#7277). - runtime-file-client: trim the binary-file fallback comment to its whys (stablyai#6606). - composer-branch-selection: drop the inline comment that restated the JSDoc (stablyai#6748). - TabBarQuickCommandsButton: correct the stale "+ Command" comment (button shows no +). No behavior change (the editor-helper reuse is behavior-equivalent, only more conservative on an edge case); typecheck, oxlint, react-doctor, oxfmt, and touched unit suites all pass.
* fix(checks): stop stale-while-revalidate from flashing a stale merged PR The synchronous fresh-return path guards on `staleMergedHeadRefetch` so a worktree that advanced off a merged PR's head does not reuse the now-stale merged review (added in #7277). The stale-while-revalidate fast path was missing that same guard, so it served the stale merged card synchronously (and kicked only a background refetch) whenever the parent-PR-checks overview polled with `{ staleWhileRevalidate: true, currentHeadOid }`. Result: a worktree that commits new work on top of a merged branch keeps showing the old "Merged" card instead of going branch-only — persistently while the background revalidation keeps failing (rate limit / gh error). Add `!staleMergedHeadRefetch` to the SWR condition so the read revalidates synchronously, matching the fresh-return path. Adds a regression test that fails without the guard. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * chore(review): clarify stale review revalidation comments * fix: avoid reusing hosted review requests from a different head * fix(checks): track concurrent review lookups by Git head * fix(hosted-review): narrow per-HEAD request fencing to a join guard Replace the HEAD-keyed in-flight map with the original single slot per request key, and skip joining an in-flight lookup only when it was started for a different known HEAD. Keep the stale-merged guard on the stale-while-revalidate path and the merged-HEAD guards on the readers. --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Neil <[email protected]> Co-authored-by: Neil <[email protected]>
Problem
Right after a PR merges, its worktree can show "No pull request found — Create a pull request to start checks and review." in the Checks panel, and the sidebar card loses its merged badge. This happens whenever the branch picked up a remote-side commit the local worktree never pulled (an "Update branch" merge, web-committed review suggestions, or a commit pushed from another machine) before merging.
Observed in the wild today on
brennanb2025/fix-agent-hibernation-ghost-wake: local HEADb5bb8c7b8sat one commit behind merged PR #7145's final head53a792106, and the panel offered to create a PR for a branch that had just merged.Root cause
Merged branch-matched (non-linked) PRs are deliberately hidden to stop reused branch names from resurrecting historical PRs — but the "does this merged PR belong to the current checkout" test is exact head equality (
shouldHideMergedImplicitPR). A worktree sitting behind its own PR's head fails it, and every renderer surface (hosted-review staleness, refresh fallback number, no-PR cache preserve, sidebar merged badge) repeats the same exact-match test, so the PR vanishes everywhere with a misleading create-PR call to action.Fix
Keep the reused-branch guard, but before hiding a merged branch-matched PR, ask GitHub whether the worktree head is one of that PR's own commits (
repos/{owner}/{repo}/commits/{sha}/pulls, single call):The probe lives in
src/main/github/merged-pr-commit-membership.ts: bounded cache (membership of a merged PR is immutable — long TTL for confirmations, short TTL for negatives so a later push can flip them),corerate-limit-guarded, and fail-safe to the previous hide behavior on any error. Confirmed heads are stamped onPRInfo/HostedReviewInfoasconfirmedContainedHeadOid, and the four renderer agreement points accept the stamp so the panel doesn't refetch-loop and the fallback PR number / cache preserve / sidebar badge stay consistent with main.getPRForBranchOutcomeis the single chokepoint used by both the PR-cache path and the hosted-review path (all providers' exec options are threaded through, so SSH/WSL lookups run in the same context as today). GitLab and the other forges have no implicit-merged hide rule to mirror — their reviews attach via explicit links.Tests
All new behavior is pinned red-green (each test fails with its product hunk reverted):
worktree-card-pr-display.tsand unit-pinned.Live validation follow-up (commit b66e972)
Exercising the real workflow in a dev build caught a loop the unit seams missed: the Checks panel passes its displayed PR number as the refresh fallback, and the PR-refresh candidate carried no worktree head, so main preserved a merged branch PR head-blind — the merged view survived new local commits instead of yielding to "No pull request found". Fixed by carrying
currentHeadOidonGitHubPRRefreshCandidate, both renderer candidate builders, thegh:prForBranchIPC, and the runtime RPC method (mirroring the hosted-review path), so the explicit-head gate applies to every renderer-driven lookup. True no-context callers keep the designed deleted-head preservation.Tests
pnpm typecheck(node/cli/web), fulloxlint(0 errors),git diff --check, fullpnpm lintincl. localization checksdemo-projectPR (branch → PR → remote-only commit → merge → local worktree one commit behind):prCache/hosted entries carryconfirmedContainedHeadOid= worktree headdemo-projectclone, disposable merged PR): behind-head worktree on the SSH-hosted repo shows the merged PR in the Checks panel + sidebar withconfirmedContainedHeadOid= worktree head in both caches; control commit flips it to "No pull request found" and it stays hidden across repeated refreshes; relay deploy/logs clean; full cleanup verifiedgithub.prForBranchexercised directly with the newcurrentHeadOidparam (behind head → merged PR + stamp; new head → null) throughOrcaRuntimeService.getRepoPRForBranchover the local runtime transport