Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: async worktree creation#71

Merged
wesbillman merged 1 commit intomainfrom
async-branch-creation
Feb 12, 2026
Merged

feat: async worktree creation#71
wesbillman merged 1 commit intomainfrom
async-branch-creation

Conversation

@matt2e
Copy link
Contributor

@matt2e matt2e commented Feb 12, 2026

Screenshot 2026-02-12 at 11 41 36 am

Summary

Splits local branch creation into two phases—a fast DB record insert and a background git worktree setup—so the modal dismisses instantly and the user sees a "Creating worktree…" spinner on the branch card instead of blocking on a potentially slow git operation. This mirrors the existing pattern used by remote branches (fast DB insert → dismiss → slow workspace provisioning in background).

Changes

Backend (lib.rs)

  • create_branch now only creates the DB record and returns immediately with worktree_path = None — no git operations
  • setup_worktree (new Tauri command) takes a branch_id, looks up the branch and project, creates the git worktree, and records the workdir entry; separated so the frontend can call it in the background after the modal closes

Frontend

  • NewBranchModal.svelte — stripped down to just call createBranch and onCreated; no longer orchestrates worktree setup or prerun actions itself
  • ProjectHome.svelte — after onCreated dismisses the modal, detects local branches with no worktreePath and kicks off setupWorktree in the background; on success it reactively updates the branch list and then fires prerun actions
  • BranchCard.svelte — adds a "Creating worktree…" loading state (spinner + branch info header) for local branches that don't yet have a worktreePath
  • commands.ts — adds setupWorktree(branchId) wrapper and documents the two-step contract on createBranch

Split create_branch into two steps so the modal dismisses immediately:

1. create_branch (fast) — creates the DB record only, returns with
   worktreePath=null
2. setup_worktree (slow) — creates the git worktree and workdir record,
   called in the background by ProjectHome after the modal closes

BranchCard now shows a "Creating worktree…" spinner when a local branch
has no worktreePath yet. Once setup_worktree resolves, ProjectHome updates
the branch record and the card transitions to its normal state, then
prerun actions fire automatically.

This matches the existing pattern used by remote branches (fast DB insert
→ dismiss → slow workspace provisioning in background).
@matt2e matt2e changed the title Make local branch creation async by deferring worktree setup to the background feat: async worktree creation Feb 12, 2026
@wesbillman wesbillman merged commit eb3bfb5 into main Feb 12, 2026
3 checks passed
@wesbillman wesbillman deleted the async-branch-creation branch February 12, 2026 19:48
taylorkmho added a commit that referenced this pull request Feb 12, 2026
* origin/main:
  feat: async worktree creation (#71)
  fix: Skip main worktree on project import and remove main badge UI (#70)
  feat(ui): replace long-press picker with explicit New note / New commit buttons (#67)
  fix: remember ordered list of recent agents instead of single last-used (#65)
  fix: capitalize 'Staged' in macOS application menu (#64)
  fix: dismiss new branch dialog immediately for remote branches (#57)
  feat: add Amp (Sourcegraph) as a supported ACP agent (#55)
  feat: restore subfolder autocomplete in new project dialog (#56)
  Consolidate ACP implementations into acp-client crate (#52)

# Conflicts:
#	staged/src/lib/BranchCard.svelte
#	staged/src/lib/NewSessionModal.svelte
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.

2 participants