MCPcopy Create free account
hub / github.com/RioArisk/claudecode_api_RemoteControl / restartClaude

Function restartClaude

lib/pty-manager.js:128–156  ·  view source on GitHub ↗
(newCwd)

Source from the content-addressed store, hash-verified

126}
127
128function 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
158module.exports = {
159 spawnClaude,

Callers 1

setupWebSocketServerFunction · 0.85

Calls 7

logFunction · 0.85
trustProjectCwdFunction · 0.85
stopTailingFunction · 0.85
setTurnStateFunction · 0.85
setupHooksFunction · 0.85
broadcastFunction · 0.85
spawnClaudeFunction · 0.85

Tested by

no test coverage detected