Skip to content

perf(worktrees): preserve Git scans when saving sort order - #27343

Merged
nwparker merged 2 commits into
mainfrom
nwparker/perf-sort-order-no-scan
Oct 11, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/perf-sort-order-no-scan

Conversation

@nwparker

@nwparker nwparker commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Saving the sidebar order on a paired remote host should not make Git scan every repository again. Reuse the existing scans while publishing the same order updates to desktop and mobile clients.

What Changed

Order saves already invalidate the combined worktree rows so the next listing reads fresh sortOrder metadata. They now explicitly skip invalidating the separate Git scan caches through an optional flag on the existing notifier. The flag is also forwarded through the desktop window notifier, so both headless and desktop hosts preserve those scans. Structural changes still invalidate the caches; the desktop notification and existing worktreesChanged event remain in place.

Why

@mmarabel identified this waste and proposed the host fix in #27271. Their report measured 25 Git worktree scans per save and 40–74 fleet sweeps per hour on a paired host with 25 repositories. This removes the scans caused by order saves while preserving normal cache expiry and structural invalidation.

A focused notifier option avoids another notification method or a renderer scheduler. The regression proves a save publishes the new order with one initial Git scan instead of two, then proves a structural change still triggers a second scan.

Linked Issue

Addresses the unnecessary host scans in #27268. The repeated desktop lineage downloads described there remain outside this change.

Visual Proof

N/A — only background cache invalidation changes; no rendered interface changes.

Testing

  • Native app manual acceptance
  • Automated regression added and verified failing before the fix

macOS arm64, with ORCA_BACKGROUND_LAUNCH=1:

  • The scan-count regression failed before the fix: two Git scans instead of one. Coverage now includes both headless and desktop-window hosts, with identical order notifications.
  • 11 tests passed across the sort-order regression, structural invalidation and resolved-cache suites, with no skips.
  • 22 targeted cache/order tests passed through the runtime compatibility entry point.
  • Full pnpm tc passed.
  • pnpm run check:code-quality:changed passed with zero new findings across three files.
  • Changed-file formatting and git diff --check passed.

GitHub CI passed on the merged head d3eb9b6052409b71ee4305accc103e1ae3add1b8. Live paired-host acceptance was not performed locally.

Review

Independent review checked notifier callers, resolved metadata projection, structural invalidation and cache freshness. The production change affects only the sort-order notification call and an optional flag that defaults to current behavior.

Agent skill upstream boundary

  • Not applicable; no upstream skill source or assets copied.

Notes

No new subprocesses, dependencies, RPC fields or stream messages. Scan ownership stays on the execution host. Folder-workspace metadata still gets refreshed, SSH scan policy is unchanged, and older clients receive the same event. Expected merge risk is low; no negative user-facing trade-offs identified.

This change makes no claim to the original PR's reduction from roughly 1.4 MB to 0.3 MB per save: that required separate renderer changes.

Checklist

  • This PR is small and focused
  • Explained the user experience, mechanism and reason for the approach
  • N/A visual proof explained
  • Self-reviewed and independently reviewed
  • Cross-platform, SSH, mobile and compatibility considered
  • Full lint, test suite and build; focused checks above passed and CI will cover the remaining gates

@coderabbitai

coderabbitai Bot commented Oct 11, 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: 7faccaa4-38b6-4a9c-a275-9399c55543a5


📥 Commits

Reviewing files that changed from the base of the PR and between be2c872 and d3eb9b6.



📒 Files selected for processing (4)
  • src/main/runtime/orca-runtime-get-status.ts
  • src/main/runtime/runtime-notifier-contract.ts
  • src/main/runtime/runtime-sort-order-scan-cache.test.ts
  • src/main/window/runtime-window-lifecycle.ts


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




📝 Walkthrough
📝 Walkthrough

Walkthrough

The worktree-change notification now accepts an option to skip Git scan invalidation. Sort-order persistence uses that option. Tests check that sort-order updates publish a worktree-change event without another Git scan, while a removal-change notification triggers a rescan.



Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to d3eb9

No actionable issue was established that would prevent merging. The desktop scan-regression test coverage remains uncertain.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description check Passed The description is complete and directly matches the change. It includes the required ELI5, change summary, rationale, linked issue, visual proof, testing details, review notes, compatibility consider…
Title check Passed The title clearly and concisely describes the primary change: preserving Git scans when saving sidebar order. It is specific, relevant, and suitable for project history.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR




  • Autofix · 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.

Credit @mmarabel for identifying the repeated scans and the host-only approach in #27271.

Co-authored-by: mmarabel <[email protected]>
@nwparker
nwparker force-pushed the nwparker/perf-sort-order-no-scan branch from 762841b to be2c872 Compare October 11, 2026 03:44
…p hosts too

The desktop window notifier ran the worktree-change invalidators unconditionally,
so a desktop (or paired-host) Orca still cleared Git scan caches on every sidebar
order save. Carry the invalidateGitScans flag through the notifier; every other
caller keeps the default.
@nwparker
nwparker merged commit e4f599d into main Oct 11, 2026
39 checks passed
@nwparker nwparker changed the title perf(worktrees): preserve Git scans when saving sidebar order perf(worktrees): avoid redundant scans and lineage reads after order saves Oct 11, 2026
@nwparker nwparker changed the title perf(worktrees): avoid redundant scans and lineage reads after order saves perf(worktrees): preserve Git scans when saving sort order Oct 11, 2026
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