Skip to content

Commit ccb7a7a

Browse files
committed
Show event fields in log modal
1 parent 25df418 commit ccb7a7a

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

web/src/components/EventLogModal.tsx

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ReactMarkdown, { defaultUrlTransform } from "react-markdown";
44
import remarkGfm from "remark-gfm";
55
import { api, HttpError } from "../api/client";
66
import type { APIResponseAttempt, EventLogEntry, UsageEventRecord } from "../api/types";
7-
import { formatBytes, formatTimestamp } from "../lib/utils";
7+
import { formatBytes, formatCost, formatLatency, formatNumber, formatTimestamp } from "../lib/utils";
88
import {
99
extractRequestTurns,
1010
extractRequestToolDeclarations,
@@ -145,7 +145,7 @@ export default function EventLogModal({ event, onClose }: Props) {
145145
};
146146
}, [event.request_id]);
147147

148-
const tabs: Tab[] = useMemo(() => buildTabs(entry), [entry]);
148+
const tabs: Tab[] = useMemo(() => buildTabs(entry, event), [entry, event]);
149149

150150
// If a previously-selected tab disappears (e.g., entry reloaded with fewer
151151
// attempts), fall back to the first tab.
@@ -344,7 +344,7 @@ function isInteractiveTarget(target: EventTarget): boolean {
344344
return target instanceof Element && !!target.closest("button, a, input, textarea, select, [data-no-drag]");
345345
}
346346

347-
function buildTabs(entry: EventLogEntry | null): Tab[] {
347+
function buildTabs(entry: EventLogEntry | null, event: UsageEventRecord): Tab[] {
348348
if (!entry) return [];
349349
const tabs: Tab[] = [];
350350

@@ -353,6 +353,10 @@ function buildTabs(entry: EventLogEntry | null): Tab[] {
353353
label: "Info",
354354
render: () => (
355355
<Panel>
356+
<div className="mb-3">
357+
<Label>Event</Label>
358+
<KVList map={eventRecordMap(event)} />
359+
</div>
356360
<div className="mb-3">
357361
<Label>File</Label>
358362
<div className="font-mono text-[11px] break-all">{entry.file}</div>
@@ -436,6 +440,36 @@ function buildTabs(entry: EventLogEntry | null): Tab[] {
436440
return tabs;
437441
}
438442

443+
function eventRecordMap(event: UsageEventRecord): Record<string, string> {
444+
return {
445+
event_key: displayValue(event.event_key),
446+
timestamp: displayValue(formatTimestamp(event.timestamp)),
447+
provider: displayValue(event.provider),
448+
model: displayValue(event.model),
449+
api_group_key: displayValue(event.api_group_key),
450+
api_group_display: displayValue(event.api_group_display),
451+
source: displayValue(event.source),
452+
source_display: displayValue(event.source_display),
453+
auth_index: displayValue(event.auth_index),
454+
auth_type: displayValue(event.auth_type),
455+
endpoint: displayValue(event.endpoint),
456+
request_id: displayValue(event.request_id),
457+
latency_ms: displayValue(`${event.latency_ms} (${formatLatency(event.latency_ms)})`),
458+
input_tokens: formatNumber(event.input_tokens),
459+
cached_tokens: formatNumber(event.cached_tokens),
460+
output_tokens: formatNumber(event.output_tokens),
461+
reasoning_tokens: formatNumber(event.reasoning_tokens),
462+
total_tokens: formatNumber(event.total_tokens),
463+
failed: event.failed ? "true" : "false",
464+
cost: formatCost(event.cost),
465+
};
466+
}
467+
468+
function displayValue(value: string | undefined | null): string {
469+
const v = (value || "").trim();
470+
return v || "—";
471+
}
472+
439473
function APIResponsesView({ attempts }: { attempts: APIResponseAttempt[] }) {
440474
return (
441475
<div className="space-y-4">

0 commit comments

Comments
 (0)