MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / trackCursor

Method trackCursor

apps/kimi-web/src/api/daemon/ws.ts:453–463  ·  view source on GitHub ↗

* Advance the tracked cursor from a durable event envelope (seq + epoch). * Volatile frames are skipped (their seq is the same watermark, and a * volatile frame can never carry a NEWER seq than the last durable one).

(frame: Record<string, unknown>)

Source from the content-addressed store, hash-verified

451 * volatile frame can never carry a NEWER seq than the last durable one).
452 */
453 private trackCursor(frame: Record<string, unknown>): void {
454 if (frame['volatile'] === true) return;
455 const sid = frame['session_id'];
456 const seq = frame['seq'];
457 if (typeof sid !== 'string' || typeof seq !== 'number') return;
458 const existing = this.subscriptions.get(sid);
459 if (!existing) return; // not a session we manage
460 if (seq <= existing.seq && existing.epoch !== undefined) return;
461 const epoch = typeof frame['epoch'] === 'string' ? (frame['epoch'] as string) : existing.epoch;
462 this.subscriptions.set(sid, { seq: Math.max(seq, existing.seq), epoch });
463 }
464
465 private send(msg: unknown): void {
466 if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;

Callers 1

handleFrameMethod · 0.95

Calls 2

getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected