Repository navigation
fix(worktrees): a phone or CLI create keeps a sparse preset only when its folders match - #26104
Conversation
… directories match The window's create records a sparse preset on the new worktree only when the checked-out directories are exactly that preset's, so an edited selection is not shown as the preset it began as. The host's create wrote whatever preset id it was sent. Both now share one check (moved out of the two copies in the window's create path).
…d never fail the create on them The shared preset check took the preset list up front, so every create read the presets even with no preset chosen (the window's create used to skip the read), and a read that threw failed the create - on the host after `git worktree add` had already run. The check now takes a reader, returns early when no preset was sent, and reads inside its try so unreadable presets record no preset instead of blocking the create. Repeated checked-out directories no longer match a preset with a different set of directories.
Review and QA summary (8243c74)The problem. Orca saves which sparse-checkout preset a new workspace came from ( The user-facing change. Nothing visible today: no screen displays the saved preset id, and no current client sends one to the host (the phone's create sends no sparse settings, the CLI has no sparse option). What changes is the saved record. A host create with a mismatched or unknown preset id no longer stores it, which matches desktop creates ahead of desktop creates moving onto the host. Desktop creates behave the same as before. The PR description has been corrected to say this; it previously said the workspace was "labelled" with the preset. Fixed during review (commit 8243c74).
Deferred (not this PR).
Verified.
In every row, on both builds, the create succeeded, the worktree exists on disk, and the sparse checkout holds exactly the requested folders. Nothing was worse than main. Not verified. The desktop-window path was not exercised in a running app, since it's a pure refactor covered by its existing tests and has no UI. No mobile emulator run: the phone sends no sparse settings and nothing on the phone shows the preset. No screenshots, since nothing on screen changes; the RPC transcripts are the evidence. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughA shared Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Host-created worktrees now keep a sparse preset ID only when the preset belongs to the repository and its folders match the checked-out folders. A failed preset read no longer fails the create. The change is tested and I found no merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
ELI5
When you create a workspace with a sparse checkout (only some folders checked out), Orca saves which sparse preset you started from in the workspace's record, but only when the folders you actually checked out are exactly that preset's. If you picked a preset and then changed the folder list, the workspace isn't that preset any more.
The desktop's own create already applies that rule. A create that goes through the host instead (the
worktree.createcall used by the phone, the CLI andagent.launch) saved whatever preset id it was sent. This PR makes the host's create apply the same rule, so the two create paths agree before desktop creates move onto the host.What Changed
The problem.
createManagedWorktree→materializeRuntimeLocalWorktree) wrote the request'ssparsePresetIdwithout checking it: a stale id, another repo's preset, or a preset whose folders had been edited was saved as-is.worktree-remote.ts) keeps the id only when the preset belongs to the repo and its folders match, and it did that in two copied blocks.User-facing change.
The mechanism.
attributedSparsePresetId(readPresets, repoId, presetId, directories), holds the existing rule: the preset must belong to this repo and its folders must equal the checked-out ones as a set.Why
Linked Issue
Part of the new-workspace launch unification (parity fixes before the desktop composer moves onto
agent.launch).Visual Proof
These images are the raw RPC results from the live QA run (M4Air, main c8dcffc vs PR 8243c74): each row sends the same
worktree.createto main and to the PR, then reads the savedsparsePresetIdback fromworktree.list.Testing
sparse-preset-attribution.test.ts(new): a preset whose folders match in any order (or with a trailing slash) is kept; an edited selection, a duplicated folder list, another repo's preset, a deleted preset, a corrupt preset, or no preset records none; the presets aren't read when no preset id was sent; a failed read records none.runtime-local-worktree-create.test.ts: the host's create records the preset for exactly its folders, none for an edited selection, and still succeeds (with no preset) when reading presets fails.The window's existing tests (
worktrees-setup-launch-sparse-checkout.test.ts,worktrees-windows.test.ts) pass unchanged.tc:node, oxlint.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Notes
createRemoteWorktree, which now uses the same function.Author: @BrennanKB5