Skip to content

fix(checks): keep a merged PR visible when the worktree sits behind its own PR head - #7277

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/checks-panel-merged-pr-status
Jul 4, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/checks-panel-merged-pr-status

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

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 HEAD b5bb8c7b8 sat one commit behind merged PR #7145's final head 53a792106, 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):

  • A behind-head commit of the same PR ⇒ same line of work ⇒ keep showing the merged PR.
  • Old base-branch commits carry no association with the PR ⇒ reused branch names stay hidden (guard intact).
  • Commits never pushed to GitHub ⇒ probe 422s ⇒ stay hidden (new local work).

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), core rate-limit-guarded, and fail-safe to the previous hide behavior on any error. Confirmed heads are stamped on PRInfo/HostedReviewInfo as confirmedContainedHeadOid, 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.

getPRForBranchOutcome is 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):

  • main: shows a merged branch PR when the worktree head is one of its own commits; keeps hiding for a different PR's commit (reused branch), on probe failure, and while the core rate-limit budget is blocked (no probe call); reuses the cached membership answer across polls; uses the caller-supplied worktree head without shelling out.
  • renderer: hosted-review cache serves a confirmed merged review without refetch-looping; no-PR refresh preserves a confirmed behind-head merged PR; the refresh candidate keeps the confirmed merged PR as its fallback number; sidebar merged-badge predicate extracted to worktree-card-pr-display.ts and 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 currentHeadOid on GitHubPRRefreshCandidate, both renderer candidate builders, the gh:prForBranch IPC, 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), full oxlint (0 errors), git diff --check, full pnpm lint incl. localization checks
  • 309 tests across the seven touched/adjacent suites; every product hunk pinned red-green (fails with its hunk reverted): membership show/hide/error/rate-limit/cache, hosted-review staleness serve-from-cache, fallback-number gate, preserve-on-miss, sidebar badge predicate, coordinator head forwarding, candidate head presence
  • Real-API probes of the association assumption (behind-head commit → its PR; final head → its PR; old base-branch commit → none)
  • Live dev-build E2E on a disposable demo-project PR (branch → PR → remote-only commit → merge → local worktree one commit behind):
    • Checks panel renders #N Merged + title for the behind-head worktree (previously "No pull request found — Create a pull request…"); sidebar card shows the merged badge; prCache/hosted entries carry confirmedContainedHeadOid = worktree head
    • Control: a new local commit on the same branch flips both surfaces back to "No pull request found" / plain branch card (reused-branch guard intact, no self-sustaining merged view)
    • Cleanup: test worktree/branches (local + remote) removed, isolated app profile deleted
  • Live SSH E2E (throwaway Linux Docker SSH target, real demo-project clone, disposable merged PR): behind-head worktree on the SSH-hosted repo shows the merged PR in the Checks panel + sidebar with confirmedContainedHeadOid = 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 verified
  • Runtime RPC github.prForBranch exercised directly with the new currentHeadOid param (behind head → merged PR + stamp; new head → null) through OrcaRuntimeService.getRepoPRForBranch over the local runtime transport
  • Networked serve-mode runtime-environment transport for the same RPC (same handler code, different transport) — not exercised; plain SSH repos don't use it

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

coderabbitai Bot commented Jul 4, 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 352cb77f-838e-412e-bb70-1afc306bef4b

📥 Commits

Reviewing files that changed from the base of the PR and between 04c8b9b and 26cf75a.

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

📝 Walkthrough

Walkthrough

Adds 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 confirmedContainedHeadOid and currentHeadOid. Sidebar worktree display helpers and tests are updated to treat a confirmed-contained commit the same as a direct PR head match.

Changes

Related issues: None
Related PRs: None
Suggested labels: enhancement, github-integration
Suggested reviewers: None

Sequence Diagram(s)

See the hidden artifact diagram for the PR lookup request flow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, but it does not follow the required template sections like Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes. Rewrite it into the repository template with Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes, and fill each required section.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: keeping a merged PR visible when the worktree is behind its PR head.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e667c142-1581-4e37-a691-de9038d67679

📥 Commits

Reviewing files that changed from the base of the PR and between 41e395b and 96d139f.

📒 Files selected for processing (13)
  • src/main/github/client.test.ts
  • src/main/github/client.ts
  • src/main/github/merged-pr-commit-membership.ts
  • 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
  • src/shared/hosted-review-github.ts
  • src/shared/hosted-review.ts
  • src/shared/types.ts

Comment thread src/main/github/client.ts Resolved
Comment thread src/renderer/src/store/slices/github.ts Resolved
brennanb2025 and others added 2 commits July 3, 2026 17:39
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]>

@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: 8103510c-8022-449d-9622-0b0c90098bfe

📥 Commits

Reviewing files that changed from the base of the PR and between 84b99b2 and b66e972.

📒 Files selected for processing (10)
  • 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.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/store/slices/github.test.ts
  • src/renderer/src/store/slices/github.ts
  • src/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

@brennanb2025
brennanb2025 merged commit b099e27 into main Jul 4, 2026
2 checks passed
nwparker added a commit that referenced this pull request Jul 4, 2026
…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.
xianjianlf2 added a commit to xianjianlf2/orca that referenced this pull request Aug 31, 2026
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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
nwparker added a commit that referenced this pull request Oct 24, 2026
* 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]>
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