feat: non-blocking worktree creation with in-tab progress#4729
Open
tmchow wants to merge 1 commit into
Open
Conversation
The Create Worktree modal stayed open with a spinning button for the full create IPC (base-ref git fetch + `git worktree add`, ~10-15s on heavy repos) and only dismissed once it resolved, so the user stared at a frozen modal with no way to work elsewhere. Run creation in the background instead. On submit the modal closes immediately and an in-tab "Creating worktree…" panel shows live setup status, wiring the previously-unused `createWorktree:progress` main->renderer event via a per-creation correlation id. A sidebar row tracks each in-flight create, the user can navigate to other worktrees or cancel while it runs, and on success it swaps to the real worktree + terminal in one frame. Failure shows the error in the panel with retry; remote/runtime targets (no progress events) show an indeterminate spinner. Pending creations live in a separate store map rather than a faked Worktree row, so git-status, the tab model, persistence, and PTY spawning are untouched. Only the composer quick-create path changes; other createWorktree callers keep their synchronous behavior.
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — this PR makes worktree creation non-blocking: the modal closes immediately on submit and git fetch + git worktree add run in the background with an in-tab progress panel and sidebar strip.
PendingWorktreeCreationstore map — separate fromworktreesByReposoactiveWorktreeIdstays strictly real; rides on acreationIdcorrelation id for concurrent creates.WorktreeCreationPanel— stepped checklist (fetching → creating) for local targets, indeterminate spinner for remote/runtime targets; error state with Retry/Dismiss.PendingWorktreeCreationsStrip— sidebar row per in-flight creation, with cancel and error indicators; memoized on map reference to avoid re-renders from unrelated store updates.worktree-creation-flow.ts— background orchestration: captures the composer's resolved state into aWorktreeCreationRequest, runscreateWorktreein a fire-and-forget promise, and handles the race where the user dismissed mid-flight by checking the pending entry post-await.setActiveWorktreenow clearsactivePendingCreationId— navigating to any worktree dismisses the creation panel;removePendingWorktreeCreationonly clears the active surface when it pointed at the removed entry, so dismissing a background creation doesn't yank the user.WorktreeStartupPayloadextracted from inline types — deduplicates the anonymous startup-object shape acrossactivateAndRevealWorktree,ensureWorktreeHasInitialTerminal, andapplyDefaultTerminalTabs.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Contributor
|
I think we're on the same wavelength. I was thinking about this. I was wondering though maybe... maybe we can actually just immediatly open the worktree? How?
So in other words, we can make the process instant... just the file might now show up till a few seconds later Interested to hear your thoughts |
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
Creating a worktree no longer blocks you. The Create Worktree modal used to stay open with a spinning button until the entire create finished — base-ref
git fetch+git worktree add, which runs 10–15s on heavy repos — so you sat staring at a frozen modal with nothing else you could do. Now the modal closes the instant you submit and the work continues in the background, where you can watch it, leave it, or cancel it.A new in-tab panel shows live setup status as the worktree spins up, a row in the sidebar tracks each in-flight create, and when git finishes the workspace swaps straight to its terminal. You can switch to other worktrees while one is being created, and if creation fails the panel shows the error with a Retry.
Demo
Before (Left) vs After (Right)
CleanShot_2026-06-05_at_17.12.13-converted.mp4
Behavior
Design notes
Worktreeto get an early sidebar row would ripple through git-status, the tab model, session persistence, and PTY spawning. Keeping them separate meansactiveWorktreeIdstays strictly real and the existing worktree lifecycle is untouched.createWorktree:progresswith no listener; this wires it up and adds a per-create correlation id so concurrent creates each drive their own panel.createWorktreecallers (palette, automation dispatch, session fork) keep their synchronous behavior.Testing
typecheck+lintclean; renderer suite green (2023 tests).