Repository navigation
fix(worktree): restore sparse checkout without per-poll git subprocesses - #1316
Merged
Merged
Conversation
- Use Set-based comparison for sparse preset matching (order-independent) - Replace JSON.stringify with arraysShallowEqual for worktree comparison - Improve detectSparseCheckout to use sparse-checkout list (per-worktree) - Surface cleanup failure context in addSparseWorktree error message - Move sparse checkout UI to bottom of advanced options - Remove unused src/shared/sparse-paths.ts (dead code from rebase) - Fix build-relay.mjs ROOT path after scripts/ → config/scripts/ move Co-authored-by: Orca <help@stably.ai>
…rocess listWorktrees runs on every 3s git-status poll and on every worktree refresh. The original sparse-checkout detection in #1131 spawned `git sparse-checkout list` per non-bare worktree per call, so a user with N worktrees paid 1+N git processes every poll. That regressed main-thread responsiveness enough to require a full revert in #1290. Replace the subprocess with a single fs.stat on the per-worktree `info/sparse-checkout` config file, reached via the existing resolveGitDir helper so linked worktrees resolve to their real `.git/worktrees/<name>` directory. Same truthiness semantics, orders of magnitude cheaper, no new state. Co-authored-by: Orca <help@stably.ai>
mralexsaavedra
pushed a commit
to mralexsaavedra/orca
that referenced
this pull request
May 2, 2026
…ses (stablyai#1316) Co-authored-by: Orca <help@stably.ai> Co-authored-by: Colin <colin.chambachan@gmail.com>
7 tasks done
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…ses (stablyai#1316) Co-authored-by: Orca <help@stably.ai> Co-authored-by: Colin <colin.chambachan@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-lands the sparse checkout feature from #1131 and fixes the performance regression that forced its revert in #1290.
main(previously reviewed)fix(worktree): detect sparse checkout via fs.stat instead of git subprocess): the actual fix, isolated as a standalone diff so reviewers can see exactly what changedRoot cause of the lag
listWorktrees()insrc/main/git/worktree.tsrandetectSparseCheckout(worktree.path)for every non-bare, non-sparse worktree on every call. That detection was implemented as agit sparse-checkout listsubprocess — so the call multiplied 1 git process into1 + Ngit processes per invocation (N = non-bare worktrees).listWorktreesis on the hot path:useGitStatusPollingcallsfetchWorktrees(activeRepoId)every 3 seconds while the window is focused (src/renderer/src/components/right-sidebar/useGitStatusPolling.ts:8,94)fetchAllWorktreesfans outfetchWorktreesover every repo in parallel on startup and on repo-count changesWith multiple repos × multiple worktrees, this produced a continuous stream of git subprocess spawns on the main process every 3s. Each macOS
gitspawn is ~30–100ms of fork/exec + git startup — enough to visibly saturate main-process CPU and delay IPC to the renderer. The symptom "only laggy when the Orca window is focused" matches thedocument.hasFocus()gate on the poll.Remote repos were unaffected because the relay's
listWorktrees(src/relay/git-handler.ts:287-296) does not carry the sparse probe — consistent with the revert PR's observation that the issue was local-only.Fix
detectSparseCheckoutnow does a singlefs.staton<gitdir>/info/sparse-checkout, reusing the existingresolveGitDirhelper (promoted to an export instatus.ts) so linked worktrees correctly resolve to their.git/worktrees/<name>directory. Semantics are preserved — Git writes that file when sparse checkout is enabled for the worktree and does not write it otherwise, which is the same truthiness the oldsparse-checkout liststdout check was asserting.No subprocess, one syscall, no new state.
The updated unit test asserts the absence of
git sparse-checkout listin the call list, so the regression can't silently come back.Verification
pnpm run typecheck— cleanpnpm run lint— 0 warnings, 0 errorssrc/main/git,src/main/ipc/worktrees.test.ts,src/main/ipc/repos-sparse-presets.test.ts) — 125 passed, 0 failedTest plan
git worktree listper cycle, not a burst ofgit sparse-checkout listprocessesMade with Orca 🐋