import { Activity, BadgeDollarSign, Brain, Gauge as GaugeIcon, Loader2, TrendingUp } from 'lucide-react' import type { ReactNode } from 'react' import { Panel } from './ui' import { CAP, can } from '../lib/can' import { useMutation, useQueryClient } from '@tanstack/react-query' import { useAioeStatus } from '../tools/screenmatch/queries' import { screenApi } from '../tools/screenmatch/api' import { useAuth } from '../lib/useAuth' import { fmtDate } from '../lib/format' import type { CCExecutiveCard } from '../lib/types' const ICONS: Record = { mission_readiness: , revenue_at_risk: , growth_capacity: , staffing_confidence: , } function stateColor(state: string): string { if (state === 'ok') return 'var(--color-ok)' if (state === 'watch') return 'var(--color-warn)' if (state === 'risk') return 'var(--color-risk)' return 'var(--color-faint)' } // The executive intelligence row: four cards backed by real queries. A card with no feeding data // says so and names the feed; it never shows a fake number. export function ExecutiveCards({ cards }: { cards: CCExecutiveCard[] }) { if (!cards?.length) return null return (
{cards.map((c) => (
{ICONS[c.key]} {c.title}
{c.no_data ? (

{c.data_note}

) : ( <>
{c.value}

{c.detail}

)}
))}
) } // Admin only proof the optimization engine is alive: outcomes recorded, the last engine run, the // active weight profile, and this month's adjustments. When shadow mode is on and a candidate // profile is pending, an admin can promote it here (the human in the loop step). Internal // instrumentation, not marketing. export function ContinuousLearningTile() { const { principal } = useAuth() const status = useAioeStatus() const qc = useQueryClient() const promote = useMutation({ mutationFn: () => screenApi.aioePromote(), onSuccess: () => void qc.invalidateQueries({ queryKey: ['aioe', 'status'] }), }) // Capability, not role name: the previous role string test hid the promote control from superuser, // which is the one role that holds every capability. if (!can(principal, CAP.orgSettings) || status.isError || !status.data) return null const s = status.data return (
{s.shadowMode && (
Shadow mode {s.pendingCandidateVersion ? ( <> Candidate profile {s.pendingCandidateVersion} is proposed and awaiting review. ) : ( No candidate proposed yet. The engine proposes; a human promotes. )} {promote.isError && {(promote.error as Error).message}}
)}

Recorded screening outcomes tune the scoring weight profile on a nightly batch. Every change is versioned and audited. {s.shadowMode && ' In shadow mode the engine proposes; an admin promotes.'} {!s.updaterConfigured && ' The batch updater is not configured on this deployment; outcomes are accumulating.'}

) } function Stat({ k, v }: { k: string; v: string }) { return (
{k}
{v}
) }