Skip to content

fix(checks): stop the transient "PR already exists" card before the PR loads - #10008

Merged
brennanb2025 merged 9 commits into
mainfrom
brennanb2025/fix-transient-pr-already-exists
Jul 23, 2026
Merged

brennanb2025 merged 9 commits into
mainfrom
brennanb2025/fix-transient-pr-already-exists

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On a cold mount, the Checks/right-sidebar panel briefly shows a terminal "Pull request already exists" card (with only an Open Review button) instead of the real PR panel. A manual refresh then loads the PR normally.

Root cause — regression from #9428

Two signals feed the panel's exhaustive state selector from different async sources:

  • existing_review comes from the cache-backed eligibility probe — fast.
  • reviewLookup: 'found' requires the full PRInfo to hydrate into the PR cache — slower.

#9428 introduced the four-state selector and ranks existing_review as a terminal safety blocker above every loading state. So during the hydration window the panel settles on the terminal "already exists" card rather than a self-updating loading state. Compounding it, the auto-fetch used a lazy swr priority, so the renderable PR landed slowly unless the user forced a foreground refresh (which uses active/80).

Fix

  1. Selector (checks-panel-empty-state.ts) — while a PR fetch is queued/in-flight and we have positive-but-not-yet-renderable review evidence (existing_review or positive_unresolved), show the self-updating "Checking status" state instead of the terminal card. It flips to the review once details land. A concurrent branch blocker (publish/sync/auth/needs_push) still owns the copy.
  2. Fetch priority (checks-panel-pr-refresh-request.ts + call site) — when a review is known to exist but no renderable PR is cached, escalate the auto-fetch to a foreground active/80 request (matching manual refresh) so it resolves promptly.

Reuses existing i18n keys; no new copy.

Verification

Ran end-to-end in the real Electron app via /electron, against this PR's own worktree (branch has an open PR → the exact existing_review context that used to stall).

1. During load — the new self-updating "Checking pull request status" state (where the terminal "already exists" card used to appear):

checking status

2. Resolves automatically to the real PR panel — no manual refresh:

resolved PR panel

Also verified:

  • Unit tests: checks-panel-empty-state.test.ts + checks-panel-pr-refresh-request.test.ts (35 pass) — the in-flight → Checking-status transition, the settled-fetch terminal card still showing, and the branch-blocker precedence.

  • tsc (renderer project) + oxlint clean.

  • The real selector module, as compiled by Vite and executed inside the running app, across every scenario:

    Scenario Rendered title
    existing_review + in-flight fetch Checking pull request status (renderReview=false) ✅ was the terminal card
    existing_review + queued fetch Checking pull request status ✅
    existing_review, fetch settled Pull request already exists (Open Review) ✅ terminal card preserved when truly unrenderable
    positive_unresolved + queued Checking pull request status ✅
    branch blocker + in-flight No upstream configured ✅ blocker still wins

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ada2895-370b-42bf-aa8f-fd32a4b82481

📥 Commits

Reviewing files that changed from the base of the PR and between 5a22f3d and 7bfb5e1.

📒 Files selected for processing (3)
  • src/renderer/src/components/right-sidebar/ChecksPanel.tsx
  • src/renderer/src/components/right-sidebar/checks-panel-pr-refresh-request.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel-pr-refresh-request.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/right-sidebar/ChecksPanel.tsx

📝 Walkthrough

Walkthrough

The checks panel now detects positive review evidence that is not yet rendered and passes it to the PR refresh resolver. The resolver can select an active foreground fetch for this condition. Empty-state handling displays a checking status during queued or in-flight refreshes while preserving concurrent branch blockers. Additional tests cover refresh selection and state precedence.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the bug, fix, screenshots, and verification, but it omits required template sections like Summary, AI Review Report, Security Audit, and Notes. Rewrite it to follow the template: add Summary, Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes, including the requested cross-platform review.
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.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: preventing the transient 'PR already exists' card while the PR loads.
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.

…R loads

The Checks panel briefly showed the terminal "Pull request already exists"
card (Open Review only) on a cold mount, and only rendered the real PR panel
after a manual refresh.

