Git worktrees & launch dialog
Launch AI agents with an optional initial prompt inside isolated per-tab Git worktrees, with safe dirty-checked cleanup when closing the tab.
Running two agents on the same working directory causes file conflicts and broken git status states. muxbay solves this with the unified Launch Session dialog: launch any built-in agent or custom CLI profile with an optional Initial Prompt inside its own isolated Git worktree.
The Launch Session dialog
While every 1-click quick-launch entry in the + tab menu (and mobile new-tab sheet) remains intact, choosing Launch Session… opens the full launcher:
- Agent or Profile — pick any built-in target (Claude, Codex, Gemini (
agy), Pi, Oh My Pi (omp), Terminal) or any enabled custom CLI Profile configured in Settings → CLI Profiles. - Initial Prompt (optional) — write a multi-line task prompt (submit anytime with ⌘Enter / Ctrl+Enter).
- Isolated Git Worktree (toggle) — create or attach a dedicated branch checkout for this tab.
- Tab Name (optional) — defaults to the branch name (for worktree tabs) or the profile name.
Server-side Initial Prompt delivery
Typing a prompt into a newly spawned agent tab often fails if the CLI is still booting or pauses on a folder trust prompt.
muxbay queues the initialPrompt on the server (src/lib/initial-prompt-delivery.ts) and waits until the agent reaches cliState === 'idle':
- It automatically waits through startup and any
needs-inputfolder trust confirmation. - Once ready, it delivers the text safely via
tmux send-keys -l/ bracketed paste (sendPromptText), followed by submission. - If you picked a CLI Profile with a
defaultPrompt, the Launch Session dialog pre-fills it automatically so you can review or tweak it before launching.
Isolated Git worktrees per tab
When Create isolated worktree is enabled inside a workspace pointing to a Git repository (GET /api/git/worktrees):
- Base branch — choose from all local and remote branches detected in the repo.
- Branch name — validated in real time (
isValidGitBranchName). Click Suggest branch to auto-generate a clean slug from your Initial Prompt (for examplefeat/fix-oauth-callback). - Use existing branch — if the local branch name already exists, a checkbox lets you attach the worktree to that existing branch instead of failing.
Where worktrees live and how workspaces stay clean
Managed worktrees are created at:
~/.purplemux/worktrees/<repo>-<hash>/<slug>-<id>/
- Worktree tabs display a purple
GitBranchbadge in the tab bar showing the branch name. - Right-click the tab and choose Copy worktree path to copy the exact directory path to your clipboard.
- Workspace root safety: opening or focusing a worktree tab never overwrites the workspace's primary root directory (
directories[0]), so new standard tabs still start in your main repository.
Multi-Agent Compare (Fan-out)
Switch Launch Session… to Compare agents to benchmark or race multiple agents on the exact same task:
- Select two or more providers (Claude, Codex, Gemini (
agy), Pi, Oh My Pi (omp)). - Enter your Initial Prompt once — every selected agent receives it as soon as its session becomes idle.
- With Isolated Git worktree enabled, each agent gets its own suffixed branch (
<branch>-claude,<branch>-agy,<branch>-codex) so diffs never collide and can be compared side by side.
Push branch & Create PR (gh pr create)
Right-click any worktree tab and choose Push / Create PR… (WorktreePrDialog, backed by /api/git/worktree-pr) to complete the branch lifecycle from the browser:
- Inspect ahead commit count, live
diff --statagainst the base branch, and uncommitted file warnings. - Detect any existing pull request via GitHub CLI (
gh pr view) or fill in a PR title, description, and optional Draft PR flag. - Choose Push branch (
git push -u origin <branch>) or Push & Create PR (gh pr create).
Safe cleanup on tab close
When you close a tab backed by a worktree, muxbay opens the Worktree Close Dialog (WorktreeCloseDialog) instead of silently deleting files:
- It runs a live status check (
GET /api/git/worktrees?statusPath=...) to detect uncommitted or untracked changes (dirty+ changed file count). - You choose what happens next:
- Keep on disk — closes the tab and tmux session while keeping the worktree directory and branch intact.
- Remove worktree — removes the directory (if uncommitted changes exist, you must explicitly check Force remove even with uncommitted changes first).
- Also delete branch — optional checkbox to delete the local Git branch when removing the worktree.
What's next
- Supported agents & CLI profiles — create reusable presets with
defaultPromptanddefaultWorktree. - Copy, paste & context menus — copy worktree paths and move tabs across workspaces.
- Git workflow panel — inspect diffs and sync inside any worktree tab.