Skip to content

[Feature]: Launch agent immediately; run git worktree in background #130

Closed

Description

@gsvprharsha

What problem are you trying to solve?

When creating a new branch session, the agent tab is not launched until the git worktree finishes being created. Worktree creation is not instant, so the user sits and waits before the agent starts. The perceived latency undermines the feel of "instant" branch sessions.

What would the solution look like?

Order should be:

  1. Row is created in the sidebar (instant — already the case).
  2. Agent tab opens (instant).
  3. Agent process fires immediately against a temporary/placeholder cwd or is queued to swap cwd once the worktree is ready.
  4. Git worktree creation runs in the background; the session rebinds to the real path when ready.

The user should never wait on the worktree to see the agent start. UI can show a subtle "preparing branch…" indicator on the session row until the rebind completes.

Alternatives you've considered

  • Pre-create a warm worktree pool per project — reduces latency but adds disk overhead and complexity.
  • Keep the current behavior but show a progress indicator — treats the symptom, not the cause.

Which area does this touch?

  • Agent / terminal nodes

Before submitting

  • I searched existing issues and this hasn't been requested yet
  • This is aligned with the direction in ROADMAP.md, or I've explained why it should be

Activity

  1. added
    enhancement
    on Sep 27, 2026
  2. changed the title [-]Agent launch should not wait on git worktree creation[/-] [+][Feature]: Launch agent immediately; run git worktree in background[/+] on Sep 27, 2026
  3. added
    help wanted
    on Sep 30, 2026
  4. gsvprharsha commented on Sep 30, 2026

    @gsvprharsha
    CollaboratorAuthor

    Status: stuck — help wanted

    We've tried several approaches and none have cracked it. The tab opens instantly, but the xterm.js pane doesn't actually start the agent process until the git worktree finishes building.

    What we've tried

    • Parallelize worktree add with session prep (commit 18c94c3) — helps a little on wall-clock, but the agent still doesn't fire in xterm until the worktree write settles.
    • Open the tab first, spawn agent second — tab shows immediately, but the PTY write / xterm attach path stalls behind the worktree op somewhere in the async chain.
    • Placeholder cwd, rebind later — attempted routing the agent at a temp dir and swapping cwd on ready. Either the agent didn't accept the swap cleanly, or xterm still waited on the same upstream await.

    The mystery

    The tab UI paints instantly. The agent PTY appears to be dispatched. But visually in xterm, nothing renders / no prompt streams until the worktree git worktree add returns. Feels like something in the Tauri command / PTY plumbing is serialized behind the worktree future even when we tokio::spawn it.

    Where we suspect the block

    • Something in src-tauri/src/lib.rs around PTY session creation may be holding a lock or awaiting worktree completion.
    • Possibly xterm's onData / attach isn't wired until after the worktree resolves.
    • Could also be a frontend await in the branch-launch flow that we haven't isolated.

    What would help

    • Fresh eyes on the branch-launch → PTY spawn → xterm attach chain.
    • A repro-and-fix PR, or even just a diagnosis of where the actual serialization happens.

    Constraints (per project rules): don't modify core PTY infrastructure (create_pty_session, write_to_pty, WorkspaceView PTY wiring) — only the consumer / launch flow.

  5. added a commit that references this issue on Sep 30, 2026
    467da5f
  6. added a commit that references this issue on Nov 22, 2026
    18c94c3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions