Skip to content

Refresh visible reviews automatically and stop settled merged polling - #25788

Merged
nwparker merged 7 commits into
mainfrom
nwparker/bug-background-pr-polling-sends-excessive-github
Oct 6, 2026
Merged

nwparker merged 7 commits into
mainfrom
nwparker/bug-background-pr-polling-sends-excessive-github

Conversation

@nwparker

@nwparker nwparker commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca was repeatedly asking GitHub about completed pull requests, including cards outside the visible list. It now refreshes the reviews you can see, stops automatic refreshes after merged checks finish, and checks again when your work changes. No polling setting is added.

What Changed

One owner refreshes branch review metadata per execution host: the main coordinator for local/SSH/WSL GitHub repositories, and a shared renderer queue for runtime-owned repositories and other review providers. Cards and Source Control no longer run separate metadata timers. The Checks panel refreshes check details separately.

Visible review Automatic interval
Selected open/draft review 60 seconds
Other on-screen open/draft review 120 seconds
Merged review with pending or missing checks 60 seconds
Merged review with successful, failed, or completed/no-check status Stops
Closed review 15 minutes, to detect reopening
Branch with no review 60 seconds selected; 15 minutes otherwise
Hidden window, offscreen card, or collapsed group No periodic requests

Visibility means an actual card intersects the sidebar viewport, or the selected workspace has a visible Checks/Source Control panel. Overscan does not count. Visibility return/re-exposure checks stale data once behind a 10-second cooldown. HEAD/link changes, push, review creation/mutation, activation and explicit refresh still discover fresh state. Existing rate-limit and background-budget admission can delay automatic requests.

Failures preserve the last good answer and retry exponentially, without retrying faster than the normal interval. HEAD changes and alias visibility changes retain failure deadlines. Out-of-order responses cannot restart polling stopped by a newer result. Identical in-flight branch/check reads share a request; successful PR mutations invalidate the existing host-scoped generation so the next read cannot join an older lookup. Known Enterprise host authentication lasts 15 minutes; missing authentication retries after one minute.

Why

Verified the original issue with failing request-count regressions before changing production code. Reviewed the design before implementation, then used parallel adversarial reviews to find and fix response-ordering, mutation, visibility and retry races.

A single automatic visibility policy keeps active work current without making users tune a setting. A permanent host cache would hide changes from older clients; the existing found-review host TTL stays at 60 seconds, while current clients stop unnecessary scheduling. An optional cache-bypass field preserves mixed-version compatibility. Credit to @ggbdpq for the initial fix in #25774; included as commit co-author.

Linked Issue

Fixes #25746

Visual Proof

N/A — no layout or controls changed. Background behavior was checked in a hidden Electron renderer through CDP with a 100-workspace fixture: actual viewport cards were eligible, overscan was excluded, scrolling replaced the eligible set, hiding cleared it, and the selected panel remained eligible with the sidebar closed. Measured eligibility: 25 mounted cards / 15 visible; after scroll, 36 mounted / 16 visible; hidden, zero; selected panel with sidebar closed, one.

Measurements

Request counts use fake time and mocked request boundaries; they are not a live Enterprise benchmark. Policy allocations use the actual hook source with simulated React hook slots.

Scenario Before After
Settled merged PR, initial lookup plus 31 minutes continuously visible 2 lookups 1 lookup; still 1 after 24 hours, with no periodic timer
Two simultaneous identical branch lookups 2 resolver calls 1 resolver call
Known Enterprise authentication host, initial probe plus another after 14 minutes 2 probes 1 probe; positive cache expires at 15 minutes
Merged PR with pending/missing checks Continued polling Continues every 60 seconds while visible
Checks policy allocations across five simulated renders, including hide/reopen 5 instances 1 instance; ref/object identity and failure state retained
Unrelated agent updates in visibility reporting Rebuilt candidates/serialized each update 1,000 updates cause zero additional serializations

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

1,628 focused tests across 179 files pass on macOS, covering GitHub lookup/coalescing and mutations; hosted-review caches/providers; IPC/RPC compatibility; renderer cache ownership, selected aliases, visibility and retry scheduling; checks detail polling; and refresh sweeps. Regression tests include real held in-flight mutation lookups, old responses completing after newer results, empty/neutral completed checks, scrolling inside a tall lineage group, hidden-window cleanup, and HEAD changes during failure backoff, discovery after loading older persisted merged-review metadata, lazy Checks policy allocation, and real sidebar card memo/lineage integration.

pnpm tc, changed-code quality, the standalone React Doctor changed-lines gate, the full anti-slop audit, max-lines checks and the Electron production build pass on the final diff. GitHub CI passed all five Node 24 test shards, relay integration, static analysis/typechecking and Linux/Windows packaging on a06ddf607743; the separate mobile and headless persistence checks also passed. Live SSH/WSL and a live Enterprise account remain follow-up platform validation; their execution/provider boundaries have automated coverage. The test-selection evidence report is advisory and excluded from the merge gate.

