(value: string)
| 97 | } |
| 98 | |
| 99 | async function handleSelect(value: string) { |
| 100 | if (!worktreeSession) return; |
| 101 | |
| 102 | const hasTmux = Boolean(worktreeSession.tmuxSessionName); |
| 103 | |
| 104 | if (value === 'keep' || value === 'keep-with-tmux') { |
| 105 | setStatus('keeping'); |
| 106 | logEvent('tengu_worktree_kept', { |
| 107 | commits: commitCount, |
| 108 | changed_files: changes.length, |
| 109 | }); |
| 110 | await keepWorktree(); |
| 111 | process.chdir(worktreeSession.originalCwd); |
| 112 | setCwd(worktreeSession.originalCwd); |
| 113 | recordWorktreeExit(); |
| 114 | getPlansDirectory.cache.clear?.(); |
| 115 | if (hasTmux) { |
| 116 | setResultMessage( |
| 117 | `Worktree kept. Your work is saved at ${worktreeSession.worktreePath} on branch ${worktreeSession.worktreeBranch}. Reattach to tmux session with: tmux attach -t ${worktreeSession.tmuxSessionName}`, |
| 118 | ); |
| 119 | } else { |
| 120 | setResultMessage( |
| 121 | `Worktree kept. Your work is saved at ${worktreeSession.worktreePath} on branch ${worktreeSession.worktreeBranch}`, |
| 122 | ); |
| 123 | } |
| 124 | setStatus('done'); |
| 125 | } else if (value === 'keep-kill-tmux') { |
| 126 | setStatus('keeping'); |
| 127 | logEvent('tengu_worktree_kept', { |
| 128 | commits: commitCount, |
| 129 | changed_files: changes.length, |
| 130 | }); |
| 131 | if (worktreeSession.tmuxSessionName) { |
| 132 | await killTmuxSession(worktreeSession.tmuxSessionName); |
| 133 | } |
| 134 | await keepWorktree(); |
| 135 | process.chdir(worktreeSession.originalCwd); |
| 136 | setCwd(worktreeSession.originalCwd); |
| 137 | recordWorktreeExit(); |
| 138 | getPlansDirectory.cache.clear?.(); |
| 139 | setResultMessage( |
| 140 | `Worktree kept at ${worktreeSession.worktreePath} on branch ${worktreeSession.worktreeBranch}. Tmux session terminated.`, |
| 141 | ); |
| 142 | setStatus('done'); |
| 143 | } else if (value === 'remove' || value === 'remove-with-tmux') { |
| 144 | setStatus('removing'); |
| 145 | logEvent('tengu_worktree_removed', { |
| 146 | commits: commitCount, |
| 147 | changed_files: changes.length, |
| 148 | }); |
| 149 | if (worktreeSession.tmuxSessionName) { |
| 150 | await killTmuxSession(worktreeSession.tmuxSessionName); |
| 151 | } |
| 152 | try { |
| 153 | await cleanupWorktree(); |
| 154 | process.chdir(worktreeSession.originalCwd); |
| 155 | setCwd(worktreeSession.originalCwd); |
| 156 | recordWorktreeExit(); |
no test coverage detected