Skip to content

Add sparse checkout worktree creation - #1131

Merged
Jinwoo-H merged 4 commits into
stablyai:mainfrom
colinchambachan:feat-sparse-checkout
Apr 30, 2026
Merged

Jinwoo-H merged 4 commits into
stablyai:mainfrom
colinchambachan:feat-sparse-checkout

Conversation

@colinchambachan

@colinchambachan colinchambachan commented Apr 26, 2026 •

Copy link
Copy Markdown
Contributor

Sparse Checkout Worktree Creation

Summary

  • Add sparse checkout support to local worktree creation using Git cone-mode sparse checkout.
  • Add repo-scoped sparse checkout presets that can be selected/saved from the new-workspace composer.
  • Add per-repo Settings management for sparse presets, including create, edit, and delete.
  • Show sparse worktree metadata on worktree cards so sparse state is visible after creation.

Closes #254

User-Visible Behavior

Users can enable sparse checkout while creating a local worktree, enter repo-relative directories, and optionally save those directories as a per-repo preset. Presets are reusable in the same repo and can also be managed from that repo's Settings section.

Git cone-mode semantics apply: selected directories are included, unrelated directories are pruned, and Git may keep root-level files such as lockfiles or project config files.

Sparse checkout is intentionally limited to local repositories in this PR. Remote/SSH sparse creation is rejected with a clear error.

Screenshots / Recording

Screen.Recording.2026-04-26.at.2.04.48.PM.mov

EDIT: UI updated based on maintainer feedback

image image

Tests

  • pnpm run lint
    • Passes with 2 existing warnings in src/renderer/src/components/diff-comments/useDiffCommentDecorator.tsx.
  • pnpm run typecheck
  • pnpm test
    • 257 files passed.
    • 2848 tests passed, 7 skipped.
  • pnpm build

Manual Testing Notes

  • Created a normal worktree with sparse checkout disabled; behavior was unchanged.
  • Created a sparse worktree with selected directories and verified Git sparse checkout state.
  • Confirmed root-level files such as lockfiles/config can remain, which matches Git cone-mode behavior.
  • Confirmed unrelated directories are excluded while selected directories are present.
  • Confirmed saved presets are scoped per repo and usable from the composer/settings flow.

AI Code Review Summary

The implementation keeps sparse checkout behind the local worktree creation path and preserves the default full-checkout path when sparse mode is off. Sparse directories are normalized and de-duplicated before use, and sparse metadata is persisted on worktree metadata so the renderer can explain sparse state later. Presets are keyed by repo ID and are not shared across repositories.

Cross-platform compatibility:

  • No keyboard shortcut behavior is changed.
  • Directory inputs accept Windows-style backslashes and normalize them to Git repo-relative slash paths.
  • Main-process path handling continues to use existing path utilities for worktree path computation.
  • Remote/SSH sparse checkout is explicitly unsupported for now instead of attempting platform-specific behavior.

Security audit:

  • Sparse directory inputs reject parent traversal (..) before reaching Git.
  • Root-like or empty sparse directory sets are rejected.
  • Preset saves validate the target repo ID before persistence.
  • The feature does not introduce shell interpolation for user-entered sparse paths; paths are passed through existing Git argument APIs.
  • No new network calls or credential handling are introduced.

Platform Notes

Manual verification so far was on macOS. The feature relies on Git sparse-checkout behavior and should work on Linux/Windows for local repositories, with path input normalized before persistence/use.

@colinchambachan
colinchambachan marked this pull request as ready for review April 26, 2026 18:11
@colinchambachan
colinchambachan force-pushed the feat-sparse-checkout branch 2 times, most recently from 334a5af to bd06404 Compare April 29, 2026 12:42
@nwparker
nwparker requested review from Jinwoo-H and removed request for brennanb2025 April 29, 2026 18:12
@Jinwoo-H
Jinwoo-H force-pushed the feat-sparse-checkout branch from bd06404 to cf53f05 Compare April 30, 2026 07:27
- 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>
@Jinwoo-H
Jinwoo-H merged commit 79faafc into stablyai:main Apr 30, 2026
2 checks passed
mralexsaavedra pushed a commit to mralexsaavedra/orca that referenced this pull request May 2, 2026
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
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.

Support optional sparse checkout for new worktrees

2 participants