Prometheus Entity Management API
    Preparing search index...

    use-entity-diff.ts — Compute field-level diffs between entity graph states.

    Reuses core time-travel primitives:

    • recordGraphSnapshot / restoreGraphSnapshot from devtools-time-travel
    • useGraphStore for current live entity data

    This hook does NOT write to the store during diff computation. It reads two states (a "before" snapshot and the current live graph) and computes a declarative FieldDiff[] — the rendering is left to EntityDiff / EntityApproval.

    Hook→Store: reads via useGraphStore.getState() (not via React subscribe) so diff snapshots are point-in-time and do not cause continuous re-renders.

    interface EntityDiffProps {
        className?: string;
        classNames?: EntityDiffClassNames;
        entityId: string;
        entityType: string;
        externalDiff?: EntityDiffResult | null;
        formatValue?: (value: unknown) => string;
        includeUnchanged?: boolean;
        renderRow?: (diff: FieldDiff, index: number) => ReactNode;
        showControls?: boolean;
    }

    Hierarchy (View Summary)

    Index
    className?: string
    entityId: string
    entityType: string
    externalDiff?: EntityDiffResult | null

    Controlled mode: pass an external diff result (e.g. from a parent EntityApproval that owns the hook). When provided, the component's internal useEntityDiff hook is still created (hooks rules require unconditional calls) but rendering uses the controlled diff.

    formatValue?: (value: unknown) => string

    Custom value formatter; defaults to JSON.stringify.

    includeUnchanged?: boolean

    If true, include unchanged fields in the result (default: false).

    renderRow?: (diff: FieldDiff, index: number) => ReactNode

    Custom renderer for a single field diff row.

    showControls?: boolean

    Whether to show control buttons (capture/recompute/restore). Default: true