Repository navigation
fix(worktrees): stop CLI-created worktrees flashing into a filtered sidebar - #30194
Merged
Merged
Conversation
… metadata is saved A watcher-driven listing during `git worktree add` surfaced the new checkout as a bare external row. The host's default-terminal request then made that stale row active, so it slipped past Hide sleeping and Hide CLI-created until the next refresh hid it (~1s flash).
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
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 |
…ee-visiblity # Conflicts: # src/main/runtime/workspaces/workspace-catalog.ts
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.
ELI5
When an agent creates a worktree with
orca worktree create, the new worktree flashed into the sidebar for about a second and then vanished, even with "Hide CLI-created" and "Hide sleeping" on. Rows above and below jumped around. Now Orca waits to list the new worktree until it knows who created it, so the filters hide it from the start.What Changed
Before: CLI-created worktrees briefly appeared in the sidebar despite the filters, then disappeared once the next refresh landed.
After: they never appear while those filters are on. With the filters off they still appear normally, with the "Created by Orca CLI" badge.
Mechanism:
git worktree addit refreshed the list and found the half-created checkout. Its metadata wasn't saved yet, so it had no "created by CLI" or creator tag and read as an outside worktree.The fix adds
src/main/worktree-create-in-flight.ts. The runtime create path (CLI, mobile, agent launch) holds the new path from beforegit worktree adduntil its metadata is persisted, and always releases it, even when creation fails. The worktree listings (worktrees:list,worktrees:listAll, detected listing and the runtime catalog listing) leave held paths out. The window's first sight of the worktree is therefore a fully tagged row. As a side benefit, the half-created checkout no longer gets placeholder metadata written for it.Why
The fault is a listing that exposes a checkout before Orca has finished describing it, so the fix belongs in the listing. Alternatives considered:
Hiding the checkout from listings fixes the cause for every reader. Path-resolution lookups (
listRepoWorktreesForResolution) are untouched, so nothing in the create flow loses the worktree.The hold covers both the requested path and its real path, resolved through the nearest existing parent before creation. This handles symlinked workspace directories and nested parents that Git has not created yet. WSL paths are translated to the host filesystem before resolving aliases.
Linked Issue
N/A (maintainer).
Visual Proof
N/A. The bug is a ~1s flash that needs specific timing to reproduce. It was verified by sampling the renderer's state and DOM (below), not with screenshots.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Unit tests cover per-repo holds, overlapping holds, path normalization, and symlinked workspace directories with missing parents. The symlink regression fails against the original implementation and passes with the fix. Runtime-create tests check that the hold is active during Git creation and released after metadata is saved or creation fails.
Review reproduced the symlink mismatch with a real Git checkout on macOS: the requested alias and the real path in
git worktree list --porcelaindiffered.Reproduced in an isolated dev build on macOS: a repo set to show external worktrees, all the sidebar filters on, and the renderer's worktree refresh slowed by 1.5s. The DOM and store were sampled every ~30ms.
Before the fix: a card for the new worktree appeared for about 150ms to 1s. At that moment it was a stale external row with a live terminal and no
cliProvenance.After the fix: 7 creates across an 8,000-file repo and a 60,000-file repo (4–6s checkout) showed 0 cards. Refreshes that ran mid-checkout left the new worktree out. It first appeared as
orca-managedwithcliProvenance.The default terminal is still created and works.
With the filters off, the card appears normally once creation finishes.
pnpm tc:node, the related main tests andcheck:code-quality:changedpass.Notes
areWorktreePathsEqual, so this works across platforms.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)