Add thread audit replay controls
This commit is contained in:
1 parent
bbf90a1a62
commit
6768d19239
19 files changed
+299
-3
No files matched your search
@@ -100,6 +100,7 @@ export function SettingsPage({ snapshot, actions }: PageProps) {
|
||||
const evalCases = useMemo(() => snapshot.evalCases.filter((item) => item.orgId === orgId), [snapshot.evalCases, orgId]);
|
||||
const evalRuns = useMemo(() => snapshot.evalRuns.filter((item) => item.orgId === orgId), [snapshot.evalRuns, orgId]);
|
||||
const prBotGates = useMemo(() => snapshot.prBotGates.filter((item) => item.orgId === orgId), [snapshot.prBotGates, orgId]);
|
||||
const auditReplayRuns = useMemo(() => snapshot.auditReplayRuns.filter((item) => item.orgId === orgId), [snapshot.auditReplayRuns, orgId]);
|
||||
|
||||
return (
|
||||
<div className="split-main" style={{ height: "calc(100vh - 44px)", margin: "-28px -32px -40px" }}>
|
||||
@@ -193,6 +194,7 @@ export function SettingsPage({ snapshot, actions }: PageProps) {
|
||||
exports={complianceExports}
|
||||
legalHolds={legalHolds}
|
||||
retentionFreezes={retentionFreezes}
|
||||
auditReplayRuns={auditReplayRuns}
|
||||
actions={actions}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Children, type FormEvent, type ReactNode } from "react";
|
||||
import { Button, Icon, Pill } from "../../shared/ui";
|
||||
import type {
|
||||
AgentRecord,
|
||||
AuditReplayRunRecord,
|
||||
ChatSpaceRecord,
|
||||
ChatThreadRecord,
|
||||
ComplianceExportRecord,
|
||||
@@ -24,6 +25,7 @@ export function CompliancePanel({
|
||||
exports,
|
||||
legalHolds,
|
||||
retentionFreezes,
|
||||
auditReplayRuns,
|
||||
actions,
|
||||
}: {
|
||||
orgId: string;
|
||||
@@ -36,6 +38,7 @@ export function CompliancePanel({
|
||||
exports: ComplianceExportRecord[];
|
||||
legalHolds: LegalHoldRecord[];
|
||||
retentionFreezes: RetentionFreezeRecord[];
|
||||
auditReplayRuns: AuditReplayRunRecord[];
|
||||
actions: SnapshotActions;
|
||||
}) {
|
||||
const submitExport = (event: FormEvent<HTMLFormElement>) => {
|
||||
@@ -79,6 +82,16 @@ export function CompliancePanel({
|
||||
})).then((result) => { if (result) event.currentTarget.reset(); });
|
||||
};
|
||||
|
||||
const submitReplay = (event: FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
const form = new FormData(event.currentTarget);
|
||||
void actions.run(() => window.agentCompany.createAuditReplay({
|
||||
orgId,
|
||||
threadId: String(form.get("threadId") ?? ""),
|
||||
createdByEmployeeId: employeeId,
|
||||
}));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<h1 className="page-h1">Compliance</h1>
|
||||
@@ -133,6 +146,18 @@ export function CompliancePanel({
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card">
|
||||
<SectionTitle icon="refresh" title="Thread replay" />
|
||||
<form onSubmit={submitReplay} style={{ display: "grid", gap: 10 }}>
|
||||
<LabeledSelect label="Thread" name="threadId">
|
||||
{chatThreads.map((thread) => <option key={thread.id} value={thread.id}>{thread.title}</option>)}
|
||||
</LabeledSelect>
|
||||
<div className="row" style={{ justifyContent: "flex-end" }}>
|
||||
<Button tone="primary" size="small" type="submit" disabled={chatThreads.length === 0}><Icon name="refresh" size={12} /> Run</Button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card">
|
||||
<SectionTitle icon="inbox" title="Export history" />
|
||||
<RecordList emptyLabel="0 exports">
|
||||
@@ -147,6 +172,19 @@ export function CompliancePanel({
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section className="card" style={{ marginTop: 16 }}>
|
||||
<SectionTitle icon="list" title="Replay runs" />
|
||||
<RecordList emptyLabel="0 replay runs">
|
||||
{auditReplayRuns.map((run) => (
|
||||
<RecordRow
|
||||
key={run.id}
|
||||
title={threadTitle(chatThreads, run.threadId)}
|
||||
meta={`${run.eventCount} events · ${run.eventDigest.slice(0, 12)} · ${formatRelative(run.createdAt)}`}
|
||||
/>
|
||||
))}
|
||||
</RecordList>
|
||||
</section>
|
||||
|
||||
<section className="card" style={{ marginTop: 16 }}>
|
||||
<SectionTitle icon="approve" title="Active controls" />
|
||||
<RecordList emptyLabel="0 active controls">
|
||||
@@ -176,7 +214,7 @@ export function CompliancePanel({
|
||||
);
|
||||
}
|
||||
|
||||
function SectionTitle({ icon, title }: { icon: "approve" | "docs" | "inbox" | "pause" | "shield"; title: string }) {
|
||||
function SectionTitle({ icon, title }: { icon: "approve" | "docs" | "inbox" | "list" | "pause" | "refresh" | "shield"; title: string }) {
|
||||
return (
|
||||
<div className="row" style={{ marginBottom: 12 }}>
|
||||
<Icon name={icon} size={14} color="var(--text-3)" />
|
||||
@@ -238,3 +276,9 @@ function splitPair(value: string): [string, string] {
|
||||
if (index < 1) throw new Error("Compliance selector value is invalid.");
|
||||
return [value.slice(0, index), value.slice(index + 1)];
|
||||
}
|
||||
|
||||
function threadTitle(threads: ChatThreadRecord[], threadId: string): string {
|
||||
const thread = threads.find((item) => item.id === threadId);
|
||||
if (!thread) throw new Error("Audit replay thread is missing from snapshot.");
|
||||
return thread.title;
|
||||
}
|
||||
Reference in new issue
Block a user