caelum0x 695a365ae4 feat: PaperTrail — enterprise evidence-verification platform
Multi-tenant platform (182 pages, 228 API routes, ~30 modules) built on a
deterministic verification core: clinical-trial claims checked against
ClinicalTrials.gov registered results and raw event counts (ARR/NNT/RR+CI
recomputed in code, oracle-tested), code-enforced exact-span grounding, and
multi-source cross-verification. Auth/RBAC/multi-tenancy, document processing
at scale (unpdf + Docling), agentic workflows, Claude Science connector,
compliance/audit, billing, public API, and more.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 07:21:22 +03:00

94 lines
2.8 KiB
TypeScript

"use client";
import { useCallback, useEffect, useState } from "react";
import {
fetchFlagAudit,
type FlagAuditEntry,
} from "@/components/flags/api";
import {
EmptyState,
ErrorState,
LoadingState,
relativeTime,
} from "@/components/flags/ui";
// Recent change history for a flag, read from the org audit log. `refreshKey`
// lets the parent force a reload after it saves a change.
const ACTION_LABELS: Record<string, string> = {
"feature_flag.created": "Created",
"feature_flag.updated": "Updated",
"feature_flag.deleted": "Deleted",
};
export function FlagAudit({
flagId,
refreshKey = 0,
}: {
flagId: string;
refreshKey?: number;
}) {
const [entries, setEntries] = useState<FlagAuditEntry[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const load = useCallback(async () => {
setLoading(true);
setError(null);
const res = await fetchFlagAudit(flagId);
if (!res.success || !res.data) {
setError(res.error ?? "Failed to load history.");
setLoading(false);
return;
}
setEntries(res.data);
setLoading(false);
}, [flagId]);
useEffect(() => {
void load();
}, [load, refreshKey]);
return (
<section className="rounded-lg border border-ink/10 bg-white p-5">
<h2 className="text-sm font-semibold text-ink">History</h2>
<div className="mt-3">
{loading ? (
<LoadingState label="Loading history…" />
) : error ? (
<ErrorState message={error} onRetry={load} />
) : entries.length === 0 ? (
<EmptyState title="No recorded changes yet." />
) : (
<ul className="space-y-2">
{entries.map((entry) => (
<li
key={entry.id}
className="flex items-start justify-between gap-3 border-b border-ink/5 pb-2 text-sm last:border-0"
>
<div>
<span className="font-medium text-ink/80">
{ACTION_LABELS[entry.action] ?? entry.action}
</span>
{typeof entry.metadata.rolloutPercent === "number" && (
<span className="ml-2 text-xs text-ink/50">
rollout {String(entry.metadata.rolloutPercent)}%
</span>
)}
{typeof entry.metadata.enabled === "boolean" && (
<span className="ml-2 text-xs text-ink/50">
{entry.metadata.enabled ? "enabled" : "disabled"}
</span>
)}
</div>
<span className="whitespace-nowrap text-[11px] text-ink/40">
{relativeTime(entry.createdAt)}
</span>
</li>
))}
</ul>
)}
</div>
</section>
);
}