()
| 780 | } |
| 781 | |
| 782 | export async function keepWorktree(): Promise<void> { |
| 783 | if (!currentWorktreeSession) { |
| 784 | return |
| 785 | } |
| 786 | |
| 787 | try { |
| 788 | const { worktreePath, originalCwd, worktreeBranch } = currentWorktreeSession |
| 789 | |
| 790 | // Change back to original directory first |
| 791 | process.chdir(originalCwd) |
| 792 | |
| 793 | // Clear the session but keep the worktree intact |
| 794 | currentWorktreeSession = null |
| 795 | |
| 796 | // Update config |
| 797 | saveCurrentProjectConfig(current => ({ |
| 798 | ...current, |
| 799 | activeWorktreeSession: undefined, |
| 800 | })) |
| 801 | |
| 802 | logForDebugging( |
| 803 | `Linked worktree preserved at: ${worktreePath}${worktreeBranch ? ` on branch: ${worktreeBranch}` : ''}`, |
| 804 | ) |
| 805 | logForDebugging( |
| 806 | `You can continue working there by running: cd ${worktreePath}`, |
| 807 | ) |
| 808 | } catch (error) { |
| 809 | logForDebugging(`Error keeping worktree: ${error}`, { |
| 810 | level: 'error', |
| 811 | }) |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | export async function cleanupWorktree(): Promise<void> { |
| 816 | if (!currentWorktreeSession) { |
no test coverage detected