Review

Deliberate design review completed before implementation. Parallel Codex and Claude Opus 5.5 adversarial reviews iterated through the fixes and both ended with no remaining actionable findings. The Opus final sweep also passed 938 main/shared tests and 2,385 renderer tests; these overlap the integration coverage above. Foreground exposure retains the existing three-refreshes-per-30-seconds burst limit, cooldown and failure deadlines.

Agent skill upstream boundary

  • Not applicable; no upstream skill code or resources copied.

Notes

Desktop review polling only; the separate headless-server polling work in #23311 is outside this change. Host cache fallback on an upstream error can preserve a previously successful answer; older hosts retain their existing cache behavior when they do not support explicit bypass.

Checklist

  • Focused on background review request volume
  • Explained user-facing behavior, mechanism and choice of approach
  • No new controls; background behavior and request measurements provided
  • Self-reviewed correctness, security and performance
  • Cross-platform, SSH/runtime, folder workspace and provider behavior considered
  • Final local validation, independent reviews and GitHub merge gates clean

nwparker and others added 2 commits October 5, 2026 22:03
Remove the polling toggle and its guards. Keep state-aware refresh pacing,
shared in-flight reads, and explicit refresh cache bypass.

Co-authored-by: ggbdpq <[email protected]>
@nwparker nwparker changed the title Reduce background PR polling and duplicate GitHub requests Refresh visible reviews automatically and stop settled merged polling Oct 6, 2026
nwparker and others added 2 commits October 5, 2026 23:12
Use one metadata refresh owner per host, report actual viewport cards and
selected panels, and keep foreground discovery behind cooldown and retry
gates. Preserve failure deadlines and reject superseded completions.
Fence pending reads after PR mutations and share identical provider reads.
Remove the separate card/panel metadata timers and keep checks detail
retry state when the same panel is reopened. No polling setting remains.

Co-authored-by: ggbdpq <[email protected]>
Reuse active pacing for selected foreground requests while preserving
visible cooldown and retry gates. Commit foreground admission only after
visibility acknowledgment, and remove obsolete Checks refresh state.

Co-authored-by: ggbdpq <[email protected]>
@nwparker
nwparker marked this pull request as ready for review October 6, 2026 06:20
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 94821105-2973-41ef-a6fa-9a715470d976
📥 Commits

Reviewing files that changed from the base of the PR and between 70001f3 and a06ddf6.

📒 Files selected for processing (1)
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-polling.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The changes coalesce scoped GitHub PR and checks reads, invalidate hosted-review lookups after successful PR mutations, and revise PR refresh cadence, visibility tracking, and request ownership. They add visible hosted-review target discovery and scheduling. Checks-panel polling now uses shared status and retry policies, and retains check data after fetch failures. Hosted-review lookups can bypass fresh cached results. The changes also remove earlier checks-panel and sidebar polling flows and add tests for these paths.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to a06dd

Some linked-review users may find Push unavailable after reopening a window if target discovery was skipped while hidden and no matching upstream exists. The checks-panel polling change preserves its visibility gates; the remaining conditional push blockage should be addressed or accepted before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #25746 requests reduced polling for merged or closed reviews, reuse of concurrent identical reads, less frequent Enterprise authentication checks, and a setting to limit or disable background PR… Add a global or per-repository setting to limit or disable background PR/check polling, and add automated tests for the setting’s behavior.
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 65 functions across 57 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The refresh scheduling, visibility tracking, request coalescing, authentication caching, mutation invalidation, and associated tests support issue #25746’s desktop GitHub request-volume objectives. Th…
Title check ✅ Passed The title clearly summarizes the main change: automatic refreshes for visible reviews and stopping polling for settled merged reviews.
Description check ✅ Passed The description is mostly complete. It includes the required explanation, linked issue, justified visual-proof N/A, testing details, review notes, and checklist. It also describes the user-facing beha…
Full details: Linked Issues check

Explanation

Issue #25746 requests reduced polling for merged or closed reviews, reuse of concurrent identical reads, less frequent Enterprise authentication checks, and a setting to limit or disable background PR/check polling. The PR implements state- and visibility-aware refresh, coalesces requests, and reports a 15-minute positive Enterprise authentication cache. The current PR description and change summary confirm that no polling setting was added. This leaves a requested coding objective unmet. #23311 concerns separate headless-server work and does not add scope here.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 56f87a69-ff19-4424-a5ff-38b54051f103
📥 Commits

Reviewing files that changed from the base of the PR and between 8d2e926 and 93920f2.

