MCPcopy
hub / github.com/claude-code-best/claude-code / reconnect

Function reconnect

src/ssh/createSSHSession.ts:208–235  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

206 let currentProc = proc
207
208 const reconnect = async (): Promise<Subprocess> => {
209 logForDebugging('[SSH] reconnect: re-spawning SSH process with --continue')
210 const reconnectArgs = [...sshArgs]
211 const cmdIdx = reconnectArgs.length - 1
212 const existingCmd = reconnectArgs[cmdIdx]!
213 if (!existingCmd.includes('--continue')) {
214 reconnectArgs[cmdIdx] = existingCmd.replace(
215 / -p(?:\s|$)/,
216 ' -p --continue ',
217 )
218 }
219
220 const newProc = Bun.spawn(reconnectArgs, {
221 stdin: 'pipe',
222 stdout: 'pipe',
223 stderr: 'pipe',
224 })
225
226 const newStderrChunks: string[] = []
227 collectStderr(newProc, newStderrChunks)
228
229 await waitForInit(newProc, remoteCwd)
230 currentProc = newProc
231 stderrChunks.length = 0
232 stderrChunks.push(...newStderrChunks)
233
234 return newProc
235 }
236
237 return {
238 remoteCwd,

Callers 1

attemptReconnectMethod · 0.85

Calls 6

collectStderrFunction · 0.85
waitForInitFunction · 0.85
buildCliLaunchFunction · 0.85
logForDebuggingFunction · 0.50
spawnMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected