Fix SSE event type to include prompt_json field

The prompt SSE event now includes prompt_json to transmit structured
prompt data to the dashboard for rich prompt rendering.
This commit is contained in:
Jared Miller 2026-01-28 13:02:05 -05:00
parent d3fac77f6f
commit a9e6392649
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C
2 changed files with 18 additions and 4 deletions

View file

@ -1,7 +1,7 @@
// SQLite database schema and queries
import { Database } from "bun:sqlite";
import type { Device, OutputLog, Session, PromptData } from "./types";
import type { Device, OutputLog, PromptData, Session } from "./types";
// Extend Prompt interface to include prompt_json field
export interface Prompt {
@ -153,9 +153,18 @@ export function getActiveSessions(): Session[] {
// Prompt functions
export function createPrompt(sessionId: number, promptText: string, promptJson?: string): Prompt {
export function createPrompt(
sessionId: number,
promptText: string,
promptJson?: string,
): Prompt {
const now = Date.now();
const row = createPromptStmt.get(sessionId, now, promptText, promptJson ?? null);
const row = createPromptStmt.get(
sessionId,
now,
promptText,
promptJson ?? null,
);
const prompt = row as any;
// Parse prompt_json if present

View file

@ -71,7 +71,11 @@ export interface ExitPlanPrompt {
options: PromptOption[];
}
export type PromptData = PermissionPrompt | QuestionPrompt | ExitPlanPrompt | null;
export type PromptData =
| PermissionPrompt
| QuestionPrompt
| ExitPlanPrompt
| null;
export type AnswerResponse =
| { type: "option"; value: string }
@ -109,6 +113,7 @@ export type SSEEvent =
prompt_id: number;
session_id: number;
prompt_text: string;
prompt_json?: string | null;
}
| {
type: "prompt_response";