Skip to content

feat(tui): add worktree support for session creation#13528

Open
abrekhov wants to merge 2 commits intoanomalyco:devfrom
abrekhov:feat/tui-worktree-support
Open

feat(tui): add worktree support for session creation#13528
abrekhov wants to merge 2 commits intoanomalyco:devfrom
abrekhov:feat/tui-worktree-support

Conversation

@abrekhov
Copy link

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)

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search results, I found one potentially related PR:

PR #12008: fix: filter CLI sessions by current directory for worktree support

Why it might be related: This PR addresses worktree support at the CLI level by filtering sessions based on the current directory. Since the current PR (13528) adds worktree support to the TUI with directory-based session isolation, these two PRs are working on related aspects of the same worktree feature - one for CLI and one for TUI.

All other search results either returned the current PR itself (13528) or unrelated PRs about memory leaks, layouts, snapshots, etc.

…on sync

- Replace standalone signal with KV-derived accessor for worktree selection
- Forward global.event RPC channel in createEventSource for cross-worktree events
- Add directory field to SessionRoute for worktree-scoped navigation
- Use worktree-scoped client in session.sync when directory is provided
- Track resolved directory through submit flow for correct routing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant