story-kit: merge 292_story_show_server_logs_in_web_ui

This commit is contained in:
Dave
2026-03-19 01:29:33 +00:00
parent 2346602b30
commit 2f0d796b38
6 changed files with 384 additions and 15 deletions

View File

@@ -85,7 +85,9 @@ export type WsResponse =
/** Streaming token from a /btw side question response. */
| { type: "side_question_token"; content: string }
/** Final signal that the /btw side question has been fully answered. */
| { type: "side_question_done"; response: string };
| { type: "side_question_done"; response: string }
/** A single server log entry (bulk on connect, then live). */
| { type: "log_entry"; timestamp: string; level: string; message: string };
export interface ProviderConfig {
provider: string;
@@ -376,6 +378,11 @@ export class ChatWebSocket {
private onOnboardingStatus?: (needsOnboarding: boolean) => void;
private onSideQuestionToken?: (content: string) => void;
private onSideQuestionDone?: (response: string) => void;
private onLogEntry?: (
timestamp: string,
level: string,
message: string,
) => void;
private connected = false;
private closeTimer?: number;
private wsPath = DEFAULT_WS_PATH;
@@ -461,6 +468,8 @@ export class ChatWebSocket {
this.onSideQuestionToken?.(data.content);
if (data.type === "side_question_done")
this.onSideQuestionDone?.(data.response);
if (data.type === "log_entry")
this.onLogEntry?.(data.timestamp, data.level, data.message);
if (data.type === "pong") {
window.clearTimeout(this.heartbeatTimeout);
this.heartbeatTimeout = undefined;
@@ -516,6 +525,7 @@ export class ChatWebSocket {
onOnboardingStatus?: (needsOnboarding: boolean) => void;
onSideQuestionToken?: (content: string) => void;
onSideQuestionDone?: (response: string) => void;
onLogEntry?: (timestamp: string, level: string, message: string) => void;
},
wsPath = DEFAULT_WS_PATH,
) {
@@ -533,6 +543,7 @@ export class ChatWebSocket {
this.onOnboardingStatus = handlers.onOnboardingStatus;
this.onSideQuestionToken = handlers.onSideQuestionToken;
this.onSideQuestionDone = handlers.onSideQuestionDone;
this.onLogEntry = handlers.onLogEntry;
this.wsPath = wsPath;
this.shouldReconnect = true;