Reduce push target upstream polling churn#6413
Conversation
📝 WalkthroughWalkthroughAdds 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, and strict refresh clears it before reconciling. 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 | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.ts (1)
36-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument 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/branchhere is not obvious from the code. A shortWhycomment 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 winExercise runtime-target separation through
refreshGitStatusForWorktree.This test only proves the helper key includes
activeRuntimeEnvironmentId. It would still pass if the changed wiring ingit-status-refresh.tsstopped forwardingsettingsintogetCachedAutomaticPushTargetUpstreamStatusorstoreCachedAutomaticPushTargetUpstreamStatus. Mirroring the connection-id test throughrefreshAutomatically()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
📒 Files selected for processing (3)
src/renderer/src/components/right-sidebar/git-status-refresh.tssrc/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.test.tssrc/renderer/src/components/right-sidebar/push-target-upstream-refresh-cache.ts
Summary
Repro / Root Cause
Local WER/trace evidence showed AppHangB1-era git churn in
vendace: about 15status, 15symbolic-ref, 15check-ref-format, 15rev-list, and 30rev-parsespans per minute from 22:05-22:08. The renderer path matched that: automaticrefreshGitStatusForWorktreealways calledfetchUpstreamStatuswhenpushTargetexisted, 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 statuspoll 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.tspnpm 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.tspnpm run typecheck:webNotes
pnpm install --frozen-lockfilecompleted, butcpu-featuresoptional native build reported missing Visual Studio C++ tooling before postinstall skipped optional Electron rebuild modules.Brennan Test Changes Validation
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).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 typecheckandpnpm run typecheck:webpassed.git diff --checkpassed.devBranch=brennanb2025/burden-push-target-poll,devRepoRoot=C:\Users\neil\orca\workspaces\orca\burden-push-target-poll.demo-projectrepo with a local bareoriginand explicitpushTarget. Three automaticrefreshGitStatusForWorktreecalls 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.pnpm run lint: blocked by unrelated existing localization catalog drift insrc/renderer/src/components/settings/AgentRuntimeSetting.tsxandsrc/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
connectionIdand runtime target to keep remote/local surfaces separated.