[PR #13528] feat(tui): add worktree support for session creation #14706

Open
opened 2026-02-16 18:19:28 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13528

State: open
Merged: No


Summary

  • Adds worktree (workspace) support to the TUI, matching the Web UI's existing capability
  • Users can create isolated git worktrees per session via the /workspace slash command (aliases: /worktree, /sandbox)
  • Sessions created in a worktree use a dedicated SDK client targeting that worktree's directory, ensuring full isolation

Changes

  • context/sync.tsx — Track sandboxes list in sync store, fetch via sdk.client.worktree.list(), refresh on project.updated events
  • context/sdk.tsx — Add createClient(directory) helper to create SDK clients targeting specific worktree directories
  • component/dialog-worktree.tsx (new) — Worktree selector dialog with options: main workspace, existing sandboxes, create new
  • routes/home.tsx — Workspace state persisted via KV, workspace label in footer bar
  • component/prompt/index.tsx — Worktree-aware submit: creates worktree via API if needed, routes session/prompt calls through worktree-specific client
  • component/dialog-session-list.tsx — Shows [workspace-name] for sessions belonging to a worktree
  • app.tsx — Register /workspace slash command (only for git projects)

Testing

  • bun turbo typecheck passes all 12 packages
  • Follows existing patterns from Web UI (packages/app/src/components/prompt-input/submit.ts, session-new-view.tsx)
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13528 **State:** open **Merged:** No --- ## Summary - Adds worktree (workspace) support to the TUI, matching the Web UI's existing capability - Users can create isolated git worktrees per session via the `/workspace` slash command (aliases: `/worktree`, `/sandbox`) - Sessions created in a worktree use a dedicated SDK client targeting that worktree's directory, ensuring full isolation ## Changes - **`context/sync.tsx`** — Track `sandboxes` list in sync store, fetch via `sdk.client.worktree.list()`, refresh on `project.updated` events - **`context/sdk.tsx`** — Add `createClient(directory)` helper to create SDK clients targeting specific worktree directories - **`component/dialog-worktree.tsx`** *(new)* — Worktree selector dialog with options: main workspace, existing sandboxes, create new - **`routes/home.tsx`** — Workspace state persisted via KV, workspace label in footer bar - **`component/prompt/index.tsx`** — Worktree-aware submit: creates worktree via API if needed, routes session/prompt calls through worktree-specific client - **`component/dialog-session-list.tsx`** — Shows `[workspace-name]` for sessions belonging to a worktree - **`app.tsx`** — Register `/workspace` slash command (only for git projects) ## Testing - `bun turbo typecheck` passes all 12 packages - Follows existing patterns from Web UI (`packages/app/src/components/prompt-input/submit.ts`, `session-new-view.tsx`)
yindo added the pull-request label 2026-02-16 18:19:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14706