📒 Files selected for processing (96)
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/client-pr-lookup-coalescing.test.ts
  • src/main/github/client/check/get-pr-checks.ts
  • src/main/github/client/list/work-item-search-batch.ts
  • src/main/github/client/lookup/pr-for-branch-outcome.ts
  • src/main/github/client/merge/merge-pr.ts
  • src/main/github/client/merge/pr-auto-merge.ts
  • src/main/github/client/update/pr-details.ts
  • src/main/github/client/update/pr-ready.ts
  • src/main/github/client/update/pr-reviewers.ts
  • src/main/github/client/update/pr-state.ts
  • src/main/github/github-enterprise-repository.test.ts
  • src/main/github/github-enterprise-repository.ts
  • src/main/github/github-read-execution-scope.ts
  • src/main/github/pr-mutation-review-invalidation.test.ts
  • src/main/github/pr-mutation-review-invalidation.ts
  • src/main/github/pr-refresh-candidate-policy.ts
  • src/main/github/pr-refresh-coordinator-alias-coalescing.test.ts
  • src/main/github/pr-refresh-coordinator-completion-order.test.ts
  • src/main/github/pr-refresh-coordinator-error-cadence.test.ts
  • src/main/github/pr-refresh-coordinator-foreground-pacing.test.ts
  • src/main/github/pr-refresh-coordinator-visibility-policy.test.ts
  • src/main/github/pr-refresh-coordinator-visible-follow-up.test.ts
  • src/main/github/pr-refresh-coordinator.ts
  • src/main/github/pr-refresh-pacing.ts
  • src/main/github/pr-refresh-queue-drainer.ts
  • src/main/github/pr-refresh-queue-growth-bound.test.ts
  • src/main/github/pr-refresh-queue.ts
  • src/main/github/pr-refresh-retry-state.ts
  • src/main/github/pr-refresh-visibility.ts
  • src/main/ipc/hosted-review.test.ts
  • src/main/ipc/hosted-review.ts
  • src/main/runtime/rpc/methods/hosted-review.test.ts
  • src/main/runtime/rpc/methods/hosted-review.ts
  • src/main/runtime/runtime-hosted-review-commands.ts
  • src/main/source-control/hosted-review-branch-cache.test.ts
  • src/main/source-control/hosted-review-branch-cache.ts
  • src/main/source-control/hosted-review-scope-generations.ts
  • src/main/source-control/hosted-review.ts
  • src/renderer/src/app-shell/use-app-shell-services.ts
  • src/renderer/src/app-shell/use-visible-hosted-review-refresh.test.tsx
  • src/renderer/src/app-shell/use-visible-hosted-review-refresh.ts
  • src/renderer/src/app-shell/use-visible-review-refresh-reporting.ts
  • src/renderer/src/app-shell/visible-review-reporting.test.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
  • src/renderer/src/components/right-sidebar/checks-panel/checks-detail-polling-policy.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel/checks-detail-polling-policy.ts
  • src/renderer/src/components/right-sidebar/checks-panel/checks-panel-polling-test-model.ts
  • src/renderer/src/components/right-sidebar/checks-panel/review-state-dependencies.ts
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-detail-timer.ts
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-context-state.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-controller-state.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-foreground-effects.test.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-foreground-effects.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-polling-stability.test.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-polling.test.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-polling.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-review-state.tsx
  • src/renderer/src/components/right-sidebar/source-control/review/use-hosted-review-polling.ts
  • src/renderer/src/components/right-sidebar/source-control/review/use-review-context.ts
  • src/renderer/src/components/right-sidebar/source-control/review/use-review-push-target.test.tsx
  • src/renderer/src/components/right-sidebar/source-control/review/use-review-push-target.ts
  • src/renderer/src/components/sidebar/WorktreeCard.hosted-review-refresh.test.tsx
  • src/renderer/src/components/sidebar/use-worktree-card-lifecycle-effects.ts
  • src/renderer/src/components/sidebar/worktree-list/viewport/use-visible-review-refresh.ts
  • src/renderer/src/components/sidebar/worktree-list/viewport/visible-refresh.test.ts
  • src/renderer/src/lib/window-visibility-timeout-poller.test.ts
  • src/renderer/src/lib/window-visibility-timeout-poller.ts
  • src/renderer/src/store/github/cache-model.ts
  • src/renderer/src/store/github/check-actions-errors.test.ts
  • src/renderer/src/store/github/check-actions.ts
  • src/renderer/src/store/github/pr-result-cache.ts
  • src/renderer/src/store/github/pull-request-execution.ts
  • src/renderer/src/store/github/refresh-event-actions.ts
  • src/renderer/src/store/github/refresh-routing-actions.ts
  • src/renderer/src/store/github/refresh-sweep-actions.ts
  • src/renderer/src/store/github/slice-types.ts
  • src/renderer/src/store/github/stale-worktree-refresh-actions.ts
  • src/renderer/src/store/github/visible-hosted-review-refresh-ownership.ts
  • src/renderer/src/store/github/visible-hosted-review-refresh-scheduler.test.ts
  • src/renderer/src/store/github/visible-hosted-review-refresh-scheduler.ts
  • src/renderer/src/store/github/visible-hosted-review-refresh-targets.test.ts
  • src/renderer/src/store/github/visible-hosted-review-refresh-targets.ts
  • src/renderer/src/store/github/worktree-refresh.ts
  • src/renderer/src/store/slices/github-pr-branch-fallback-results.test.ts
  • src/renderer/src/store/slices/github-pr-refresh-owner-routing.test.ts
  • src/renderer/src/store/slices/github-refresh-sweep.test.ts
  • src/renderer/src/store/slices/github.ts
  • src/renderer/src/store/slices/hosted-review-cache-state.ts
  • src/renderer/src/store/slices/hosted-review.ts
  • src/shared/github/pull-request-refresh-types.ts
  • src/shared/hosted-review.ts
  • src/shared/review-refresh-policy.test.ts
  • src/shared/review-refresh-policy.ts
  • src/shared/rpc-contract/hosted-review-params.ts
