Skip to content

Reduce push target upstream polling churn - #6413

Merged
OrcaWin merged 2 commits into
mainfrom
brennanb2025/burden-push-target-poll
Jun 26, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
brennanb2025/burden-push-target-poll

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • cache automatic publish-target upstream comparisons for unchanged worktree identity, HEAD/branch, push target, connection, and runtime target
  • leave cached poll hits as no-ops so fresher post-push/fetch upstream status is not overwritten by an older poll result
  • keep strict/user-triggered refreshes uncached and clear automatic cache state before strict reconciliation

Repro / Root Cause

Local WER/trace evidence showed AppHangB1-era git churn in vendace: about 15 status, 15 symbolic-ref, 15 check-ref-format, 15 rev-list, and 30 rev-parse spans per minute from 22:05-22:08. The renderer path matched that: automatic refreshGitStatusForWorktree always called fetchUpstreamStatus when pushTarget existed, causing publish-target validation/comparison on every ~3s status poll.

Expected subprocess impact

For a PR-linked worktree with unchanged HEAD/branch and unchanged push target, automatic polling should now perform the publish-target upstream comparison once per 60s cache window instead of every 3s poll. That changes the expected publish-target comparison work from roughly 20 comparisons/minute to about 1 comparison/minute; the regular cheap git status poll still runs as before.

Tests

  • pnpm exec vitest run --config config/vitest.config.ts src\\renderer\\src\\components\\right-sidebar\\push-target-upstream-refresh-cache.test.ts src\\renderer\\src\\components\\right-sidebar\\git-status-refresh.test.ts
  • pnpm exec oxlint src\\renderer\\src\\components\\right-sidebar\\git-status-refresh.ts src\\renderer\\src\\components\\right-sidebar\\push-target-upstream-refresh-cache.ts src\\renderer\\src\\components\\right-sidebar\\push-target-upstream-refresh-cache.test.ts
  • pnpm run typecheck:web

Notes

  • Initial pnpm install --frozen-lockfile completed, but cpu-features optional native build reported missing Visual Studio C++ tooling before postinstall skipped optional Electron rebuild modules.

Brennan Test Changes Validation

  • Focused Vitest: pnpm exec vitest run --config config/vitest.config.ts src\renderer\src\components\right-sidebar\push-target-upstream-refresh-cache.test.ts src\renderer\src\components\right-sidebar\git-status-refresh.test.ts (15 tests passed).
  • Touched-file lint: pnpm exec oxlint src\renderer\src\components\right-sidebar\git-status-refresh.ts src\renderer\src\components\right-sidebar\push-target-upstream-refresh-cache.ts src\renderer\src\components\right-sidebar\push-target-upstream-refresh-cache.test.ts.
  • Typecheck: pnpm run typecheck and pnpm run typecheck:web passed.
  • git diff --check passed.
  • Electron validation launched from this PR worktree and verified identity: devBranch=brennanb2025/burden-push-target-poll, devRepoRoot=C:\Users\neil\orca\workspaces\orca\burden-push-target-poll.
  • Live local git validation used a disposable non-Orca demo-project repo with a local bare origin and explicit pushTarget. Three automatic refreshGitStatusForWorktree calls with unchanged HEAD/branch wrote git status three times but wrote upstream status once; a following strict refresh bypassed the automatic cache and wrote upstream status again.
  • Cleanup: disposable repo removed from the dev app, temp files deleted, PR worktree clean.
  • Full pnpm run lint: blocked by unrelated existing localization catalog drift in src/renderer/src/components/settings/AgentRuntimeSetting.tsx and src/renderer/src/components/settings/agents-search.ts; touched files pass oxlint.

No SSH/remoting live pass was run because this PR changes renderer-side scheduling/caching before provider dispatch, not SSH transport behavior. The cache key includes connectionId and runtime target to keep remote/local surfaces separated.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an in-memory cache for automatic push-target upstream status, keyed by worktree, connection, runtime environment, push target, and git status identity. The automatic git status refresh path now checks and populates the cache, strict refresh clears it, and editor failure handling invalidates matching entries. A new Vitest suite covers cache reuse, invalidation on HEAD and push target changes, TTL expiry, separation by connection and runtime environment, and strict refresh behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning It covers summary, testing, and notes, but omits required Screenshots, AI Review Report, and Security Audit sections. Add the missing Screenshots, AI Review Report, and Security Audit sections, and confirm cross-platform review plus any platform-specific follow-up.
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 describes the main change: reducing push-target upstream polling churn via caching.
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.

🧹 Nitpick comments (2)
src/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.ts (1)

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

Document why the cache key only uses HEAD/branch identity.

This key shape is the core contract of the cache, but the reason for using only head/branch here is not obvious from the code. A short Why comment would help prevent future changes from accidentally widening the key to full status data or narrowing it in a way that breaks cache reuse/invalidation behavior. As per coding guidelines, **/*.{ts,tsx,js,jsx}: When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.

Source: Coding guidelines

src/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.test.ts (1)

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

Exercise runtime-target separation through refreshGitStatusForWorktree.

This test only proves the helper key includes activeRuntimeEnvironmentId. It would still pass if the changed wiring in git-status-refresh.ts stopped forwarding settings into getCachedAutomaticPushTargetUpstreamStatus or storeCachedAutomaticPushTargetUpstreamStatus. Mirroring the connection-id test through refreshAutomatically() would cover the full integration contract. Based on the PR objective and changed-line summary, runtime-environment separation is part of the cache wiring behavior this PR is meant to guarantee.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c059399a-f6e8-41ba-ae2d-ed44fe3ebd62

📥 Commits

Reviewing files that changed from the base of the PR and between 74a012c and f327c23.

📒 Files selected for processing (3)
  • src/renderer/src/components/right-sidebar/git-status-refresh.ts
  • src/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.test.ts
  • src/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.ts

@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.

🧹 Nitpick comments (1)
src/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.ts (1)

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

Document the scope-key/full-key split.

Around Lines 41-80, the separate invalidation scope and status-specific cache key are the core non-obvious invariant here. Please add a short Why: comment so this doesn’t get collapsed later and reintroduce stale automatic entries for the same push target.

Suggested comment
 function getCacheScopeKey({
   settings,
   worktreeId,
   worktreePath,
   connectionId,
   pushTarget
 }: {
   settings?: Pick<GlobalSettings, 'activeRuntimeEnvironmentId'> | null
   worktreeId: string
   worktreePath: string
   connectionId?: string
   pushTarget: GitPushTarget
 }): string {
+  // Why: invalidation must clear every cached head/branch variant for the same
+  // worktree/runtime/push-target scope, so this key intentionally excludes status identity.
   return JSON.stringify([
     worktreeId,
     worktreePath,
     connectionId ?? null,
     getRuntimeEnvironmentKey(settings),
     getPushTargetKey(pushTarget)
   ])
 }

As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fa919622-f63b-4a10-a47f-5ec6b114a42b

📥 Commits

Reviewing files that changed from the base of the PR and between f327c23 and 41e16e8.

📒 Files selected for processing (4)
  • src/renderer/src/components/right-sidebar/git-status-refresh.ts
  • src/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.test.ts
  • src/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.ts
  • src/renderer/src/store/slices/editor.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/right-sidebar/git-status-refresh.ts
  • src/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.test.ts

@OrcaWin
OrcaWin merged commit 1293ed0 into main Jun 26, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Reduce push target upstream polling churn

* Fix push target upstream cache recovery

---------

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.

3 participants