Skip to content

fix(worktrees): stop CLI-created worktrees flashing into a filtered sidebar - #30194

Merged
nwparker merged 3 commits into
mainfrom
nwparker/brief-worktree-visiblity
Oct 18, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/brief-worktree-visiblity

Conversation

@nwparker

@nwparker nwparker commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​80 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​80
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​149 $\color{#cf222e}{\Huge{\mathbf{−}}}$​47 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​102

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:

  1. Orca watches git for worktree changes. During git worktree add it 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.
  2. Orca then saved the metadata and asked the window to open the default terminal in the background. The window attached that terminal to the stale, untagged row it still held. A running terminal means the row isn't sleeping, and with no tag the CLI filter didn't apply, so the card showed.
  3. The next refresh brought the tag, and the card disappeared.

The fix adds src/main/worktree-create-in-flight.ts. The runtime create path (CLI, mobile, agent launch) holds the new path from before git worktree add until 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:

  • Make the window refetch before creating the terminal. This only covers one trigger, and it delays every terminal request.
  • Send the full row along with the terminal request. This adds new data that has to cross between Orca's background process and the window, to patch one race.

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 --porcelain differed.

  • 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-managed with cliProvenance.

  • 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 and check:code-quality:changed pass.

Notes

  • SSH: the runtime create path refuses SSH routes before this point, and the hold only filters rows for the local host, so SSH is unaffected.
  • Paths: compared with areWorktreePathsEqual, so this works across platforms.
  • Folder workspaces: they don't go through this path.
  • Remote and mobile clients: listings simply leave the worktree out while it is being created, with no change to the data they exchange, so mixed client and host versions still work.
  • UI-initiated creates (IPC path): unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

… 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).
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5449eecc-ef70-46b4-bfc7-9c7642cf4f31
📥 Commits

Reviewing files that changed from the base of the PR and between bbdbe72 and 2cfdaa1.

📒 Files selected for processing: 7
  • src/main/ipc/worktrees/listing/detected-provider-listing.ts
  • src/main/ipc/worktrees/listing/register-worktree-catalog-handlers.ts
  • src/main/runtime/runtime-local-worktree-create.test.ts
  • src/main/runtime/runtime-local-worktree-create.ts
  • src/main/runtime/workspaces/workspace-catalog.ts
  • src/main/worktree-create-in-flight.test.ts
  • src/main/worktree-create-in-flight.ts
  • 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.

@nwparker
nwparker merged commit b5fa888 into main Oct 18, 2026
32 checks passed
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