💤 Files with no reviewable changes (7)
  • src/renderer/src/components/right-sidebar/checks-panel/review-state-dependencies.ts
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-controller-state.tsx
  • src/renderer/src/components/right-sidebar/source-control/review/use-hosted-review-polling.ts
  • src/renderer/src/components/right-sidebar/checks-panel-pr-refresh-request.ts
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-context-state.tsx
  • src/renderer/src/components/right-sidebar/checks-panel-pr-refresh-request.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-review-state.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Comment on lines +21 to +40
useEffect(() => {
if (
!isWindowVisible() ||
!isBranchVisible ||
isFolder ||
!activeWorktreeId ||
activeWorktree?.pushTarget ||
!hasResolvableReviewPushTargetLink
) {
return
}
void ensureHostedReviewPushTarget(activeWorktreeId)
}, [
activeWorktree?.pushTarget,
activeWorktreeId,
ensureHostedReviewPushTarget,
hasResolvableReviewPushTargetLink,
isBranchVisible,
isFolder
])

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Re-run the push-target check when the window becomes visible.

The effect reads isWindowVisible() once, and visibility is not a dependency. Consider a window that mounts the source-control panel while hidden, for example after an app start in the background. The effect returns early and does not run again when the window becomes visible. ensureHostedReviewPushTarget then stays uncalled until another dependency changes, such as a worktree switch.

The removed polling hook ran again on visibility changes, so this is a regression. Subscribe to visibilitychange inside the effect.

Proposed fix
   useEffect(() => {
-    if (
-      !isWindowVisible() ||
-      !isBranchVisible ||
+    if (
+      !isBranchVisible ||
       isFolder ||
       !activeWorktreeId ||
       activeWorktree?.pushTarget ||
       !hasResolvableReviewPushTargetLink
     ) {
       return
     }
-    void ensureHostedReviewPushTarget(activeWorktreeId)
+    let done = false
+    const run = (): void => {
+      if (done || !isWindowVisible()) {
+        return
+      }
+      done = true
+      void ensureHostedReviewPushTarget(activeWorktreeId)
+    }
+    run()
+    document.addEventListener('visibilitychange', run)
+    return () => document.removeEventListener('visibilitychange', run)
   }, [
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
if (
!isWindowVisible() ||
!isBranchVisible ||
isFolder ||
!activeWorktreeId ||
activeWorktree?.pushTarget ||
!hasResolvableReviewPushTargetLink
) {
return
}
void ensureHostedReviewPushTarget(activeWorktreeId)
}, [
activeWorktree?.pushTarget,
activeWorktreeId,
ensureHostedReviewPushTarget,
hasResolvableReviewPushTargetLink,
isBranchVisible,
isFolder
])
useEffect(() => {
if (
!isBranchVisible ||
isFolder ||
!activeWorktreeId ||
activeWorktree?.pushTarget ||
!hasResolvableReviewPushTargetLink
) {
return
}
let done = false
const run = (): void => {
if (done || !isWindowVisible()) {
return
}
done = true
void ensureHostedReviewPushTarget(activeWorktreeId)
}
run()
document.addEventListener('visibilitychange', run)
return () => document.removeEventListener('visibilitychange', run)
}, [
activeWorktree?.pushTarget,
activeWorktreeId,
ensureHostedReviewPushTarget,
hasResolvableReviewPushTargetLink,
isBranchVisible,
isFolder
])

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.

[Bug]: Background PR polling sends excessive GitHub API requests (merged PRs still polled, duplicate concurrent requests)

1 participant