feat: implement websocket-stream for journal server

Integrate `websocket-stream` to handle MQTT broker upgrades in the
CLI and add granular connection status tracking to the UI.

- Add `websocket-stream` dependency
- Update CLI to use `websocket-stream` for socket upgrades
- Enhance `journalStream` store with `connectionStatus` and
  `connectionError` states
- Add visual connection status indicators to `App` and `JournalPanel`
This commit is contained in:
2026-07-06 15:38:28 +08:00
parent 862ba9c01b
commit 34d647d611
6 changed files with 116 additions and 12 deletions
+6 -1
View File
@@ -20,6 +20,7 @@ import {
} from "fs";
import type { Server as HttpServer } from "http";
import type { AedesPublishPacket } from "aedes";
import websocketStream from "websocket-stream";
// ---------------------------------------------------------------------------
// Types
@@ -106,7 +107,11 @@ export async function createJournalServer(
httpServer.on("upgrade", (req, socket, head) => {
wsServer.handleUpgrade(req, socket, head, (ws) => {
broker.handle(ws as unknown as import("net").Socket);
// websocket-stream's types reference an older ws version; cast works.
const stream = websocketStream(
ws as unknown as Parameters<typeof websocketStream>[0],
);
broker.handle(stream);
});
});