diff --git a/apps/operator/pages/audit.vue b/apps/operator/pages/audit.vue index bae9bb5..8060ea2 100644 --- a/apps/operator/pages/audit.vue +++ b/apps/operator/pages/audit.vue @@ -92,6 +92,26 @@ function formatMetaValue(v: unknown): string { return String(v) } +// Compact human-readable rendering of a single side of a diff. Objects collapse +// to JSON; null / undefined / empty string render as a dim em-dash so the +// "before" side of a freshly populated field reads as clearly empty. +function formatDiffValue(v: unknown): string { + if (v === null || v === undefined || v === '') return '—' + if (typeof v === 'object') return JSON.stringify(v) + return String(v) +} + +// `metadata.diff` shape for partner.updated (and future *.updated actions): +// { fieldName: { from, to } }. Type-narrow safely; old audit rows that only +// carried `metadata.changes: string[]` are still rendered as plain chips by +// the fallback branch in the template. +interface DiffEntry { from: unknown; to: unknown } +function diffEntries(meta: Record | undefined): [string, DiffEntry][] { + const d = meta?.diff + if (!d || typeof d !== 'object') return [] + return Object.entries(d as Record) +} + // ── Tamper-evidence (Phase 3) + cold-storage archives (Phase 4) ──────── interface VerifyReport { ok: boolean @@ -273,7 +293,23 @@ function fmtRelative(iso: string | null | undefined): string { -
+ + + + + + + + + + +
{{ field }}{{ formatDiffValue(entry.from) }}{{ formatDiffValue(entry.to) }}
+ +