diff --git a/web/src/app/(dashboard)/events/page.tsx b/web/src/app/(dashboard)/events/page.tsx index 55cb9b8..1249d6f 100644 --- a/web/src/app/(dashboard)/events/page.tsx +++ b/web/src/app/(dashboard)/events/page.tsx @@ -57,6 +57,151 @@ function timeAgo(dateStr: string): string { return `${days}d ago`; } +/** Known detail keys that get their own sections — excluded from the "Other" dump. */ +const KNOWN_KEYS = [ + "error", + "errorType", + "method", + "line", + "input", + "params", + "response", + "script_source", + "caller_did", + "duration_ms", + "response_size", +] as const; + +function EventDetailBody({ event }: { event: EventLogEntry }) { + const d = event.detail; + + // Collect any keys not in KNOWN_KEYS for the "Other" section + const otherKeys = Object.keys(d).filter( + (k) => !(KNOWN_KEYS as readonly string[]).includes(k), + ); + const otherDetail = + otherKeys.length > 0 + ? Object.fromEntries(otherKeys.map((k) => [k, d[k]])) + : null; + + return ( +
+ {/* Metadata grid */} +
+
+ Subject +

{event.subject ?? "--"}

+
+
+ Actor +

+ {event.actor_did ?? "System"} +

+
+
+ Time +

+ {new Date(event.created_at).toLocaleString()} +

+
+ {d.method != null && ( +
+ Method +

{String(d.method)}

+
+ )} + {d.caller_did != null && ( +
+ Caller DID +

{String(d.caller_did)}

+
+ )} + {d.duration_ms != null && ( +
+ Duration +

{String(d.duration_ms)}ms

+
+ )} + {d.response_size != null && ( +
+ Response Size +

+ {Number(d.response_size).toLocaleString()} bytes +

+
+ )} +
+ + {/* Error section */} + {d.error != null && ( +
+ Error +
+ {d.errorType != null && ( + + {String(d.errorType)} + + )} + {d.line != null && ( + + line {String(d.line)} + + )} +

{String(d.error)}

+
+
+ )} + + {/* Request input/params */} + {(d.input != null || d.params != null) && ( +
+ + {d.input != null ? "Request Input" : "Request Params"} + + +
+ )} + + {/* Response */} + {d.response != null && ( +
+ Response + +
+ )} + + {/* Script source */} + {d.script_source != null && ( +
+ Script Source + +
+ )} + + {/* Other detail fields */} + {otherDetail && ( +
+ Other + +
+ )} +
+ ); +} + export default function EventsPage() { const { getToken } = useAuth(); const [events, setEvents] = useState([]); @@ -343,33 +488,7 @@ export default function EventsPage() { -
-
- Subject -

- {viewEvent.subject ?? "--"} -

-
-
- Actor -

- {viewEvent.actor_did ?? "System"} -

-
-
- Time -

- {new Date(viewEvent.created_at).toLocaleString()} -

-
-
-
- Detail - -
+ )}