gpt-engineer-app[bot] commited on
Commit ·
48d880e
1
Parent(s): 03fc538
Changes
Browse files- src/routeTree.gen.ts +0 -9
- src/routes/dashboard.coaching.tsx +38 -0
- src/routes/dashboard.compliance.tsx +39 -0
- src/routes/dashboard.index.tsx +272 -0
- src/routes/dashboard.reports.tsx +44 -0
- src/routes/index.tsx +46 -20
src/routeTree.gen.ts
CHANGED
|
@@ -93,12 +93,3 @@ const rootRouteChildren: RootRouteChildren = {
|
|
| 93 |
export const routeTree = rootRouteImport
|
| 94 |
._addFileChildren(rootRouteChildren)
|
| 95 |
._addFileTypes<FileRouteTypes>()
|
| 96 |
-
|
| 97 |
-
import type { getRouter } from './router.tsx'
|
| 98 |
-
import type { createStart } from '@tanstack/react-start'
|
| 99 |
-
declare module '@tanstack/react-start' {
|
| 100 |
-
interface Register {
|
| 101 |
-
ssr: true
|
| 102 |
-
router: Awaited<ReturnType<typeof getRouter>>
|
| 103 |
-
}
|
| 104 |
-
}
|
|
|
|
| 93 |
export const routeTree = rootRouteImport
|
| 94 |
._addFileChildren(rootRouteChildren)
|
| 95 |
._addFileTypes<FileRouteTypes>()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/routes/dashboard.coaching.tsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { createFileRoute } from "@tanstack/react-router";
|
| 2 |
+
import { useEffect, useState } from "react";
|
| 3 |
+
import { supabase } from "@/integrations/supabase/client";
|
| 4 |
+
import { GraduationCap } from "lucide-react";
|
| 5 |
+
|
| 6 |
+
export const Route = createFileRoute("/dashboard/coaching")({ component: CoachingPage });
|
| 7 |
+
|
| 8 |
+
function CoachingPage() {
|
| 9 |
+
const [recs, setRecs] = useState<{ incident: string; rec: string; severity: string }[]>([]);
|
| 10 |
+
useEffect(() => {
|
| 11 |
+
supabase.from("incidents").select("title,severity,analysis").eq("status", "complete").then(({ data }) => {
|
| 12 |
+
const all: any[] = [];
|
| 13 |
+
(data ?? []).forEach((i: any) => (i.analysis?.coachingRecommendations ?? []).forEach((r: string) => all.push({ incident: i.title, rec: r, severity: i.severity })));
|
| 14 |
+
setRecs(all);
|
| 15 |
+
});
|
| 16 |
+
}, []);
|
| 17 |
+
|
| 18 |
+
return (
|
| 19 |
+
<div className="p-8 space-y-6">
|
| 20 |
+
<div>
|
| 21 |
+
<div className="text-[10px] uppercase tracking-widest text-muted-foreground font-mono">Operator Development</div>
|
| 22 |
+
<h1 className="text-2xl font-bold">Coaching Recommendations</h1>
|
| 23 |
+
</div>
|
| 24 |
+
<div className="space-y-2">
|
| 25 |
+
{recs.map((r, i) => (
|
| 26 |
+
<div key={i} className="rounded-lg border border-border bg-surface p-4 flex items-start gap-4">
|
| 27 |
+
<div className="h-9 w-9 rounded-lg bg-primary/10 text-primary flex items-center justify-center shrink-0"><GraduationCap className="h-4 w-4"/></div>
|
| 28 |
+
<div className="flex-1">
|
| 29 |
+
<p className="text-sm">{r.rec}</p>
|
| 30 |
+
<p className="text-[11px] text-muted-foreground font-mono mt-1">From: {r.incident}</p>
|
| 31 |
+
</div>
|
| 32 |
+
</div>
|
| 33 |
+
))}
|
| 34 |
+
{recs.length === 0 && <p className="text-sm text-muted-foreground">No recommendations yet.</p>}
|
| 35 |
+
</div>
|
| 36 |
+
</div>
|
| 37 |
+
);
|
| 38 |
+
}
|
src/routes/dashboard.compliance.tsx
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { createFileRoute } from "@tanstack/react-router";
|
| 2 |
+
import { useEffect, useState } from "react";
|
| 3 |
+
import { supabase } from "@/integrations/supabase/client";
|
| 4 |
+
import { SeverityBadge } from "@/components/severity-badge";
|
| 5 |
+
|
| 6 |
+
export const Route = createFileRoute("/dashboard/compliance")({ component: CompliancePage });
|
| 7 |
+
|
| 8 |
+
function CompliancePage() {
|
| 9 |
+
const [flags, setFlags] = useState<any[]>([]);
|
| 10 |
+
useEffect(() => {
|
| 11 |
+
supabase.from("incidents").select("title,analysis").eq("status", "complete").then(({ data }) => {
|
| 12 |
+
const all: any[] = [];
|
| 13 |
+
(data ?? []).forEach((i: any) => (i.analysis?.complianceFlags ?? []).forEach((f: any) => all.push({ ...f, incident: i.title })));
|
| 14 |
+
setFlags(all);
|
| 15 |
+
});
|
| 16 |
+
}, []);
|
| 17 |
+
|
| 18 |
+
return (
|
| 19 |
+
<div className="p-8 space-y-6">
|
| 20 |
+
<div>
|
| 21 |
+
<div className="text-[10px] uppercase tracking-widest text-muted-foreground font-mono">Regulatory</div>
|
| 22 |
+
<h1 className="text-2xl font-bold">Compliance Concerns</h1>
|
| 23 |
+
</div>
|
| 24 |
+
<div className="space-y-2">
|
| 25 |
+
{flags.map((f, i) => (
|
| 26 |
+
<div key={i} className="rounded-lg border border-border bg-surface p-4">
|
| 27 |
+
<div className="flex items-center justify-between mb-1">
|
| 28 |
+
<code className="text-sm font-mono text-primary">{f.code}</code>
|
| 29 |
+
<SeverityBadge severity={f.severity} />
|
| 30 |
+
</div>
|
| 31 |
+
<p className="text-sm text-foreground/90">{f.description}</p>
|
| 32 |
+
<p className="text-[11px] text-muted-foreground font-mono mt-2">From: {f.incident}</p>
|
| 33 |
+
</div>
|
| 34 |
+
))}
|
| 35 |
+
{flags.length === 0 && <p className="text-sm text-muted-foreground">No compliance flags yet.</p>}
|
| 36 |
+
</div>
|
| 37 |
+
</div>
|
| 38 |
+
);
|
| 39 |
+
}
|
src/routes/dashboard.index.tsx
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { createFileRoute } from "@tanstack/react-router";
|
| 2 |
+
import { useEffect, useState, useCallback } from "react";
|
| 3 |
+
import { supabase } from "@/integrations/supabase/client";
|
| 4 |
+
import { UploadDialog } from "@/components/upload-dialog";
|
| 5 |
+
import { SeverityBadge } from "@/components/severity-badge";
|
| 6 |
+
import { ScrollArea } from "@/components/ui/scroll-area";
|
| 7 |
+
import { Button } from "@/components/ui/button";
|
| 8 |
+
import { Loader2, AlertTriangle, FileText, Cpu, Shield, Activity, BookText, Download, RefreshCw, Trash2 } from "lucide-react";
|
| 9 |
+
import { useServerFn } from "@tanstack/react-start";
|
| 10 |
+
import { analyzeIncident } from "@/server/incidents.functions";
|
| 11 |
+
import { toast } from "sonner";
|
| 12 |
+
import { cn } from "@/lib/utils";
|
| 13 |
+
|
| 14 |
+
export const Route = createFileRoute("/dashboard/")({
|
| 15 |
+
component: IncidentsPage,
|
| 16 |
+
});
|
| 17 |
+
|
| 18 |
+
type Incident = {
|
| 19 |
+
id: string; title: string; severity: string; status: string;
|
| 20 |
+
created_at: string; analysis: any; source_type: string; error: string | null;
|
| 21 |
+
raw_text: string | null; file_name: string | null;
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
function IncidentsPage() {
|
| 25 |
+
const [incidents, setIncidents] = useState<Incident[]>([]);
|
| 26 |
+
const [selectedId, setSelectedId] = useState<string | null>(null);
|
| 27 |
+
const [loading, setLoading] = useState(true);
|
| 28 |
+
const analyze = useServerFn(analyzeIncident);
|
| 29 |
+
|
| 30 |
+
const load = useCallback(async () => {
|
| 31 |
+
const { data } = await supabase.from("incidents").select("*").order("created_at", { ascending: false });
|
| 32 |
+
setIncidents((data ?? []) as any);
|
| 33 |
+
setLoading(false);
|
| 34 |
+
if (data && data.length && !selectedId) setSelectedId(data[0].id);
|
| 35 |
+
}, [selectedId]);
|
| 36 |
+
|
| 37 |
+
useEffect(() => { load(); }, [load]);
|
| 38 |
+
|
| 39 |
+
useEffect(() => {
|
| 40 |
+
const ch = supabase.channel("incidents-rt").on("postgres_changes", { event: "*", schema: "public", table: "incidents" }, () => load()).subscribe();
|
| 41 |
+
return () => { supabase.removeChannel(ch); };
|
| 42 |
+
}, [load]);
|
| 43 |
+
|
| 44 |
+
const selected = incidents.find((i) => i.id === selectedId);
|
| 45 |
+
|
| 46 |
+
const rerun = async (id: string) => {
|
| 47 |
+
try { await analyze({ data: { incidentId: id } }); toast.success("Analysis updated"); }
|
| 48 |
+
catch (e: any) { toast.error(e.message); }
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
const remove = async (id: string) => {
|
| 52 |
+
await supabase.from("incidents").delete().eq("id", id);
|
| 53 |
+
toast.success("Incident deleted");
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
return (
|
| 57 |
+
<>
|
| 58 |
+
<header className="h-16 border-b border-border flex items-center justify-between px-8 bg-surface/40 backdrop-blur">
|
| 59 |
+
<div>
|
| 60 |
+
<div className="text-[10px] uppercase tracking-widest text-muted-foreground font-mono">Operations</div>
|
| 61 |
+
<h1 className="text-lg font-semibold">Incident Analysis</h1>
|
| 62 |
+
</div>
|
| 63 |
+
<UploadDialog onCreated={(id) => setSelectedId(id)} />
|
| 64 |
+
</header>
|
| 65 |
+
|
| 66 |
+
<div className="flex-1 grid grid-cols-1 lg:grid-cols-[340px_1fr] min-h-0">
|
| 67 |
+
{/* Incident list */}
|
| 68 |
+
<div className="border-r border-border flex flex-col min-h-0">
|
| 69 |
+
<div className="px-5 py-3 border-b border-border flex items-center justify-between">
|
| 70 |
+
<h2 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">Feed ({incidents.length})</h2>
|
| 71 |
+
<button onClick={load} className="text-muted-foreground hover:text-foreground"><RefreshCw className="h-3.5 w-3.5"/></button>
|
| 72 |
+
</div>
|
| 73 |
+
<ScrollArea className="flex-1">
|
| 74 |
+
<div className="p-3 space-y-2">
|
| 75 |
+
{loading ? (
|
| 76 |
+
<div className="text-center py-12 text-muted-foreground"><Loader2 className="h-5 w-5 animate-spin mx-auto"/></div>
|
| 77 |
+
) : incidents.length === 0 ? (
|
| 78 |
+
<EmptyHint />
|
| 79 |
+
) : incidents.map((i) => (
|
| 80 |
+
<button
|
| 81 |
+
key={i.id}
|
| 82 |
+
onClick={() => setSelectedId(i.id)}
|
| 83 |
+
className={cn(
|
| 84 |
+
"w-full text-left p-3 rounded-lg border transition-colors group",
|
| 85 |
+
selectedId === i.id
|
| 86 |
+
? "bg-surface-elevated border-primary/50 shadow-[var(--shadow-glow)]"
|
| 87 |
+
: "bg-surface border-border hover:border-primary/30"
|
| 88 |
+
)}
|
| 89 |
+
>
|
| 90 |
+
<div className="flex items-start justify-between gap-2 mb-1.5">
|
| 91 |
+
<span className="font-medium text-sm leading-tight line-clamp-2">{i.title}</span>
|
| 92 |
+
<SeverityBadge severity={i.severity} />
|
| 93 |
+
</div>
|
| 94 |
+
<div className="flex items-center gap-2 text-[10px] text-muted-foreground font-mono uppercase">
|
| 95 |
+
<StatusDot status={i.status} />
|
| 96 |
+
<span>{i.status}</span>
|
| 97 |
+
<span>·</span>
|
| 98 |
+
<span>{new Date(i.created_at).toLocaleString()}</span>
|
| 99 |
+
</div>
|
| 100 |
+
</button>
|
| 101 |
+
))}
|
| 102 |
+
</div>
|
| 103 |
+
</ScrollArea>
|
| 104 |
+
</div>
|
| 105 |
+
|
| 106 |
+
{/* Detail */}
|
| 107 |
+
<ScrollArea className="bg-background">
|
| 108 |
+
{selected ? <IncidentDetail incident={selected} onRerun={() => rerun(selected.id)} onDelete={() => remove(selected.id)} /> : <DetailEmpty />}
|
| 109 |
+
</ScrollArea>
|
| 110 |
+
</div>
|
| 111 |
+
</>
|
| 112 |
+
);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
function StatusDot({ status }: { status: string }) {
|
| 116 |
+
const c = status === "complete" ? "bg-severity-low" : status === "analyzing" ? "bg-primary animate-pulse" : status === "failed" ? "bg-severity-critical" : "bg-muted-foreground";
|
| 117 |
+
return <span className={cn("h-1.5 w-1.5 rounded-full", c)} />;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
function EmptyHint() {
|
| 121 |
+
return (
|
| 122 |
+
<div className="text-center py-12 px-4">
|
| 123 |
+
<AlertTriangle className="h-8 w-8 mx-auto text-muted-foreground mb-3" />
|
| 124 |
+
<p className="text-sm font-medium">No incidents yet</p>
|
| 125 |
+
<p className="text-xs text-muted-foreground mt-1">Submit your first report to begin analysis.</p>
|
| 126 |
+
</div>
|
| 127 |
+
);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
function DetailEmpty() {
|
| 131 |
+
return <div className="h-full flex items-center justify-center text-muted-foreground text-sm">Select an incident to view analysis.</div>;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
function IncidentDetail({ incident, onRerun, onDelete }: { incident: Incident; onRerun: () => void; onDelete: () => void }) {
|
| 135 |
+
const a = incident.analysis;
|
| 136 |
+
|
| 137 |
+
const exportReport = () => {
|
| 138 |
+
if (!a?.reportMarkdown) return;
|
| 139 |
+
const blob = new Blob([a.reportMarkdown], { type: "text/markdown" });
|
| 140 |
+
const url = URL.createObjectURL(blob);
|
| 141 |
+
const link = document.createElement("a");
|
| 142 |
+
link.href = url; link.download = `${incident.title.replace(/\s+/g, "-")}.md`;
|
| 143 |
+
link.click(); URL.revokeObjectURL(url);
|
| 144 |
+
};
|
| 145 |
+
|
| 146 |
+
return (
|
| 147 |
+
<div className="p-8 space-y-6 max-w-5xl">
|
| 148 |
+
<div className="flex items-start justify-between gap-4">
|
| 149 |
+
<div className="space-y-2">
|
| 150 |
+
<div className="flex items-center gap-3">
|
| 151 |
+
<h2 className="text-2xl font-bold tracking-tight">{incident.title}</h2>
|
| 152 |
+
<SeverityBadge severity={incident.severity} />
|
| 153 |
+
</div>
|
| 154 |
+
<div className="text-xs text-muted-foreground font-mono uppercase tracking-wider flex items-center gap-2">
|
| 155 |
+
<StatusDot status={incident.status} /> {incident.status} · {incident.source_type} · {new Date(incident.created_at).toLocaleString()}
|
| 156 |
+
</div>
|
| 157 |
+
</div>
|
| 158 |
+
<div className="flex gap-2">
|
| 159 |
+
<Button variant="ghost" size="sm" onClick={onRerun} className="gap-1.5"><RefreshCw className="h-3.5 w-3.5"/> Rerun</Button>
|
| 160 |
+
{a?.reportMarkdown && <Button variant="ghost" size="sm" onClick={exportReport} className="gap-1.5"><Download className="h-3.5 w-3.5"/> Export</Button>}
|
| 161 |
+
<Button variant="ghost" size="sm" onClick={onDelete} className="gap-1.5 text-destructive hover:text-destructive"><Trash2 className="h-3.5 w-3.5"/></Button>
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
{incident.status === "analyzing" && (
|
| 166 |
+
<div className="rounded-xl border border-primary/30 bg-primary/5 p-6 flex items-center gap-3">
|
| 167 |
+
<Loader2 className="h-5 w-5 animate-spin text-primary" />
|
| 168 |
+
<div>
|
| 169 |
+
<p className="font-medium text-sm">Multi-agent analysis in progress…</p>
|
| 170 |
+
<p className="text-xs text-muted-foreground">Event → Safety → Risk → Documentation</p>
|
| 171 |
+
</div>
|
| 172 |
+
</div>
|
| 173 |
+
)}
|
| 174 |
+
|
| 175 |
+
{incident.status === "failed" && (
|
| 176 |
+
<div className="rounded-xl border border-destructive/40 bg-destructive/10 p-6">
|
| 177 |
+
<p className="font-medium text-sm text-destructive">Analysis failed</p>
|
| 178 |
+
<p className="text-xs text-muted-foreground mt-1 font-mono">{incident.error}</p>
|
| 179 |
+
</div>
|
| 180 |
+
)}
|
| 181 |
+
|
| 182 |
+
{a && (
|
| 183 |
+
<>
|
| 184 |
+
{/* Agent grid */}
|
| 185 |
+
<div className="grid grid-cols-2 lg:grid-cols-4 gap-3">
|
| 186 |
+
<AgentChip icon={Cpu} label="Event Extraction" count={a.events?.length} />
|
| 187 |
+
<AgentChip icon={Shield} label="Safety" count={a.complianceFlags?.length} />
|
| 188 |
+
<AgentChip icon={Activity} label="Risk" count={a.rootCauses?.length} />
|
| 189 |
+
<AgentChip icon={BookText} label="Documentation" count={a.coachingRecommendations?.length} />
|
| 190 |
+
</div>
|
| 191 |
+
|
| 192 |
+
<Section title="Executive Summary">
|
| 193 |
+
<p className="text-sm leading-relaxed text-foreground/90">{a.summary}</p>
|
| 194 |
+
</Section>
|
| 195 |
+
|
| 196 |
+
<div className="grid lg:grid-cols-2 gap-6">
|
| 197 |
+
<Section title="Timeline of Events" icon={Cpu}>
|
| 198 |
+
<ol className="space-y-2">
|
| 199 |
+
{a.events?.map((e: string, i: number) => (
|
| 200 |
+
<li key={i} className="flex gap-3 text-sm">
|
| 201 |
+
<span className="font-mono text-xs text-primary w-6 shrink-0">{String(i+1).padStart(2,"0")}</span>
|
| 202 |
+
<span className="text-foreground/85">{e}</span>
|
| 203 |
+
</li>
|
| 204 |
+
))}
|
| 205 |
+
</ol>
|
| 206 |
+
</Section>
|
| 207 |
+
|
| 208 |
+
<Section title="Probable Root Causes" icon={Activity}>
|
| 209 |
+
<ul className="space-y-2">
|
| 210 |
+
{a.rootCauses?.map((r: string, i: number) => (
|
| 211 |
+
<li key={i} className="text-sm flex gap-2"><span className="text-severity-high">▸</span>{r}</li>
|
| 212 |
+
))}
|
| 213 |
+
</ul>
|
| 214 |
+
</Section>
|
| 215 |
+
|
| 216 |
+
<Section title="Compliance Concerns" icon={Shield}>
|
| 217 |
+
<div className="space-y-2">
|
| 218 |
+
{a.complianceFlags?.map((c: any, i: number) => (
|
| 219 |
+
<div key={i} className="rounded-lg border border-border bg-surface p-3">
|
| 220 |
+
<div className="flex items-center justify-between mb-1">
|
| 221 |
+
<code className="text-xs font-mono text-primary">{c.code}</code>
|
| 222 |
+
<SeverityBadge severity={c.severity} />
|
| 223 |
+
</div>
|
| 224 |
+
<p className="text-xs text-muted-foreground">{c.description}</p>
|
| 225 |
+
</div>
|
| 226 |
+
))}
|
| 227 |
+
</div>
|
| 228 |
+
</Section>
|
| 229 |
+
|
| 230 |
+
<Section title="Coaching Recommendations" icon={BookText}>
|
| 231 |
+
<ul className="space-y-2">
|
| 232 |
+
{a.coachingRecommendations?.map((r: string, i: number) => (
|
| 233 |
+
<li key={i} className="text-sm flex gap-2"><span className="text-primary">→</span>{r}</li>
|
| 234 |
+
))}
|
| 235 |
+
</ul>
|
| 236 |
+
</Section>
|
| 237 |
+
</div>
|
| 238 |
+
|
| 239 |
+
{incident.raw_text && (
|
| 240 |
+
<Section title="Raw Input" icon={FileText}>
|
| 241 |
+
<pre className="text-[11px] font-mono whitespace-pre-wrap text-muted-foreground max-h-48 overflow-auto">{incident.raw_text}</pre>
|
| 242 |
+
</Section>
|
| 243 |
+
)}
|
| 244 |
+
</>
|
| 245 |
+
)}
|
| 246 |
+
</div>
|
| 247 |
+
);
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
function Section({ title, icon: Icon, children }: { title: string; icon?: any; children: React.ReactNode }) {
|
| 251 |
+
return (
|
| 252 |
+
<div className="rounded-xl border border-border bg-surface/60 p-5">
|
| 253 |
+
<div className="flex items-center gap-2 mb-3">
|
| 254 |
+
{Icon && <Icon className="h-3.5 w-3.5 text-primary" />}
|
| 255 |
+
<h3 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">{title}</h3>
|
| 256 |
+
</div>
|
| 257 |
+
{children}
|
| 258 |
+
</div>
|
| 259 |
+
);
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
function AgentChip({ icon: Icon, label, count }: { icon: any; label: string; count?: number }) {
|
| 263 |
+
return (
|
| 264 |
+
<div className="rounded-lg border border-border bg-surface p-3 flex items-center gap-3">
|
| 265 |
+
<div className="h-8 w-8 rounded-md bg-primary/10 text-primary flex items-center justify-center"><Icon className="h-4 w-4"/></div>
|
| 266 |
+
<div>
|
| 267 |
+
<div className="text-[10px] uppercase tracking-wider text-muted-foreground font-mono">{label}</div>
|
| 268 |
+
<div className="text-sm font-semibold">{count ?? 0} {count === 1 ? "item" : "items"}</div>
|
| 269 |
+
</div>
|
| 270 |
+
</div>
|
| 271 |
+
);
|
| 272 |
+
}
|
src/routes/dashboard.reports.tsx
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { createFileRoute } from "@tanstack/react-router";
|
| 2 |
+
import { useEffect, useState } from "react";
|
| 3 |
+
import { supabase } from "@/integrations/supabase/client";
|
| 4 |
+
import { SeverityBadge } from "@/components/severity-badge";
|
| 5 |
+
import { Download } from "lucide-react";
|
| 6 |
+
import { Button } from "@/components/ui/button";
|
| 7 |
+
|
| 8 |
+
export const Route = createFileRoute("/dashboard/reports")({ component: ReportsPage });
|
| 9 |
+
|
| 10 |
+
function ReportsPage() {
|
| 11 |
+
const [items, setItems] = useState<any[]>([]);
|
| 12 |
+
useEffect(() => {
|
| 13 |
+
supabase.from("incidents").select("*").eq("status", "complete").order("created_at", { ascending: false })
|
| 14 |
+
.then(({ data }) => setItems(data ?? []));
|
| 15 |
+
}, []);
|
| 16 |
+
|
| 17 |
+
const dl = (i: any) => {
|
| 18 |
+
const blob = new Blob([i.analysis?.reportMarkdown ?? ""], { type: "text/markdown" });
|
| 19 |
+
const url = URL.createObjectURL(blob);
|
| 20 |
+
const a = document.createElement("a"); a.href = url; a.download = `${i.title}.md`; a.click(); URL.revokeObjectURL(url);
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
return (
|
| 24 |
+
<div className="p-8 space-y-6">
|
| 25 |
+
<div>
|
| 26 |
+
<div className="text-[10px] uppercase tracking-widest text-muted-foreground font-mono">Documentation</div>
|
| 27 |
+
<h1 className="text-2xl font-bold">Safety Reports</h1>
|
| 28 |
+
</div>
|
| 29 |
+
<div className="space-y-2">
|
| 30 |
+
{items.map((i) => (
|
| 31 |
+
<div key={i.id} className="rounded-lg border border-border bg-surface p-4 flex items-center gap-4">
|
| 32 |
+
<SeverityBadge severity={i.severity} />
|
| 33 |
+
<div className="flex-1 min-w-0">
|
| 34 |
+
<div className="font-medium truncate">{i.title}</div>
|
| 35 |
+
<div className="text-xs text-muted-foreground line-clamp-1">{i.analysis?.summary}</div>
|
| 36 |
+
</div>
|
| 37 |
+
<Button size="sm" variant="ghost" onClick={() => dl(i)} className="gap-1.5"><Download className="h-3.5 w-3.5"/> Markdown</Button>
|
| 38 |
+
</div>
|
| 39 |
+
))}
|
| 40 |
+
{items.length === 0 && <p className="text-sm text-muted-foreground">No completed reports yet.</p>}
|
| 41 |
+
</div>
|
| 42 |
+
</div>
|
| 43 |
+
);
|
| 44 |
+
}
|
src/routes/index.tsx
CHANGED
|
@@ -1,26 +1,52 @@
|
|
| 1 |
-
import { createFileRoute } from "@tanstack/react-router";
|
|
|
|
| 2 |
|
| 3 |
-
export const Route = createFileRoute("/")({
|
| 4 |
-
component: Index,
|
| 5 |
-
});
|
| 6 |
|
| 7 |
-
|
| 8 |
-
// create separate route files (about.tsx, services.tsx, contact.tsx) — don't put all pages in this file.
|
| 9 |
-
function PlaceholderIndex() {
|
| 10 |
return (
|
| 11 |
-
<div
|
| 12 |
-
className="
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
</div>
|
| 21 |
);
|
| 22 |
}
|
| 23 |
-
|
| 24 |
-
function Index() {
|
| 25 |
-
return <PlaceholderIndex />;
|
| 26 |
-
}
|
|
|
|
| 1 |
+
import { createFileRoute, Link } from "@tanstack/react-router";
|
| 2 |
+
import { Radar, Cpu, Shield, Activity, BookText, ArrowRight } from "lucide-react";
|
| 3 |
|
| 4 |
+
export const Route = createFileRoute("/")({ component: Landing });
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
function Landing() {
|
|
|
|
|
|
|
| 7 |
return (
|
| 8 |
+
<div className="min-h-screen bg-background relative overflow-hidden">
|
| 9 |
+
<div className="absolute inset-0 opacity-40 pointer-events-none" style={{ backgroundImage: "radial-gradient(ellipse at 20% 10%, oklch(0.78 0.14 200 / 0.25), transparent 50%), radial-gradient(ellipse at 80% 60%, oklch(0.32 0.12 280 / 0.3), transparent 50%)" }}/>
|
| 10 |
+
|
| 11 |
+
<header className="relative max-w-7xl mx-auto px-6 py-6 flex items-center justify-between">
|
| 12 |
+
<div className="flex items-center gap-3">
|
| 13 |
+
<div className="h-9 w-9 rounded-lg bg-primary text-primary-foreground flex items-center justify-center shadow-[var(--shadow-glow)]"><Radar className="h-5 w-5"/></div>
|
| 14 |
+
<span className="font-bold tracking-tight">AVISYS</span>
|
| 15 |
+
</div>
|
| 16 |
+
<Link to="/auth" className="text-sm font-medium text-muted-foreground hover:text-foreground">Sign in →</Link>
|
| 17 |
+
</header>
|
| 18 |
+
|
| 19 |
+
<section className="relative max-w-5xl mx-auto px-6 pt-20 pb-24 text-center">
|
| 20 |
+
<div className="inline-flex items-center gap-2 px-3 py-1 rounded-full border border-border bg-surface/60 backdrop-blur text-[11px] font-mono uppercase tracking-widest text-muted-foreground mb-8">
|
| 21 |
+
<span className="h-1.5 w-1.5 rounded-full bg-primary animate-pulse"/> Multi-agent AV safety analysis
|
| 22 |
+
</div>
|
| 23 |
+
<h1 className="text-5xl md:text-7xl font-bold tracking-tight leading-[1.05]">
|
| 24 |
+
Turn raw incident logs into <span className="text-primary">actionable safety intelligence</span>.
|
| 25 |
+
</h1>
|
| 26 |
+
<p className="mt-6 text-lg text-muted-foreground max-w-2xl mx-auto">
|
| 27 |
+
AVISYS routes every autonomous vehicle event, near miss, and sensor log through four specialized AI agents — surfacing root causes, compliance concerns, and operator coaching plans in seconds.
|
| 28 |
+
</p>
|
| 29 |
+
<div className="mt-10 flex items-center justify-center gap-3">
|
| 30 |
+
<Link to="/auth" className="inline-flex items-center gap-2 px-6 py-3 rounded-lg bg-primary text-primary-foreground font-semibold hover:bg-primary/90 shadow-[var(--shadow-glow)]">
|
| 31 |
+
Open the console <ArrowRight className="h-4 w-4"/>
|
| 32 |
+
</Link>
|
| 33 |
+
</div>
|
| 34 |
+
|
| 35 |
+
<div className="mt-20 grid sm:grid-cols-2 lg:grid-cols-4 gap-4 text-left">
|
| 36 |
+
{[
|
| 37 |
+
{ icon: Cpu, name: "Event Extraction", desc: "Parses logs, transcripts, and sensor data into a clean event timeline." },
|
| 38 |
+
{ icon: Shield, name: "Safety Agent", desc: "Flags violations against NHTSA, ISO 26262, SAE J3016, and FMVSS." },
|
| 39 |
+
{ icon: Activity, name: "Risk Agent", desc: "Identifies probable root causes across perception, planning, and control." },
|
| 40 |
+
{ icon: BookText, name: "Documentation", desc: "Drafts an export-ready Markdown safety report and coaching plan." },
|
| 41 |
+
].map((a) => (
|
| 42 |
+
<div key={a.name} className="rounded-xl border border-border bg-surface/60 backdrop-blur p-5">
|
| 43 |
+
<div className="h-9 w-9 rounded-lg bg-primary/10 text-primary flex items-center justify-center mb-3"><a.icon className="h-4 w-4"/></div>
|
| 44 |
+
<h3 className="font-semibold text-sm">{a.name}</h3>
|
| 45 |
+
<p className="text-xs text-muted-foreground mt-1.5">{a.desc}</p>
|
| 46 |
+
</div>
|
| 47 |
+
))}
|
| 48 |
+
</div>
|
| 49 |
+
</section>
|
| 50 |
</div>
|
| 51 |
);
|
| 52 |
}
|
|
|
|
|
|
|
|
|
|
|
|