MCPcopy Create free account
hub / github.com/codeaashu/claude-code / read

Method read

src/server/web/scrollback-buffer.ts:51–65  ·  view source on GitHub ↗

* Returns all buffered bytes in chronological order (oldest first). * The returned Buffer is a copy and safe to send over a WebSocket.

()

Source from the content-addressed store, hash-verified

49 * The returned Buffer is a copy and safe to send over a WebSocket.
50 */
51 read(): Buffer {
52 if (this.stored === 0) return Buffer.alloc(0);
53
54 if (this.stored < this.capacity) {
55 // Buffer hasn't wrapped yet — contiguous region starting at index 0
56 return Buffer.from(this.buf.subarray(0, this.stored));
57 }
58
59 // Buffer is full and has wrapped — oldest data starts at writePos
60 const out = Buffer.allocUnsafe(this.capacity);
61 const tailLen = this.capacity - this.writePos;
62 this.buf.copy(out, 0, this.writePos); // tail (oldest)
63 this.buf.copy(out, tailLen, 0, this.writePos); // head (newest)
64 return out;
65 }
66}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected