import { PanelFrame } from "./PanelFrame"; import { JsonView } from "./JsonView"; import type { NormalizeResultState, TabKey } from "../state/types"; interface OutputPanelProps { tab: TabKey; onTabChange: (tab: TabKey) => void; result: NormalizeResultState | null; appLogs: string[]; } const TAB_LABELS: Record = { normalized: "Normalized JSON", fragments: "Fragment View", scope: "Scope View", flags: "Flags View", route: "Route Simulation", raw: "Raw model output", validation: "Validation", logs: "Logs" }; function asObject(value: unknown): Record | null { return value && typeof value === "object" ? (value as Record) : null; } export function OutputPanel({ tab, onTabChange, result, appLogs }: OutputPanelProps) { const tabs: TabKey[] = ["normalized", "fragments", "scope", "flags", "route", "raw", "validation", "logs"]; const normalized = asObject(result?.normalized); const schemaVersion = String(normalized?.schema_version ?? ""); const isV2 = schemaVersion === "normalized_query_v2" || schemaVersion === "normalized_query_v2_0_1" || schemaVersion === "normalized_query_v2_0_2"; const fragmentsView = isV2 ? { fragments: normalized?.fragments ?? [], discarded_fragments: normalized?.discarded_fragments ?? [] } : { note: "Fragment View доступен для normalized_query_v2." }; const scopeView = isV2 ? { message_in_scope: normalized?.message_in_scope ?? null, scope_confidence: normalized?.scope_confidence ?? null, contains_multiple_tasks: normalized?.contains_multiple_tasks ?? null, global_notes: normalized?.global_notes ?? null } : { note: "Scope View доступен для normalized_query_v2." }; const flagsView = isV2 ? Array.isArray(normalized?.fragments) ? (normalized?.fragments as Array>).map((fragment) => ({ fragment_id: fragment.fragment_id ?? null, domain_relevance: fragment.domain_relevance ?? null, candidate_labels: fragment.candidate_labels ?? [], execution_readiness: fragment.execution_readiness ?? null, clarification_reason: fragment.clarification_reason ?? null, soft_assumption_used: fragment.soft_assumption_used ?? [], route_status: fragment.route_status ?? null, no_route_reason: fragment.no_route_reason ?? null, flags: fragment.flags ?? {} })) : [] : { note: "Flags View доступен для normalized_query_v2." }; return (
{tabs.map((item) => ( ))}
{tab === "normalized" ? : null} {tab === "fragments" ? : null} {tab === "scope" ? : null} {tab === "flags" ? : null} {tab === "route" ? : null} {tab === "raw" ? : null} {tab === "validation" ? : null} {tab === "logs" ? : null}
); }