From ed53c89aac416acf987b8f8546fe28a9efcc5cb7 Mon Sep 17 00:00:00 2001 From: zbigniew sobiecki Date: Sun, 1 Mar 2026 14:47:40 +0100 Subject: [PATCH] fix(dashboard): initialize prompts at startup for System Prompt tab The dashboard API was not calling initPrompts() at startup, causing the System Prompt tab in the Agent Definition Editor to show blank content. The prompts tRPC router calls getRawTemplate() which requires initPrompts() to be called first. Changes: - Add initPrompts() call in async startDashboard() function - Add proper error handling with Sentry capture and flush before exit - Match the startup pattern used in src/router/index.ts Co-Authored-By: Claude Opus 4.5 --- src/dashboard.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/dashboard.ts b/src/dashboard.ts index 9b9f7207..89a73094 100644 --- a/src/dashboard.ts +++ b/src/dashboard.ts @@ -18,13 +18,14 @@ import { Hono } from 'hono'; import { getCookie } from 'hono/cookie'; import { cors } from 'hono/cors'; import { logger as honoLogger } from 'hono/logger'; +import { initPrompts } from './agents/prompts/index.js'; import { SESSION_COOKIE_NAME } from './api/auth/cookie.js'; import { loginHandler } from './api/auth/login.js'; import { logoutHandler } from './api/auth/logout.js'; import { resolveUserFromSession } from './api/auth/session.js'; import { computeEffectiveOrgId } from './api/context.js'; import { appRouter } from './api/router.js'; -import { captureException, setTag } from './sentry.js'; +import { captureException, flush, setTag } from './sentry.js'; setTag('role', 'dashboard'); @@ -78,5 +79,16 @@ app.onError((err, c) => { // Start const port = Number(process.env.PORT) || 3001; -console.log(`[Dashboard] Starting on port ${port}`); -serve({ fetch: app.fetch, port }); + +async function startDashboard(): Promise { + await initPrompts(); + console.log(`[Dashboard] Starting on port ${port}`); + serve({ fetch: app.fetch, port }); +} + +startDashboard().catch(async (err) => { + console.error('[Dashboard] Failed to start', { error: String(err) }); + captureException(err, { tags: { source: 'dashboard_startup' }, level: 'fatal' }); + await flush(3000); + process.exit(1); +});