"use client"; /* ═══════════════════════════════════════════════════════════════════════ RequestFlow — animated "watch a request travel through the bridge". Deine KI → KI-Brücke (MCP) → HiveGrid and back. A packet travels the track, stations light up, and a caption narrates each step. Auto-plays and loops; pauses on hover; static under prefers-reduced-motion. ═══════════════════════════════════════════════════════════════════════ */ import { useEffect, useRef, useState } from "react"; import { Sparkle, PlugsConnected, Database } from "@phosphor-icons/react/ssr"; import { CHAMFER } from "@/lib/chamfer"; // Station centres in a 3-column grid → 1/6, 3/6, 5/6. type Step = { pos: number; active: 0 | 1 | 2; n: string; title: string; detail: string; chip?: string }; const STEPS: Step[] = [ { pos: 16.7, active: 0, n: "1", title: "Du fragst", detail: "„Zeig mir alle offenen Angebote über 10.000 €.“" }, { pos: 50, active: 1, n: "2", title: "Über die KI-Brücke", detail: "Die Anfrage läuft sicher über MCP, nur im Rahmen deiner Freigaben." }, { pos: 83.3, active: 2, n: "3", title: "HiveGrid führt es aus", detail: "Liest nur die Daten deines Betriebs, jeder Zugriff protokolliert.", chip: "hg_project_search · read" }, { pos: 50, active: 1, n: "4", title: "Antwort zurück", detail: "Das Ergebnis läuft über die Brücke zurück zu deiner KI." }, { pos: 16.7, active: 0, n: "5", title: "Ergebnis in deiner KI", detail: "3 Treffer, direkt im Chat. Kein Copy-Paste, kein Tab-Wechsel." }, ]; const STATIONS = [ { icon: , label: "Deine KI", sub: "Dein KI-Client" }, { icon: , label: "KI-Brücke", sub: "MCP", dark: true }, { icon: , label: "HiveGrid", sub: "Deine Betriebsdaten" }, ]; export default function RequestFlow() { const [step, setStep] = useState(0); const paused = useRef(false); useEffect(() => { if (typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches) return; const id = window.setInterval(() => { if (!paused.current) setStep((s) => (s + 1) % STEPS.length); }, 3500); return () => window.clearInterval(id); }, []); const cur = STEPS[step]; return (
{/* bridge + travelling packet */}
{ paused.current = true; }} onMouseLeave={() => { paused.current = false; }} > {/* track line */} {/* travelling packet */} {/* stations */}
{STATIONS.map((s, i) => { const on = cur.active === i; return (
{s.icon} {s.label} {s.sub}
); })}
{/* caption — narrates the current step */}
{cur.n}
{cur.title} {cur.detail} {/* chip slot: reserve the height always so the appearing chip never shifts the layout (the page would otherwise jump every cycle). */}
{cur.chip && ( {cur.chip} )}
{/* step dots */}
{STEPS.map((s, i) => (
); }