import { useState, type ReactElement } from 'react'; import { ErrorBoundary } from './components/error-boundary.js'; import { useVault, VaultProvider } from './contexts/vault-context.js'; import { useRunSocket } from './lib/ws.js'; import { Config } from './screens/config/config.js'; import { History } from './screens/history.js'; import { Run } from './screens/run.js'; import { VaultSetup } from './screens/vault-setup.js'; import { VaultUnlock } from './screens/vault-unlock.js'; export { VaultContext } from './contexts/vault-context.js'; type AppTab = 'run' | 'history' | 'config'; const TABS: { id: AppTab; label: string }[] = [ { id: 'run', label: 'Run' }, { id: 'history', label: 'History' }, { id: 'config', label: 'Config' }, ]; function hidden(visible: boolean): React.CSSProperties { return visible ? {} : { display: 'none' }; } function AppContent(): ReactElement { const { status } = useVault(); if (status === 'loading') return
Loading…
; if (status === 'no-file') return ( ); if (status === 'locked') return ( ); return ( ); } function AppUnlocked(): ReactElement { const [tab, setTab] = useState('run'); const socket = useRunSocket(); return (
{/* Always mounted — visibility toggled via CSS so WS state survives tab switches */}
setTab('config')} isVisible={tab === 'run'} />
{tab === 'history' && ( )} {tab === 'config' && ( )}
); } export function App(): ReactElement { return ( ); }