From e40a231c81dd8d0d8cc2b8a3d4112e9d4df11c10 Mon Sep 17 00:00:00 2001 From: Oliver Kieselbach Date: Fri, 13 Feb 2026 17:58:30 +0100 Subject: [PATCH] fix autopilot_profile data displaying --- .../AutopilotMonitor.Agent/buildcounter.txt | 2 +- .../app/sessions/[sessionId]/page.tsx | 43 +++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt index 48082f72..b1bd38b6 100644 --- a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt +++ b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt @@ -1 +1 @@ -12 +13 diff --git a/src/Web/autopilot-monitor-web/app/sessions/[sessionId]/page.tsx b/src/Web/autopilot-monitor-web/app/sessions/[sessionId]/page.tsx index 9676a623..b8111619 100644 --- a/src/Web/autopilot-monitor-web/app/sessions/[sessionId]/page.tsx +++ b/src/Web/autopilot-monitor-web/app/sessions/[sessionId]/page.tsx @@ -832,9 +832,46 @@ function PhaseSection({ ); } +function normalizeJsonLikeValue(value: any): any { + if (typeof value === "string") { + const trimmed = value.trim(); + const looksLikeJson = + (trimmed.startsWith("{") && trimmed.endsWith("}")) || + (trimmed.startsWith("[") && trimmed.endsWith("]")); + + if (!looksLikeJson) return value; + + try { + return normalizeJsonLikeValue(JSON.parse(value)); + } catch { + return value; + } + } + + if (Array.isArray(value)) { + return value.map(normalizeJsonLikeValue); + } + + if (value && typeof value === "object") { + const normalized: Record = {}; + for (const [k, v] of Object.entries(value)) { + normalized[k] = normalizeJsonLikeValue(v); + } + return normalized; + } + + return value; +} + +function normalizeEventDataForDisplay(data?: Record): Record | null { + if (!data) return null; + return normalizeJsonLikeValue(data); +} + function EventRow({ event, isGalacticAdmin }: { event: EnrollmentEvent; isGalacticAdmin?: boolean }) { const [showDetails, setShowDetails] = useState(false); const [copied, setCopied] = useState(false); + const detailData = useMemo(() => normalizeEventDataForDisplay(event.data), [event.data]); const copyEventId = async () => { try { @@ -872,7 +909,7 @@ function EventRow({ event, isGalacticAdmin }: { event: EnrollmentEvent; isGalact )} - {event.data && Object.keys(event.data).length > 0 && ( + {detailData && Object.keys(detailData).length > 0 && (