MCPcopy Create free account
hub / github.com/anomalyco/opencode / handleMessage

Function handleMessage

packages/app/src/components/terminal.tsx:558–582  ·  view source on GitHub ↗
(event: MessageEvent)

Source from the content-addressed store, hash-verified

556 }
557
558 const handleMessage = (event: MessageEvent) => {
559 if (disposed) return
560 if (event.data instanceof ArrayBuffer) {
561 const bytes = new Uint8Array(event.data)
562 if (bytes[0] !== 0) return
563 const json = decoder.decode(bytes.subarray(1))
564 try {
565 const meta = JSON.parse(json) as { cursor?: unknown }
566 const next = meta?.cursor
567 if (typeof next === "number" && Number.isSafeInteger(next) && next >= 0) {
568 cursor = next
569 seek = next
570 }
571 } catch (err) {
572 debugTerminal("invalid websocket control frame", err)
573 }
574 return
575 }
576
577 const data = typeof event.data === "string" ? event.data : ""
578 if (!data) return
579 output?.push(data)
580 cursor += data.length
581 seek = cursor
582 }
583
584 const handleError = (error: Event) => {
585 if (disposed) return

Callers

nothing calls this directly

Calls 2

debugTerminalFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected