huskies: merge 643_story_web_ui_consumer_for_the_unified_status_broadcaster

This commit is contained in:
dave
2026-04-26 11:26:20 +00:00
parent f88bb5f486
commit 8673e563a9
13 changed files with 375 additions and 25 deletions
+20 -1
View File
@@ -1,5 +1,9 @@
import * as React from "react";
import type { PipelineState, WizardStateData } from "../api/client";
import type {
PipelineState,
StatusEvent,
WizardStateData,
} from "../api/client";
import { api, ChatWebSocket } from "../api/client";
import type { LogEntry } from "../components/ServerLogsPanel";
import type { Message } from "../types";
@@ -68,6 +72,9 @@ export interface UseChatWebSocketResult {
} | null>;
serverLogs: LogEntry[];
storyTokenCosts: Map<string, number>;
/** Structured pipeline status events. Each entry preserves the full
* StatusEvent so future UI stories can render per-type icons or filters. */
statusEvents: Array<{ receivedAt: string; event: StatusEvent }>;
}
export function useChatWebSocket({
@@ -116,6 +123,9 @@ export function useChatWebSocket({
const [storyTokenCosts, setStoryTokenCosts] = useState<Map<string, number>>(
new Map(),
);
const [statusEvents, setStatusEvents] = useState<
Array<{ receivedAt: string; event: StatusEvent }>
>([]);
useEffect(() => {
const ws = new ChatWebSocket();
@@ -240,6 +250,14 @@ export function useChatWebSocket({
onLogEntry: (timestamp, level, message) => {
setServerLogs((prev) => [...prev, { timestamp, level, message }]);
},
onStatusUpdate: (event) => {
// Preserve the structured event and receive timestamp so future stories
// can render per-type icons, banners, or filters without format changes.
setStatusEvents((prev) => [
...prev,
{ receivedAt: new Date().toISOString(), event },
]);
},
onConnected: () => {
setWsConnected(true);
},
@@ -276,5 +294,6 @@ export function useChatWebSocket({
setSideQuestion,
serverLogs,
storyTokenCosts,
statusEvents,
};
}