feat: complete UI/UX Rework into Sleek Glassmorphic AI OS (June 2026)

This commit is contained in:
Hitonabi
2026-06-25 22:18:51 +02:00
parent e1da5c797d
commit 6a8e55cc43
18 changed files with 2362 additions and 787 deletions
+95 -37
View File
@@ -1,20 +1,31 @@
import { useEffect, useState } from "react"
import { ExternalLink } from "lucide-react"
import { Bot, ExternalLink, Activity, Cpu, Wrench, Shield } from "lucide-react"
import { api, type AgentStatus } from "@/lib/api"
import { cn } from "@/lib/utils"
function Dot({ ok }: { ok: boolean }) {
return <span className={cn("h-2 w-2 rounded-full", ok ? "bg-emerald-500" : "bg-amber-500")} />
}
function Tile({ label, ok, detail }: { label: string; ok: boolean; detail?: string }) {
function Tile({ label, ok, detail, icon: Icon }: { label: string; ok: boolean; detail?: string; icon: any }) {
return (
<div className="rounded-lg border border-border bg-card p-4">
<div className="flex items-center gap-2">
<Dot ok={ok} />
<span className="text-sm font-medium">{label}</span>
<div className={cn(
"rounded-2xl border bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 flex flex-col justify-between gap-3 hover:border-primary/40 transition-all duration-300",
ok ? "border-border/60" : "border-amber-500/30"
)}>
<div className="flex items-center justify-between">
<span className="text-[10px] font-bold uppercase tracking-wider text-muted-foreground">{label}</span>
<Icon className={cn("h-4.5 w-4.5", ok ? "text-primary" : "text-amber-500")} />
</div>
<div className="space-y-1.5">
<div className="flex items-center gap-2">
<span className={cn(
"h-2 w-2 rounded-full ring-2 ring-black/40",
ok ? "bg-emerald-500 animate-pulse" : "bg-amber-500"
)} />
<span className="text-xs font-semibold text-foreground">
{ok ? "Bereit / Online" : "Offline / Inaktiv"}
</span>
</div>
{detail && <div className="text-[10px] font-mono text-muted-foreground truncate max-w-[200px]" title={detail}>{detail}</div>}
</div>
{detail && <div className="mt-1 text-xs text-muted-foreground">{detail}</div>}
</div>
)
}
@@ -26,60 +37,107 @@ export function AgentView() {
useEffect(() => {
const load = () => api<AgentStatus>("/api/agent/status").then(setS).catch((e) => setError(String(e)))
load()
const t = setInterval(load, 8000)
const t = setInterval(load, 5000)
return () => clearInterval(t)
}, [])
return (
<div className="space-y-4">
<div className="flex items-start justify-between">
<div className="space-y-6">
{/* Header */}
<div className="flex flex-col sm:flex-row justify-between sm:items-center gap-4">
<div>
<h1 className="text-xl font-semibold">Hermes</h1>
<h1 className="text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent">
Hermes Agenten-Cockpit
</h1>
<p className="text-sm text-muted-foreground">
Der autonome Agent läuft eigenständig (Gateway :8642) und hat seine eigene Oberfläche
(hermes-webui :8787). Mission Control verlinkt nur Chat &amp; Steuerung leben dort.
Hermes ist ein autonomer Agent, der im Hintergrund der Box läuft (Port <code>:8642</code>) und seine eigene UI besitzt.
</p>
</div>
{s?.webui_url && (
<a
href={s.webui_url}
target="_blank"
rel="noopener"
className={cn(
"flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium",
"flex h-9 px-4 items-center gap-1.5 text-xs font-semibold rounded-lg transition-all cursor-pointer shadow-md shrink-0 self-start",
s.webui_reachable
? "bg-primary text-primary-foreground hover:opacity-90"
: "border border-border text-muted-foreground",
? "bg-primary text-primary-foreground hover:opacity-90 shadow-primary/10"
: "border border-border/60 text-muted-foreground bg-background/20"
)}
>
<ExternalLink className="h-4 w-4" /> Hermes öffnen
<ExternalLink className="h-4 w-4" />
<span>Hermes WebUI öffnen</span>
</a>
)}
</div>
{error && <div className="text-sm text-muted-foreground">Status nicht lesbar ({error}).</div>}
{error && (
<div className="rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400 font-mono">
Status nicht lesbar ({error}).
</div>
)}
{s && (
<>
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
<Tile label="Gateway (:8642)" ok={s.gateway_reachable} detail={s.gateway_reachable ? "erreichbar" : "offline"} />
<Tile label="WebUI (:8787)" ok={s.webui_reachable} detail={s.webui_reachable ? "erreichbar" : "offline"} />
<Tile label="Brain" ok={s.gateway_reachable} detail={`model: ${s.brain_model || "auto"}`} />
<Tile label="Verdrahtung" ok={s.has_config} detail={`config ${s.has_config ? "✓" : "—"} · skills ${s.has_skills ? "✓" : "—"} · memories ${s.has_memories ? "✓" : "—"}`} />
<div className="space-y-6">
{/* Tile Grid */}
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
<Tile
label="Agent Gateway"
ok={s.gateway_reachable}
detail="Port :8642 (REST API)"
icon={Bot}
/>
<Tile
label="Agent WebUI"
ok={s.webui_reachable}
detail="Port :8787 (Chat UI)"
icon={Activity}
/>
<Tile
label="Aktives Gehirn"
ok={s.gateway_reachable}
detail={s.brain_model ? `Model: ${s.brain_model}` : "Model: auto"}
icon={Cpu}
/>
<Tile
label="Verdrahtung"
ok={s.has_config}
detail={`Config: ${s.has_config ? "✓" : "—"} · Skills: ${s.has_skills ? "✓" : "—"} · Memory: ${s.has_memories ? "✓" : "—"}`}
icon={Wrench}
/>
</div>
{/* Diagnostic Details if Offline */}
{!s.gateway_reachable && (
<div className="rounded-xl border border-dashed border-border bg-card/50 p-5 text-sm">
<div className="mb-2 font-medium">Hermes ist (hier) offline</div>
<p className="text-muted-foreground">
Der Agent + hermes-webui laufen auf der Box. Einrichtung & volle Verdrahtung
(Brain = <code>model: auto</code>, Tools/MCP inkl. <code>mcp_mc</code> + <code>mcp_memory</code>,
SSHWindows, lokale Browser-/Such-MCP) sind im Runbook beschrieben:
<code className="ml-1">docs/HERMES_SETUP.md</code>.
</p>
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-6 space-y-4 shadow-lg shadow-black/10">
<div className="flex items-center gap-2">
<Shield className="h-5 w-5 text-amber-500" />
<h3 className="text-sm font-bold uppercase tracking-wider text-foreground">Hermes-Agent Diagnostics</h3>
</div>
<div className="text-xs text-muted-foreground space-y-3 leading-relaxed">
<p>
Der Hermes-Dienst ist auf der Box derzeit offline oder kann sich nicht mit dem lokalen llama-swap verbinden.
</p>
<p>
Stelle sicher, dass die systemd-Dienste auf der Box laufen. Du kannst den Status im <strong>OS &amp; Updates Drawer</strong> prüfen und die Dienste bei Bedarf neu starten.
</p>
<div className="p-3.5 bg-background/25 rounded-xl border border-border/30 font-mono text-[10px] space-y-1">
<div className="text-muted-foreground/60"># Dienste manuell auf der Box prüfen:</div>
<div className="text-primary">systemctl --user status hermes-gateway</div>
<div className="text-primary">systemctl --user status hermes-webui</div>
</div>
<p>
Weitere Einrichtungsdetails (Brain-Konfiguration, MCP-Kopplungen, SSH-Tunneling und Such-Engines) findest du in der Dokumentationsdatei:
<code className="ml-1 px-1.5 py-0.5 rounded bg-muted/40 text-foreground border border-border/30">docs/HERMES_SETUP.md</code>.
</p>
</div>
</div>
)}
</>
</div>
)}
</div>
)
+71 -32
View File
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react"
import { Check, Copy } from "lucide-react"
import { Check, Copy, Terminal, Info, Globe, FolderOpen } from "lucide-react"
import { api, type ConnectResp } from "@/lib/api"
import { cn } from "@/lib/utils"
@@ -40,51 +40,63 @@ export function ConnectView() {
}
return (
<div className="space-y-4">
<div className="space-y-6">
{/* Header */}
<div>
<h1 className="text-xl font-semibold">Verbinden</h1>
<h1 className="text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent">
Verbindung &amp; Integration
</h1>
<p className="text-sm text-muted-foreground">
Fertige Snippets für deine Tools auf dem lokalen PC alle zeigen auf den Gateway der Box
(<code>model: auto</code>) + das geteilte Gedächtnis.
Kopiere vorgefertigte Konfigurationsdateien für deinen lokalen PC (IDEs, Cline, Roo Code, Cursor), um direkt auf das geteilte Gedächtnis und den Auto-Swap-Gateway der Box zuzugreifen.
</p>
</div>
<div className="flex flex-wrap items-center gap-4 text-sm bg-card/40 p-3 rounded-lg border border-border">
<div className="flex items-center gap-2">
<label className="text-muted-foreground">Box-LAN-IP:</label>
{/* Connection Variables Panel */}
<div className="grid gap-4 md:grid-cols-2 p-5 rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md shadow-lg shadow-black/10">
<div className="space-y-1.5">
<label className="text-[10px] font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5">
<Globe className="h-3.5 w-3.5 text-primary" /> Box LAN IP-Adresse
</label>
<input
value={host}
onChange={(e) => saveHost(e.target.value)}
className="w-36 rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus:ring-2 focus:ring-ring"
placeholder="z.B. 192.168.178.151"
className="w-full h-9 rounded-lg border border-border/60 bg-background/40 px-3 font-mono text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"
/>
</div>
<div className="flex items-center gap-2 flex-1 min-w-[280px]">
<label className="text-muted-foreground whitespace-nowrap">Lokaler MCP-Pfad:</label>
<div className="space-y-1.5">
<label className="text-[10px] font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5">
<FolderOpen className="h-3.5 w-3.5 text-primary" /> Lokaler MCP-Scriptpfad
</label>
<input
value={mcpPath}
onChange={(e) => saveMcpPath(e.target.value)}
placeholder="z.B. F:\Coding Stuff\mission-control-2\mcp\mcp_memory.py"
className="flex-1 rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus:ring-2 focus:ring-ring"
className="w-full h-9 rounded-lg border border-border/60 bg-background/40 px-3 font-mono text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"
/>
</div>
</div>
{error && (
<div className="rounded-md border border-border bg-card p-3 text-sm text-muted-foreground">
Snippets nicht ladbar ({error}).
<div className="rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400">
Fehler beim Generieren der Snippets: {error}
</div>
)}
{data && (
<>
<div className="flex flex-wrap gap-1">
<div className="space-y-4">
{/* Tool Tab Bar */}
<div className="flex flex-wrap gap-1 bg-card/20 p-1 border border-border/40 rounded-xl max-w-fit">
{Object.entries(data.tools).map(([key, t]) => (
<button
key={key}
onClick={() => setActive(key)}
className={cn(
"rounded-md px-3 py-1.5 text-sm transition-colors",
active === key ? "bg-primary/15 text-primary" : "text-muted-foreground hover:text-foreground",
"rounded-lg px-4 py-1.5 text-xs font-semibold tracking-wide uppercase transition-all cursor-pointer",
active === key
? "bg-primary text-primary-foreground shadow-md shadow-primary/10"
: "text-muted-foreground hover:text-foreground",
)}
>
{t.label}
@@ -93,23 +105,50 @@ export function ConnectView() {
</div>
{tool && (
<div className="space-y-2">
<div className="flex items-center justify-between">
<span className="text-xs text-muted-foreground">{tool.note}</span>
<button
onClick={copy}
className="flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent"
>
{copied ? <Check className="h-3.5 w-3.5 text-emerald-500" /> : <Copy className="h-3.5 w-3.5" />}
{copied ? "Kopiert" : "Kopieren"}
</button>
<div className="space-y-3">
{/* Note / Info */}
{tool.note && (
<div className="flex items-start gap-2.5 p-3 rounded-xl bg-primary/5 border border-primary/20 text-xs text-muted-foreground leading-relaxed">
<Info className="h-4.5 w-4.5 text-primary shrink-0 mt-0.5" />
<span>{tool.note}</span>
</div>
)}
{/* Editor Mockup Window */}
<div className="flex flex-col border border-border/60 bg-black/60 rounded-2xl overflow-hidden shadow-2xl">
{/* Editor Header Bar */}
<div className="flex h-11 items-center justify-between px-4 border-b border-border/40 bg-black/40 shrink-0">
{/* Left: Window Control Dots */}
<div className="flex items-center gap-1.5">
<span className="h-3 w-3 rounded-full bg-red-500/80 shadow-md shadow-red-500/10" />
<span className="h-3 w-3 rounded-full bg-amber-500/80 shadow-md shadow-amber-500/10" />
<span className="h-3 w-3 rounded-full bg-emerald-500/80 shadow-md shadow-emerald-500/10" />
</div>
{/* Center: File Title */}
<div className="flex items-center gap-1.5 text-[10px] font-mono text-muted-foreground/75 bg-background/30 px-3 py-1 rounded-md border border-border/20">
<Terminal className="h-3.5 w-3.5 text-primary" />
<span>{active === "cline" || active === "cursor" ? "config.json" : "settings.json"}</span>
</div>
{/* Right: Copy Action */}
<button
onClick={copy}
className="flex h-7 px-2.5 items-center gap-1.5 rounded-lg border border-border/40 bg-background/30 text-[10px] font-semibold text-muted-foreground hover:text-foreground hover:bg-background/60 transition-all cursor-pointer"
>
{copied ? <Check className="h-3.5 w-3.5 text-emerald-400" /> : <Copy className="h-3.5 w-3.5" />}
<span>{copied ? "Kopiert" : "Kopieren"}</span>
</button>
</div>
{/* Editor Code Area */}
<pre className="p-5 overflow-x-auto text-xs font-mono text-cyan-200/90 whitespace-pre leading-relaxed scrollbar-thin select-text bg-black/10">
<code>{tool.snippet}</code>
</pre>
</div>
<pre className="overflow-x-auto rounded-xl border border-border bg-card p-4 text-xs leading-relaxed">
<code>{tool.snippet}</code>
</pre>
</div>
)}
</>
</div>
)}
</div>
)
+317
View File
@@ -0,0 +1,317 @@
import { useEffect, useState } from "react"
import { Bot, Cpu, ExternalLink, Brain, Layers, Plus } from "lucide-react"
import { api, type SystemStatus, type AgentStatus, type ModelInfo, type Memory } from "@/lib/api"
import { cn } from "@/lib/utils"
function gb(b: number) {
return (b / 1024 ** 3).toFixed(1)
}
function RadialGauge({ value, label, detail }: { value: number; label: string; detail?: string }) {
const radius = 24
const circ = 2 * Math.PI * radius
const offset = circ - (Math.min(value, 100) / 100) * circ
// Verfärbung bei hoher Last
const strokeColor = value > 90
? "stroke-red-500"
: value > 75
? "stroke-amber-500"
: "stroke-primary"
return (
<div className="flex flex-col items-center gap-1.5 p-2 bg-background/20 rounded-xl border border-border/40">
<div className="relative flex h-16 w-16 items-center justify-center">
<svg className="absolute inset-0 h-full w-full -rotate-90">
<circle cx="32" cy="32" r={radius} className="stroke-muted fill-none" strokeWidth="4.5" />
<circle cx="32" cy="32" r={radius} className={cn("fill-none transition-all duration-700 ease-out", strokeColor)} strokeWidth="4.5" strokeDasharray={circ} strokeDashoffset={offset} strokeLinecap="round" />
</svg>
<span className="text-xs font-mono font-bold tracking-tight text-foreground">{Math.round(value)}%</span>
</div>
<span className="text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">{label}</span>
{detail && <span className="text-[10px] font-mono text-muted-foreground/80">{detail}</span>}
</div>
)
}
export function DashboardView() {
const [sys, setSys] = useState<SystemStatus | null>(null)
const [agent, setAgent] = useState<AgentStatus | null>(null)
const [models, setModels] = useState<ModelInfo[]>([])
const [running, setRunning] = useState<string[]>([])
const [memories, setMemories] = useState<Memory[]>([])
// Quick Memory Form State
const [memContent, setMemContent] = useState("")
const [memCat, setMemCat] = useState("stable")
const [savingMem, setSavingMem] = useState(false)
function loadData() {
api<SystemStatus>("/api/system/status").then(setSys).catch(() => {})
api<AgentStatus>("/api/agent/status").then(setAgent).catch(() => {})
api<{ models: ModelInfo[]; running?: string[] }>("/api/models")
.then((d) => {
setModels(d.models)
setRunning(d.running || [])
})
.catch(() => {})
api<Memory[]>("/api/memory?category=").then((d) => setMemories(d.slice(0, 3))).catch(() => {})
}
useEffect(() => {
loadData()
const t = setInterval(loadData, 3000)
return () => clearInterval(t)
}, [])
async function saveQuickMemory() {
if (!memContent.trim() || savingMem) return
setSavingMem(true)
try {
await api("/api/memory", {
method: "POST",
body: JSON.stringify({ content: memContent, category: memCat, source: "dashboard" }),
})
setMemContent("")
// Liste sofort aktualisieren
api<Memory[]>("/api/memory?category=").then((d) => setMemories(d.slice(0, 3))).catch(() => {})
} catch (e) {
console.error(e)
} finally {
setSavingMem(false)
}
}
const activeModels = models.filter((m) => m.role)
return (
<div className="space-y-6">
<div>
<h1 className="text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent">
Zentrale
</h1>
<p className="text-sm text-muted-foreground">Aktueller Status von System, Modellen und Agent.</p>
</div>
<div className="grid gap-6 sm:grid-cols-2">
{/* Card 1: System Status */}
<div className="flex flex-col justify-between rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/15">
<div>
<div className="flex items-center gap-2 mb-4">
<Cpu className="h-4.5 w-4.5 text-primary" />
<h2 className="text-sm font-semibold tracking-wide uppercase text-foreground">System-Status</h2>
</div>
{sys ? (
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
<RadialGauge value={sys.cpu.percent} label="CPU" detail={`${sys.cpu.cores} Cores`} />
<RadialGauge value={sys.ram.percent} label="RAM" detail={`${gb(sys.ram.used)} / ${gb(sys.ram.total)} GB`} />
{sys.gpu && sys.gpu.busy_percent != null && (
<RadialGauge
value={sys.gpu.busy_percent}
label="GPU"
detail={sys.gpu.gtt_used != null && sys.gpu.gtt_total != null ? `${gb(sys.gpu.gtt_used)} / ${gb(sys.gpu.gtt_total)} GB` : undefined}
/>
)}
{sys.disk && (
<RadialGauge value={sys.disk.percent} label="Disk" detail={`${gb(sys.disk.used)} / ${gb(sys.disk.total)} GB`} />
)}
</div>
) : (
<div className="h-28 flex items-center justify-center text-xs text-muted-foreground">Lade Systemdaten</div>
)}
</div>
{sys?.temp && (sys.temp.cpu || sys.temp.gpu) && (
<div className="mt-4 flex gap-4 text-xs font-mono text-muted-foreground/80 border-t border-border/30 pt-3">
{sys.temp.cpu != null && <span>CPU Temp: {sys.temp.cpu} °C</span>}
{sys.temp.gpu != null && <span>GPU Temp: {sys.temp.gpu} °C</span>}
</div>
)}
</div>
{/* Card 2: Hermes Agent Status */}
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/15 flex flex-col justify-between">
<div>
<div className="flex items-center justify-between mb-4">
<div className="flex items-center gap-2">
<Bot className="h-4.5 w-4.5 text-primary" />
<h2 className="text-sm font-semibold tracking-wide uppercase text-foreground">Hermes Agent</h2>
</div>
{agent?.webui_url && (
<a
href={agent.webui_url}
target="_blank"
rel="noopener"
className={cn(
"flex items-center gap-1 px-3 py-1 rounded-lg text-xs font-medium transition-all",
agent.webui_reachable
? "bg-primary text-primary-foreground hover:opacity-90 shadow-md shadow-primary/20"
: "border border-border text-muted-foreground"
)}
>
<ExternalLink className="h-3 w-3" /> Hermes öffnen
</a>
)}
</div>
{agent ? (
<div className="space-y-3">
<div className="grid grid-cols-2 gap-3">
<div className="p-3 bg-background/20 rounded-xl border border-border/40">
<div className="text-[10px] text-muted-foreground uppercase font-semibold">Gateway</div>
<div className="flex items-center gap-2 mt-1">
<span className={cn("h-2 w-2 rounded-full", agent.gateway_reachable ? "bg-emerald-500 animate-pulse" : "bg-amber-500")} />
<span className="text-xs font-medium">{agent.gateway_reachable ? "Online" : "Offline"}</span>
</div>
</div>
<div className="p-3 bg-background/20 rounded-xl border border-border/40">
<div className="text-[10px] text-muted-foreground uppercase font-semibold">WebUI</div>
<div className="flex items-center gap-2 mt-1">
<span className={cn("h-2 w-2 rounded-full", agent.webui_reachable ? "bg-emerald-500 animate-pulse" : "bg-amber-500")} />
<span className="text-xs font-medium">{agent.webui_reachable ? "Online" : "Offline"}</span>
</div>
</div>
</div>
<div className="p-3 bg-background/20 rounded-xl border border-border/40">
<div className="text-[10px] text-muted-foreground uppercase font-semibold">Aktives Gehirn</div>
<div className="text-xs font-medium mt-1 font-mono text-primary flex items-center gap-1.5">
<Layers className="h-3.5 w-3.5" />
{agent.brain_model ? `model: ${agent.brain_model}` : "model: auto"}
</div>
</div>
</div>
) : (
<div className="h-28 flex items-center justify-center text-xs text-muted-foreground">Lade Agenten-Status</div>
)}
</div>
<div className="mt-3 text-[10px] text-muted-foreground/80 border-t border-border/30 pt-3">
Gedächtnis & Stack-Tools via MCP gekoppelt.
</div>
</div>
</div>
<div className="grid gap-6 sm:grid-cols-2">
{/* Card 3: Active Model Roles */}
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/15 flex flex-col justify-between">
<div>
<div className="flex items-center gap-2 mb-4">
<Layers className="h-4.5 w-4.5 text-primary" />
<h2 className="text-sm font-semibold tracking-wide uppercase text-foreground">Aktive Rollen</h2>
</div>
<div className="space-y-2">
{activeModels.length === 0 ? (
<div className="text-xs text-muted-foreground py-6 text-center">Keine Modelle als Rollen zugewiesen.</div>
) : (
activeModels.map((m) => {
const isRunning = running.includes(m.name)
return (
<div
key={m.name}
className={cn(
"flex items-center justify-between p-3 rounded-xl border transition-all duration-300",
isRunning
? "border-primary/50 bg-primary/5 shadow-md shadow-primary/5"
: "border-border/40 bg-background/20"
)}
>
<div>
<div className="flex items-center gap-2">
<span className={cn("text-xs font-semibold uppercase px-1.5 py-0.5 rounded",
m.role === "fast" ? "bg-cyan-500/15 text-cyan-400" :
m.role === "heavy" ? "bg-amber-500/15 text-amber-400" :
m.role === "coder" ? "bg-violet-500/15 text-violet-400" :
m.role === "vision" ? "bg-pink-500/15 text-pink-400" : "bg-muted text-muted-foreground"
)}>
{m.role}
</span>
{isRunning && (
<span className="flex h-2 w-2 relative">
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
<span className="relative inline-flex rounded-full h-2 w-2 bg-emerald-500"></span>
</span>
)}
</div>
<div className="text-xs font-medium mt-1.5 truncate max-w-[200px] sm:max-w-[280px]" title={m.name}>
{m.name}
</div>
</div>
<div className="text-[10px] font-mono text-muted-foreground">
{isRunning ? "Warm / Aktiv" : "Bereit"}
</div>
</div>
)
})
)}
</div>
</div>
<div className="mt-4 text-[10px] text-muted-foreground/80 border-t border-border/30 pt-3">
Laden erfolgt automatisch per Auto-Swap.
</div>
</div>
{/* Card 4: Quick Memory Input */}
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/15 flex flex-col justify-between">
<div>
<div className="flex items-center gap-2 mb-4">
<Brain className="h-4.5 w-4.5 text-primary" />
<h2 className="text-sm font-semibold tracking-wide uppercase text-foreground">Gedächtnis-Schnellform</h2>
</div>
<div className="space-y-3">
<div className="flex items-start gap-2">
<textarea
value={memContent}
onChange={(e) => setMemContent(e.target.value)}
placeholder="Fakt / Regel auf der Box speichern..."
rows={2}
className="flex-1 resize-none rounded-xl border border-border/50 bg-background/30 px-3 py-2 text-xs outline-none focus:ring-1.5 focus:ring-primary transition-all"
/>
</div>
<div className="flex items-center gap-2 justify-end">
<select
value={memCat}
onChange={(e) => setMemCat(e.target.value)}
className="rounded-lg border border-border/50 bg-background/50 px-2 py-1 text-xs outline-none"
>
<option value="stable">🔵 Fakt</option>
<option value="instruction">📋 Regel</option>
<option value="user">👤 User</option>
<option value="versioned">🟡 Version</option>
</select>
<button
onClick={saveQuickMemory}
disabled={!memContent.trim() || savingMem}
className="flex items-center gap-1 rounded-lg bg-primary px-3 py-1 text-xs font-semibold text-primary-foreground hover:opacity-90 disabled:opacity-50 transition-all cursor-pointer"
>
<Plus className="h-3.5 w-3.5" /> Speichern
</button>
</div>
</div>
<div className="mt-4 space-y-2">
<div className="text-[10px] text-muted-foreground uppercase font-semibold tracking-wider">Zuletzt gespeichert:</div>
{memories.length === 0 ? (
<div className="text-xs text-muted-foreground/75 py-2">Keine Einträge vorhanden.</div>
) : (
memories.map((m) => (
<div key={m.id} className="text-xs bg-background/10 border border-border/30 rounded-lg p-2 flex items-start gap-2">
<span className="shrink-0 text-[10px] font-mono text-muted-foreground/80 px-1 py-0.5 rounded bg-muted/20">
{m.category}
</span>
<span className="truncate flex-1 text-muted-foreground hover:text-foreground transition-colors" title={m.content}>
{m.content}
</span>
</div>
))
)}
</div>
</div>
<div className="mt-4 text-[10px] text-muted-foreground/80 border-t border-border/30 pt-3">
Steht allen Clients (IDEs, Hermes) per MCP zur Verfügung.
</div>
</div>
</div>
</div>
)
}
+178 -73
View File
@@ -1,12 +1,26 @@
import { useEffect, useState } from "react"
import { Trash2, Sparkles } from "lucide-react"
import { Trash2, Sparkles, User, Scroll, Shield, Tag, Clock, Search, Plus, BookOpen } from "lucide-react"
import { api, type DedupeResult, type Memory } from "@/lib/api"
import { cn } from "@/lib/utils"
const CATEGORIES = ["user", "instruction", "stable", "versioned", "ephemeral"]
const CAT_LABEL: Record<string, string> = {
user: "👤 User", instruction: "📋 Regel", stable: "🔵 Fakt",
versioned: "🟡 Version", ephemeral: "⏱ Temporär",
const CAT_CONFIG: Record<string, { label: string; icon: any; color: string; border: string; bg: string; text: string }> = {
user: { label: "User", icon: User, color: "text-cyan-400", border: "border-cyan-500/30", bg: "bg-cyan-500/10", text: "text-cyan-400" },
instruction: { label: "Regel", icon: Scroll, color: "text-violet-400", border: "border-violet-500/30", bg: "bg-violet-500/10", text: "text-violet-400" },
stable: { label: "Fakt", icon: Shield, color: "text-indigo-400", border: "border-indigo-500/30", bg: "bg-indigo-500/10", text: "text-indigo-400" },
versioned: { label: "Version", icon: Tag, color: "text-amber-400", border: "border-amber-500/30", bg: "bg-amber-500/10", text: "text-amber-400" },
ephemeral: { label: "Temporär", icon: Clock, color: "text-pink-400", border: "border-pink-500/30", bg: "bg-pink-500/10", text: "text-pink-400" },
}
const DEFAULT_CAT = { label: "Gedächtnis", icon: BookOpen, color: "text-muted-foreground", border: "border-border/40", bg: "bg-muted/10", text: "text-muted-foreground" }
const BORDER_CLASSES: Record<string, string> = {
user: "border-l-cyan-500/80",
instruction: "border-l-violet-500/80",
stable: "border-l-indigo-500/80",
versioned: "border-l-amber-500/80",
ephemeral: "border-l-pink-500/80",
}
export function MemoryView() {
@@ -16,123 +30,214 @@ export function MemoryView() {
const [content, setContent] = useState("")
const [category, setCategory] = useState("stable")
const [error, setError] = useState("")
const [deduping, setDeduping] = useState(false)
function load() {
const params = new URLSearchParams()
if (q) params.set("q", q)
if (filter) params.set("category", filter)
api<Memory[]>(`/api/memory?${params}`).then(setItems).catch((e) => setError(String(e)))
api<Memory[]>(`/api/memory?${params}`)
.then(setItems)
.catch((e) => setError(String(e)))
}
useEffect(load, [q, filter])
async function add() {
if (!content.trim()) return
await api("/api/memory", { method: "POST", body: JSON.stringify({ content, category, source: "ui" }) })
await api("/api/memory", {
method: "POST",
body: JSON.stringify({ content, category, source: "ui" })
})
setContent("")
load()
}
async function del(id: string) {
await api(`/api/memory/${id}`, { method: "DELETE" })
load()
}
async function cleanup() {
const dry = await api<DedupeResult>("/api/memory/dedupe", {
method: "POST", body: JSON.stringify({ apply: false }),
})
if (dry.duplicate_count === 0) {
alert("Keine Dubletten gefunden — alles sauber.")
return
}
if (confirm(`${dry.duplicate_count} Dublette(n) in ${dry.groups.length} Gruppe(n) gefunden. Entfernen?`)) {
await api("/api/memory/dedupe", { method: "POST", body: JSON.stringify({ apply: true }) })
load()
setDeduping(true)
try {
const dry = await api<DedupeResult>("/api/memory/dedupe", {
method: "POST",
body: JSON.stringify({ apply: false }),
})
if (dry.duplicate_count === 0) {
alert("Keine Dubletten gefunden — alles sauber.")
return
}
if (confirm(`${dry.duplicate_count} Dublette(n) in ${dry.groups.length} Gruppe(n) gefunden. Entfernen?`)) {
await api("/api/memory/dedupe", {
method: "POST",
body: JSON.stringify({ apply: true })
})
load()
}
} catch (e: any) {
alert(`Fehler: ${e.message}`)
} finally {
setDeduping(false)
}
}
return (
<div className="space-y-4">
<div className="flex items-start justify-between">
<div className="space-y-6">
{/* Header */}
<div className="flex flex-col sm:flex-row justify-between sm:items-center gap-4">
<div>
<h1 className="text-xl font-semibold">Gedächtnis</h1>
<h1 className="text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent">
Gedächtnis-Pool (Memory)
</h1>
<p className="text-sm text-muted-foreground">
Die geteilte Verfassung" — alle Tools (Hermes, IDEs) lesen/schreiben hier via MCP.
Die geteilte Konstitution des Systems. Alle Instanzen (Hermes, IDEs, Gateway) lesen und schreiben hierauf per MCP-Protokoll.
</p>
</div>
<button
onClick={cleanup}
className="flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent"
disabled={deduping}
className="flex h-9 px-4 items-center gap-1.5 text-xs font-semibold rounded-lg border border-border/60 bg-card hover:border-primary/50 transition-all cursor-pointer shadow-md disabled:opacity-50 shrink-0 self-start"
>
<Sparkles className="h-3.5 w-3.5 text-primary" /> Aufräumen
<Sparkles className="h-4 w-4 text-primary animate-pulse" />
<span>Deduplizieren</span>
</button>
</div>
{/* Add */}
<div className="rounded-xl border border-border bg-card p-3">
{/* Add New Fact Box */}
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 space-y-4">
<div className="text-xs font-bold uppercase tracking-wider text-muted-foreground">Neuen Eintrag anlegen</div>
<textarea
value={content}
onChange={(e) => setContent(e.target.value)}
placeholder="Neuen Fakt / Regel hinzufügen"
rows={2}
className="w-full resize-none rounded-md border border-border bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring"
placeholder="Füge eine neue Regel, eine Vorliebe oder einen stabilen Fakt über das Projekt oder dich hinzu..."
rows={3}
className="w-full resize-none rounded-xl border border-border/60 bg-background/30 p-3.5 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground transition-all leading-relaxed"
/>
<div className="mt-2 flex items-center gap-2">
<select
value={category}
onChange={(e) => setCategory(e.target.value)}
className="rounded-md border border-border bg-background px-2 py-1.5 text-sm outline-none"
<div className="flex flex-wrap items-center justify-between gap-3">
<div className="flex items-center gap-2">
<span className="text-[10px] font-semibold text-muted-foreground uppercase tracking-wider">Kategorie</span>
<select
value={category}
onChange={(e) => setCategory(e.target.value)}
className="h-8 rounded-lg border border-border/60 bg-background/50 px-2 py-1 text-xs outline-none font-semibold text-foreground cursor-pointer"
>
{CATEGORIES.map((c) => (
<option key={c} value={c} className="bg-popover text-foreground">
{CAT_CONFIG[c]?.label || c}
</option>
))}
</select>
</div>
<button
onClick={add}
className="h-9 px-4 rounded-lg bg-primary text-primary-foreground text-xs font-semibold hover:opacity-90 transition-all flex items-center gap-1.5 cursor-pointer shadow-md shadow-primary/10"
>
{CATEGORIES.map((c) => (
<option key={c} value={c}>{CAT_LABEL[c]}</option>
))}
</select>
<button onClick={add} className="rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:opacity-90">
Speichern
<Plus className="h-4 w-4" /> Speichern
</button>
</div>
</div>
{/* Filter */}
<div className="flex flex-wrap items-center gap-2">
<input
value={q}
onChange={(e) => setQ(e.target.value)}
placeholder="Suchen"
className="rounded-md border border-border bg-card px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring"
/>
<button
onClick={() => setFilter("")}
className={cn("rounded-md px-2.5 py-1.5 text-xs", !filter ? "bg-primary/15 text-primary" : "text-muted-foreground hover:text-foreground")}
>
Alle
</button>
{CATEGORIES.map((c) => (
{/* Filter / Search HUD */}
<div className="flex flex-col md:flex-row items-stretch md:items-center gap-3">
<div className="relative flex-1">
<input
value={q}
onChange={(e) => setQ(e.target.value)}
placeholder="Gedächtnis durchsuchen..."
className="w-full h-9 pl-9 pr-3 rounded-lg border border-border/60 bg-card/45 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"
/>
<Search className="absolute left-3 top-2.5 h-3.5 w-3.5 text-muted-foreground" />
</div>
<div className="flex flex-wrap items-center gap-1.5 p-1 bg-card/30 border border-border/40 rounded-xl overflow-x-auto max-w-full">
<button
key={c}
onClick={() => setFilter(c)}
className={cn("rounded-md px-2.5 py-1.5 text-xs", filter === c ? "bg-primary/15 text-primary" : "text-muted-foreground hover:text-foreground")}
onClick={() => setFilter("")}
className={cn(
"h-7 px-3 rounded-lg text-[10px] font-semibold uppercase tracking-wider transition-all cursor-pointer whitespace-nowrap",
!filter ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:text-foreground"
)}
>
{CAT_LABEL[c]}
Alle
</button>
))}
{CATEGORIES.map((c) => {
const conf = CAT_CONFIG[c] || DEFAULT_CAT
const Icon = conf.icon
return (
<button
key={c}
onClick={() => setFilter(c)}
className={cn(
"h-7 px-2.5 rounded-lg text-[10px] font-semibold uppercase tracking-wider transition-all cursor-pointer flex items-center gap-1 whitespace-nowrap",
filter === c
? "bg-primary text-primary-foreground"
: "text-muted-foreground hover:text-foreground"
)}
>
<Icon className="h-3 w-3" />
<span>{conf.label}</span>
</button>
)
})}
</div>
</div>
{error && <div className="text-sm text-muted-foreground">Fehler: {error}</div>}
{error && (
<div className="rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400">
Fehler beim Laden des Gedächtnisses: {error}
</div>
)}
{/* List */}
<div className="space-y-2">
{items.length === 0 && <div className="text-sm text-muted-foreground">Keine Einträge.</div>}
{items.map((m) => (
<div key={m.id} className="flex items-start gap-3 rounded-lg border border-border bg-card p-3">
<span className="shrink-0 rounded bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground">
{CAT_LABEL[m.category] || m.category}
</span>
<span className="flex-1 text-sm">{m.content}</span>
<span className="shrink-0 text-[11px] text-muted-foreground">{m.source}</span>
<button onClick={() => del(m.id)} className="shrink-0 text-muted-foreground hover:text-red-500">
<Trash2 className="h-4 w-4" />
</button>
{/* Facts List */}
<div className="space-y-3">
{items.length === 0 ? (
<div className="text-xs text-muted-foreground border border-dashed border-border/60 rounded-2xl p-12 text-center">
Keine Einträge für die aktuellen Filterkriterien gefunden.
</div>
))}
) : (
items.map((m) => {
const conf = CAT_CONFIG[m.category] || DEFAULT_CAT
const Icon = conf.icon
return (
<div
key={m.id}
className={cn(
"flex items-start justify-between gap-4 p-4 rounded-xl border border-l-4 bg-card/45 backdrop-blur-md border-border/60 shadow-md shadow-black/5 hover:border-primary/20 transition-all group",
BORDER_CLASSES[m.category] || "border-l-muted"
)}
>
<div className="flex items-start gap-3 flex-1 min-w-0">
<span className={cn(
"flex items-center gap-1 px-2 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider font-mono shrink-0",
conf.bg, conf.text
)}>
<Icon className="h-3 w-3" />
<span className="hidden sm:inline">{conf.label}</span>
</span>
<span className="text-xs text-foreground leading-relaxed break-words whitespace-pre-wrap flex-1">{m.content}</span>
</div>
<div className="flex items-center gap-3 shrink-0">
<span className="text-[9px] font-mono text-muted-foreground/60 bg-background/20 px-1.5 py-0.5 rounded uppercase tracking-wider">
{m.source}
</span>
<button
onClick={() => del(m.id)}
className="h-7 w-7 rounded-lg flex items-center justify-center border border-border/40 text-muted-foreground hover:text-red-400 hover:bg-red-500/5 transition-all opacity-0 group-hover:opacity-100"
title="Eintrag löschen"
>
<Trash2 className="h-3.5 w-3.5" />
</button>
</div>
</div>
)
})
)}
</div>
</div>
)
+330 -174
View File
@@ -1,13 +1,15 @@
import { useEffect, useState } from "react"
import { Download } from "lucide-react"
import { Download, Search, Trash2, Edit3, Star, Layers, Activity, HardDrive } from "lucide-react"
import { api, type DiscoverResp, type Fit, type Job, type ModelInfo } from "@/lib/api"
import { CapsChips } from "@/components/CapsChips"
import { cn } from "@/lib/utils"
function fmtBytes(b?: number) {
if (!b) return ""
return `${(b / 1024 ** 3).toFixed(1)} GB`
if (b > 1024 ** 3) return `${(b / 1024 ** 3).toFixed(1)} GB`
return `${(b / 1024 ** 2).toFixed(0)} MB`
}
function fmtEta(s?: number) {
if (!s) return ""
const m = Math.floor(s / 60)
@@ -16,36 +18,69 @@ function fmtEta(s?: number) {
function JobsBar() {
const [jobs, setJobs] = useState<Job[]>([])
function load() {
api<{ jobs: Job[] }>("/api/jobs")
.then((d) => setJobs(d.jobs || []))
.catch(() => {})
}
useEffect(() => {
const load = () => api<{ jobs: Job[] }>("/api/jobs").then((d) => setJobs(d.jobs)).catch(() => {})
load()
const t = setInterval(load, 2000)
return () => clearInterval(t)
}, [])
async function cancelJob(jobId: string) {
try {
await api(`/api/jobs/${jobId}/cancel`, { method: "POST" })
load()
} catch (e: any) {
alert(`Fehler: ${e.message}`)
}
}
const active = jobs.filter((j) => j.state === "running" || j.state === "queued")
const recent = jobs.filter((j) => j.state !== "running" && j.state !== "queued").slice(-3)
if (active.length === 0 && recent.length === 0) return null
return (
<div className="space-y-2 rounded-xl border border-border bg-card p-3">
<div className="text-xs font-medium text-muted-foreground">Downloads</div>
<div className="space-y-3 rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-4 shadow-lg shadow-black/10">
<div className="text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">Aktive Downloads</div>
{active.map((j) => (
<div key={j.id} className="space-y-1">
<div className="flex justify-between text-xs">
<span className="truncate">{j.label}</span>
<span className="text-muted-foreground">
{j.progress ?? 0}% · {fmtBytes(j.done_bytes)}/{fmtBytes(j.total_bytes)}
{j.eta_s ? ` · ETA ${fmtEta(j.eta_s)}` : ""}
</span>
<div key={j.id} className="space-y-1.5 p-3 rounded-xl bg-background/20 border border-border/40">
<div className="flex justify-between items-center text-xs">
<span className="font-semibold truncate max-w-[250px]">{j.label}</span>
<div className="flex items-center gap-3">
<span className="text-muted-foreground font-mono">
{j.progress ?? 0}% {fmtBytes(j.done_bytes)}/{fmtBytes(j.total_bytes)}
{j.eta_s ? ` • ETA ${fmtEta(j.eta_s)}` : ""}
</span>
<button
onClick={() => cancelJob(j.id)}
className="text-[10px] text-red-400 hover:text-red-300 font-semibold border border-red-500/25 bg-red-500/5 px-2 py-0.5 rounded transition-all"
>
Abbrechen
</button>
</div>
</div>
<div className="h-1.5 overflow-hidden rounded-full bg-muted">
<div className="h-full rounded-full bg-primary transition-all" style={{ width: `${j.progress ?? 0}%` }} />
<div className="h-full rounded-full bg-primary transition-all duration-500" style={{ width: `${j.progress ?? 0}%` }} />
</div>
</div>
))}
{recent.map((j) => (
<div key={j.id} className="flex justify-between text-xs text-muted-foreground">
<div key={j.id} className="flex justify-between items-center text-xs text-muted-foreground px-1">
<span className="truncate">{j.label}</span>
<span className={j.state === "done" ? "text-emerald-500" : "text-amber-500"}>{j.state}</span>
<span className={cn(
"font-semibold text-[10px] px-1.5 py-0.5 rounded uppercase font-mono",
j.state === "done" ? "bg-emerald-500/10 text-emerald-400" : "bg-amber-500/10 text-amber-400"
)}>
{j.state}
</span>
</div>
))}
</div>
@@ -57,19 +92,20 @@ function fmtSize(b: number | null) {
const gb = b / 1024 ** 3
return gb >= 1 ? `${gb.toFixed(1)} GB` : `${(b / 1024 ** 2).toFixed(0)} MB`
}
function fmtCtx(c: number | null) {
return c ? `${Math.round(c / 1024)}k` : "—"
}
function FitBadge({ fit }: { fit: Fit }) {
const tone = {
perfect: "bg-emerald-500/15 text-emerald-500",
marginal: "bg-amber-500/15 text-amber-500",
too_tight: "bg-red-500/15 text-red-500",
perfect: "bg-emerald-500/15 text-emerald-400 border border-emerald-500/20",
marginal: "bg-amber-500/15 text-amber-400 border border-amber-500/20",
too_tight: "bg-red-500/15 text-red-400 border border-red-500/20",
}[fit.level]
return (
<span className={cn("rounded px-1.5 py-0.5 text-[11px] font-medium", tone)}>
{fit.text} · ~{fit.req_gb} GB
<span className={cn("rounded px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider font-mono", tone)}>
{fit.text} {fit.req_gb} GB RAM
</span>
)
}
@@ -78,99 +114,146 @@ const ROLES = ["", "fast", "heavy", "coder", "reasoning", "agent", "vision", "sc
function Installed() {
const [models, setModels] = useState<ModelInfo[]>([])
const [running, setRunning] = useState<string[]>([])
const [error, setError] = useState("")
const [loading, setLoading] = useState(true)
function load() {
api<{ models: ModelInfo[] }>("/api/models")
.then((d) => setModels(d.models))
api<{ models: ModelInfo[]; running?: string[] }>("/api/models")
.then((d) => {
setModels(d.models || [])
setRunning(d.running || [])
})
.catch((e) => setError(String(e)))
.finally(() => setLoading(false))
}
useEffect(load, [])
useEffect(() => {
load()
const t = setInterval(load, 3000)
return () => clearInterval(t)
}, [])
async function setRole(name: string, role: string) {
await api(`/api/models/${encodeURIComponent(name)}/role`, {
method: "POST", body: JSON.stringify({ role: role || null }),
method: "POST",
body: JSON.stringify({ role: role || null }),
})
load()
}
async function setCtx(name: string, cur: number | null) {
const v = prompt("Kontextlänge (Tokens):", String(cur || 32768))
if (!v) return
await api(`/api/models/${encodeURIComponent(name)}/ctx`, {
method: "POST", body: JSON.stringify({ ctx: parseInt(v, 10) }),
method: "POST",
body: JSON.stringify({ ctx: parseInt(v, 10) }),
})
load()
}
async function del(name: string) {
if (!confirm(`Modell '${name}' aus der Config entfernen? (GGUF-Datei bleibt)`)) return
await api(`/api/models/${encodeURIComponent(name)}`, { method: "DELETE" })
load()
}
if (loading) return <div className="text-sm text-muted-foreground">Lade</div>
if (loading) return <div className="text-xs text-muted-foreground py-6 text-center">Lade installierte Modelle</div>
if (error)
return (
<div className="rounded-md border border-border bg-card p-3 text-sm text-muted-foreground">
<div className="rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400">
Engine nicht erreichbar oder keine Config gefunden ({error}).
</div>
)
return (
<div className="overflow-hidden rounded-xl border border-border bg-card">
<table className="w-full text-sm">
<thead>
<tr className="border-b border-border text-left text-xs text-muted-foreground">
<th className="px-4 py-2 font-medium">Modell</th>
<th className="px-4 py-2 font-medium">Rolle</th>
<th className="px-4 py-2 font-medium">Fähigkeiten</th>
<th className="px-4 py-2 font-medium">Kontext</th>
<th className="px-4 py-2 font-medium">Größe</th>
<th className="px-4 py-2 font-medium">Aktionen</th>
</tr>
</thead>
<tbody>
{models.length === 0 && (
<tr>
<td colSpan={6} className="px-4 py-8 text-center text-muted-foreground">
Keine Modelle konfiguriert.
</td>
</tr>
)}
{models.map((m) => (
<tr key={m.name} className="border-b border-border/50 last:border-0">
<td className="px-4 py-2.5 font-medium">{m.name}</td>
<td className="px-4 py-2.5">
<select
value={m.role || ""}
onChange={(e) => setRole(m.name, e.target.value)}
className="rounded-md border border-border bg-background px-1.5 py-1 text-xs outline-none"
title="Rolle/Alias setzen (so tauschst du z.B. das fast-Hirn)"
>
{ROLES.map((r) => (
<option key={r} value={r}>{r || "—"}</option>
))}
</select>
</td>
<td className="px-4 py-2.5">
<CapsChips caps={m.capabilities} />
</td>
<td className="px-4 py-2.5">
<button onClick={() => setCtx(m.name, m.ctx)} className="text-muted-foreground hover:text-foreground" title="Kontext ändern">
{fmtCtx(m.ctx)}
</button>
</td>
<td className="px-4 py-2.5 text-muted-foreground">{fmtSize(m.size_bytes)}</td>
<td className="px-4 py-2.5">
<button onClick={() => del(m.name)} className="text-muted-foreground hover:text-red-500" title="Aus Config entfernen">
🗑
</button>
</td>
</tr>
))}
</tbody>
</table>
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{models.length === 0 ? (
<div className="col-span-full text-xs text-muted-foreground border border-dashed border-border/60 rounded-2xl p-12 text-center">
Keine Modelle konfiguriert. Verwende den Tab "Modelle finden" zum Herunterladen.
</div>
) : (
models.map((m) => {
const isRunning = running.includes(m.name)
return (
<div
key={m.name}
className={cn(
"rounded-2xl border bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 flex flex-col justify-between gap-4 transition-all duration-300 hover:border-primary/40 group",
isRunning ? "border-primary/45 shadow-primary/5" : "border-border/60"
)}
>
<div className="space-y-3.5">
<div className="flex items-start justify-between gap-3">
<div className="space-y-1">
<h3 className="text-xs font-bold tracking-tight text-foreground line-clamp-2 break-all" title={m.name}>
{m.name}
</h3>
<div className="flex items-center gap-2">
<span className="text-[10px] font-mono text-muted-foreground bg-background/40 px-1.5 py-0.5 rounded border border-border/30">
{m.quant || "GGUF"}
</span>
{isRunning && (
<span className="flex items-center gap-1 text-[9px] font-semibold text-emerald-400 uppercase tracking-wider">
<Activity className="h-3 w-3 animate-pulse" /> Warm
</span>
)}
</div>
</div>
<button
onClick={() => del(m.name)}
className="h-7 w-7 rounded-lg flex items-center justify-center border border-border/40 text-muted-foreground hover:text-red-400 hover:bg-red-500/5 transition-all opacity-0 group-hover:opacity-100 shrink-0"
title="Modell aus Config entfernen"
>
<Trash2 className="h-3.5 w-3.5" />
</button>
</div>
<div className="border-t border-border/30 pt-3 flex flex-wrap gap-1">
<CapsChips caps={m.capabilities} />
</div>
</div>
<div className="space-y-3 pt-2">
<div className="grid grid-cols-2 gap-2 text-[10px] font-mono text-muted-foreground">
<div className="flex items-center gap-1.5 p-2 bg-background/20 rounded-lg border border-border/20">
<HardDrive className="h-3.5 w-3.5 text-primary/80" />
<div>
<div className="text-[8px] uppercase tracking-wider font-semibold text-muted-foreground/60">Größe</div>
<div className="text-foreground font-semibold">{fmtSize(m.size_bytes)}</div>
</div>
</div>
<button
onClick={() => setCtx(m.name, m.ctx)}
className="flex items-center gap-1.5 p-2 bg-background/20 rounded-lg border border-border/20 hover:border-primary/40 text-left transition-colors"
>
<Edit3 className="h-3.5 w-3.5 text-primary/80" />
<div>
<div className="text-[8px] uppercase tracking-wider font-semibold text-muted-foreground/60">Kontext</div>
<div className="text-foreground font-semibold">{fmtCtx(m.ctx)}</div>
</div>
</button>
</div>
<div className="flex items-center justify-between gap-2 border-t border-border/30 pt-3">
<span className="text-[10px] font-semibold text-muted-foreground uppercase tracking-wider">Rolle</span>
<select
value={m.role || ""}
onChange={(e) => setRole(m.name, e.target.value)}
className="h-8 rounded-lg border border-border/60 bg-background/60 px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground cursor-pointer font-semibold min-w-[120px]"
title="Weise diesem Modell eine Systemrolle zu"
>
{ROLES.map((r) => (
<option key={r} value={r} className="bg-popover text-foreground">{r || "Keine Rolle"}</option>
))}
</select>
</div>
</div>
</div>
)
})
)}
</div>
)
}
@@ -186,85 +269,119 @@ function AddModel() {
async function loadQuants(r?: string) {
const rr = r ?? repo
if (!rr.trim()) return
setMsg("Lade Quants…")
setMsg("Analysiere HuggingFace Repository...")
try {
const d = await api<{ repo: string; quants: string[] }>(`/api/hf/quants?repo=${encodeURIComponent(rr)}`)
setRepo(d.repo)
setQuants(d.quants)
if (d.quants.length) setQuant(d.quants.includes("Q4_K_M") ? "Q4_K_M" : d.quants[0])
setMsg(d.quants.length ? "" : "Keine GGUF-Quants gefunden")
setMsg(d.quants.length ? "" : "Keine GGUF-Dateien in diesem Repository gefunden.")
} catch (e) {
setMsg(`Fehler: ${e}`)
}
}
async function search() {
if (!q.trim()) return
const d = await api<{ results: { repo: string; downloads: number }[] }>(`/api/hf/search?q=${encodeURIComponent(q)}`)
setResults(d.results)
setMsg("Durchsuche HuggingFace...")
try {
const d = await api<{ results: { repo: string; downloads: number }[] }>(`/api/hf/search?q=${encodeURIComponent(q)}`)
setResults(d.results)
setMsg(d.results.length ? "" : "Keine Ergebnisse gefunden.")
} catch (e) {
setMsg(`Suche fehlgeschlagen: ${e}`)
}
}
async function install() {
if (!repo.trim()) return
setMsg("Installiere…")
setMsg("Download-Job wird initiiert...")
try {
await api("/api/models/install", {
method: "POST", body: JSON.stringify({ repo, quant, jinja: true }),
method: "POST",
body: JSON.stringify({ repo, quant, jinja: true }),
})
setMsg(`Download gestartet: ${repo} (${quant}) Fortschritt oben.`)
setMsg(`Download gestartet: ${repo} (${quant}). Fortschritt wird oben angezeigt.`)
} catch (e) {
setMsg(`Fehler: ${e}`)
setMsg(`Download-Fehler: ${e}`)
}
}
return (
<div className="space-y-3 rounded-xl border border-border bg-card p-4">
<div className="text-sm font-medium">Eigenes Modell laden (HuggingFace)</div>
<div className="flex flex-wrap items-center gap-2">
<div className="space-y-4 rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10">
<div className="text-xs font-bold uppercase tracking-wider text-muted-foreground">HF Download &amp; Suche</div>
<div className="flex flex-col sm:flex-row gap-2">
<input
value={repo}
onChange={(e) => setRepo(e.target.value)}
placeholder="HF-URL oder org/repo (z.B. unsloth/Qwen3.6-35B-A3B-GGUF)"
className="min-w-[280px] flex-1 rounded-md border border-border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring"
placeholder="HF-URL oder org/repo (z.B. unsloth/Qwen2.5-Coder-7B-Instruct-GGUF)"
className="flex-1 h-9 rounded-lg border border-border/60 bg-background/40 px-3 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"
/>
<button onClick={() => loadQuants()} className="rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent">
Quants laden
</button>
{quants.length > 0 && (
<>
<select value={quant} onChange={(e) => setQuant(e.target.value)} className="rounded-md border border-border bg-background px-2 py-1.5 text-sm">
{quants.map((qq) => <option key={qq} value={qq}>{qq}</option>)}
</select>
<button onClick={install} className="rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:opacity-90">
Installieren
</button>
</>
)}
<div className="flex gap-2">
<button
onClick={() => loadQuants()}
className="h-9 px-4 rounded-lg border border-border/60 bg-background/20 text-xs font-semibold hover:border-primary/50 hover:bg-background/40 transition-all cursor-pointer whitespace-nowrap"
>
Quants laden
</button>
{quants.length > 0 && (
<>
<select
value={quant}
onChange={(e) => setQuant(e.target.value)}
className="h-9 rounded-lg border border-border/60 bg-background/40 px-3 text-xs outline-none text-foreground font-semibold"
>
{quants.map((qq) => <option key={qq} value={qq} className="bg-popover text-foreground">{qq}</option>)}
</select>
<button
onClick={install}
className="h-9 px-4 rounded-lg bg-primary text-primary-foreground text-xs font-semibold hover:opacity-90 transition-all cursor-pointer flex items-center gap-1.5"
>
<Download className="h-3.5 w-3.5" /> Herunterladen
</button>
</>
)}
</div>
</div>
<div className="flex flex-wrap items-center gap-2">
<input
value={q}
onChange={(e) => setQ(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && search()}
placeholder="HuggingFace durchsuchen (GGUF)…"
className="min-w-[240px] flex-1 rounded-md border border-border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring"
/>
<button onClick={search} className="rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent">Suchen</button>
<div className="flex gap-2 border-t border-border/20 pt-4">
<div className="relative flex-1">
<input
value={q}
onChange={(e) => setQ(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && search()}
placeholder="HuggingFace durchsuchen (z.B. Llama-3.1)..."
className="w-full h-9 pl-9 pr-3 rounded-lg border border-border/60 bg-background/40 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"
/>
<Search className="absolute left-3 top-2.5 h-3.5 w-3.5 text-muted-foreground" />
</div>
<button
onClick={search}
className="h-9 px-4 rounded-lg border border-border/60 bg-background/20 text-xs font-semibold hover:border-primary/50 hover:bg-background/40 transition-all cursor-pointer"
>
Suchen
</button>
</div>
{results.length > 0 && (
<div className="max-h-48 space-y-1 overflow-y-auto">
<div className="max-h-48 space-y-1.5 overflow-y-auto border border-border/40 bg-background/20 p-2 rounded-xl scrollbar-thin">
{results.map((r) => (
<button
key={r.repo}
onClick={() => { setRepo(r.repo); setResults([]); setQ(""); loadQuants(r.repo) }}
className="flex w-full items-center justify-between rounded-md px-2 py-1 text-left text-xs hover:bg-accent"
className="flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-xs bg-background/10 border border-border/10 hover:border-primary/30 hover:bg-background/30 transition-all"
>
<span className="truncate">{r.repo}</span>
<span className="text-muted-foreground">{r.downloads.toLocaleString()}</span>
<span className="font-semibold truncate">{r.repo}</span>
<span className="text-[10px] font-mono text-muted-foreground flex items-center gap-1 shrink-0">
<Download className="h-3 w-3" /> {r.downloads.toLocaleString()}
</span>
</button>
))}
</div>
)}
{msg && <div className="text-xs text-muted-foreground">{msg}</div>}
{msg && <div className="text-[10px] font-medium text-primary font-mono">{msg}</div>}
</div>
)
}
@@ -283,59 +400,90 @@ function Discover() {
}, [])
async function install(repo: string, role: string, quant: string, toolCapable: boolean) {
setInstalling((s) => ({ ...s, [repo]: "" }))
setInstalling((s) => ({ ...s, [repo]: "Starte..." }))
try {
await api("/api/models/install", {
method: "POST",
body: JSON.stringify({ repo, role, quant, jinja: toolCapable }),
})
setInstalling((s) => ({ ...s, [repo]: "geladen" }))
setInstalling((s) => ({ ...s, [repo]: "Download läuft" }))
} catch (e) {
setInstalling((s) => ({ ...s, [repo]: `Fehler` }))
setInstalling((s) => ({ ...s, [repo]: "Fehler" }))
}
}
if (loading) return <div className="text-sm text-muted-foreground">Suche aktuelle Modelle</div>
if (loading) return <div className="text-xs text-muted-foreground py-12 text-center">Analysiere Hardware und suche passende GGUF-Empfehlungen</div>
if (error || !data)
return (
<div className="rounded-md border border-border bg-card p-3 text-sm text-muted-foreground">
Modell-Quellen gerade nicht erreichbar ({error}).
<div className="rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400">
Empfehlungsdienst temporär nicht erreichbar ({error}).
</div>
)
return (
<div className="space-y-6">
<AddModel />
<div className="text-xs text-muted-foreground">
Live von HuggingFace · Hardware-Fit für ~{data.sys_ram_gb} GB · = beste Wahl je Kategorie
<div className="text-[10px] font-mono text-muted-foreground bg-background/25 border border-border/40 p-3 rounded-xl">
Modell-Registry geladen für {data.sys_ram_gb} GB System-RAM markiert die empfohlene Standard-Rolle.
</div>
{data.categories.map((cat) => (
<div key={cat.role} className="space-y-2">
<h3 className="text-sm font-semibold">{cat.title}</h3>
<div className="grid gap-2 sm:grid-cols-2">
{cat.models.map((m) => (
<div key={m.repo} className="rounded-lg border border-border bg-card p-3">
<div className="flex items-center gap-2">
{cat.recommended === m.repo && <span title="beste Wahl"></span>}
<span className="truncate text-sm font-medium">{m.name}</span>
<div key={cat.role} className="space-y-3">
<div className="flex items-center gap-2 px-1">
<Layers className="h-4 w-4 text-primary" />
<h3 className="text-xs font-bold uppercase tracking-wider text-foreground">{cat.title}</h3>
</div>
<div className="grid gap-4 sm:grid-cols-2">
{cat.models.map((m) => {
const isRec = cat.recommended === m.repo
return (
<div
key={m.repo}
className={cn(
"rounded-2xl border bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 flex flex-col justify-between gap-4 transition-all duration-300 hover:border-primary/40",
isRec ? "border-primary/30" : "border-border/60"
)}
>
<div className="space-y-3.5">
<div className="flex items-start justify-between gap-3">
<div className="space-y-1">
<div className="flex items-center gap-1.5">
{isRec && <span title="Empfohlen für diese Rolle"><Star className="h-3.5 w-3.5 text-amber-400 fill-amber-400" /></span>}
<h4 className="text-xs font-bold text-foreground truncate max-w-[200px]" title={m.name}>
{m.name}
</h4>
</div>
<span className="text-[10px] font-mono text-muted-foreground">{m.author}</span>
</div>
<div className="text-[10px] font-mono bg-background/40 px-1.5 py-0.5 rounded border border-border/30 text-muted-foreground">
{m.quant}
</div>
</div>
<div className="flex flex-wrap items-center gap-1.5 border-t border-border/30 pt-3">
<CapsChips caps={m.caps} />
<FitBadge fit={m.fit} />
</div>
</div>
{m.fit.level !== "too_tight" && (
<button
onClick={() => install(m.repo, m.role, m.quant, m.caps.tools !== "no")}
disabled={!!installing[m.repo]}
className={cn(
"mt-2 h-8 w-full flex items-center justify-center gap-1.5 rounded-lg text-xs font-semibold transition-all cursor-pointer border border-border/60 bg-background/20 hover:border-primary/50 disabled:opacity-50",
installing[m.repo] && "border-primary/40 bg-primary/5 text-primary"
)}
>
<Download className={cn("h-3.5 w-3.5", !installing[m.repo] && "text-primary")} />
{installing[m.repo] || "Modell laden"}
</button>
)}
</div>
<div className="mt-1 text-xs text-muted-foreground">{m.author}</div>
<div className="mt-2 flex flex-wrap items-center gap-1">
<CapsChips caps={m.caps} />
<FitBadge fit={m.fit} />
</div>
{m.fit.level !== "too_tight" && (
<button
onClick={() => install(m.repo, m.role, m.quant, m.caps.tools !== "no")}
disabled={!!installing[m.repo]}
className="mt-2 flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-xs hover:bg-accent disabled:opacity-60"
>
<Download className="h-3.5 w-3.5 text-primary" />
{installing[m.repo] || "Installieren"}
</button>
)}
</div>
))}
)
})}
</div>
</div>
))}
@@ -346,32 +494,40 @@ function Discover() {
export function ModelsView() {
const [tab, setTab] = useState<"installed" | "discover">("installed")
return (
<div className="space-y-4">
<div>
<h1 className="text-xl font-semibold">Modelle &amp; Routing</h1>
<p className="text-sm text-muted-foreground">
Installierte Modelle (mit Fähigkeiten) und aktuell beste Modelle für deine Hardware.
</p>
<div className="space-y-6">
<div className="flex flex-col sm:flex-row justify-between sm:items-center gap-4">
<div>
<h1 className="text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent">
Modell-Zentrale
</h1>
<p className="text-sm text-muted-foreground">
Verwalte installierte GGUFs, weise Systemrollen zu und lade neue Modelle von HuggingFace.
</p>
</div>
<div className="flex rounded-xl border border-border/60 bg-card/45 backdrop-blur-md p-1 self-start">
{(["installed", "discover"] as const).map((t) => (
<button
key={t}
onClick={() => setTab(t)}
className={cn(
"rounded-lg px-4 py-1.5 text-xs font-semibold tracking-wide uppercase transition-all cursor-pointer",
tab === t
? "bg-primary text-primary-foreground shadow-md shadow-primary/10"
: "text-muted-foreground hover:text-foreground",
)}
>
{t === "installed" ? "Installiert" : "Suchen & Entdecken"}
</button>
))}
</div>
</div>
<JobsBar />
<div className="inline-flex rounded-lg border border-border bg-card p-0.5 text-sm">
{(["installed", "discover"] as const).map((t) => (
<button
key={t}
onClick={() => setTab(t)}
className={cn(
"rounded-md px-3 py-1.5 transition-colors",
tab === t ? "bg-primary/15 text-primary" : "text-muted-foreground hover:text-foreground",
)}
>
{t === "installed" ? "Installiert" : "Modelle finden"}
</button>
))}
<div className="transition-all duration-300">
{tab === "installed" ? <Installed /> : <Discover />}
</div>
{tab === "installed" ? <Installed /> : <Discover />}
</div>
)
}
+157 -51
View File
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react"
import { Route, GitBranch, ArrowRight, Settings, AlertCircle } from "lucide-react"
import { api, type RoutingResp } from "@/lib/api"
import { cn } from "@/lib/utils"
@@ -7,79 +8,184 @@ export function RoutingView() {
const [error, setError] = useState("")
useEffect(() => {
api<RoutingResp>("/api/routing").then(setData).catch((e) => setError(String(e)))
api<RoutingResp>("/api/routing")
.then(setData)
.catch((e) => setError(String(e)))
}, [])
return (
<div className="space-y-4">
<div className="space-y-6">
{/* Header */}
<div>
<h1 className="text-xl font-semibold">Routing</h1>
<h1 className="text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent">
Gateway &amp; Routing
</h1>
<p className="text-sm text-muted-foreground">
Eingebauter OpenAI-Gateway: ein Endpunkt für alle Tools. <code>model: auto</code> = schnell im
Alltag (<code>fast</code>), wechselt bei komplexen/langen Anfragen auf <code>heavy</code>.
Gilt für Hermes <em>und</em> Vibe Coding.
Eingebauter OpenAI-Gateway für Vibe Coding &amp; Hermes. Verwende den Endpunkt <code>model: auto</code>, um je nach Komplexität automatisch zwischen <code>fast</code> und <code>heavy</code> zu routen.
</p>
</div>
{error && (
<div className="rounded-md border border-border bg-card p-3 text-sm text-muted-foreground">
Gateway-Config nicht lesbar ({error}).
<div className="rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400">
Gateway-Konfiguration nicht lesbar ({error}).
</div>
)}
{data && (
<>
<div className="flex items-center gap-2 text-sm">
<span
className={cn(
"h-2 w-2 rounded-full",
data.gateway_reachable ? "bg-emerald-500" : "bg-amber-500",
)}
/>
Gateway {data.gateway_reachable ? "online" : "offline"}
{data.endpoint && <span className="text-muted-foreground">· {data.endpoint}</span>}
<div className="space-y-6">
{/* Status HUD Card */}
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 flex flex-col sm:flex-row justify-between sm:items-center gap-4">
<div className="flex items-center gap-3">
<span className={cn(
"h-2.5 w-2.5 rounded-full ring-2 ring-black/40",
data.gateway_reachable ? "bg-emerald-500 animate-pulse" : "bg-amber-500"
)} />
<div>
<div className="text-xs font-semibold uppercase tracking-wider text-foreground">Gateway-Status</div>
<div className="text-[10px] text-muted-foreground mt-0.5 font-mono">{data.endpoint || "Lokaler Proxy"}</div>
</div>
</div>
{data.heavy_threshold_chars && (
<span className="ml-auto text-xs text-muted-foreground">
autoheavy ab {data.heavy_threshold_chars} Zeichen
</span>
<div className="p-3 bg-background/25 rounded-xl border border-border/30 text-right">
<div className="text-[9px] text-muted-foreground uppercase font-bold tracking-wider">Auto-Routing-Schwelle</div>
<div className="text-xs font-semibold text-primary mt-0.5 font-mono">
&gt; {data.heavy_threshold_chars.toLocaleString()} Zeichen heavy
</div>
</div>
)}
</div>
<div className="overflow-hidden rounded-xl border border-border bg-card">
<table className="w-full text-sm">
<thead>
<tr className="border-b border-border text-left text-xs text-muted-foreground">
<th className="px-4 py-2 font-medium">Gateway-Modell</th>
<th className="px-4 py-2 font-medium"> Backend (llama-swap)</th>
</tr>
</thead>
<tbody>
{data.routes.map((r) => (
<tr key={r.name} className="border-b border-border/50 last:border-0">
<td className="px-4 py-2.5 font-medium">{r.name}</td>
<td className="px-4 py-2.5 font-mono text-xs text-muted-foreground">{r.target}</td>
</tr>
))}
</tbody>
</table>
{/* Visual Routing flow */}
<div className="grid gap-6 md:grid-cols-3">
{/* Box 1: Ingress */}
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 flex flex-col justify-between gap-4">
<div>
<div className="flex items-center gap-2 mb-3">
<Settings className="h-4.5 w-4.5 text-primary" />
<h3 className="text-xs font-bold uppercase tracking-wider text-foreground">1. API Ingress</h3>
</div>
<p className="text-xs text-muted-foreground leading-relaxed">
Deine IDE oder dein Agent sendet Anfragen mit <code>model: auto</code> an den lokalen Gateway-Port.
</p>
</div>
<div className="p-3 bg-background/20 rounded-xl border border-border/20 font-mono text-[10px]">
<div className="text-muted-foreground/60">HEADER</div>
<div className="text-primary truncate">Authorization: Bearer key</div>
<div className="text-muted-foreground/60 mt-1">MODEL</div>
<div className="text-foreground">"auto"</div>
</div>
</div>
{/* Box 2: Routing Logic */}
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 flex flex-col justify-between gap-4">
<div>
<div className="flex items-center gap-2 mb-3">
<Route className="h-4.5 w-4.5 text-primary" />
<h3 className="text-xs font-bold uppercase tracking-wider text-foreground">2. Analysator</h3>
</div>
<p className="text-xs text-muted-foreground leading-relaxed">
Der Gateway misst die Länge des Prompts. Kurze Tasks landen bei <code>fast</code>, anspruchsvolle Tasks werden an <code>heavy</code> weitergeleitet.
</p>
</div>
<div className="space-y-1.5 font-mono text-[9px] p-2 bg-background/10 rounded-xl border border-border/10">
<div className="flex items-center justify-between text-cyan-400">
<span>Prompt &lt; {data.heavy_threshold_chars}</span>
<span className="flex items-center gap-1">Fast-Hirn <ArrowRight className="h-3 w-3" /></span>
</div>
<div className="flex items-center justify-between text-violet-400">
<span>Prompt &gt;= {data.heavy_threshold_chars}</span>
<span className="flex items-center gap-1">Heavy-Hirn <ArrowRight className="h-3 w-3" /></span>
</div>
</div>
</div>
{/* Box 3: Execution */}
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 flex flex-col justify-between gap-4">
<div>
<div className="flex items-center gap-2 mb-3">
<GitBranch className="h-4.5 w-4.5 text-primary" />
<h3 className="text-xs font-bold uppercase tracking-wider text-foreground">3. Llama Swap</h3>
</div>
<p className="text-xs text-muted-foreground leading-relaxed">
Llama Swap tauscht das Modell bei Bedarf vollautomatisch im VRAM aus (Auto-Swap). Keine manuelle Zuweisung nötig.
</p>
</div>
<div className="p-3 bg-primary/5 rounded-xl border border-primary/20 text-center">
<span className="text-[10px] font-bold text-primary animate-pulse">Auto-Swap aktiv</span>
</div>
</div>
</div>
{/* Active Routes Cards */}
<div className="space-y-3">
<h3 className="text-xs font-bold uppercase tracking-wider text-muted-foreground px-1">Gateway-Routen</h3>
<div className="grid gap-3 sm:grid-cols-2">
{data.routes.map((r) => (
<div
key={r.name}
className="flex items-center justify-between p-4 rounded-xl border border-border/60 bg-card/45 backdrop-blur-md hover:border-primary/30 transition-colors"
>
<div className="space-y-1">
<div className="text-xs font-bold text-foreground font-mono">{r.name}</div>
<div className="text-[9px] text-muted-foreground uppercase">Gateway-Alias</div>
</div>
<div className="flex items-center gap-2">
<ArrowRight className="h-3.5 w-3.5 text-muted-foreground/60" />
<div className="px-2.5 py-1 rounded-lg bg-background/40 border border-border/40 text-[10px] font-mono text-primary font-semibold truncate max-w-[160px] sm:max-w-[200px]" title={r.target}>
{r.target}
</div>
</div>
</div>
))}
</div>
</div>
{/* Fallback Rules */}
{data.fallbacks.length > 0 && (
<div className="rounded-xl border border-border bg-card p-4 text-sm">
<div className="mb-2 font-medium">Eskalation (Fallbacks)</div>
<ul className="space-y-1 text-muted-foreground">
{data.fallbacks.map((f, i) => {
const [k, v] = Object.entries(f)[0]
return (
<li key={i}>
<code>{k}</code> <code>{v.join(", ")}</code>
</li>
)
})}
</ul>
<div className="space-y-3">
<div className="flex items-center gap-1.5 px-1">
<AlertCircle className="h-4 w-4 text-amber-500" />
<h3 className="text-xs font-bold uppercase tracking-wider text-muted-foreground">Eskalationspfad (Fallbacks)</h3>
</div>
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-4 space-y-3">
<div className="text-[10px] text-muted-foreground">
Sollte ein angefordertes Modell offline oder überlastet sein, eskaliert das Routing sequenziell entlang dieser vordefinierten Kette:
</div>
<div className="space-y-2">
{data.fallbacks.map((f, i) => {
const [k, v] = Object.entries(f)[0]
return (
<div
key={i}
className="flex flex-wrap items-center gap-2 p-2.5 bg-background/25 rounded-xl border border-border/20 font-mono text-xs"
>
<span className="font-semibold text-amber-400">{k}</span>
<ArrowRight className="h-3 w-3 text-muted-foreground/60" />
<div className="flex flex-wrap gap-1.5">
{v.map((item, idx) => (
<span
key={idx}
className={cn(
"px-1.5 py-0.5 rounded text-[10px]",
idx === 0 ? "bg-primary/10 text-primary border border-primary/20" : "bg-muted text-muted-foreground"
)}
>
{item}
</span>
))}
</div>
</div>
)
})}
</div>
</div>
</div>
)}
</>
</div>
)}
</div>
)
+271 -140
View File
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react"
import { ExternalLink, RefreshCw, Save } from "lucide-react"
import { ExternalLink, RefreshCw, Save, Cpu, HardDrive, Cpu as GpuIcon, Activity, ShieldAlert } from "lucide-react"
import { api, type ServicesResp, type SystemStatus, type UpdatesResp } from "@/lib/api"
import { cn } from "@/lib/utils"
@@ -7,95 +7,140 @@ function gb(b: number) {
return (b / 1024 ** 3).toFixed(1)
}
function Maintenance() {
const [u, setU] = useState<UpdatesResp | null>(null)
const [msg, setMsg] = useState("")
function load() {
api<UpdatesResp>("/api/maintenance/updates").then(setU).catch(() => {})
}
useEffect(load, [])
async function post(path: string, label: string) {
setMsg(`${label}`)
try {
const r = await api<{ job_id?: string; ok?: boolean; err?: string }>(path, { method: "POST" })
setMsg(r.job_id ? `${label} gestartet (Job ${r.job_id})` : r.ok ? `${label}` : `${label}: ${r.err || "?"}`)
} catch (e) {
setMsg(`${label}: ${e}`)
}
}
async function restart(service: string) {
setMsg(`Restart ${service}`)
try {
const r = await api<{ ok: boolean; err?: string }>("/api/maintenance/restart", {
method: "POST", body: JSON.stringify({ service }),
})
setMsg(r.ok ? `Restart ${service}` : `Restart ${service}: ${r.err || "?"}`)
} catch (e) {
setMsg(`Restart ${service}: ${e}`)
}
}
async function upgrade(repo: string, role: string) {
setMsg(`Lade ${repo}`)
try {
await api("/api/models/install", { method: "POST", body: JSON.stringify({ repo, role, quant: "Q4_K_M", jinja: true }) })
setMsg(`Upgrade ${repo} gestartet`)
} catch (e) {
setMsg(`Fehler: ${e}`)
}
}
function DiagnosticBar({ label, percent, detail, icon: Icon }: { label: string; percent: number; detail?: string; icon: any }) {
const barColor = percent > 90
? "bg-red-500 shadow-md shadow-red-500/20"
: percent > 75
? "bg-amber-500 shadow-md shadow-amber-500/20"
: "bg-primary shadow-md shadow-primary/20"
return (
<div className="rounded-xl border border-border bg-card p-4">
<div className="mb-3 flex items-center justify-between">
<span className="text-sm font-medium">Wartung &amp; Updates</span>
{u && (
<span className="flex gap-2 text-xs">
<span className={cn("rounded px-1.5 py-0.5", u.os ? "bg-amber-500/15 text-amber-500" : "bg-muted text-muted-foreground")}>OS: {u.os}</span>
<span className={cn("rounded px-1.5 py-0.5", u.engine ? "bg-amber-500/15 text-amber-500" : "bg-muted text-muted-foreground")}>Engine: {u.engine ? "neu" : "aktuell"}</span>
<span className={cn("rounded px-1.5 py-0.5", u.models ? "bg-primary/15 text-primary" : "bg-muted text-muted-foreground")}>Modelle: {u.models}</span>
</span>
)}
</div>
<div className="flex flex-wrap gap-2 text-sm">
<button onClick={() => post("/api/maintenance/os-update", "OS-Update")} className="rounded-md border border-border px-2.5 py-1.5 hover:bg-accent">OS aktualisieren</button>
<button onClick={() => post("/api/maintenance/engine-update", "Engine-Update")} className="rounded-md border border-border px-2.5 py-1.5 hover:bg-accent">Engine aktualisieren</button>
<button onClick={() => restart("llama-swap")} className="flex items-center gap-1 rounded-md border border-border px-2.5 py-1.5 hover:bg-accent"><RefreshCw className="h-3.5 w-3.5" /> Engine neu starten</button>
<button onClick={() => { if (confirm("Box wirklich neu starten?")) post("/api/maintenance/reboot", "Reboot") }} className="rounded-md border border-border px-2.5 py-1.5 text-amber-500 hover:bg-accent">Reboot</button>
</div>
{u && u.model_list.length > 0 && (
<div className="mt-3 space-y-1">
<div className="text-xs text-muted-foreground">Modell-Upgrades verfügbar:</div>
{u.model_list.map((m) => (
<div key={m.repo} className="flex items-center justify-between text-xs">
<span className="truncate"><span className="text-primary">{m.role}</span> · {m.repo}</span>
<button onClick={() => upgrade(m.repo, m.role)} className="rounded-md border border-border px-2 py-0.5 hover:bg-accent">Upgrade</button>
</div>
))}
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 flex flex-col justify-between gap-3 hover:border-primary/30 transition-all duration-300">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<Icon className="h-4.5 w-4.5 text-primary" />
<span className="text-xs font-semibold uppercase tracking-wider text-foreground">{label}</span>
</div>
)}
{msg && <div className="mt-2 text-xs text-muted-foreground">{msg}</div>}
<div className="mt-2 text-[11px] text-muted-foreground">
OS-Update/Reboot brauchen einmalig erweiterte NOPASSWD-sudoers (siehe BEDIENUNG/CUTOVER).
<span className="text-xs font-mono font-bold text-foreground">{Math.round(percent)}%</span>
</div>
<div className="w-full h-2 bg-background/40 rounded-full overflow-hidden border border-border/20">
<div
className={cn("h-full transition-all duration-700 ease-out", barColor)}
style={{ width: `${Math.min(percent, 100)}%` }}
/>
</div>
{detail && <div className="text-[10px] font-mono text-muted-foreground/80">{detail}</div>}
</div>
)
}
function Bar({ label, percent, detail }: { label: string; percent: number; detail?: string }) {
function MaintenanceSection() {
const [u, setU] = useState<UpdatesResp | null>(null)
const [msg, setMsg] = useState("")
const [loading, setLoading] = useState(false)
function load() {
api<UpdatesResp>("/api/maintenance/updates").then(setU).catch(() => {})
}
useEffect(load, [])
async function postAction(path: string, label: string) {
setMsg(`${label} wird ausgeführt...`)
setLoading(true)
try {
const r = await api<{ job_id?: string; ok?: boolean; err?: string }>(path, { method: "POST" })
setMsg(r.job_id ? `${label} gestartet (Job-ID: ${r.job_id})` : r.ok ? `${label} erfolgreich ausgeführt.` : `Fehler: ${r.err || "Unbekannt"}`)
} catch (e: any) {
setMsg(`Fehler bei ${label}: ${e.message}`)
} finally {
setLoading(false)
}
}
async function upgradeModel(repo: string, role: string) {
setMsg(`Upgrade für ${repo} wird gestartet...`)
try {
await api("/api/models/install", {
method: "POST",
body: JSON.stringify({ repo, role, quant: "Q4_K_M", jinja: true })
})
setMsg(`Upgrade-Download gestartet.`)
} catch (e: any) {
setMsg(`Upgrade fehlgeschlagen: ${e.message}`)
}
}
return (
<div className="rounded-lg border border-border bg-card p-4">
<div className="flex items-baseline justify-between">
<span className="text-sm font-medium">{label}</span>
<span className="text-sm text-muted-foreground">{Math.round(percent)}%</span>
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 space-y-4">
<div className="flex items-center justify-between">
<div className="text-xs font-bold uppercase tracking-wider text-muted-foreground">Wartung &amp; Updates</div>
{u && (
<div className="flex gap-1.5 text-[9px] font-mono font-bold uppercase tracking-wider">
<span className={cn("px-1.5 py-0.5 rounded", u.os ? "bg-amber-500/10 text-amber-400 border border-amber-500/20" : "bg-background/40 text-muted-foreground border border-border/20")}>
OS: {u.os}
</span>
<span className={cn("px-1.5 py-0.5 rounded", u.engine ? "bg-amber-500/10 text-amber-400 border border-amber-500/20" : "bg-background/40 text-muted-foreground border border-border/20")}>
Engine: {u.engine ? "neu" : "aktuell"}
</span>
<span className={cn("px-1.5 py-0.5 rounded", u.models ? "bg-primary/10 text-primary border border-primary/20" : "bg-background/40 text-muted-foreground border border-border/20")}>
Modelle: {u.models}
</span>
</div>
)}
</div>
<div className="mt-2 h-2 overflow-hidden rounded-full bg-muted">
<div className="h-full rounded-full bg-primary" style={{ width: `${Math.min(percent, 100)}%` }} />
<div className="flex flex-wrap gap-2">
<button
onClick={() => postAction("/api/maintenance/os-update", "OS-Update")}
disabled={loading}
className="h-8 px-3 rounded-lg border border-border/60 bg-background/20 text-xs font-semibold hover:border-primary/50 hover:bg-background/40 transition-all cursor-pointer disabled:opacity-50"
>
OS (Apt) aktualisieren
</button>
<button
onClick={() => postAction("/api/maintenance/engine-update", "Engine-Update")}
disabled={loading}
className="h-8 px-3 rounded-lg border border-border/60 bg-background/20 text-xs font-semibold hover:border-primary/50 hover:bg-background/40 transition-all cursor-pointer disabled:opacity-50"
>
Engine aktualisieren
</button>
<button
onClick={() => { if (confirm("Bist du sicher, dass du den Host neu starten willst?")) postAction("/api/maintenance/reboot", "Reboot") }}
disabled={loading}
className="h-8 px-3 rounded-lg border border-red-500/30 bg-red-500/5 text-red-400 text-xs font-semibold hover:bg-red-500/10 transition-all cursor-pointer disabled:opacity-50"
>
Host Reboot
</button>
</div>
{u && u.model_list.length > 0 && (
<div className="mt-3 space-y-2 border-t border-border/20 pt-3">
<div className="text-[10px] font-bold uppercase tracking-wider text-muted-foreground">Verfügbare Modell-Updates:</div>
<div className="space-y-1.5">
{u.model_list.map((m) => (
<div key={m.repo} className="flex items-center justify-between p-2.5 rounded-xl bg-background/20 border border-border/30 text-xs font-semibold">
<span className="truncate"><span className="text-primary uppercase font-mono text-[10px] mr-1.5">{m.role}</span> {m.repo}</span>
<button
onClick={() => upgradeModel(m.repo, m.role)}
className="px-2.5 py-1 text-[10px] font-bold rounded-md bg-primary text-primary-foreground hover:opacity-90 transition-all cursor-pointer"
>
Laden
</button>
</div>
))}
</div>
</div>
)}
{msg && <div className="text-[10px] font-mono text-primary font-medium">{msg}</div>}
<div className="text-[9px] text-muted-foreground/60 leading-normal border-t border-border/10 pt-2 flex items-center gap-1">
<ShieldAlert className="h-3.5 w-3.5 shrink-0" />
<span>OS-Update & Reboot benötigen NOPASSWD Berechtigungen in der sudoers Datei des Hosts.</span>
</div>
{detail && <div className="mt-1 text-xs text-muted-foreground">{detail}</div>}
</div>
)
}
@@ -105,107 +150,193 @@ export function SystemView() {
const [svc, setSvc] = useState<ServicesResp | null>(null)
const [error, setError] = useState("")
const [backupMsg, setBackupMsg] = useState("")
const [restartingServices, setRestartingServices] = useState<Record<string, boolean>>({})
function load() {
api<SystemStatus>("/api/system/status").then(setS).catch((e) => setError(String(e)))
api<ServicesResp>("/api/system/services").then(setSvc).catch(() => {})
}
useEffect(() => {
const load = () => {
api<SystemStatus>("/api/system/status").then(setS).catch((e) => setError(String(e)))
api<ServicesResp>("/api/system/services").then(setSvc).catch(() => {})
}
load()
const t = setInterval(load, 3000)
return () => clearInterval(t)
}, [])
async function doBackup() {
setBackupMsg("")
setBackupMsg("Backup snapshotted...")
try {
const r = await api<{ ok: boolean; snapshot: string; files: string[] }>("/api/system/backup", { method: "POST" })
setBackupMsg(r.ok ? `Snapshot ${r.snapshot} (${r.files.length} Dateien)` : "Nichts zu sichern")
} catch (e) {
setBackupMsg(`Fehler: ${e}`)
setBackupMsg(r.ok ? `Snapshot erzeugt: ${r.snapshot} (${r.files.length} Dateien)` : "Keine Änderungen zu sichern.")
} catch (e: any) {
setBackupMsg(`Fehler: ${e.message}`)
}
}
async function restartService(serviceId: string) {
setRestartingServices(prev => ({ ...prev, [serviceId]: true }))
try {
const r = await api<{ ok: boolean; err?: string }>("/api/maintenance/restart", {
method: "POST",
body: JSON.stringify({ service: serviceId })
})
if (r.ok) {
alert(`Dienst ${serviceId} wurde erfolgreich neu gestartet.`)
} else {
alert(`Fehler beim Neustart: ${r.err || "Unbekannter Fehler"}`)
}
} catch (e: any) {
alert(`Fehler: ${e.message}`)
} finally {
setRestartingServices(prev => ({ ...prev, [serviceId]: false }))
}
}
return (
<div className="space-y-4">
<div className="space-y-6">
{/* Header */}
<div>
<h1 className="text-xl font-semibold">System</h1>
<p className="text-sm text-muted-foreground">Live-Auslastung der Box, Dienste &amp; Updates.</p>
<h1 className="text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent">
System-Diagnose &amp; Status
</h1>
<p className="text-sm text-muted-foreground flex items-center gap-1">
Echtzeit-Ressourcen der Box, Dienst-Überwachung und Systempflege.
</p>
</div>
{error && (
<div className="rounded-md border border-border bg-card p-3 text-sm text-muted-foreground">
<div className="rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400 font-mono">
System-Status nicht lesbar ({error}).
</div>
)}
{/* Metrics Section */}
{s && (
<div className="grid gap-3 sm:grid-cols-2">
<Bar label="CPU" percent={s.cpu.percent} detail={s.cpu.cores ? `${s.cpu.cores} Kerne` : undefined} />
<Bar
label="RAM"
percent={s.ram.percent}
detail={`${gb(s.ram.used)} / ${gb(s.ram.total)} GB`}
/>
{s.gpu && s.gpu.busy_percent != null && (
<Bar
label="GPU"
percent={s.gpu.busy_percent}
detail={
s.gpu.gtt_used != null && s.gpu.gtt_total
? `${gb(s.gpu.gtt_used)} / ${gb(s.gpu.gtt_total)} GB (GTT/unified)`
: s.gpu.vram_used != null && s.gpu.vram_total
? `${gb(s.gpu.vram_used)} / ${gb(s.gpu.vram_total)} GB VRAM`
: undefined
}
/>
)}
{s.disk && (
<Bar label="Disk (Modelle)" percent={s.disk.percent} detail={`${gb(s.disk.used)} / ${gb(s.disk.total)} GB`} />
<div className="space-y-4">
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
<DiagnosticBar label="CPU" percent={s.cpu.percent} detail={s.cpu.cores ? `${s.cpu.cores} Cores` : undefined} icon={Cpu} />
<DiagnosticBar label="RAM" percent={s.ram.percent} detail={`${gb(s.ram.used)} / ${gb(s.ram.total)} GB`} icon={Activity} />
{s.gpu && s.gpu.busy_percent != null && (
<DiagnosticBar
label="GPU"
percent={s.gpu.busy_percent}
detail={
s.gpu.gtt_used != null && s.gpu.gtt_total
? `${gb(s.gpu.gtt_used)} / ${gb(s.gpu.gtt_total)} GB (GTT/unified)`
: s.gpu.vram_used != null && s.gpu.vram_total
? `${gb(s.gpu.vram_used)} / ${gb(s.gpu.vram_total)} GB VRAM`
: undefined
}
icon={GpuIcon}
/>
)}
{s.disk && (
<DiagnosticBar label="Disk" percent={s.disk.percent} detail={`${gb(s.disk.used)} / ${gb(s.disk.total)} GB`} icon={HardDrive} />
)}
</div>
{/* Temperatures display */}
{s.temp && (s.temp.cpu || s.temp.gpu) && (
<div className="flex gap-3 text-[10px] font-mono text-muted-foreground bg-background/25 border border-border/40 p-2.5 rounded-xl self-start w-fit">
{s.temp.cpu != null && (
<span className="flex items-center gap-1">
CPU-Temperatur: <span className="text-foreground font-bold">{s.temp.cpu} °C</span>
</span>
)}
{s.temp.cpu != null && s.temp.gpu != null && <span>|</span>}
{s.temp.gpu != null && (
<span className="flex items-center gap-1">
GPU-Temperatur: <span className="text-foreground font-bold">{s.temp.gpu} °C</span>
</span>
)}
</div>
)}
</div>
)}
{s?.temp && (s.temp.cpu || s.temp.gpu) && (
<div className="flex gap-3 text-sm text-muted-foreground">
{s.temp.cpu != null && <span>CPU {s.temp.cpu} °C</span>}
{s.temp.gpu != null && <span>GPU {s.temp.gpu} °C</span>}
</div>
)}
{/* Dienste-Health + Observability-Links */}
{/* Services Health matrix */}
{svc && (
<div className="rounded-xl border border-border bg-card p-4">
<div className="mb-3 text-sm font-medium">Dienste</div>
<div className="grid gap-2 sm:grid-cols-2">
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 space-y-4">
<div className="text-xs font-bold uppercase tracking-wider text-muted-foreground">Homelab-Dienste</div>
<div className="grid gap-3 sm:grid-cols-2">
{svc.services.map((x) => (
<div key={x.name} className="flex items-center gap-2 text-sm">
<span className={cn("h-2 w-2 rounded-full", x.ok ? "bg-emerald-500" : "bg-amber-500")} />
<span>{x.name}</span>
<span className="ml-auto font-mono text-xs text-muted-foreground">{x.url}</span>
<div
key={x.name}
className="flex items-center justify-between p-3.5 rounded-xl bg-background/20 border border-border/30 hover:border-primary/20 transition-all group"
>
<div className="flex items-center gap-2.5 min-w-0">
<span className={cn(
"h-2.5 w-2.5 rounded-full ring-2 ring-black/40",
x.ok ? "bg-emerald-500" : "bg-amber-500"
)} />
<div className="truncate">
<div className="text-xs font-bold text-foreground truncate">{x.name}</div>
<div className="text-[9px] text-muted-foreground/60 font-mono mt-0.5 truncate">{x.url}</div>
</div>
</div>
<button
onClick={() => restartService(x.name)}
disabled={restartingServices[x.name]}
className="h-7 w-7 rounded-lg border border-border/40 text-muted-foreground hover:text-primary hover:bg-primary/5 flex items-center justify-center transition-all opacity-0 group-hover:opacity-100"
title="Dienst neu starten"
>
<RefreshCw className={cn("h-3.5 w-3.5", restartingServices[x.name] && "animate-spin")} />
</button>
</div>
))}
</div>
<div className="mt-3 flex flex-wrap gap-3 text-xs">
<a href={svc.links.engine_ui} target="_blank" rel="noopener" className="flex items-center gap-1 text-primary hover:underline">
<ExternalLink className="h-3 w-3" /> Engine-Logs (llama-swap /ui)
{/* Service Links */}
<div className="flex flex-wrap gap-4 border-t border-border/20 pt-4 text-[10px] font-semibold text-muted-foreground">
<a
href={svc.links.engine_ui}
target="_blank"
rel="noopener"
className="flex items-center gap-1 text-primary hover:text-primary-foreground hover:bg-primary/10 px-2 py-1 rounded transition-colors"
>
<ExternalLink className="h-3 w-3" /> Engine Dashboard (llama-swap)
</a>
<a href={svc.links.gateway} target="_blank" rel="noopener" className="flex items-center gap-1 text-primary hover:underline">
<ExternalLink className="h-3 w-3" /> Gateway
<a
href={svc.links.gateway}
target="_blank"
rel="noopener"
className="flex items-center gap-1 text-primary hover:text-primary-foreground hover:bg-primary/10 px-2 py-1 rounded transition-colors"
>
<ExternalLink className="h-3 w-3" /> OpenAI Gateway
</a>
</div>
</div>
)}
{/* Backup */}
<div className="flex items-center gap-3">
<button onClick={doBackup} className="flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm hover:bg-accent">
<Save className="h-3.5 w-3.5 text-primary" /> Backup jetzt
</button>
{backupMsg && <span className="text-xs text-muted-foreground">{backupMsg}</span>}
{/* Backup snapshot panel */}
<div className="rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 flex flex-col sm:flex-row justify-between sm:items-center gap-4">
<div className="space-y-1">
<h3 className="text-xs font-bold uppercase tracking-wider text-foreground">System-Backup &amp; Snapshot</h3>
<p className="text-[10px] text-muted-foreground">Erzeuge einen Git-Snapshot der aktuellen Konfigurationen und des System-Zustands.</p>
</div>
<div className="flex items-center gap-3 self-start sm:self-auto shrink-0">
<button
onClick={doBackup}
className="h-9 px-4 rounded-lg bg-primary text-primary-foreground text-xs font-semibold hover:opacity-90 transition-all flex items-center gap-1.5 cursor-pointer shadow-md shadow-primary/10"
>
<Save className="h-4 w-4" /> Snapshot erstellen
</button>
</div>
</div>
<Maintenance />
{backupMsg && (
<div className="text-[10px] font-mono text-primary font-medium bg-primary/5 p-3 rounded-xl border border-primary/20">
{backupMsg}
</div>
)}
{/* Maintenance controls inside system view */}
<MaintenanceSection />
</div>
)
}