Parse ANSI codes in output before SSE broadcast

This commit is contained in:
Jared Miller 2026-01-28 14:17:13 -05:00
parent 3f226996e7
commit 11e72b1025
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -1,6 +1,7 @@
// Core server: HTTP + WebSocket + SSE // Core server: HTTP + WebSocket + SSE
import type { ServerWebSocket } from "bun"; import type { ServerWebSocket } from "bun";
import { ansiToHtml } from "./ansi";
import { import {
appendOutput, appendOutput,
createPrompt, createPrompt,
@ -420,11 +421,11 @@ const server = Bun.serve<SessionData>({
// Handle output message // Handle output message
if (msg.type === "output") { if (msg.type === "output") {
appendOutput(ws.data.sessionId, msg.data); appendOutput(ws.data.sessionId, msg.data); // Store raw ANSI
broadcastSSE({ broadcastSSE({
type: "output", type: "output",
session_id: ws.data.sessionId, session_id: ws.data.sessionId,
data: msg.data, data: ansiToHtml(msg.data), // Parse for display
}); });
return; return;
} }