gpt-engineer-app[bot] commited on
Commit
427892a
·
2 Parent(s): 18aae29c9f558a

Added pipeline bar animation

Browse files

X-Lovable-Edit-ID: edt-d053ffcc-20c3-4af9-9c36-d2a4a5881a48

src/components/agent-pipeline.tsx ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useState } from "react";
2
+ import { Cpu, Shield, Activity, BookText, Check, Loader2 } from "lucide-react";
3
+ import { cn } from "@/lib/utils";
4
+
5
+ const AGENTS = [
6
+ { key: "event", label: "Event Extraction", icon: Cpu, task: "Parsing timeline & sensor events…" },
7
+ { key: "safety", label: "Safety", icon: Shield, task: "Cross-checking NHTSA / ISO 26262…" },
8
+ { key: "risk", label: "Risk", icon: Activity, task: "Inferring probable root causes…" },
9
+ { key: "docs", label: "Documentation", icon: BookText, task: "Drafting safety report…" },
10
+ ] as const;
11
+
12
+ const STEP_MS = 1400;
13
+
14
+ export function AgentPipeline() {
15
+ const [active, setActive] = useState(0);
16
+ const [tick, setTick] = useState(0);
17
+
18
+ useEffect(() => {
19
+ const id = setInterval(() => {
20
+ setTick((t) => t + 1);
21
+ setActive((a) => (a + 1) % AGENTS.length);
22
+ }, STEP_MS);
23
+ return () => clearInterval(id);
24
+ }, []);
25
+
26
+ // Smooth progress within current step
27
+ const [progress, setProgress] = useState(0);
28
+ useEffect(() => {
29
+ setProgress(0);
30
+ const start = Date.now();
31
+ const id = setInterval(() => {
32
+ const p = Math.min(100, ((Date.now() - start) / STEP_MS) * 100);
33
+ setProgress(p);
34
+ if (p >= 100) clearInterval(id);
35
+ }, 40);
36
+ return () => clearInterval(id);
37
+ }, [tick]);
38
+
39
+ return (
40
+ <div className="rounded-xl border border-primary/30 bg-primary/5 p-5 space-y-4 overflow-hidden relative">
41
+ {/* Scanline */}
42
+ <div className="absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-primary to-transparent opacity-60 animate-[scanline_2.4s_linear_infinite]" />
43
+
44
+ <div className="flex items-center gap-2">
45
+ <Loader2 className="h-4 w-4 animate-spin text-primary" />
46
+ <p className="font-medium text-sm">Multi-agent analysis in progress</p>
47
+ <span className="ml-auto text-[10px] font-mono uppercase tracking-widest text-muted-foreground">
48
+ {String(active + 1).padStart(2, "0")} / {String(AGENTS.length).padStart(2, "0")}
49
+ </span>
50
+ </div>
51
+
52
+ <div className="grid grid-cols-4 gap-2">
53
+ {AGENTS.map((agent, i) => {
54
+ const Icon = agent.icon;
55
+ const state = i < active ? "done" : i === active ? "active" : "pending";
56
+ return (
57
+ <div
58
+ key={agent.key}
59
+ className={cn(
60
+ "rounded-lg border p-3 transition-colors duration-300",
61
+ state === "done" && "border-severity-low/40 bg-severity-low/5",
62
+ state === "active" && "border-primary/60 bg-primary/10 shadow-[0_0_20px_-8px_hsl(var(--primary))]",
63
+ state === "pending" && "border-border bg-surface/40 opacity-60"
64
+ )}
65
+ >
66
+ <div className="flex items-center gap-2">
67
+ <div
68
+ className={cn(
69
+ "h-7 w-7 rounded-md flex items-center justify-center shrink-0 transition-colors",
70
+ state === "done" && "bg-severity-low/20 text-severity-low",
71
+ state === "active" && "bg-primary/20 text-primary",
72
+ state === "pending" && "bg-muted/30 text-muted-foreground"
73
+ )}
74
+ >
75
+ {state === "done" ? (
76
+ <Check className="h-3.5 w-3.5" />
77
+ ) : state === "active" ? (
78
+ <Icon className="h-3.5 w-3.5 animate-pulse" />
79
+ ) : (
80
+ <Icon className="h-3.5 w-3.5" />
81
+ )}
82
+ </div>
83
+ <div className="min-w-0">
84
+ <div className="text-[10px] font-mono uppercase tracking-wider text-muted-foreground truncate">
85
+ Agent {i + 1}
86
+ </div>
87
+ <div className="text-xs font-medium truncate">{agent.label}</div>
88
+ </div>
89
+ </div>
90
+ <div className="mt-2 h-1 w-full rounded-full bg-background/60 overflow-hidden">
91
+ <div
92
+ className={cn(
93
+ "h-full rounded-full transition-all",
94
+ state === "done" && "w-full bg-severity-low",
95
+ state === "active" && "bg-primary",
96
+ state === "pending" && "w-0 bg-primary"
97
+ )}
98
+ style={state === "active" ? { width: `${progress}%` } : undefined}
99
+ />
100
+ </div>
101
+ </div>
102
+ );
103
+ })}
104
+ </div>
105
+
106
+ <div className="flex items-center gap-2 text-xs text-muted-foreground font-mono">
107
+ <span className="h-1.5 w-1.5 rounded-full bg-primary animate-pulse" />
108
+ <span className="truncate">{AGENTS[active].task}</span>
109
+ </div>
110
+
111
+ <style>{`
112
+ @keyframes scanline {
113
+ 0% { transform: translateX(-100%); }
114
+ 100% { transform: translateX(100%); }
115
+ }
116
+ `}</style>
117
+ </div>
118
+ );
119
+ }
src/routeTree.gen.ts CHANGED
@@ -195,12 +195,3 @@ const rootRouteChildren: RootRouteChildren = {
195
  export const routeTree = rootRouteImport
196
  ._addFileChildren(rootRouteChildren)
197
  ._addFileTypes<FileRouteTypes>()
198
-
199
- import type { getRouter } from './router.tsx'
200
- import type { createStart } from '@tanstack/react-start'
201
- declare module '@tanstack/react-start' {
202
- interface Register {
203
- ssr: true
204
- router: Awaited<ReturnType<typeof getRouter>>
205
- }
206
- }
 
195
  export const routeTree = rootRouteImport
196
  ._addFileChildren(rootRouteChildren)
197
  ._addFileTypes<FileRouteTypes>()
 
 
 
 
 
 
 
 
 
src/routes/dashboard.index.tsx CHANGED
@@ -2,6 +2,7 @@ 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";
@@ -162,15 +163,7 @@ function IncidentDetail({ incident, onRerun, onDelete }: { incident: Incident; o
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">
 
2
  import { useEffect, useState, useCallback } from "react";
3
  import { supabase } from "@/integrations/supabase/client";
4
  import { UploadDialog } from "@/components/upload-dialog";
5
+ import { AgentPipeline } from "@/components/agent-pipeline";
6
  import { SeverityBadge } from "@/components/severity-badge";
7
  import { ScrollArea } from "@/components/ui/scroll-area";
8
  import { Button } from "@/components/ui/button";
 
163
  </div>
164
  </div>
165
 
166
+ {incident.status === "analyzing" && <AgentPipeline />}
 
 
 
 
 
 
 
 
167
 
168
  {incident.status === "failed" && (
169
  <div className="rounded-xl border border-destructive/40 bg-destructive/10 p-6">