import type { ReactElement } from 'react'; import type { SessionInfoPayload } from '@/lib/chat-contract'; import { MAX_MANIFEST_ITEMS } from './limits'; import { asString, asStringArray } from './runtime-guards'; interface SessionPanelProps { sessionInfo: SessionInfoPayload | null; onSetThinking: (level: string) => void; } const THINKING_LEVEL_UNAVAILABLE = ''; export function SessionPanel({ sessionInfo, onSetThinking, }: SessionPanelProps): ReactElement | null { if (!sessionInfo) return null; // The reducer already caps this before storing it, but the render site // defends independently — a hostile payload must never be able to force // this { // The placeholder option is not a real, settable level — a // malformed availableThinkingLevels list must never let the // client emit set:thinking for it. if (!hasThinkingLevels) return; onSetThinking(event.target.value); }} > {hasThinkingLevels ? ( availableThinkingLevels.map((level) => ( )) ) : ( )} {sessionInfo.routingDecision ? ( {asString(sessionInfo.routingDecision.reason)} ) : null} ); }