Root cause (regression from #9428): the eligibility probe resolves
`existing_review` from cache faster than the renderable PR hydrates, and the
new exhaustive selector ranks `existing_review` as a terminal safety blocker
above every loading state. So during the fetch window the panel settled on the
terminal card instead of a self-updating loading state. The auto-fetch also
used a lazy SWR priority, so the PR landed slowly unless the user forced a
foreground refresh.

Fix:
- Selector: while a PR fetch is queued/in-flight and we have positive-but-not-
  yet-renderable review evidence (existing_review or positive_unresolved), show
  the self-updating "Checking status" state instead of the terminal card. It
  flips to the review once details land. A concurrent branch blocker still owns
  the copy.
- Fetch: when a review is known to exist but no renderable PR is cached, escalate
  the auto-fetch to a foreground `active`/80 request (matching manual refresh) so
  it resolves promptly.

Reuses existing i18n keys; adds unit coverage for both parts.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-transient-pr-already-exists branch from 53445ac to b534fa6 Compare July 22, 2026 23:40
…sient-pr-already-exists

# Conflicts:
#	src/main/ipc/worktree-common-git-directory.ts
#	src/main/skills/skill-installation-topology.ts
Fold unresolved-review promotion into the existing refresh effect so cached evidence produces one dispatch instead of an SWR plus active pair. Keep non-GitHub evidence on the budgeted path to avoid forced GitHub work for GitLab and other providers.

@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

🧹 Nitpick comments (1)
src/renderer/src/components/right-sidebar/ChecksPanel.tsx (1)

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

Document the foreground-refresh deduplication ref.

Line 528 introduces non-obvious coordination state. Add a concise comment explaining that it prevents repeated foreground provider work for the same refresh context and review evidence.

As per coding guidelines, TypeScript/JavaScript code should add concise, ideally one-line comments only for non-obvious code, explaining why rather than how.

Proposed comment
+  // Avoid repeating foreground provider work for the same refresh context and review evidence.
  const foregroundedUnrenderedReviewKeyRef = useRef<string | null>(null)

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 77df5ea0-e379-4c52-8a4d-f47fa9a26f8f

📥 Commits

Reviewing files that changed from the base of the PR and between f622c77 and 5a22f3d.

📒 Files selected for processing (5)
  • src/renderer/src/components/right-sidebar/ChecksPanel.tsx
  • src/renderer/src/components/right-sidebar/checks-panel-empty-state.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel-empty-state.ts
  • src/renderer/src/components/right-sidebar/checks-panel-pr-refresh-request.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel-pr-refresh-request.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/renderer/src/components/right-sidebar/checks-panel-empty-state.ts
  • src/renderer/src/components/right-sidebar/checks-panel-empty-state.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel-pr-refresh-request.ts

@brennanb2025
brennanb2025 merged commit 7ba946e into main Jul 23, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…R loads (stablyai#10008)

* fix(checks): stop the transient "PR already exists" card before the PR loads

The Checks panel briefly showed the terminal "Pull request already exists"
card (Open Review only) on a cold mount, and only rendered the real PR panel
after a manual refresh.

Root cause (regression from stablyai#9428): the eligibility probe resolves
`existing_review` from cache faster than the renderable PR hydrates, and the
new exhaustive selector ranks `existing_review` as a terminal safety blocker
above every loading state. So during the fetch window the panel settled on the
terminal card instead of a self-updating loading state. The auto-fetch also
used a lazy SWR priority, so the PR landed slowly unless the user forced a
foreground refresh.

Fix:
- Selector: while a PR fetch is queued/in-flight and we have positive-but-not-
  yet-renderable review evidence (existing_review or positive_unresolved), show
  the self-updating "Checking status" state instead of the terminal card. It
  flips to the review once details land. A concurrent branch blocker still owns
  the copy.
- Fetch: when a review is known to exist but no renderable PR is cached, escalate
  the auto-fetch to a foreground `active`/80 request (matching manual refresh) so
  it resolves promptly.

Reuses existing i18n keys; adds unit coverage for both parts.

* fix(checks): bound unresolved review foreground refreshes

* fix(types): exclude absent stat overloads

* fix(checks): preserve refresh precedence and budget

* fix(checks): avoid redundant foreground PR refreshes

Fold unresolved-review promotion into the existing refresh effect so cached evidence produces one dispatch instead of an SWR plus active pair. Keep non-GitHub evidence on the budgeted path to avoid forced GitHub work for GitLab and other providers.

* fix(checks): scope foreground refreshes by provider
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