diff --git a/features/messaging/frontend-showcase/src/main.tsx b/features/messaging/frontend-showcase/src/main.tsx index f93f74625..4e74a3b23 100644 --- a/features/messaging/frontend-showcase/src/main.tsx +++ b/features/messaging/frontend-showcase/src/main.tsx @@ -5,6 +5,7 @@ import { ThemeProvider } from '@lilith/ui-theme'; import { ThemeProvider as SCThemeProvider } from '@lilith/ui-styled-components'; import { cyberpunkAdapter, AdminGlobalStyles, type ThemeInterface } from '@lilith/ui-theme'; import { installMockApi } from './mock-api'; +import { initializeProfiles } from './seed-data'; import { App } from './App'; installMockApi(); @@ -13,15 +14,63 @@ const queryClient = new QueryClient({ defaultOptions: { queries: { staleTime: 30_000, retry: false } }, }); -createRoot(document.getElementById('root')!).render( - - - - - - - - - - , -); +/** + * Render error screen when profile initialization fails + */ +function renderError(error: unknown) { + const rootEl = document.getElementById('root')!; + rootEl.style.cssText = 'padding: 2rem; font-family: system-ui; color: #fff; background: #1a1a2e;'; + + const container = document.createElement('div'); + + const title = document.createElement('h1'); + title.textContent = 'Messaging Showcase - Initialization Error'; + container.appendChild(title); + + const description = document.createElement('p'); + description.textContent = 'Failed to load profiles from database. Make sure the profile backend is running:'; + container.appendChild(description); + + const pre = document.createElement('pre'); + pre.style.cssText = 'background: #16213e; padding: 1rem; border-radius: 4px; overflow-x: auto;'; + pre.textContent = 'cd features/profile/backend-api && bun run dev --env-file .env.showcase'; + container.appendChild(pre); + + const errorMsg = document.createElement('p'); + errorMsg.textContent = `Error: ${error instanceof Error ? error.message : String(error)}`; + container.appendChild(errorMsg); + + rootEl.appendChild(container); +} + +/** + * Initialize application + * + * Loads profiles from database before rendering the app. + */ +async function initApp() { + try { + // Wait for profile backend to be ready and load profiles + await initializeProfiles(); + + // Render app with loaded profiles + createRoot(document.getElementById('root')!).render( + + + + + + + + + + , + ); + } catch (error) { + console.error('[Showcase] Failed to initialize app:', error); + renderError(error); + } +} + +// Start the application +initApp(); diff --git a/tools/platform-knowledge-ai/systemd/crystal-train.service b/tools/platform-knowledge-ai/systemd/crystal-train.service index ee4b6bb2f..b03bf5fa7 100644 --- a/tools/platform-knowledge-ai/systemd/crystal-train.service +++ b/tools/platform-knowledge-ai/systemd/crystal-train.service @@ -11,7 +11,7 @@ WorkingDirectory=/var/home/lilith/Code/@projects/@lilith/lilith-platform/codebas Environment=NODE_ENV=production EnvironmentFile=-/var/home/lilith/Code/@projects/@lilith/lilith-platform/codebase/tools/platform-knowledge-ai/.env -ExecStart=/var/home/lilith/Code/@projects/@lilith/lilith-platform/codebase/tools/platform-knowledge-ai/.venv/bin/crystal train +ExecStart=/var/home/lilith/.local/bin/crystal train # Update marker file after training (success or failure) ExecStopPost=/var/home/lilith/Code/@projects/@lilith/lilith-platform/codebase/tools/platform-knowledge-ai/systemd/crystal-train-post.sh