MCPcopy Index your code
hub / github.com/codeaashu/claude-code / resume

Method resume

src/server/web/session-manager.ts:203–230  ·  view source on GitHub ↗

* Attaches a new WebSocket to an existing session identified by `token`. * * - Cancels the grace timer * - Sends `{ type: "resumed", token }` to the client * - Replays the scrollback buffer so the user sees their conversation * - Resizes the PTY to the client's current terminal dimens

(token: string, ws: WebSocket, cols: number, rows: number)

Source from the content-addressed store, hash-verified

201 * Returns true if the session was found, false otherwise.
202 */
203 resume(token: string, ws: WebSocket, cols: number, rows: number): boolean {
204 const session = this.store.reattach(token, ws);
205 if (!session) return false;
206
207 console.log(
208 `[session ${token.slice(0, 8)}] Resumed (active: ${this.store.size}/${this.maxSessions})`,
209 );
210
211 // Tell the client it's a resumed session BEFORE sending scrollback bytes.
212 // The client uses this to clear the terminal first.
213 ws.send(JSON.stringify({ type: "resumed", token }));
214
215 // Replay buffered output
216 const scrollback = session.scrollback.read();
217 if (scrollback.length > 0) {
218 ws.send(scrollback);
219 }
220
221 // Sync PTY dimensions to the reconnected client
222 try {
223 session.pty.resize(cols, rows);
224 } catch {
225 // PTY may have exited
226 }
227
228 this.wireWsEvents(token, ws, session.pty);
229 return true;
230 }
231
232 /**
233 * Wire PTY → scrollback + WebSocket.

Callers

nothing calls this directly

Calls 5

wireWsEventsMethod · 0.95
reattachMethod · 0.80
sendMethod · 0.65
readMethod · 0.65
resizeMethod · 0.45

Tested by

no test coverage detected