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

Function sendReplay

lib/ws-server.js:53–77  ·  view source on GitHub ↗
(ws, lastSeq = null)

Source from the content-addressed store, hash-verified

51const { restartClaude } = require('./pty-manager');
52
53function sendReplay(ws, lastSeq = null) {
54 const normalizedLastSeq = Number.isInteger(lastSeq) && lastSeq >= 0 ? lastSeq : null;
55 const replayFrom = normalizedLastSeq == null ? 0 : normalizedLastSeq;
56 const records = replayFrom > 0
57 ? state.eventBuffer.filter(record => record.seq > replayFrom)
58 : state.eventBuffer;
59
60 log(`Replay start -> ${wsLabel(ws)} from=${replayFrom} count=${records.length} currentSession=${state.currentSessionId ?? 'null'}`);
61
62 for (const record of records) {
63 ws.send(JSON.stringify({
64 type: 'log_event',
65 seq: record.seq,
66 event: record.event,
67 }));
68 }
69
70 sendWs(ws, {
71 type: 'replay_done',
72 sessionId: state.currentSessionId,
73 lastSeq: latestEventSeq(),
74 resumed: normalizedLastSeq != null,
75 }, 'sendReplay');
76 sendTurnState(ws, 'sendReplay');
77}
78
79function sendInitialMessages(ws) {
80 sendWs(ws, {

Callers 1

setupWebSocketServerFunction · 0.85

Calls 5

logFunction · 0.85
wsLabelFunction · 0.85
sendWsFunction · 0.85
latestEventSeqFunction · 0.85
sendTurnStateFunction · 0.85

Tested by

no test coverage detected