Repository navigation
fix(checks): hide stale merged PRs after workspace HEAD changes - #7815
Conversation
|
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
Walkthrough
Priority: Merge Risk:
|
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) <noreply@anthropic.com>
|
Rebased onto the latest Validation:
|
00275be to
dfa03a0
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Greptile SummaryThe PR prevents stale-while-revalidate reads from immediately returning a merged GitHub review after the worktree advances beyond its head.
Confidence Score: 4/5The stale-card fix should be completed before merging because an old-head request already in flight can still return the merged review after the worktree advances. The new guard fixes the normal cached-return path, but request deduplication does not distinguish head OIDs and returns an existing promise without rechecking its result against the current head. Files Needing Attention: src/renderer/src/store/slices/hosted-review.ts and src/renderer/src/store/slices/hosted-review.test.ts
|
| Filename | Overview |
|---|---|
| src/renderer/src/store/slices/hosted-review.ts | Adds the intended SWR cache guard, but the subsequent head-insensitive in-flight deduplication can still return the stale merged review during a head-change race. |
| src/renderer/src/store/slices/hosted-review.test.ts | Covers the ordinary stale merged-head revalidation path, but not an old-head request remaining in flight when the new-head SWR read occurs. |
Reviews (1): Last reviewed commit: "fix(checks): stop stale-while-revalidate..." | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 4d7502f2-9a15-40a8-8a1c-e6a77e9b369d
📒 Files selected for processing (3)
src/renderer/src/store/slices/hosted-review-request-state.tssrc/renderer/src/store/slices/hosted-review.test.tssrc/renderer/src/store/slices/hosted-review.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Retain the contributor's HEAD-scoped request ownership and stale-while-revalidate guard. Apply the existing merged-head ownership check to Source Control, Checks, and completed folder-overview outcomes, since these consumers also read branch caches directly. Preserve same-head, confirmed-contained, and unknown-head cache behavior while avoiding stale merged-review action fallbacks after new work advances the branch. Original contribution: stablyai#7815 Original head: d6e106c Co-authored-by: MarkXian <mark-xian@foxmail.com>
# Conflicts: # src/renderer/src/components/right-sidebar/source-control/review/use-hosted-review-state.test.tsx
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.
|
Maintainer follow-up (merged current main, which resolved the test conflict, plus ceb5f3a):
|
ELI5
When new commits move a workspace past an old merged GitHub PR, Source Control now shows Create PR while Orca checks the new commit. The merged PR remains visible when the workspace is still at its original commit.
What changed
Verification
gh, production resolver/IPC/store, and a controlled local HTTPS provider. After moving A → B, Source Control showed the old merged PR until delayed commit membership returned[]. No review/card/cache data was injected.b443994558b064b9fdc56ddab62fd3c64d841557(tree20656e8dd2b8656d2887ef2b3cc91853ab103bf2). At fresh real commitc3bf811f56075956cd6db5b3ff027361f9673d5f, Source Control shows Create PR while both naturally populated raw caches still hold merged PR Improve terminal font rendering, per-pane zoom, and UI zoom #7 and membership lookup is pending for 12 seconds. The settled state also remains correct.git diff --checkpass. Independent review found no blockers and separately exercised response-order races and the merged-HEAD predicate matrix.ORCA_BACKGROUND_LAUNCH=1. Native mobile, Linux/Windows, live SSH, full build, and full suite were not run locally; broader coverage is left to CI.Visual proof
Untouched main, after advancing beyond the old merged PR (membership pending):
Final candidate, still at the merged PR's original commit:
Final candidate, after advancing to a new real commit (membership pending):
Credit and disclosure
Original contribution by @xianjianlf2 / MarkXian. Original contributor HEAD remains an ancestor, and
Co-authored-by: MarkXian <mark-xian@foxmail.com>is retained. This investigation, extension, verification, and publication were assisted by OpenAI Codex. The contributor's original disclosure and description are retained below.Follow-up to #7277. No dedicated issue is currently linked.
Contributor description retained from before this update
ELI5
After new commits move a worktree past a merged PR, Orca should check the current branch before returning that old merged card. Overlapping checks for different commits must also keep their results separate.
What Changed
Why
One in-flight slot per branch/hint loses track of A when B starts. Merely checking the head before reusing that slot avoids a wrong-head result but still duplicates requests. Resetting numeric generations after completion also permits an older request to regain write ownership after cache eviction.
Linked Issue
Follow-up to #7277 and the review feedback on this PR. No dedicated issue is currently linked; the contribution-template issue-link requirement remains outstanding.
Visual Proof
Rendered validation remains outstanding: a before/after recording of the Source Control stale-card transition has not been captured. The automated request/cache tests below are not presented as visual proof.
Testing
On macOS with
ORCA_BACKGROUND_LAUNCH=1:pnpm test src/renderer/src/store/slices/hosted-review.test.ts src/renderer/src/store/slices/hosted-review-cache.test.ts src/renderer/src/store/slices/hosted-review-cache-race.test.ts src/renderer/src/store/slices/github-pr-branch-hosted-review-cache.test.ts src/renderer/src/store/slices/github-pr-refresh-hosted-review-cache-leak.test.ts: 61 tests passed.pnpm tc:web, formatting, changed-code quality checks, andgit diff --checkpassed.AI Disclosure
Originally developed with Claude Code; this follow-up used OpenAI Codex for diagnosis, implementation, regression tests, and self-review.
Review
Reviewed both response orders, cache eviction, completed-request cleanup, force-refresh behavior, and existing cache race/leak coverage. The new key retains repository/runtime/hint isolation and uses the existing null normalization. Changes are provider-neutral in-flight bookkeeping shared by local IPC and remote runtime RPC; no wire payload, Git command, permission, path, or shortcut changes. Unique symbols stay in process-local request state and are not persisted or serialized.
Agent skill upstream boundary
Checklist
Author
X: @mark86202384100
October 8 upstream refresh
Merged current upstream main and retained its monotonic lookup generation sequence alongside request isolation by Git HEAD. All 50 hosted-review tests across 4 suites, renderer type checking, and focused oxlint checks pass with ORCA_BACKGROUND_LAUNCH=1. This refresh was AI-assisted.