Skip to content

feat(sessions): add ability to move chat sessions between worktrees#223

Open
BowgartField wants to merge 1 commit intocoollabsio:mainfrom
BowgartField:session-worktree-migration
Open

feat(sessions): add ability to move chat sessions between worktrees#223
BowgartField wants to merge 1 commit intocoollabsio:mainfrom
BowgartField:session-worktree-migration

Conversation

@BowgartField
Copy link
Copy Markdown
Contributor

Summary

  • Add "Move to Worktree" context menu option on session tabs (right-click) to move a session from one worktree to another within the same project
  • When the source worktree has uncommitted changes, a confirmation dialog asks whether to migrate them (via git stash/pop) or move the session only
  • Automatically navigates to the target worktree after a successful move
  • Clears CLI session IDs on move (they're tied to the original working directory) and saves a conversation transcript as a per-session context file so Claude retains conversation history in the new worktree

Changes

Backend (Rust):

  • storage.rs: New move_session_to_worktree() — atomically moves session between worktree indices with deadlock-safe locking, clears CLI session IDs, updates metadata
  • commands.rs: New Tauri command with optional git stash/pop for uncommitted changes migration + conversation transcript generation
  • lib.rs: Register command
  • dispatch.rs: Web access dispatch match arm

Frontend (React):

  • MoveSessionDialog.tsx: New AlertDialog with 3 options (move with changes / without / cancel)
  • SessionChatModal.tsx: Full integration — fetches sibling worktrees, handles move logic, uncommitted changes detection, navigation after move
  • SessionListRow.tsx: "Move to Worktree" submenu in context menu
  • session-card-utils.tsx: New props for worktree list and move handler
  • ProjectCanvasView.tsx: Wire up onNavigateToWorktree callback

Test plan

  • Open a project with 2+ worktrees
  • Right-click a session tab → "Move to Worktree" → pick a target
  • On clean worktree: session moves immediately with toast
  • On dirty worktree: dialog appears with 3 options
  • After move: modal navigates to target worktree with moved session selected
  • Send a message referencing prior conversation → Claude has context via transcript
  • Move last session from a worktree → source shows empty session list

- Add move_session_to_worktree command with optional change migration
- Support stashing uncommitted changes when moving sessions
- Preserve conversation history via transcript when moving to new worktree
- Add MoveSessionDialog component for migration confirmation
- Add context menu options to move sessions in SessionListRow and SessionChatModal
- Implement atomic index updates with deadlock prevention for concurrent moves
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