feat(terminal): create worktree from agent terminal and transfer session#4767
Merged
gregpriday merged 2 commits intodevelopfrom Apr 1, 2026
Merged
Conversation
- Add TERMINAL_GRACEFUL_KILL IPC channel exposing PtyClient.gracefulKill to renderer - Add gracefulKill to preload, ElectronAPI types, and terminalClient - Add terminal.moveToNewWorktree ActionId and action definition - Add onCreated callback to CreateDialogState in worktreeStore - Update NewWorktreeDialog to pass worktreeId to onWorktreeCreated callback - Wire onCreated callback through App.tsx NewWorktreeDialog integration - Add moveToNewWorktreeAndTransfer store action in restart.ts - Add "Move to New Worktree…" menu item in PanelHeader dropdown (agent panels) - Add "Move to New Worktree…" item in TerminalContextMenu (agent panels) - Add unit tests for worktreeStore onCreated callback lifecycle
- Fix test type annotation (remove invalid ReturnType wrapper) - Fix stale closure in error handler (use newCwd instead of terminal.cwd) - Add .catch() to dynamic import chain for error visibility - Fix test GitHubPR mock to match interface (OPEN state, GitHubUser author) - Fix indentation in moveToNewWorktreeAndTransfer
dbea737 to
dbe9376
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NewWorktreeDialogflow, then gracefully shuts down the current agent session and restarts it in the new worktree with session resume argsgracefulShutdown/agentSessionId/buildResumeCommandlogic already present in the agent registry; no new shutdown mechanics neededResolves #4756
Changes
electron/ipc/channels.ts+handlers/terminal/lifecycle.ts+preload.cts: newterminal.getWorkingDirectoryIPC call so the renderer can read a PTY's cwd before shutdownsrc/store/slices/terminalRegistry/restart.ts:moveToNewWorktreethunk that sequences graceful shutdown, session ID capture, worktree creation trigger, and agent restart in the target directoryshared/types/actions.ts+src/services/actions/definitions/terminalSpawnActions.ts:terminal.moveToNewWorktreeaction wired upsrc/components/Panel/PanelHeader.tsx+src/components/Terminal/TerminalContextMenu.tsx: menu entry exposed in both the three-dots dropdown and the right-click context menu, only shown for agent panelssrc/components/Worktree/NewWorktreeDialog.tsx: minor prop additions to support being triggered programmatically with a callbacksrc/store/worktreeStore.ts:onWorktreeCreatedcallback slot so the terminal store can hook into post-creationsrc/store/slices/__tests__/worktreeStore.onCreated.test.ts: unit tests covering the callback registration and invocationTesting
Unit tests added for the
onWorktreeCreatedcallback path. The existing restart and graceful-shutdown unit tests cover the underlying mechanics. Rannpm run checkclean (zero errors, warnings are pre-existing).