Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Add metrics sampler and new agent console UI

Juan Denis04571a8d0ad9
diff --git a/agent/internal/agent/agent.go b/agent/internal/agent/agent.go
index 9cb2a903..b783e76d 100644
--- a/agent/internal/agent/agent.go
+++ b/agent/internal/agent/agent.go
@@ -39,6 +39,7 @@ type Agent struct {
metrics *metrics.Collector
terminal *terminal.Manager
ipc *ipc.Server
+ sampler *metricSampler
// Active subscriptions
subscriptions map[string]context.CancelFunc
@@ -97,6 +98,7 @@ func New(cfg *config.Config, log *logger.Logger) (*Agent, error) {
docker: dockerClient,
metrics: metricsCollector,
terminal: termManager,
+ sampler: newMetricSampler(300), // 5 min @ 1 Hz
subscriptions: make(map[string]context.CancelFunc),
handlers: make(map[string]CommandHandler),
startTime: time.Now(),
@@ -217,6 +219,11 @@ func (a *Agent) Run(ctx context.Context) error {
// Start discovery responder
go a.discoveryLoop(ctx)
+ // Start the desktop-console metrics sampler (1 Hz ring buffer, 5 min)
+ if a.sampler != nil {
+ go a.samplerLoop(ctx)
+ }
+
// Wait for context cancellation or restart request
select {
case <-ctx.Done():
@@ -1346,6 +1353,17 @@ func (a *Agent) GetDetailedMetrics() *ipc.DetailedMetrics {
}
}
+// GetMetricsHistory returns the recent CPU/memory ring buffer for the
+// desktop console's sparkline charts. Returns an empty slice (not nil) when
+// metrics are disabled or the sampler hasn't run yet, so the JSON shape
+// stays stable.
+func (a *Agent) GetMetricsHistory() []ipc.MetricSample {
+ if a.sampler == nil {
+ return []ipc.MetricSample{}
+ }
+ return a.sampler.snapshot()
+}
+
// GetConnectionInfo returns WebSocket connection information for the IPC API
func (a *Agent) GetConnectionInfo() ipc.ConnectionInfo {
info := ipc.ConnectionInfo{
diff --git a/agent/internal/agent/sampler.go b/agent/internal/agent/sampler.go
new file mode 100644
index 00000000..e92e50ef
--- /dev/null
+++ b/agent/internal/agent/sampler.go
@@ -0,0 +1,80 @@
+package agent
+
+import (
+ "context"
+ "sync"
+ "time"
+
+ "github.com/serverkit/agent/internal/ipc"
+)
+
+// metricSampler maintains a fixed-size ring buffer of CPU and memory samples
+// taken once per second. The agent's main metrics path (Collect → emit over
+// the WebSocket) already pulls live values, but the desktop console needs a
+// short-lived history to render sparklines without keeping a long-lived
+// websocket of its own to the agent. 300 samples × 1 s = 5 minutes of
+// scrollback, which matches the Overview tab design.
+type metricSampler struct {
+ mu sync.Mutex
+ samples []ipc.MetricSample
+ cap int
+}
+
+func newMetricSampler(capacity int) *metricSampler {
+ return &metricSampler{
+ samples: make([]ipc.MetricSample, 0, capacity),
+ cap: capacity,
+ }
+}
+
+// push records one sample, evicting the oldest when the buffer is full.
+func (s *metricSampler) push(sample ipc.MetricSample) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ if len(s.samples) >= s.cap {
+ copy(s.samples, s.samples[1:])
+ s.samples = s.samples[:len(s.samples)-1]
+ }
+ s.samples = append(s.samples, sample)
+}
+
+// snapshot returns a copy of the current samples in chronological order so
+// the caller can serialize them without holding the lock.
+func (s *metricSampler) snapshot() []ipc.MetricSample {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ out := make([]ipc.MetricSample, len(s.samples))
+ copy(out, s.samples)
+ return out
+}
+
+// samplerLoop runs until ctx is cancelled. Every tick it pulls one CPU/Mem
+// sample from the agent's metrics collector and pushes it into the ring.
+// Transient collection errors are swallowed: a one-tick gap is preferable
+// to a stutter in the graph or a noisy log.
+func (a *Agent) samplerLoop(ctx context.Context) {
+ ticker := time.NewTicker(1 * time.Second)
+ defer ticker.Stop()
+
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-ticker.C:
+ if a.metrics == nil || a.sampler == nil {
+ continue
+ }
+ collectCtx, cancel := context.WithTimeout(ctx, 1500*time.Millisecond)
+ sm, err := a.metrics.Collect(collectCtx)
+ cancel()
+ if err != nil {
+ continue
+ }
+ a.sampler.push(ipc.MetricSample{
+ Timestamp: time.Now().UnixMilli(),
+ CPU: sm.CPUPercent,
+ Mem: sm.MemoryPercent,
+ })
+ }
+ }
+}
diff --git a/agent/internal/ipc/handlers.go b/agent/internal/ipc/handlers.go
index c01bac6e..07a6c805 100644
--- a/agent/internal/ipc/handlers.go
+++ b/agent/internal/ipc/handlers.go
@@ -49,6 +49,20 @@ func (h *Handlers) HandleMetrics(w http.ResponseWriter, r *http.Request) {
h.writeJSON(w, metrics)
}
+// HandleMetricsHistory returns the recent CPU/memory ring buffer used by
+// the agent console to render sparklines. The buffer is bounded (5 minutes
+// at 1 Hz) so the response is always tiny.
+func (h *Handlers) HandleMetricsHistory(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodGet {
+ http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
+ return
+ }
+ samples := h.provider.GetMetricsHistory()
+ h.writeJSON(w, map[string]interface{}{
+ "samples": samples,
+ })
+}
+
// HandleConnection returns WebSocket connection information
func (h *Handlers) HandleConnection(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
diff --git a/agent/internal/ipc/server.go b/agent/internal/ipc/server.go
index bd1d1970..fdbe5f4d 100644
--- a/agent/internal/ipc/server.go
+++ b/agent/internal/ipc/server.go
@@ -15,6 +15,7 @@ import (
type StatusProvider interface {
GetStatus() AgentStatus
GetDetailedMetrics() *DetailedMetrics
+ GetMetricsHistory() []MetricSample
GetConnectionInfo() ConnectionInfo
GetRecentLogs(lines int) []string
Restart() error
@@ -75,6 +76,14 @@ type NetworkMetrics struct {
PacketsRecv uint64 `json:"packets_recv"`
}
+// MetricSample is one entry in the agent's CPU/memory ring buffer used by
+// the desktop console to render sparklines. Timestamp is unix milliseconds.
+type MetricSample struct {
+ Timestamp int64 `json:"t"`
+ CPU float64 `json:"cpu"`
+ Mem float64 `json:"mem"`
+}
+
// ConnectionInfo contains WebSocket connection details
type ConnectionInfo struct {
Connected bool `json:"connected"`
@@ -116,6 +125,7 @@ func (s *Server) Start(ctx context.Context) error {
handlers := NewHandlers(s.provider, s.log)
mux.HandleFunc("/status", handlers.HandleStatus)
mux.HandleFunc("/metrics", handlers.HandleMetrics)
+ mux.HandleFunc("/metrics/history", handlers.HandleMetricsHistory)
mux.HandleFunc("/connection", handlers.HandleConnection)
mux.HandleFunc("/logs", handlers.HandleLogs)
mux.HandleFunc("/restart", handlers.HandleRestart)
diff --git a/agent/ui/src/App.jsx b/agent/ui/src/App.jsx
index c665c05a..0ab76d5a 100644
--- a/agent/ui/src/App.jsx
+++ b/agent/ui/src/App.jsx
@@ -1,11 +1,22 @@
import { Routes, Route, Navigate } from 'react-router-dom';
-import ConsolePage from './pages/ConsolePage.jsx';
+import Shell from './components/Shell.jsx';
+import Overview from './pages/Overview.jsx';
+import Activity from './pages/Activity.jsx';
+import Logs from './pages/Logs.jsx';
+import Actions from './pages/Actions.jsx';
+import About from './pages/About.jsx';
export default function App() {
return (
<Routes>
- <Route path="/console" element={<ConsolePage />} />
- <Route path="*" element={<Navigate to="/console" replace />} />
+ <Route element={<Shell />}>
+ <Route path="/overview" element={<Overview />} />
+ <Route path="/activity" element={<Activity />} />
+ <Route path="/logs" element={<Logs />} />
+ <Route path="/actions" element={<Actions />} />
+ <Route path="/about" element={<About />} />
+ </Route>
+ <Route path="*" element={<Navigate to="/overview" replace />} />
</Routes>
);
}
diff --git a/agent/ui/src/components/Shell.jsx b/agent/ui/src/components/Shell.jsx
new file mode 100644
index 00000000..529f0da2
--- /dev/null
+++ b/agent/ui/src/components/Shell.jsx
@@ -0,0 +1,13 @@
+import { Outlet } from 'react-router-dom';
+import Sidebar from './Sidebar.jsx';
+
+export default function Shell() {
+ return (
+ <div className="shell">
+ <Sidebar />
+ <main className="shell__main">
+ <Outlet />
+ </main>
+ </div>
+ );
+}
diff --git a/agent/ui/src/components/Sidebar.jsx b/agent/ui/src/components/Sidebar.jsx
new file mode 100644
index 00000000..c3d348fa
--- /dev/null
+++ b/agent/ui/src/components/Sidebar.jsx
@@ -0,0 +1,47 @@
+import { NavLink } from 'react-router-dom';
+import {
+ LayoutDashboard,
+ History,
+ FileText,
+ Wrench,
+ Info,
+ Server,
+} from 'lucide-react';
+
+const NAV = [
+ { to: '/overview', label: 'Overview', icon: LayoutDashboard },
+ { to: '/activity', label: 'Activity', icon: History },
+ { to: '/logs', label: 'Logs', icon: FileText },
+ { to: '/actions', label: 'Actions', icon: Wrench },
+ { to: '/about', label: 'About', icon: Info },
+];
+
+export default function Sidebar() {
+ return (
+ <aside className="sidebar">
+ <div className="sidebar__brand">
+ <div className="sidebar__brand-icon">
+ <Server size={18} />
+ </div>
+ <div>
+ <div className="sidebar__brand-name">ServerKit</div>
+ <div className="sidebar__brand-sub">Agent Console</div>
+ </div>
+ </div>
+ <nav className="sidebar__nav">
+ {NAV.map(({ to, label, icon: Icon }) => (
+ <NavLink
+ key={to}
+ to={to}
+ className={({ isActive }) =>
+ 'sidebar__link' + (isActive ? ' sidebar__link--active' : '')
+ }
+ >
+ <Icon size={16} />
+ <span>{label}</span>
+ </NavLink>
+ ))}
+ </nav>
+ </aside>
+ );
+}
diff --git a/agent/ui/src/ipc/client.js b/agent/ui/src/ipc/client.js
new file mode 100644
index 00000000..608eff77
--- /dev/null
+++ b/agent/ui/src/ipc/client.js
@@ -0,0 +1,50 @@
+// Tiny client for the agent's local IPC server. Always 127.0.0.1 — the IPC
+// server refuses non-loopback binds — so we don't worry about CORS, auth, or
+// retries beyond the simple ones the hooks already handle.
+
+const DEFAULT_PORT = 19780;
+
+// Resolve the IPC base URL. The agent UI runs in WebView2 served from
+// 127.0.0.1:<random>, so we can't get the IPC port from the document origin.
+// We accept an override via an env var (Vite injects it at build time) and
+// otherwise fall back to the default port baked into the agent's config.
+const PORT =
+ Number(import.meta.env.VITE_AGENT_IPC_PORT) ||
+ Number(window.__SERVERKIT_IPC_PORT__) ||
+ DEFAULT_PORT;
+
+const BASE = `http://127.0.0.1:${PORT}`;
+
+async function get(path) {
+ const res = await fetch(`${BASE}${path}`, {
+ method: 'GET',
+ headers: { Accept: 'application/json' },
+ });
+ if (!res.ok) {
+ const text = await res.text().catch(() => '');
+ throw new Error(`IPC ${path} ${res.status}: ${text || res.statusText}`);
+ }
+ return res.json();
+}
+
+async function post(path, body) {
+ const res = await fetch(`${BASE}${path}`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
+ body: body ? JSON.stringify(body) : null,
+ });
+ if (!res.ok) {
+ const text = await res.text().catch(() => '');
+ throw new Error(`IPC ${path} ${res.status}: ${text || res.statusText}`);
+ }
+ return res.json();
+}
+
+export const ipc = {
+ health: () => get('/health'),
+ status: () => get('/status'),
+ metricsHistory: () => get('/metrics/history'),
+ connection: () => get('/connection'),
+ logs: (lines = 200) => get(`/logs?lines=${lines}`),
+ restart: () => post('/restart'),
+};
diff --git a/agent/ui/src/ipc/hooks.js b/agent/ui/src/ipc/hooks.js
new file mode 100644
index 00000000..07145859
--- /dev/null
+++ b/agent/ui/src/ipc/hooks.js
@@ -0,0 +1,53 @@
+import { useEffect, useState, useRef } from 'react';
+import { ipc } from './client.js';
+
+// Generic polling hook. Calls fetcher() on mount and then every intervalMs.
+// Cancels on unmount and treats overlapping requests defensively (last write
+// wins, but a stale response can't overwrite the current one).
+function usePolling(fetcher, intervalMs) {
+ const [data, setData] = useState(null);
+ const [error, setError] = useState(null);
+ const seq = useRef(0);
+
+ useEffect(() => {
+ let cancelled = false;
+ async function tick() {
+ const mySeq = ++seq.current;
+ try {
+ const result = await fetcher();
+ if (cancelled || mySeq !== seq.current) return;
+ setData(result);
+ setError(null);
+ } catch (err) {
+ if (cancelled || mySeq !== seq.current) return;
+ setError(err.message || String(err));
+ }
+ }
+ tick();
+ const id = setInterval(tick, intervalMs);
+ return () => {
+ cancelled = true;
+ clearInterval(id);
+ };
+ // fetcher is captured by reference; in our use it's always a stable
+ // module-level function, so we deliberately exclude it from deps.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [intervalMs]);
+
+ return { data, error };
+}
+
+export function useStatus(intervalMs = 2000) {
+ const { data, error } = usePolling(ipc.status, intervalMs);
+ return { status: data, error };
+}
+
+export function useMetricsHistory(intervalMs = 2000) {
+ const { data, error } = usePolling(ipc.metricsHistory, intervalMs);
+ return { samples: data?.samples || [], error };
+}
+
+export function useConnection(intervalMs = 5000) {
+ const { data, error } = usePolling(ipc.connection, intervalMs);
+ return { connection: data, error };
+}
diff --git a/agent/ui/src/pages/About.jsx b/agent/ui/src/pages/About.jsx
new file mode 100644
index 00000000..a230423f
--- /dev/null
+++ b/agent/ui/src/pages/About.jsx
@@ -0,0 +1,30 @@
+import { useStatus } from '../ipc/hooks.js';
+
+export default function About() {
+ const { status } = useStatus(5000);
+ return (
+ <div className="page">
+ <header className="page__header">
+ <h1 className="page__title">About</h1>
+ <p className="page__sub muted">ServerKit Agent Console</p>
+ </header>
+ <div className="card">
+ <div className="info-row">
+ <span className="info-row__label">Version</span>
+ <span className="info-row__value">{status?.version || '—'}</span>
+ </div>
+ <div className="info-row">
+ <span className="info-row__label">Agent ID</span>
+ <span className="info-row__value info-row__value--mono">{status?.agent_id || '—'}</span>
+ </div>
+ <div className="info-row">
+ <span className="info-row__label">Hostname</span>
+ <span className="info-row__value">{status?.agent_name || '—'}</span>
+ </div>
+ </div>
+ <div className="card empty-state">
+ Unpair and Uninstall actions will land here in the next milestone.
+ </div>
+ </div>
+ );
+}
diff --git a/agent/ui/src/pages/Actions.jsx b/agent/ui/src/pages/Actions.jsx
new file mode 100644
index 00000000..74e7f6c5
--- /dev/null
+++ b/agent/ui/src/pages/Actions.jsx
@@ -0,0 +1,15 @@
+export default function Actions() {
+ return (
+ <div className="page">
+ <header className="page__header">
+ <h1 className="page__title">Actions</h1>
+ <p className="page__sub">
+ <span className="muted">Coming next milestone — Start, Stop, Restart, Re-pair, diagnostic bundle.</span>
+ </p>
+ </header>
+ <div className="card empty-state">
+ Service controls and recovery actions will live here.
+ </div>
+ </div>
+ );
+}
diff --git a/agent/ui/src/pages/Activity.jsx b/agent/ui/src/pages/Activity.jsx
new file mode 100644
index 00000000..90286834
--- /dev/null
+++ b/agent/ui/src/pages/Activity.jsx
@@ -0,0 +1,15 @@
+export default function Activity() {
+ return (
+ <div className="page">
+ <header className="page__header">
+ <h1 className="page__title">Activity</h1>
+ <p className="page__sub">
+ <span className="muted">Coming next milestone — human-readable event timeline.</span>
+ </p>
+ </header>
+ <div className="card empty-state">
+ Pairing events, connection drops, restart actions, and panel-issued commands will land here.
+ </div>
+ </div>
+ );
+}
diff --git a/agent/ui/src/pages/ConsolePage.jsx b/agent/ui/src/pages/ConsolePage.jsx
deleted file mode 100644
index e4759794..00000000
--- a/agent/ui/src/pages/ConsolePage.jsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { Activity } from 'lucide-react';
-
-// Hello-world placeholder. The real Overview/Activity/Logs/Actions tabs land
-// in the next milestone — this exists so the webview pipeline can be smoke
-// tested end-to-end (Vite build → embed.FS → localhost server → WebView2).
-export default function ConsolePage() {
- return (
- <div className="console">
- <header className="console__header">
- <div className="console__brand">
- <Activity size={20} />
- <span>ServerKit Agent</span>
- </div>
- <span className="console__version">console preview</span>
- </header>
- <main className="console__body">
- <h1>Console is alive</h1>
- <p className="console__lead">
- The webview host loaded the embedded React app over the
- localhost asset server. From here we'll layer on the
- Overview, Activity, Logs, and Actions tabs.
- </p>
- </main>
- </div>
- );
-}
diff --git a/agent/ui/src/pages/Logs.jsx b/agent/ui/src/pages/Logs.jsx
new file mode 100644
index 00000000..4199d17f
--- /dev/null
+++ b/agent/ui/src/pages/Logs.jsx
@@ -0,0 +1,15 @@
+export default function Logs() {
+ return (
+ <div className="page">
+ <header className="page__header">
+ <h1 className="page__title">Logs</h1>
+ <p className="page__sub">
+ <span className="muted">Coming next milestone — tail of agent.log with level filter and clear.</span>
+ </p>
+ </header>
+ <div className="card empty-state">
+ The raw JSON-line agent log will be tailed here, with INFO/WARN/ERROR filtering, search, and a Clear button.
+ </div>
+ </div>
+ );
+}
diff --git a/agent/ui/src/pages/Overview.jsx b/agent/ui/src/pages/Overview.jsx
new file mode 100644
index 00000000..56a1915b
--- /dev/null
+++ b/agent/ui/src/pages/Overview.jsx
@@ -0,0 +1,144 @@
+import { useEffect, useState } from 'react';
+import { Copy, Check } from 'lucide-react';
+import { LineChart, Line, ResponsiveContainer, YAxis } from 'recharts';
+import { useStatus, useMetricsHistory } from '../ipc/hooks.js';
+
+function StatusPill({ status }) {
+ if (!status) return <span className="pill pill--muted">Loading…</span>;
+ if (!status.registered) return <span className="pill pill--warn">Not paired</span>;
+ if (status.connected) return <span className="pill pill--ok">Connected</span>;
+ if (status.running) return <span className="pill pill--warn">Reconnecting</span>;
+ return <span className="pill pill--muted">Stopped</span>;
+}
+
+function CopyButton({ value }) {
+ const [copied, setCopied] = useState(false);
+ if (!value) return null;
+ return (
+ <button
+ type="button"
+ className="copy-btn"
+ onClick={() => {
+ navigator.clipboard.writeText(value);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1200);
+ }}
+ title={copied ? 'Copied!' : 'Copy'}
+ >
+ {copied ? <Check size={14} /> : <Copy size={14} />}
+ </button>
+ );
+}
+
+function formatUptime(seconds) {
+ if (!seconds || seconds < 0) return '—';
+ const s = Math.floor(seconds);
+ const days = Math.floor(s / 86400);
+ const hours = Math.floor((s % 86400) / 3600);
+ const minutes = Math.floor((s % 3600) / 60);
+ if (days > 0) return `${days}d ${hours}h`;
+ if (hours > 0) return `${hours}h ${minutes}m`;
+ if (minutes > 0) return `${minutes}m ${s % 60}s`;
+ return `${s}s`;
+}
+
+function Sparkline({ data, dataKey, accent }) {
+ if (!data || data.length === 0) {
+ return <div className="sparkline sparkline--empty">collecting samples…</div>;
+ }
+ return (
+ <div className="sparkline">
+ <ResponsiveContainer width="100%" height={64}>
+ <LineChart data={data} margin={{ top: 4, right: 4, bottom: 4, left: 4 }}>
+ <YAxis hide domain={[0, 100]} />
+ <Line
+ type="monotone"
+ dataKey={dataKey}
+ stroke={accent}
+ strokeWidth={2}
+ dot={false}
+ isAnimationActive={false}
+ />
+ </LineChart>
+ </ResponsiveContainer>
+ </div>
+ );
+}
+
+export default function Overview() {
+ const { status, error: statusError } = useStatus(2000);
+ const { samples } = useMetricsHistory(2000);
+
+ // Recharts wants plain objects; flatten the IPC payload.
+ const chartData = samples.map((s) => ({
+ t: s.t,
+ cpu: s.cpu,
+ mem: s.mem,
+ }));
+
+ const lastCpu = chartData.length ? chartData[chartData.length - 1].cpu : status?.cpu_percent;
+ const lastMem = chartData.length ? chartData[chartData.length - 1].mem : status?.mem_percent;
+
+ return (
+ <div className="page">
+ <header className="page__header">
+ <div>
+ <h1 className="page__title">{status?.agent_name || 'Agent'}</h1>
+ <div className="page__sub">
+ <StatusPill status={status} />
+ {status?.version && <span className="muted">v{status.version}</span>}
+ </div>
+ </div>
+ </header>
+
+ {statusError && (
+ <div className="banner banner--warn">
+ Can't reach the agent IPC server. Is the service running? ({statusError})
+ </div>
+ )}
+
+ <section className="card">
+ <h2 className="card__title">Connection</h2>
+ <div className="info-row">
+ <span className="info-row__label">Server URL</span>
+ <span className="info-row__value info-row__value--mono">
+ {status?.server_url || '—'}
+ <CopyButton value={status?.server_url} />
+ </span>
+ </div>
+ <div className="info-row">
+ <span className="info-row__label">Agent ID</span>
+ <span className="info-row__value info-row__value--mono">
+ {status?.agent_id || '—'}
+ <CopyButton value={status?.agent_id} />
+ </span>
+ </div>
+ <div className="info-row">
+ <span className="info-row__label">Uptime</span>
+ <span className="info-row__value">{formatUptime(status?.uptime_seconds)}</span>
+ </div>
+ </section>
+
+ <section className="metrics">
+ <div className="card metric-card">
+ <div className="metric-card__head">
+ <h2 className="card__title">CPU</h2>
+ <span className="metric-card__value">
+ {lastCpu != null ? `${lastCpu.toFixed(1)}%` : '—'}
+ </span>
+ </div>
+ <Sparkline data={chartData} dataKey="cpu" accent="#6366f1" />
+ </div>
+ <div className="card metric-card">
+ <div className="metric-card__head">
+ <h2 className="card__title">Memory</h2>
+ <span className="metric-card__value">
+ {lastMem != null ? `${lastMem.toFixed(1)}%` : '—'}
+ </span>
+ </div>
+ <Sparkline data={chartData} dataKey="mem" accent="#10b981" />
+ </div>
+ </section>
+ </div>
+ );
+}
diff --git a/agent/ui/src/styles/main.scss b/agent/ui/src/styles/main.scss
index 9b3a7a75..e3ff0eb0 100644
--- a/agent/ui/src/styles/main.scss
+++ b/agent/ui/src/styles/main.scss
@@ -14,62 +14,308 @@ body,
color: $text-primary;
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
font-size: 14px;
+ line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
+button {
+ font-family: inherit;
+}
+
a {
color: $accent;
text-decoration: none;
}
-.console {
+.muted {
+ color: $text-tertiary;
+}
+
+// ─── App shell ───────────────────────────────────────────────────────────
+
+.shell {
+ display: grid;
+ grid-template-columns: 220px 1fr;
+ height: 100vh;
+ width: 100vw;
+ overflow: hidden;
+}
+
+.shell__main {
+ overflow-y: auto;
+ background: $bg-body;
+}
+
+// ─── Sidebar ─────────────────────────────────────────────────────────────
+
+.sidebar {
+ background: $bg-sidebar;
+ border-right: 1px solid $border-default;
display: flex;
flex-direction: column;
- height: 100%;
- min-height: 100vh;
+ padding: $space-md;
+ gap: $space-lg;
}
-.console__header {
+.sidebar__brand {
display: flex;
align-items: center;
- justify-content: space-between;
- padding: 12px 20px;
- background: $bg-sidebar;
- border-bottom: 1px solid $border-default;
- -webkit-app-region: drag;
+ gap: $space-sm;
+ padding: $space-sm 4px;
}
-.console__brand {
- display: flex;
- align-items: center;
- gap: 8px;
+.sidebar__brand-icon {
+ width: 32px;
+ height: 32px;
+ border-radius: $radius-sm;
+ background: linear-gradient(135deg, $accent, #8b5cf6);
+ display: grid;
+ place-items: center;
+ color: white;
+}
+
+.sidebar__brand-name {
font-weight: 600;
color: $text-primary;
+ line-height: 1.2;
}
-.console__version {
+.sidebar__brand-sub {
+ font-size: 11px;
color: $text-tertiary;
- font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.08em;
+ line-height: 1.2;
+ margin-top: 2px;
}
-.console__body {
- flex: 1;
- padding: 32px;
- max-width: 720px;
- margin: 0 auto;
- width: 100%;
+.sidebar__nav {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+
+.sidebar__link {
+ display: flex;
+ align-items: center;
+ gap: $space-sm;
+ padding: 8px 10px;
+ border-radius: $radius-sm;
+ color: $text-secondary;
+ font-size: 13px;
+ font-weight: 500;
+ transition: background 120ms, color 120ms;
+
+ &:hover {
+ background: $bg-hover;
+ color: $text-primary;
+ }
- h1 {
- margin: 0 0 12px;
- font-size: 24px;
- font-weight: 600;
+ &--active {
+ background: $bg-elevated;
+ color: $text-primary;
}
}
-.console__lead {
- color: $text-secondary;
- line-height: 1.55;
+// ─── Page ────────────────────────────────────────────────────────────────
+
+.page {
+ padding: $space-xl;
+ max-width: 980px;
+ margin: 0 auto;
+ display: flex;
+ flex-direction: column;
+ gap: $space-lg;
+}
+
+.page__header {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: $space-md;
+}
+
+.page__title {
+ margin: 0 0 6px;
+ font-size: 22px;
+ font-weight: 600;
+ letter-spacing: -0.01em;
+}
+
+.page__sub {
margin: 0;
+ display: flex;
+ gap: $space-sm;
+ align-items: center;
+ font-size: 13px;
+}
+
+// ─── Cards ───────────────────────────────────────────────────────────────
+
+.card {
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: $radius-md;
+ padding: $space-lg;
+ display: flex;
+ flex-direction: column;
+ gap: $space-md;
+}
+
+.card__title {
+ margin: 0;
+ font-size: 12px;
+ font-weight: 600;
+ color: $text-tertiary;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+}
+
+.empty-state {
+ color: $text-secondary;
+ font-size: 13px;
+ line-height: 1.6;
+}
+
+// ─── Pills ───────────────────────────────────────────────────────────────
+
+.pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 3px 10px;
+ border-radius: 999px;
+ font-size: 12px;
+ font-weight: 500;
+ line-height: 1.4;
+
+ &::before {
+ content: '';
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: currentColor;
+ }
+
+ &--ok {
+ background: rgba($success, 0.12);
+ color: $success;
+ }
+ &--warn {
+ background: rgba($warning, 0.15);
+ color: $warning;
+ }
+ &--muted {
+ background: $bg-hover;
+ color: $text-tertiary;
+ }
+}
+
+// ─── Banner ──────────────────────────────────────────────────────────────
+
+.banner {
+ border-radius: $radius-md;
+ padding: 12px 16px;
+ font-size: 13px;
+ border: 1px solid;
+ display: flex;
+ gap: $space-sm;
+ align-items: flex-start;
+
+ &--warn {
+ background: rgba($warning, 0.08);
+ border-color: rgba($warning, 0.3);
+ color: lighten($warning, 12%);
+ }
+}
+
+// ─── Info rows ───────────────────────────────────────────────────────────
+
+.info-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: $space-md;
+ padding: 10px 0;
+ border-bottom: 1px solid $border-subtle;
+
+ &:last-child {
+ border-bottom: none;
+ }
+}
+
+.info-row__label {
+ font-size: 12px;
+ color: $text-tertiary;
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+}
+
+.info-row__value {
+ color: $text-primary;
+ font-size: 13px;
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ text-align: right;
+ word-break: break-all;
+
+ &--mono {
+ font-family: 'JetBrains Mono', 'Consolas', ui-monospace, monospace;
+ font-size: 12px;
+ }
+}
+
+.copy-btn {
+ background: transparent;
+ border: 1px solid $border-default;
+ color: $text-tertiary;
+ border-radius: $radius-sm;
+ padding: 4px 6px;
+ cursor: pointer;
+ display: inline-flex;
+ align-items: center;
+ transition: color 120ms, border-color 120ms;
+
+ &:hover {
+ color: $text-primary;
+ border-color: $border-active;
+ }
+}
+
+// ─── Metrics ─────────────────────────────────────────────────────────────
+
+.metrics {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: $space-md;
+}
+
+.metric-card {
+ gap: $space-sm;
+}
+
+.metric-card__head {
+ display: flex;
+ justify-content: space-between;
+ align-items: baseline;
+}
+
+.metric-card__value {
+ font-size: 24px;
+ font-weight: 600;
+ font-variant-numeric: tabular-nums;
+ color: $text-primary;
+}
+
+.sparkline {
+ margin: 0 -8px;
+
+ &--empty {
+ height: 64px;
+ display: grid;
+ place-items: center;
+ color: $text-tertiary;
+ font-size: 12px;
+ }
}