(newCwd)
| 126 | } |
| 127 | |
| 128 | function restartClaude(newCwd) { |
| 129 | log(`Restarting Claude with new CWD: ${newCwd}`); |
| 130 | state.CWD = newCwd; |
| 131 | try { |
| 132 | trustProjectCwd(state.CWD); |
| 133 | } catch (err) { |
| 134 | log(`Failed to trust Claude project cwd "${state.CWD}": ${err.message}`); |
| 135 | } |
| 136 | |
| 137 | stopTailing(); |
| 138 | |
| 139 | state.currentSessionId = null; |
| 140 | state.transcriptPath = null; |
| 141 | state.transcriptOffset = 0; |
| 142 | state.eventBuffer = []; |
| 143 | state.eventSeq = 0; |
| 144 | state.tailCatchingUp = false; |
| 145 | setTurnState('idle', { sessionId: null, reason: 'restart_claude' }); |
| 146 | |
| 147 | const procToRestart = state.claudeProc; |
| 148 | state.claudeProc = null; |
| 149 | if (procToRestart) { |
| 150 | procToRestart.kill(); |
| 151 | } |
| 152 | |
| 153 | setupHooks(); |
| 154 | broadcast({ type: 'cwd_changed', cwd: state.CWD, sessionId: null, lastSeq: 0 }); |
| 155 | spawnClaude(); |
| 156 | } |
| 157 | |
| 158 | module.exports = { |
| 159 | spawnClaude, |
no test coverage detected