(chunk, uiState)
| 116 | } |
| 117 | |
| 118 | function handleSSEChunk(chunk, uiState) { |
| 119 | const lines = chunk.split("\n"); |
| 120 | for (const line of lines) { |
| 121 | if (!line.startsWith("data:")) continue; |
| 122 | const json = line.slice(5).trim(); |
| 123 | if (!json) continue; |
| 124 | let evt; |
| 125 | try { |
| 126 | evt = JSON.parse(json); |
| 127 | } catch (e) { |
| 128 | console.warn("Failed to parse event JSON", e); |
| 129 | continue; |
| 130 | } |
| 131 | renderUIEvent(evt, uiState); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | function renderUIEvent(ev, uiState) { |
| 136 | if (!ev || !ev.channel || !ev.type) return; |
no test coverage detected