Skip to content

perf(worktrees): skip unchanged lineage after sidebar order saves - #27384

Merged
nwparker merged 2 commits into
mainfrom
nwparker/perf-order-save-lineage-followup
Oct 11, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/perf-order-save-lineage-followup

Conversation

@nwparker

@nwparker nwparker commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​461 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​458
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​178 $\color{#cf222e}{\Huge{\mathbf{−}}}$​37 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​141

ELI5

Saving the sidebar order on a paired host downloads the same parent relationships once per repository. This removes those repeated downloads when the client's relationships are already current. Other clients still receive and display the new order.

What Changed

The Git-scan fix already landed in #27343. This companion adds optional sortOrderOnly: true to its existing remote change event. The desktop still fetches each affected repository and updates Smart sort normally; it skips only the unrelated host-wide lineage request.

That skip requires a successful lineage read for the same store, pairing revision and connection generation, with no pending read or subsequent invalidation. Existing lineage reads share a small readiness observer, including startup, manual, best-effort and failed-write recovery paths. Structural events invalidate before repository discovery or queueing; project/replay refreshes invalidate before scheduling. Cold clients, failed reads, reconnects, renames, mixed event bursts and older hosts keep the existing full refresh and concurrency.

Why

@mmarabel identified the waste in #27268 and proposed the original host change in #27271. Their paired-host capture measured 25 repositories, about 105 worktrees and approximately 1.4 MB downloaded per order save, mostly 25 identical lineage replies.

A compatible hint removes work that the host knows is unrelated to an order save. A generic per-host batch would delay a new parent assignment behind an unrelated slow listing/read. The readiness guard preserves the existing opportunity to recover after failed or incomplete refreshes without a timer, serialized queue or stale-result cache.

Linked Issue

Addresses the repeated lineage downloads in #27268, following the merged host-scan fix in #27343. Keep the issue open: this preserves Smart-sort updates and sortEpoch, including cold-client ordering and the existing creation-grace behavior; it does not claim to eliminate subsequent re-sorts.

Visual Proof

N/A — background work is removed; the displayed order and parent relationships keep their existing behavior.

Testing

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

macOS arm64, with ORCA_BACKGROUND_LAUNCH=1:

  • The existing headless and desktop host scan regressions still pass with the added remote hint; local window notifications and structural invalidation are unchanged.
  • The new 25-repository regression fails against the original event handler with 25 lineage calls and passes with zero after hydration. A 105-row response fixture represents 923,325 bytes of repeated serialized lineage bodies per save; this is a fixture byte count, not a new live-link capture.
  • Actual store-action regressions cover cold hydration, unchanged sort-update behavior, failed ordinary and best-effort refresh recovery, pending reads, queued structural events, old-success fencing, reconnect/re-pair, different hosts, local events and rename/deletion cleanup.
  • On current main: 101 tests passed across nine suites, including headless/desktop order-save scan invalidation and the actual renderer lineage actions. Another 31 targeted runtime lineage/order tests passed. Earlier combined validation passed 145 focused tests before this companion was rebased.
  • Node and web typechecks, changed-file lint/format, changed-code quality gate and git diff --check passed.

Node and web typechecks and the changed-code quality gate also passed on the combined branch. Full lint, native Windows/Linux acceptance and build remain for CI.

Review

Independent review rejected the generic batch for visible freshness delay, then reproduced and fixed failed-refresh and unknown-repository discovery gaps in the hint version. Final source and wire review found no remaining blocker; adverse interleavings and old/new event payloads were checked independently.

Agent skill upstream boundary

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

Notes

No new dependencies, subprocesses, timers or stream opcodes. Old hosts send unmarked events and get the original refresh; old clients ignore the optional field. Mobile still receives the same event and refreshes order. Direct SSH and local desktop notifications keep their existing paths. Folder relationships use the same authoritative read/merge path. Expected merge risk is low; no negative user-facing trade-offs identified.

Checklist

  • This PR is small and focused
  • Explained the user experience, mechanism and choice of 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 covers the remaining gates

Mark order-only remote events and skip redundant lineage downloads only
after a successful current-host read. Preserve independent cold, failed,
pending and structural refreshes, including reconnect and re-pair.

Addresses #27268.

Co-authored-by: mmarabel <[email protected]>
@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: a4084b7f-84e1-4266-8023-43f6925f0ab0

📥 Commits

Reviewing files that changed from the base of the PR and between 5d09004 and b965a7c.


📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime-create-managed-worktree.ts
  • src/main/runtime/orca-runtime-tests/ssh-worktree-lifecycle.spec.ts

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



📝 Walkthrough

Walkthrough

The runtime marks sort-order persistence events with sortOrderOnly: true. SSH worktree creation emits a change event after recording lineage. The renderer carries the hint through event handling and refresh queues. It tracks lineage readiness across refreshes, runtime revisions, and connection generations. The renderer skips lineage fetching only for eligible order-only events when lineage is fresh. Structural events and other ineligible cases trigger lineage refreshes.


Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to b965a

Fresh lineage lets order-only updates avoid redundant reads, while structural changes and recovery paths still refresh it. No actionable merge risk was established; the change appears ready for normal CI and merge.

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 13 functions across 16 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the main change: skipping unchanged lineage refreshes after sidebar order saves.
Description check Passed The description is complete and directly matches the implementation. It explains the user impact, mechanism, rationale, linked issue, testing, compatibility, and review status. It also notes that full…
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.

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

Paired clients now skip lineage refetch on sort-order-only events, so the
pre-lineage create notify on the SSH route could leave lineage stale until
the next structural change.
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