// What the system is doing, as Dashtreme colour static widgets (fly_trader/ui/state.py status_rows, pushed every second):
// paper or live, trading or not, which model, the fly, training, whether the feed is current. A memecoin page shows its
// chain's row, a Kalshi page Kalshi's, a system page one widget per market.
import { useLocation } from 'react-router'
import { useApp } from '../context'
import { useTopic } from '../lib/hooks'
import { Callout, Metric, STATE_COLOR, Tip } from './ui'
export type StatusWidget = { key: string; label: string; value: string; sub: string | null; color: string; icon: string; help: string | null }
type Row = { key: string; label: string; widgets: StatusWidget[]; error: string | null }
export function useStatusRows(): { rows: Row[] | undefined; error: string | undefined } {
const { data, error } = useTopic<{ rows: Row[] }>('status')
return { rows: data?.rows, error }
}
function Tile({ w }: { w: StatusWidget }) {
const tile =
return w.help ? {tile} : tile
}
/** Which row a route shows: kalshi pages → kalshi, /rh → rh, memecoin pages → the chosen chain, system pages → all. */
export function rowFor(path: string, chain: string): string | 'all' {
if (path.startsWith('/kalshi')) return 'kalshi'
if (path.startsWith('/rh')) return 'rh'
if (path === '/' || path.startsWith('/trades')) return chain
if (path.startsWith('/model') || path.startsWith('/data')) return 'sol'
return 'all'
}
export function StatusWidgets() {
const { chain } = useApp()
const loc = useLocation()
const { rows, error } = useStatusRows()
if (!rows) return error ? Status unavailable: {error} :
const want = rowFor(loc.pathname, chain)
if (want === 'all') {
return (
{rows.map((r) => {
if (r.error) return
{r.error}
const eng = r.widgets.find((w) => w.key === 'engine'), money = r.widgets.find((w) => w.key === 'money'), feed = r.widgets.find((w) => w.key === 'feed')
if (!eng) return null
const bad = feed && feed.color === 'red' && eng.color === 'green'
return
})}
)
}
const row = rows.find((r) => r.key === want) ?? rows[0]
if (!row) return null
if (row.error) return {row.error}
return {row.widgets.map((w) => )}
}