11import { useMemo } from 'react'
2- import { Activity , Boxes , Radio , ShieldAlert } from 'lucide-react'
2+ import { Activity , Boxes , Cpu , Radio , ShieldAlert } from 'lucide-react'
33
44import { useDevices , useFaults , useHealth , useRun } from '../../api/queries'
55import { AsyncState } from '../../components/AsyncState'
@@ -25,48 +25,61 @@ export function DashboardPage() {
2525 ( ) => events . filter ( ( event ) => event . event_type === 'transaction_completed' ) . slice ( - 8 ) ,
2626 [ events ] ,
2727 )
28+ const enabledFaults = faults . data ?. filter ( ( fault ) => fault . enabled ) . length ?? 0
2829
2930 return (
3031 < div className = "page-stack" >
3132 < PageHeader
32- eyebrow = "Operational overview "
33- title = "Simulator pulse "
33+ eyebrow = "Control plane / Overview "
34+ title = "System overview "
3435 description = "Authoritative snapshots from REST, live operational context from the domain event stream."
3536 action = { < div className = "header-status" > < span > Event stream</ span > < StatusBadge status = { connectionStatus } /> </ div > }
3637 />
37- < div className = "metric-grid" >
38- < MetricCard accent = "cyan" detail = { health . isError ? 'API unavailable' : 'Control API' } icon = { Radio } label = "Server health" value = { health . data ?. status ?? 'checking' } />
39- < MetricCard accent = "violet" detail = "Loaded runtime models" icon = { Boxes } label = "Devices" value = { devices . data ?. length ?? '—' } />
40- < MetricCard accent = "amber" detail = { `${ faults . data ?. filter ( ( fault ) => fault . enabled ) . length ?? 0 } enabled` } icon = { ShieldAlert } label = "Fault profiles" value = { faults . data ?. length ?? '—' } />
41- < MetricCard detail = "Retained in this session" icon = { Activity } label = "Live events" value = { events . length } />
42- </ div >
43- < div className = "dashboard-grid" >
44- < GlassPanel eyebrow = "Runtime snapshot" title = "Device states" >
38+ < div className = "dashboard-command-grid" >
39+ < GlassPanel className = "runtime-map-panel" eyebrow = "Runtime snapshot" title = "Device map" action = { < span className = "panel-count" > { devices . data ?. length ?? 0 } loaded</ span > } >
4540 { devices . isPending && < AsyncState kind = "loading" title = "Loading devices" /> }
4641 { devices . isError && < AsyncState detail = { devices . error . message } kind = "error" title = "Device snapshot unavailable" /> }
4742 { devices . data ?. length === 0 && < AsyncState kind = "empty" title = "No devices loaded" /> }
48- < div className = "state-list " >
43+ < div className = "runtime-device-grid " >
4944 { devices . data ?. map ( ( device ) => (
50- < div className = "state-row" key = { device . id } >
45+ < article className = "runtime-device-card" key = { device . id } >
46+ < div className = "runtime-device-icon" > < Cpu aria-hidden = "true" size = { 18 } /> </ div >
5147 < div > < strong > { device . id } </ strong > < span > { humanize ( device . bus ) } bus</ span > </ div >
5248 < StatusBadge status = { device . state } />
53- </ div >
49+ </ article >
5450 ) ) }
5551 </ div >
5652 </ GlassPanel >
57- < GlassPanel className = "dashboard-run-panel" eyebrow = "Orchestration" title = "Active scenario run" >
58- < BrandLogo className = "panel-brand-watermark" decorative />
59- { ! activeRunId && < AsyncState detail = "Start a scenario to track it here." kind = "empty" title = "No active run" /> }
60- { activeRun . isError && < AsyncState detail = { activeRun . error . message } kind = "error" title = "Run status unavailable" /> }
61- { activeRun . data && (
62- < div className = "run-overview" >
63- < div > < span > Run ID</ span > < strong > { activeRun . data . run_id } </ strong > </ div >
64- < div > < span > Scenario</ span > < strong > { activeRun . data . scenario_id } </ strong > </ div >
65- < div > < span > Status</ span > < StatusBadge status = { activeRun . data . status } /> </ div >
53+ < div className = "dashboard-side-stack" >
54+ < GlassPanel className = "dashboard-run-panel" eyebrow = "Orchestration" title = "Running scenario" >
55+ < BrandLogo className = "panel-brand-watermark" decorative />
56+ { ! activeRunId && < AsyncState detail = "Start a scenario to track it here." kind = "empty" title = "No active run" /> }
57+ { activeRun . isError && < AsyncState detail = { activeRun . error . message } kind = "error" title = "Run status unavailable" /> }
58+ { activeRun . data && (
59+ < div className = "run-overview" >
60+ < div > < span > Run ID</ span > < strong > { activeRun . data . run_id } </ strong > </ div >
61+ < div > < span > Scenario</ span > < strong > { activeRun . data . scenario_id } </ strong > </ div >
62+ < div > < span > Status</ span > < StatusBadge status = { activeRun . data . status } /> </ div >
63+ </ div >
64+ ) }
65+ </ GlassPanel >
66+ < GlassPanel className = "stream-health-panel" eyebrow = "Live telemetry" title = "Event stream" action = { < StatusBadge status = { connectionStatus } /> } >
67+ < div className = "stream-health-stats" >
68+ < div > < span > Retained events</ span > < strong > { events . length . toLocaleString ( ) } </ strong > </ div >
69+ < div > < span > Transactions</ span > < strong > { recentTransactions . length } </ strong > </ div >
70+ < div > < span > Enabled faults</ span > < strong > { enabledFaults } </ strong > </ div >
6671 </ div >
67- ) }
68- </ GlassPanel >
69- < GlassPanel className = "dashboard-transactions" eyebrow = "Data plane telemetry" title = "Latest completed transactions" >
72+ </ GlassPanel >
73+ </ div >
74+ </ div >
75+ < div className = "metric-grid" >
76+ < MetricCard accent = "cyan" detail = { health . isError ? 'API unavailable' : 'Control API' } icon = { Radio } label = "Server health" value = { health . data ?. status ?? 'checking' } />
77+ < MetricCard accent = "violet" detail = "Loaded runtime models" icon = { Boxes } label = "Active devices" value = { devices . data ?. length ?? '—' } />
78+ < MetricCard accent = "amber" detail = { `${ enabledFaults } enabled` } icon = { ShieldAlert } label = "Fault profiles" value = { faults . data ?. length ?? '—' } />
79+ < MetricCard detail = "Current session" icon = { Activity } label = "Domain events" value = { events . length } />
80+ </ div >
81+ < div className = "dashboard-grid" >
82+ < GlassPanel className = "dashboard-transactions" eyebrow = "Data plane telemetry" title = "Recent transactions" >
7083 { connectionStatus === 'disconnected' && recentTransactions . length === 0 && (
7184 < AsyncState detail = "The UI will resume from its last event ID." kind = "disconnected" title = "Event stream disconnected" />
7285 ) }
0 commit comments