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.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat(ui): incidents absorbs fleet alerts, and four more pages join the convention
Juan Denis2b4e360a2c71
diff --git a/backend/app/models/server_template.py b/backend/app/models/server_template.pyindex 19544d6e..ad7672dc 100644--- a/backend/app/models/server_template.py+++ b/backend/app/models/server_template.py@@ -115,6 +115,12 @@ class ServerTemplate(db.Model):return parent_specdef to_dict(self):+ # Compliance is recorded per ASSIGNMENT, but the question asked of a+ # template list is "which template is drifting?" — so each row carries+ # its own tally. Pulling the statuses in one go costs the same single+ # query the bare assignment count used to.+ statuses = [s for (s,) in self.assignments.with_entities(+ ServerTemplateAssignment.status)]return {'id': self.id,'name': self.name,@@ -131,7 +137,9 @@ class ServerTemplate(db.Model):'sysctl_params': self.sysctl_params,'auto_remediate': self.auto_remediate,'remediation_approval_required': self.remediation_approval_required,- 'assignment_count': self.assignments.count(),+ 'assignment_count': len(statuses),+ 'compliant_count': statuses.count(ServerTemplateAssignment.STATUS_COMPLIANT),+ 'drifted_count': statuses.count(ServerTemplateAssignment.STATUS_DRIFTED),'created_by': self.created_by,'created_at': self.created_at.isoformat() if self.created_at else None,'updated_at': self.updated_at.isoformat() if self.updated_at else None,diff --git a/frontend/src/components/EnvironmentVariables.jsx b/frontend/src/components/EnvironmentVariables.jsxindex 7ce164e3..d13b0474 100644--- a/frontend/src/components/EnvironmentVariables.jsx+++ b/frontend/src/components/EnvironmentVariables.jsx@@ -1,5 +1,7 @@-import { useState, useEffect, useRef } from 'react';-import { Plus } from 'lucide-react';+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';+import {+ Copy, Download, Eye, EyeOff, History, Pencil, Plus, Trash2, Upload, Variable,+} from 'lucide-react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';import { Button } from '@/components/ui/button';@@ -10,7 +12,56 @@ import { Badge } from '@/components/ui/badge';import { Label } from '@/components/ui/label';import Modal from './Modal';import EmptyState from './EmptyState';-import { DataTable, DataTableFooter } from '@/components/ds';+import { DataTable, DataTableFooter, ListToolbar, SearchField } from '@/components/ds';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';++// What a masked value renders as. Unchanged from the list this table replaces:+// every env var is stored as a secret, so every value is dots until the row's+// eye (or Show All) reveals it.+const MASK = '••••••••••••';++// What the Description and Applies-to cells show when the row carries neither.+// They have to be real values, not '': `ruleIsArmed` drops any rule whose value+// is empty, so "description is ''" would filter nothing at all — and the+// Undocumented view below is exactly that rule.+const NO_DESCRIPTION = '—';+const ALL_SERVICES = 'All services';++const BY_KEY = [{ key: 'key', direction: 'asc' }];+const NO_RULES = { match: 'all', rules: [] };++// Built-in saved views. Scope is deliberately not one of them: it only exists+// on compose apps, and the Applies-to column's own menu already offers the+// per-service pick-list with live counts wherever it applies.+const ENV_VIEWS = [+ {+ // Every variable the container will see, in the order you would read a+ // .env file. The landing view, and the one that says "nothing is+ // filtered".+ name: 'All variables',+ state: { sorts: BY_KEY, hiddenKeys: [], columnFilters: NO_RULES },+ },+ {+ // A hygiene worklist rather than a slice: a variable nobody described+ // is a variable nobody can safely delete, and it is the one most likely+ // to outlive whoever added it. Empty on a fully documented app, which+ // is exactly the answer it exists to give.+ name: 'Undocumented',+ state: {+ sorts: BY_KEY,+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'env1', field: 'description', op: 'is', value: NO_DESCRIPTION }],+ },+ },+ },+];const EnvironmentVariables = ({ appId }) => {const toast = useToast();@@ -40,7 +91,15 @@ const EnvironmentVariables = ({ appId }) => {const [importContent, setImportContent] = useState('');const [importOverwrite, setImportOverwrite] = useState(true);const [history, setHistory] = useState([]);- const [filter, setFilter] = useState('');+ const [search, setSearch] = useState('');++ const { sorts, setSorts } = useTableSort({+ defaultSorts: BY_KEY,+ storageKey: 'serverkit-table-svc-env-sort',+ });+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({+ storageKey: 'serverkit-table-svc-env-cols',+ });const fileInputRef = useRef(null);@@ -252,230 +311,306 @@ const EnvironmentVariables = ({ appId }) => {toast.success('Copied to clipboard');}- // Filter env vars- const filteredEnvVars = filter- ? envVars.filter(ev =>- ev.key.toLowerCase().includes(filter.toLowerCase()) ||- (ev.description && ev.description.toLowerCase().includes(filter.toLowerCase()))- )- : envVars;+ // The search box narrows the rows before any column rule sees them, over+ // the two fields you actually remember: the key and what someone wrote it+ // was for.+ const filteredEnvVars = useMemo(() => {+ const needle = search.trim().toLowerCase();+ if (!needle) return envVars;+ return envVars.filter((ev) => (+ ev.key.toLowerCase().includes(needle)+ || (ev.description && ev.description.toLowerCase().includes(needle))+ ));+ }, [envVars, search]);++ // Declared above the loading guard: the chrome below is a hook, so it+ // cannot sit behind an early return.+ const columns = [+ {+ key: 'key',+ header: 'Key',+ sortable: true,+ hideable: false,+ // An identifier you type a fragment of, never pick from a list.+ type: 'text',+ value: (ev) => ev.key || '',+ sortValue: (ev) => ev.key || '',+ cellClassName: 'sk-cell-name env-cell-key',+ render: (ev) => ev.key,+ },+ {+ key: 'value',+ header: 'Value',+ sortable: false,+ // Neither sortable nor filterable, and `value` answers with the+ // mask rather than the secret: those three accessors also feed the+ // "⋮" export and the column menu's pick-list, so a real accessor+ // here would make the grid the one path that hands out a value the+ // rest of the tab keeps behind an eye toggle.+ filterable: false,+ value: () => MASK,+ cellClassName: 'env-cell-value',+ render: (ev) => (editingId === ev.id ? (+ <div className="env-edit-row">+ <Input+ type="text"+ value={editValue}+ onChange={(e) => setEditValue(e.target.value)}+ autoFocus+ onKeyDown={(e) => {+ if (e.key === 'Enter') handleUpdate(ev.key);+ if (e.key === 'Escape') cancelEditing();+ }}+ />+ {composeServices.length > 0 && (+ <select+ className="env-target-select__control"+ value={editTargetService}+ onChange={(e) => setEditTargetService(e.target.value)}+ title="Inject this variable into a single compose service"+ >+ <option value="">All services</option>+ {composeServices.map((svc) => (+ <option key={svc} value={svc}>{svc}</option>+ ))}+ </select>+ )}+ <Button size="sm" onClick={() => handleUpdate(ev.key)}>Save</Button>+ <Button variant="outline" size="sm" onClick={cancelEditing}>Cancel</Button>+ </div>+ ) : (showValues[ev.id] ? ev.value : MASK)),+ },+ // Only compose apps can target a single service, so on a single-service+ // app the column would say "All services" on every row and answer+ // nothing. But `composeServices` comes from the app's CURRENT compose+ // file, and a variable can still carry a `target_service` from before a+ // service was renamed or removed — hiding the column outright is how a+ // variable that applies to exactly one service silently looks like it+ // applies to all of them. Show it whenever either source says there is+ // a distinction to draw.+ ...(composeServices.length > 0 || envVars.some((ev) => ev.target_service) ? [{+ key: 'scope',+ header: 'Applies to',+ sortable: true,+ // Declared, not inferred: a compose app with two services and three+ // variables is over the enum cardinality ratio and would degrade to+ // free text, turning the per-service pick-list into a typed+ // fragment.+ type: 'enum',+ value: (ev) => ev.target_service || ALL_SERVICES,+ sortValue: (ev) => ev.target_service || ALL_SERVICES,+ render: (ev) => (ev.target_service ? (+ <span+ className="env-target-chip"+ title={`Applies only to the "${ev.target_service}" service`}+ >+ → {ev.target_service}+ </span>+ ) : <span className="env-muted">{ALL_SERVICES}</span>),+ }] : []),+ {+ key: 'description',+ header: 'Description',+ sortable: true,+ // Text, never enum: on an app where nothing is documented the+ // inference would see one repeated dash and offer a checklist.+ // `value` substitutes the dash the cell shows so the undocumented+ // rows are addressable by the view below; `sortValue` stays '' so+ // they collate as empty rather than as whatever "—" sorts under.+ type: 'text',+ value: (ev) => ev.description || NO_DESCRIPTION,+ sortValue: (ev) => ev.description || '',+ render: (ev) => ev.description || <span className="env-muted">{NO_DESCRIPTION}</span>,+ },+ {+ key: 'actions',+ header: 'Actions',+ sortable: false,+ hideable: false,+ className: 'actions-cell',+ cellClassName: 'actions-cell',+ render: (ev) => (+ <>+ <button+ type="button"+ className="btn-icon"+ onClick={() => toggleShowValue(ev.id)}+ title={showValues[ev.id] ? 'Hide value' : 'Show value'}+ >+ {showValues[ev.id] ? <EyeOff size={16} /> : <Eye size={16} />}+ </button>+ <button+ type="button"+ className="btn-icon"+ onClick={() => copyToClipboard(ev.value)}+ title="Copy value"+ >+ <Copy size={16} />+ </button>+ <button+ type="button"+ className="btn-icon"+ onClick={() => startEditing(ev)}+ title="Edit"+ >+ <Pencil size={16} />+ </button>+ <button+ type="button"+ className="btn-icon btn-danger"+ onClick={() => handleDelete(ev.key)}+ title="Delete"+ >+ <Trash2 size={16} />+ </button>+ </>+ ),+ },+ ];++ // The page-private half of a saved view: the search box narrows the rows+ // before any column rule runs, so a view has to carry it.+ const pageState = useMemo(() => ({ search }), [search]);+ const applyPage = useCallback((saved) => {+ if (saved.search !== undefined) setSearch(saved.search);+ }, []);++ // Scoped to this tab, and namespaced: /services/:id renders one tab at a+ // time but the Events tab on the same ROUTE hosts a chrome of its own, so+ // unscoped the two would read and write the same ?view=/?sort= and each+ // would arrive as the other's.+ const chrome = useTableChrome({+ columns,+ rows: filteredEnvVars,+ viewPageKey: 'servicedetail-environment',+ urlScope: 'env',+ builtinViews: ENV_VIEWS,+ noun: 'variables',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ pageState,+ applyPage,+ });if (loading) {- return <EmptyState loading loadingVariant="form" title="Loading environment variables..." />;+ return <EmptyState loading loadingVariant="table" title="Loading environment variables..." />;}return (<div className="env-vars-container">- <div className="section-header">- <h3>Environment Variables</h3>- <div className="header-actions">- <Button size="sm" onClick={openAddModal}>- <Plus size={15} />- Add Variable- </Button>- {envVars.length > 0 && (- <Button variant="outline" size="sm" onClick={toggleShowAll} title={allVisible ? 'Hide all values' : 'Show all values'}>- {allVisible ? (- <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/>- <line x1="1" y1="1" x2="23" y2="23"/>- </svg>- ) : (- <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>- <circle cx="12" cy="12" r="3"/>- </svg>- )}- {allVisible ? 'Hide All' : 'Show All'}- </Button>- )}- <Button variant="outline" size="sm" onClick={() => setShowImportModal(true)}>- <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"/>- </svg>- Import- </Button>- <Button variant="outline" size="sm" onClick={() => handleExport(true)}>- <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"/>- </svg>- Export- </Button>- <Button variant="outline" size="sm" onClick={handleShowHistory}>- <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2">- <circle cx="12" cy="12" r="10"/>- <polyline points="12 6 12 12 16 14"/>- </svg>- History- </Button>- </div>- </div>-<p className="hint">Environment variables are encrypted at rest and masked by default. Changes require an app restart to take effect.</p>- {/* Variables — bordered panel with a titled head + count */}- <section className="env-panel">- <div className="env-panel__head">- <span className="env-panel__title">- Variables- {envVars.length > 0 && (- <span className="env-panel__count">{envVars.length}</span>- )}- </span>- {envVars.length > 5 && (- <div className="env-panel__filter">- <Input- type="text"- value={filter}- onChange={(e) => setFilter(e.target.value)}- placeholder="Filter variables..."- />- {filter && (- <button type="button" className="filter-clear" onClick={() => setFilter('')}>×</button>- )}- </div>- )}- </div>- <div className="env-panel__body">- {filteredEnvVars.length === 0 ? (- <div className="env-empty">- <p>{filter ? 'No matching variables' : 'No environment variables defined yet'}</p>- {!filter && (- <Button size="sm" onClick={openAddModal}>- <Plus size={15} />- Add Variable- </Button>- )}- </div>- ) : (- <div className="env-list">- {filteredEnvVars.map(envVar => (- <div key={envVar.id} className="env-item">- <div className="env-item-header">- <span className="env-key">- {envVar.key}- {envVar.target_service && (- <span- className="env-target-chip"- title={`Applies only to the "${envVar.target_service}" service`}- >- → {envVar.target_service}- </span>- )}- </span>- <div className="env-item-actions">- <button type="button"- className="btn-icon"- onClick={() => toggleShowValue(envVar.id)}- title={showValues[envVar.id] ? 'Hide value' : 'Show value'}- >- {showValues[envVar.id] ? (- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/>- <line x1="1" y1="1" x2="23" y2="23"/>- </svg>- ) : (- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>- <circle cx="12" cy="12" r="3"/>- </svg>- )}- </button>- <button type="button"- className="btn-icon"- onClick={() => copyToClipboard(envVar.value)}- title="Copy value"- >- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">- <rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>- <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>- </svg>- </button>- <button type="button"- className="btn-icon"- onClick={() => startEditing(envVar)}- title="Edit"- >- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>- <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>- </svg>- </button>- <button type="button"- className="btn-icon btn-danger"- onClick={() => handleDelete(envVar.key)}- title="Delete"- >- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">- <polyline points="3 6 5 6 21 6"/>- <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>- </svg>- </button>- </div>- </div>-- {editingId === envVar.id ? (- <div className="env-edit-row">- <Input- type="text"- value={editValue}- onChange={(e) => setEditValue(e.target.value)}- autoFocus- onKeyDown={(e) => {- if (e.key === 'Enter') handleUpdate(envVar.key);- if (e.key === 'Escape') cancelEditing();- }}- />- {composeServices.length > 0 && (- <select- className="env-target-select__control"- value={editTargetService}- onChange={(e) => setEditTargetService(e.target.value)}- title="Inject this variable into a single compose service"- >- <option value="">All services</option>- {composeServices.map((svc) => (- <option key={svc} value={svc}>{svc}</option>- ))}- </select>- )}- <Button size="sm" onClick={() => handleUpdate(envVar.key)}>- Save- </Button>- <Button variant="outline" size="sm" onClick={cancelEditing}>- Cancel- </Button>- </div>- ) : (- <div className="env-value">- {showValues[envVar.id] ? envVar.value : '••••••••••••'}- </div>- )}-- {envVar.description && (- <div className="env-description">{envVar.description}</div>- )}- </div>- ))}- </div>- )}-- {/* Footer actions */}- {envVars.length > 0 && (- <div className="env-footer">- <Button variant="outline" size="sm" className="env-clear-btn" onClick={handleClearAll}>- <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2">- <polyline points="3 6 5 6 21 6"/>- <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>- </svg>- Clear All+ {envVars.length === 0 ? (+ <EmptyState+ icon={Variable}+ title="No environment variables"+ description="Add one here, or import an existing .env file."+ action={(+ <div className="env-empty-actions">+ <Button onClick={openAddModal}>+ <Plus size={15} />+ Add Variable+ </Button>+ <Button variant="outline" onClick={() => setShowImportModal(true)}>+ <Upload size={14} />+ Import</Button></div>)}- </div>- </section>+ />+ ) : (+ <>+ {/* One row of chrome: the view name is this tab's heading and+ the search, the filter and the "⋮" ride the same line.+ ServiceDetail owns the page top bar, so the chrome stays+ inline here rather than being hoisted (see+ useTopbarChrome). No count on it — the footer reports+ that, under the rows it is counting. */}+ <GridViewPicker+ views={chrome.views}+ label="variables"+ onCreate={chrome.createView}+ actions={(+ <>+ <SearchField+ value={search}+ onSearch={setSearch}+ placeholder="Search keys or descriptions…"+ />+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadEnvVars} />+ </>+ )}+ />++ {/* What acts on the .env file itself, rather than on what you+ are looking at. Refresh is gone from it — it is in the "⋮". */}+ <ListToolbar>+ <Button size="sm" onClick={openAddModal}>+ <Plus size={15} />+ Add Variable+ </Button>+ <Button+ variant="outline"+ size="sm"+ onClick={toggleShowAll}+ title={allVisible ? 'Hide all values' : 'Show all values'}+ >+ {allVisible ? <EyeOff size={14} /> : <Eye size={14} />}+ {allVisible ? 'Hide All' : 'Show All'}+ </Button>+ <Button variant="outline" size="sm" onClick={() => setShowImportModal(true)}>+ <Upload size={14} />+ Import+ </Button>+ <Button variant="outline" size="sm" onClick={() => handleExport(true)}>+ <Download size={14} />+ Export+ </Button>+ <Button variant="outline" size="sm" onClick={handleShowHistory}>+ <History size={14} />+ History+ </Button>+ <Button variant="outline" size="sm" className="env-clear-btn" onClick={handleClearAll}>+ <Trash2 size={14} />+ Clear All+ </Button>+ </ListToolbar>++ <GridChips {...chrome.chipProps} />++ <DataTable+ columns={chrome.columns}+ data={filteredEnvVars}+ keyField="id"+ sorts={sorts}+ onSortsChange={setSorts}+ {...chrome.tableProps}+ tableClassName="data-table"+ emptyTitle="No variables match your search."+ emptyMessage=""+ footer={(+ <DataTableFooter+ // DataTable applies the column rules itself, so+ // the shown count comes from the chrome —+ // `envVars` is only ever the whole file.+ shown={chrome.shownCount}+ total={envVars.length}+ noun="variable"+ />+ )}+ />+ </>+ )}++ <GridFilterDrawer {...chrome.drawerProps} />{/* Add Variable Modal */}<Modal open={showAddModal} onClose={() => setShowAddModal(false)} title="Add Environment Variable">diff --git a/frontend/src/components/ds/grid/viewState.js b/frontend/src/components/ds/grid/viewState.jsindex 19176b5b..fbe5f261 100644--- a/frontend/src/components/ds/grid/viewState.js+++ b/frontend/src/components/ds/grid/viewState.js@@ -117,6 +117,17 @@ export function sameViewState(a, b, { rename } = {}) {rules: side.columnFilters.rules.map((r) => canon(r, true)),};}+ // Compare only the `page` keys the page still captures. The bag is the one+ // place a page may invent a key, so it is also the one place a key can be+ // RETIRED — when a page stops capturing (say) a bucket it has replaced with+ // a column rule, every view a user saved while it existed would otherwise+ // never compare equal again, leaving "Unsaved" pinned on forever with+ // nothing the user can do to clear it. A key the live state no longer knows+ // about is not a difference the user made.+ const liveKeys = new Set(Object.keys(left.page || {}));+ right.page = Object.fromEntries(+ Object.entries(right.page || {}).filter(([k]) => liveKeys.has(k)),+ );return JSON.stringify(canon(left)) === JSON.stringify(canon(right));}diff --git a/frontend/src/components/monitoring/FleetAlertsPanel.jsx b/frontend/src/components/monitoring/FleetAlertsPanel.jsxdeleted file mode 100644index 1eb78402..00000000--- a/frontend/src/components/monitoring/FleetAlertsPanel.jsx+++ /dev/null@@ -1,188 +0,0 @@-import { useState, useEffect } from 'react';-import { CheckCircle, Eye } from 'lucide-react';-import api from '../../services/api';-import { useToast } from '../../contexts/ToastContext';-import { Button } from '@/components/ui/button';-import { DataTable, DataTableFooter, Pill, SegControl } from '@/components/ds';-import { useTableSort } from '@/hooks/useTableSort';-import { useColumnVisibility } from '@/hooks/useColumnVisibility';-import { METRIC_LABELS } from './fleetMetrics';--const ALERT_FILTERS = [- { value: 'active', label: 'Active' },- { value: 'acknowledged', label: 'Acknowledged' },- { value: 'resolved', label: 'Resolved' },- { value: 'all', label: 'All' },-];--// Alerts raised by per-server thresholds across the fleet. The panel host's own-// alerts are a different system (a single set of limits, delivered by the-// monitoring scheduler) and sit above this in the Incidents timeline; the limits-// behind these rows are edited on the Rules tab.-export default function FleetAlertsPanel({ scope, refreshKey = 0 }) {- const toast = useToast();- const [alerts, setAlerts] = useState([]);- const [filter, setFilter] = useState('active');- const [reloadKey, setReloadKey] = useState(0);-- useEffect(() => {- let cancelled = false;- api.getFleetAlerts({- status: filter !== 'all' ? filter : undefined,- // Following the top-bar scope keeps every section answering the- // same question about the same host.- server_id: scope && scope !== 'host' ? scope : undefined,- })- .then((data) => { if (!cancelled) setAlerts(Array.isArray(data) ? data : []); })- .catch(() => { if (!cancelled) setAlerts([]); });- return () => { cancelled = true; };- }, [filter, scope, refreshKey, reloadKey]);-- const runAction = async (fn, failure) => {- try {- await fn();- setReloadKey((k) => k + 1);- } catch {- toast.error(failure);- }- };-- const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-fleet-alerts-sort' });- const {- hiddenKeys, setHiddenKeys,- } = useColumnVisibility({ storageKey: 'serverkit-table-fleet-alerts-cols' });-- // Columns for the shared DataTable; cell markup is identical to the- // hand-rolled table it replaces (.sk-cell-mono, .mon-row-actions).- const alertColumns = [- {- key: 'server',- header: 'Server',- sortable: true,- hideable: false,- sortValue: (a) => a.server_name || '',- render: (a) => a.server_name,- },- {- key: 'metric',- header: 'Metric',- sortable: true,- sortValue: (a) => METRIC_LABELS[a.metric] || a.metric,- render: (a) => METRIC_LABELS[a.metric] || a.metric,- },- {- key: 'value',- header: 'Value',- sortable: true,- sortValue: (a) => a.value ?? null,- cellClassName: 'sk-cell-mono',- render: (a) => `${a.value}%`,- },- {- key: 'threshold',- header: 'Threshold',- sortable: true,- sortValue: (a) => a.threshold ?? null,- cellClassName: 'sk-cell-mono',- render: (a) => `${a.threshold}%`,- },- {- key: 'severity',- header: 'Severity',- sortable: true,- sortValue: (a) => a.severity || '',- render: (a) => <Pill kind={a.severity === 'critical' ? 'red' : 'amber'}>{a.severity}</Pill>,- },- {- key: 'status',- header: 'Status',- sortable: true,- sortValue: (a) => a.status || '',- render: (a) => (- <Pill kind={a.status === 'active' ? 'red' : a.status === 'acknowledged' ? 'amber' : 'green'}>- {a.status}- </Pill>- ),- },- {- key: 'time',- header: 'Time',- sortable: true,- sortValue: (a) => (a.created_at ? new Date(a.created_at).getTime() : null),- render: (a) => new Date(a.created_at).toLocaleString(),- },- {- key: 'actions',- header: '',- sortable: false,- hideable: false,- cellClassName: 'mon-row-actions',- render: (a) => (- <>- {a.status === 'active' && (- <Button- variant="ghost"- size="sm"- onClick={() => runAction(- () => api.acknowledgeFleetAlert(a.id),- 'Failed to acknowledge alert',- )}- >- <Eye size={14} /> Ack- </Button>- )}- {a.status !== 'resolved' && (- <Button- variant="ghost"- size="sm"- onClick={() => runAction(- () => api.resolveFleetAlert(a.id),- 'Failed to resolve alert',- )}- >- <CheckCircle size={14} /> Resolve- </Button>- )}- </>- ),- },- ];-- return (- <section className="monitoring-panel">- <div className="monitoring-panel__header">- <h3>Fleet alerts</h3>- <div>- <SegControl value={filter} onChange={setFilter} options={ALERT_FILTERS} />- </div>- </div>-- {alerts.length > 0 ? (- <DataTable- columns={alertColumns}- data={alerts}- keyField="id"- sorts={sorts}- onSortsChange={setSorts}- hiddenKeys={hiddenKeys}- onHiddenKeysChange={setHiddenKeys}- className="mon-table-scroll"- footer={(- <DataTableFooter- shown={alerts.length}- total={alerts.length}- noun="alert"- />- )}- />- ) : (- <p className="mon-panel-hint">- <CheckCircle size={14} />- {filter === 'all'- ? 'No fleet alerts have ever been raised.'- : `No ${filter} fleet alerts.`}- </p>- )}- </section>- );-}diff --git a/frontend/src/components/service-detail/EventsTab.jsx b/frontend/src/components/service-detail/EventsTab.jsxindex 4c616319..d9377149 100644--- a/frontend/src/components/service-detail/EventsTab.jsx+++ b/frontend/src/components/service-detail/EventsTab.jsx@@ -1,6 +1,14 @@-import { useEffect, useMemo, useState } from 'react';+import { useCallback, useEffect, useMemo, useState } from 'react';+import { History } from 'lucide-react';import { Button } from '@/components/ui/button';-import { Pill } from '@/components/ds';+import { DataTable, DataTableFooter, Drawer, Pill, SearchField } from '@/components/ds';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';+import { InfoList, InfoItem } from '../InfoList';import api from '../../services/api';import { useAuth } from '../../contexts/AuthContext';import { useDeployments } from '../../hooks/useDeployments';@@ -19,6 +27,66 @@ const DEPLOY_TONE = {// Env-var change action → tone (mirrors the history modal's Badge variants).const ENV_TONE = { created: 'green', updated: 'amber', deleted: 'red' };+// The three streams this timeline merges, in the order the Kind menu lists+// them. Declared rather than derived: an app that has never been deployed+// still has "Deploy" as a real kind, and a pick-list that hides it would+// suggest otherwise.+const KIND_LABELS = { deploy: 'Deploy', env: 'Config', audit: 'Audit' };+const KIND_ORDER = ['Deploy', 'Config', 'Audit'];++// What a cell shows when the row genuinely has nothing behind that column —+// an audit entry has no outcome, and env history records a user id rather than+// a name. It has to be a real value, not '': `ruleIsArmed` drops rules whose+// value is empty, so "status is ''" would filter nothing at all.+const NONE = '—';++const titleCase = (word) => (word ? word.charAt(0).toUpperCase() + word.slice(1) : '');++const NO_RULES = { match: 'all', rules: [] };+const NEWEST_FIRST = [{ key: 'time', direction: 'desc' }];++// Built-in saved views. Both slices ride axes the merged stream really has —+// which source an entry came from, and whether a deploy failed — and both are+// the questions the flat timeline buries once an admin's audit entries are+// interleaved with the deploys.+const EVENT_VIEWS = [+ {+ // Everything that happened to this service, newest first: the landing+ // view, and the one that says "nothing is filtered". Named for the+ // picker's own fallback heading ("All " + label) so the two agree.+ name: 'All events',+ state: { sorts: NEWEST_FIRST, hiddenKeys: [], columnFilters: NO_RULES },+ },+ {+ // The release history on its own. For an admin the audit feed is the+ // loudest of the three streams, and "when did this last ship" is the+ // question the tab exists to answer.+ name: 'Deployments',+ state: {+ sorts: NEWEST_FIRST,+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'ev1', field: 'kind', op: 'any', value: ['Deploy'] }],+ },+ },+ },+ {+ // Only deploys carry an outcome, so this is the one failure axis the+ // data supports. Empty on a service that has never broken, which is+ // exactly the answer it exists to give.+ name: 'Failed deploys',+ state: {+ sorts: NEWEST_FIRST,+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'ev2', field: 'status', op: 'any', value: ['Failed'] }],+ },+ },+ },+];+// One timeline for everything that happened to this service (the CRM record// timeline): deployments, environment-variable changes, and — for admins —// audit-log entries targeting this app. Newest first.@@ -27,158 +95,334 @@ const EventsTab = ({ appId }) => {const { isAdmin } = useAuth();const [envHistory, setEnvHistory] = useState([]);const [auditLogs, setAuditLogs] = useState([]);- const [expandedId, setExpandedId] = useState(null);+ const [search, setSearch] = useState('');+ const [deployDetail, setDeployDetail] = useState(null);- useEffect(() => {- let cancelled = false;+ const { sorts, setSorts } = useTableSort({+ defaultSorts: NEWEST_FIRST,+ storageKey: 'serverkit-table-svc-events-sort',+ });+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({+ storageKey: 'serverkit-table-svc-events-cols',+ });++ // The two supplemental streams. Split out of the effect so the "⋮" Refresh+ // reloads the whole table rather than only its deploys. `isStale` is how+ // the mount effect still discards a response that lands after the appId+ // changed; a manual refresh has nothing to go stale against and omits it.+ const loadSupplemental = useCallback((isStale = () => false) => {api.getEnvVarHistory(appId, 30)- .then((res) => { if (!cancelled) setEnvHistory(res?.history || []); })+ .then((res) => { if (!isStale()) setEnvHistory(res?.history || []); }).catch(() => { /* history is supplemental — the timeline works without it */ });if (isAdmin) {api.getActivityFeed({ target_type: 'app', target_id: appId, per_page: 50 })- .then((res) => { if (!cancelled) setAuditLogs(res?.logs || []); })+ .then((res) => { if (!isStale()) setAuditLogs(res?.logs || []); }).catch(() => { /* non-admin / feed unavailable — deploys still show */ });}- return () => { cancelled = true; };}, [appId, isAdmin]);- // Merge every source into one newest-first stream.+ useEffect(() => {+ let cancelled = false;+ loadSupplemental(() => cancelled);+ return () => { cancelled = true; };+ }, [loadSupplemental]);++ const refresh = useCallback(() => { reload(); loadSupplemental(); }, [reload, loadSupplemental]);++ // Merge every source into one newest-first stream of rows that all carry+ // the SAME shape — when / kind / text / status / actor — because a column+ // rule reads one accessor across every row, whatever produced it.const events = useMemo(() => {const items = [];deployments.forEach((deploy, idx) => items.push({+ // Indexed, not just `deploy.id`: the hook merges two deploy systems+ // that number their records independently, so their ids can collide.+ id: `deploy-${idx}-${deploy.id ?? ''}`,kind: 'deploy',+ at: deploy.timestamp,ts: new Date(deploy.timestamp).getTime() || 0,+ // getDeployStatus already labels a successful deploy "Live"; there+ // is no separate latest-success label to compute.+ status: getDeployStatus(deploy.status).label,+ tone: DEPLOY_TONE[deploy.status] || 'cyan',+ actor: deploy.trigger || NONE,+ text: deploy.commitMessage || deploy.version || `Deployment #${deployments.length - idx}`,deploy,- deployIndex: idx,}));envHistory.forEach((entry, idx) => items.push({+ id: `env-${entry.id ?? idx}-${entry.changed_at}`,kind: 'env',+ at: entry.changed_at,ts: new Date(entry.changed_at).getTime() || 0,+ status: titleCase(entry.action),+ tone: ENV_TONE[entry.action] || 'cyan',+ // The history row stores changed_by as a user id, never a name.+ actor: NONE,+ text: `${entry.key} ${entry.action}`,entry,- key: `env-${idx}-${entry.changed_at}`,}));auditLogs.forEach((log) => items.push({+ id: `audit-${log.id}`,kind: 'audit',+ at: log.created_at,ts: new Date(log.created_at).getTime() || 0,- log,+ status: NONE,+ tone: 'violet',+ actor: log.username || NONE,+ text: (log.action || '').replace(/[._]/g, ' '),+ detail: log.details?.name || '',}));return items.sort((a, b) => b.ts - a.ts);}, [deployments, envHistory, auditLogs]);+ const rows = useMemo(() => {+ const needle = search.trim().toLowerCase();+ if (!needle) return events;+ return events.filter((event) => (+ `${event.text} ${event.status} ${event.actor} ${KIND_LABELS[event.kind]}`+ .toLowerCase()+ .includes(needle)+ ));+ }, [events, search]);++ // Declared above the loading/empty guards: the chrome below is a hook, so+ // it cannot sit behind an early return.+ const columns = [+ {+ key: 'time',+ header: 'When',+ sortable: true,+ hideable: false,+ // Relative in the cell, exact on hover — "3h ago" is what you scan+ // for, the timestamp is what you quote in an incident.+ type: 'date',+ value: (event) => event.at || null,+ sortValue: (event) => event.ts,+ cellClassName: 'sk-cell-mono',+ render: (event) => (+ <span title={event.at ? new Date(event.at).toLocaleString() : ''}>+ {formatRelativeTime(event.at)}+ </span>+ ),+ },+ {+ key: 'kind',+ header: 'Kind',+ sortable: true,+ // Declared, not inferred: a young service with three entries of+ // three kinds fails the enum cardinality ratio and would fall back+ // to free text, which turns the pick-list into a typed fragment and+ // the "Deployments" view into a no-op.+ type: 'enum',+ enumOrder: KIND_ORDER,+ groupable: true,+ value: (event) => KIND_LABELS[event.kind],+ groupValue: (event) => KIND_LABELS[event.kind],+ sortValue: (event) => KIND_LABELS[event.kind],+ render: (event) => <span className="sk-tag">{KIND_LABELS[event.kind]}</span>,+ },+ {+ key: 'event',+ header: 'Event',+ sortable: true,+ hideable: false,+ // Commit subjects and audit actions: high cardinality, so a typed+ // fragment is the useful control rather than a pick-list.+ type: 'text',+ value: (event) => event.text,+ sortValue: (event) => event.text,+ cellClassName: 'sk-cell-name',+ render: (event) => {+ const sub = event.kind === 'deploy'+ ? [event.deploy.branch, event.deploy.duration && formatDuration(event.deploy.duration)]+ .filter(Boolean).join(' · ')+ : event.detail;+ return (+ <div className="events-tab__cell">+ <span className="events-tab__event-message">+ {event.kind === 'deploy' && event.deploy.commitSha && (+ <span className="events-tab__event-sha">+ {event.deploy.commitSha.substring(0, 7)}+ </span>+ )}+ {event.kind === 'env' ? <><b>{event.entry.key}</b> {event.entry.action}</> : event.text}+ </span>+ {sub && <span className="sk-cell-sub">{sub}</span>}+ </div>+ );+ },+ },+ {+ key: 'status',+ header: 'Status',+ sortable: true,+ // No enumOrder: the pick-list should offer the outcomes this+ // service actually produced, with their live counts, rather than+ // every outcome the three streams could theoretically emit.+ type: 'enum',+ value: (event) => event.status,+ sortValue: (event) => event.status,+ render: (event) => (event.status === NONE+ ? <span className="events-tab__none">{NONE}</span>+ : <Pill kind={event.tone}>{event.status}</Pill>),+ },+ {+ key: 'actor',+ header: 'Triggered by',+ sortable: true,+ // A person for an audit entry, a mechanism ('push', 'manual') for a+ // deploy — one column because the question is the same one.+ type: 'text',+ value: (event) => event.actor,+ sortValue: (event) => event.actor,+ cellClassName: 'sk-cell-mono',+ render: (event) => event.actor,+ },+ ];++ // The page-private half of a saved view: the search box narrows the merged+ // stream before any column rule sees it, so a view has to carry it.+ const pageState = useMemo(() => ({ search }), [search]);+ const applyPage = useCallback((saved) => {+ if (saved.search !== undefined) setSearch(saved.search);+ }, []);++ // Scoped to this tab, and namespaced: /services/:id renders one tab at a+ // time but the Env Vars tab on the same ROUTE hosts a chrome of its own, so+ // unscoped the two would read and write the same ?view=/?sort= and each+ // would arrive as the other's.+ const chrome = useTableChrome({+ columns,+ rows,+ viewPageKey: 'servicedetail-events',+ urlScope: 'events',+ builtinViews: EVENT_VIEWS,+ noun: 'events',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ pageState,+ applyPage,+ });+if (loading) {- return <EmptyState loading title="Loading activity..." />;+ return <EmptyState loading loadingVariant="table" title="Loading activity..." />;}if (error) {return (- <div className="events-tab__empty">- <h3>Failed to load activity</h3>- <p>{error}</p>- <Button variant="outline" onClick={reload}>Retry</Button>- </div>+ <EmptyState+ icon={History}+ title="Failed to load activity"+ description={error}+ action={<Button variant="outline" onClick={refresh}>Retry</Button>}+ />);}if (events.length === 0) {return (- <div className="events-tab__empty">- <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" style={{ opacity: 0.4 }}>- <circle cx="12" cy="12" r="10"/>- <polyline points="12 6 12 12 16 14"/>- </svg>- <h3>No activity yet</h3>- <p>Deployments, config changes and edits to this service will show up here.</p>- </div>+ <EmptyState+ icon={History}+ title="No activity yet"+ description="Deployments, config changes and edits to this service will show up here."+ />);}- const latestSuccessIdx = deployments.findIndex((d) => d.status === 'success');-return (<div className="events-tab">- <div className="events-tab__header">- <h3 className="svc-eyebrow">- Activity <span className="svc-eyebrow__count">· {events.length}</span>- </h3>- <Button variant="outline" size="sm" onClick={reload}>Refresh</Button>- </div>-- <div className="events-tab__timeline">- {events.map((event) => {- if (event.kind !== 'deploy') {- const isEnv = event.kind === 'env';- const tone = isEnv ? (ENV_TONE[event.entry.action] || 'cyan') : 'violet';- const text = isEnv- ? <><b>{event.entry.key}</b> {event.entry.action}</>- : <>{(event.log.action || '').replace(/[._]/g, ' ')}</>;- const detail = !isEnv && event.log.details?.name- ? <span>{event.log.details.name}</span>- : null;- return (- <div- key={isEnv ? event.key : `audit-${event.log.id}`}- className="events-tab__event events-tab__event--compact"- >- <div className={`events-tab__event-status events-tab__event-status--${tone}`} />- <div className="events-tab__event-body">- <div className="events-tab__event-header">- <span className="events-tab__event-message">{text}</span>- <Pill kind={tone}>{isEnv ? 'config' : 'audit'}</Pill>- </div>- <div className="events-tab__event-meta">- {detail}- <span>{formatRelativeTime(isEnv ? event.entry.changed_at : event.log.created_at)}</span>- </div>- </div>- </div>- );- }-- const deploy = event.deploy;- const statusInfo = getDeployStatus(deploy.status);- const tone = DEPLOY_TONE[deploy.status] || 'cyan';- const isExpanded = expandedId === deploy.id;- const isLatest = event.deployIndex === latestSuccessIdx;-- return (- <div- key={`deploy-${deploy.id}`}- className={`events-tab__event ${isExpanded ? 'events-tab__event--expanded' : ''}`}- onClick={() => setExpandedId(isExpanded ? null : deploy.id)}- >- <div className={`events-tab__event-status events-tab__event-status--${tone}`} />- <div className="events-tab__event-body">- <div className="events-tab__event-header">- <div className="events-tab__event-commit">- {deploy.commitSha && (- <span className="events-tab__event-sha">- {deploy.commitSha.substring(0, 7)}- </span>- )}- <span className="events-tab__event-message">- {deploy.commitMessage || deploy.version || `Deployment #${deployments.length - event.deployIndex}`}- </span>- </div>- <Pill kind={isLatest ? 'green' : tone}>- {isLatest ? 'Live' : statusInfo.label}- </Pill>- </div>- <div className="events-tab__event-meta">- {deploy.duration && <span>{formatDuration(deploy.duration)}</span>}- {deploy.trigger && <span>{deploy.trigger}</span>}- {deploy.branch && <span>{deploy.branch}</span>}- <span>{formatRelativeTime(deploy.timestamp)}</span>- </div>- {isExpanded && deploy.logs && (- <div className="events-tab__event-logs">- <pre>{deploy.logs}</pre>- </div>- )}+ {/* One row of chrome: the view name is this tab's heading and the+ search, the filter and the "⋮" ride the same line. ServiceDetail+ owns the page top bar, so the chrome stays inline here rather+ than being hoisted (see useTopbarChrome). Refresh is not+ repeated as a button — it is in the "⋮". */}+ <GridViewPicker+ views={chrome.views}+ label="events"+ onCreate={chrome.createView}+ actions={(+ <>+ <SearchField+ value={search}+ onSearch={setSearch}+ placeholder="Search activity…"+ />+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={refresh} />+ </>+ )}+ />++ <GridChips {...chrome.chipProps} />++ <DataTable+ columns={chrome.columns}+ data={rows}+ keyField="id"+ sorts={sorts}+ onSortsChange={setSorts}+ {...chrome.tableProps}+ // Only a deploy has anything more to show; config and audit+ // rows are already fully rendered, exactly as the old timeline+ // made only deploy entries expandable.+ onRowClick={(event) => { if (event.kind === 'deploy') setDeployDetail(event); }}+ rowClassName={(event) => (event.kind === 'deploy' ? '' : 'is-static')}+ tableClassName="data-table"+ emptyTitle="No activity matches your search."+ emptyMessage=""+ footer={(+ <DataTableFooter+ // DataTable applies the column rules itself, so the+ // shown count comes from the chrome — `events` is only+ // ever the whole merged stream.+ shown={chrome.shownCount}+ total={events.length}+ noun="event"+ />+ )}+ />++ <GridFilterDrawer {...chrome.drawerProps} />++ {/* The old timeline expanded a deploy row in place to show its+ build log. A row cannot expand inside a shared table, so the+ same log opens in the app's one drawer instead. */}+ <Drawer+ open={!!deployDetail}+ onOpenChange={(open) => { if (!open) setDeployDetail(null); }}+ title={deployDetail?.text || 'Deployment'}+ subtitle={deployDetail?.at ? new Date(deployDetail.at).toLocaleString() : ''}+ >+ {deployDetail?.deploy && (+ <>+ <InfoList>+ <InfoItem label="Status" value={deployDetail.status} />+ <InfoItem label="Triggered by" value={deployDetail.actor} />+ {deployDetail.deploy.branch && (+ <InfoItem label="Branch" value={deployDetail.deploy.branch} mono />+ )}+ {deployDetail.deploy.commitSha && (+ <InfoItem label="Commit" value={deployDetail.deploy.commitSha} mono />+ )}+ {deployDetail.deploy.duration && (+ <InfoItem label="Duration" value={formatDuration(deployDetail.deploy.duration)} />+ )}+ </InfoList>+ {deployDetail.deploy.logs ? (+ <div className="events-tab__event-logs">+ <pre>{deployDetail.deploy.logs}</pre></div>- </div>- );- })}- </div>+ ) : (+ <p className="events-tab__none">No build log was captured for this deployment.</p>+ )}+ </>+ )}+ </Drawer></div>);};diff --git a/frontend/src/components/settings/InvitationsTab.jsx b/frontend/src/components/settings/InvitationsTab.jsxindex ca26c559..ef6a6cc2 100644--- a/frontend/src/components/settings/InvitationsTab.jsx+++ b/frontend/src/components/settings/InvitationsTab.jsx@@ -3,7 +3,7 @@ import api from '../../services/api';import InviteModal from './InviteModal';import { Button } from '@/components/ui/button';import { Badge } from '@/components/ui/badge';-import { DataTable, ListToolbar } from '@/components/ds';+import { DataTable } from '@/components/ds';import {useTableChrome, GridViewPicker, GridChips, GridFilterButton,GridToolsMenu, GridFilterDrawer,@@ -280,6 +280,18 @@ const InvitationsTab = () => {onCreate={chrome.createView}actions={(<>+ {/* Same shape as the users table above it — the two sit+ on one screen, so the primary action has to land in+ the same place on both lines. */}+ <Button variant="default" size="sm" onClick={() => setShowInviteModal(true)}>+ <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2">+ <path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>+ <circle cx="8.5" cy="7" r="4"/>+ <line x1="20" y1="8" x2="20" y2="14"/>+ <line x1="23" y1="11" x2="17" y2="11"/>+ </svg>+ Invite User+ </Button><GridFilterButtoncount={chrome.filterCount}onClick={() => chrome.setDrawerOpen(true)}@@ -288,17 +300,6 @@ const InvitationsTab = () => {</>)}/>- <ListToolbar>- <Button variant="default" size="sm" onClick={() => setShowInviteModal(true)}>- <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>- <circle cx="8.5" cy="7" r="4"/>- <line x1="20" y1="8" x2="20" y2="14"/>- <line x1="23" y1="11" x2="17" y2="11"/>- </svg>- Invite User- </Button>- </ListToolbar><GridChips {...chrome.chipProps} />diff --git a/frontend/src/components/settings/RecycleBinTab.jsx b/frontend/src/components/settings/RecycleBinTab.jsxindex 90df8fc9..f46e7236 100644--- a/frontend/src/components/settings/RecycleBinTab.jsx+++ b/frontend/src/components/settings/RecycleBinTab.jsx@@ -5,7 +5,7 @@ import { useToast } from '@/contexts/ToastContext';import { useAuth } from '@/contexts/AuthContext';import { Button } from '@/components/ui/button';import EmptyState from '@/components/EmptyState';-import { SegControl, Pill, DataTable, ListToolbar } from '@/components/ds';+import { Pill, DataTable, DataTableFooter } from '@/components/ds';import {useTableChrome, GridViewPicker, GridChips, GridFilterButton,GridToolsMenu, GridFilterDrawer,@@ -16,12 +16,10 @@ import ConfirmDialog from '@/components/ConfirmDialog';// Built-in saved views. Neither one names a `kind`: the registry decides what// lands here, so a preset that spelled out 'domain' would be a list this file-// otherwise never hard-codes — and it would duplicate the type SegControl-// anyway. Both views work on whatever the server registered.-//-// `page.kind` is spelled out on both. The SegControl is part of the captured-// state, so a preset that left it out would compare unequal to the live state-// the instant it was applied and the picker would read "Unsaved" every time.+// otherwise never hard-codes, and it would go stale the day a new model becomes+// restorable. Narrowing to one type is the Type column's own menu — it offers+// exactly the values present, with live counts, and combines with everything+// else. These two answer the questions no column menu can.const RECYCLEBIN_VIEWS = [{// Oldest deletion first — the rows closest to being reaped by the@@ -33,20 +31,18 @@ const RECYCLEBIN_VIEWS = [hiddenKeys: [],groupBy: null,columnFilters: { match: 'all', rules: [] },- page: { kind: 'all' },},},{- // No rules either: everything, bucketed by what it is. The group- // headers carry the per-type counts, so this answers "what kind of- // thing have we been deleting" without touching the SegControl.+ // No rules: everything, bucketed by what it is. The group headers carry+ // the per-type counts, so this answers "what kind of thing have we been+ // deleting" without a fixed row of chips to keep in sync.name: 'By type',state: {sorts: [{ key: 'deleted_at', direction: 'desc' }],hiddenKeys: [],groupBy: 'kind',columnFilters: { match: 'all', rules: [] },- page: { kind: 'all' },},},];@@ -58,9 +54,7 @@ export default function RecycleBinTab() {const toast = useToast();const { isAdmin } = useAuth();const [items, setItems] = useState([]);- const [kinds, setKinds] = useState([]);const [retentionDays, setRetentionDays] = useState(30);- const [kind, setKind] = useState('all');const [loading, setLoading] = useState(true);const [busyId, setBusyId] = useState(null);const [purgeTarget, setPurgeTarget] = useState(null);@@ -83,7 +77,6 @@ export default function RecycleBinTab() {setLoading(true);const data = await api.getRecycleBin();setItems(data.items || []);- setKinds(data.kinds || []);setRetentionDays(data.retention_days ?? 30);} catch (err) {toast.error(err.message || 'Could not load the recycle bin');@@ -128,20 +121,6 @@ export default function RecycleBinTab() {}};- const shown = useMemo(- () => (kind === 'all' ? items : items.filter((i) => i.kind === kind)),- [items, kind],- );-- const filters = useMemo(() => [- { value: 'all', label: 'All', count: items.length },- ...kinds.map((k) => ({- value: k,- label: `${k.replace(/_/g, ' ')}s`,- count: items.filter((i) => i.kind === k).length,- })),- ], [items, kinds]);-const columns = useMemo(() => [{key: 'label',@@ -228,15 +207,12 @@ export default function RecycleBinTab() {], [busyId, isAdmin, retentionDays]); // eslint-disable-line react-hooks/exhaustive-deps// Single table on this tab, so no `urlScope` — the shareable link keeps- // the plain `?view=` every other single-table page produces.- //- // The type SegControl goes in `pageState`, so saving a view remembers- // which type you had picked. A preset that omits `kind` must land back on- // 'all': the envelope's page bag is `{}` there, and `undefined` would- // leave the SegControl with no selected option.+ // the plain `?view=` every other single-table page produces. No `pageState`+ // either: everything this page can narrow by now lives in the envelope's+ // shared keys, so a view saved here is the same shape as anywhere else.const chrome = useTableChrome({columns,- rows: shown,+ rows: items,viewPageKey: 'settings-recyclebin',builtinViews: RECYCLEBIN_VIEWS,noun: 'items',@@ -246,8 +222,6 @@ export default function RecycleBinTab() {setHiddenKeys,groupBy,setGroupBy,- pageState: { kind },- applyPage: (p) => setKind(p.kind || 'all'),});return (@@ -293,26 +267,25 @@ export default function RecycleBinTab() {</>)}/>- {/* The toolbar survives only for the type quick-filter. The- retention window is already spelled out in the hint- above, so repeating it here bought nothing. */}- <ListToolbar- filters={<SegControl value={kind} onChange={setKind} options={filters} />}- /><GridChips {...chrome.chipProps} /><DataTablecolumns={chrome.columns}- data={shown}+ data={items}keyField={rowKey}sorts={sorts}onSortsChange={setSorts}{...chrome.tableProps}groupBy={groupBy}onGroupByChange={setGroupBy}- emptyTitle="Nothing of this type"- emptyMessage="Try another type."+ footer={(+ <DataTableFooter+ shown={chrome.shownCount}+ total={items.length}+ noun="item"+ />+ )}/></>)}diff --git a/frontend/src/components/settings/UsersTab.jsx b/frontend/src/components/settings/UsersTab.jsxindex 96a35933..1259eae7 100644--- a/frontend/src/components/settings/UsersTab.jsx+++ b/frontend/src/components/settings/UsersTab.jsx@@ -7,7 +7,7 @@ import LoginLinksSection from './LoginLinksSection';import Modal from '../Modal';import { Button } from '@/components/ui/button';import { Badge } from '@/components/ui/badge';-import { DataTable, ListToolbar } from '@/components/ds';+import { DataTable } from '@/components/ds';import {useTableChrome, GridViewPicker, GridChips, GridFilterButton,GridToolsMenu, GridFilterDrawer,@@ -363,6 +363,17 @@ const UsersTab = () => {onCreate={chrome.createView}actions={(<>+ {/* Add User rides the chrome line rather than a bar of+ its own: that bar held one button, and a table gets+ ONE row of chrome. Primary action first, then the+ icons that act on what you are looking at. */}+ <Button variant="default" size="sm" onClick={handleAddUser}>+ <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2">+ <line x1="12" y1="5" x2="12" y2="19"/>+ <line x1="5" y1="12" x2="19" y2="12"/>+ </svg>+ Add User+ </Button><GridFilterButtoncount={chrome.filterCount}onClick={() => chrome.setDrawerOpen(true)}@@ -371,15 +382,6 @@ const UsersTab = () => {</>)}/>- <ListToolbar>- <Button variant="default" onClick={handleAddUser}>- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">- <line x1="12" y1="5" x2="12" y2="19"/>- <line x1="5" y1="12" x2="19" y2="12"/>- </svg>- Add User- </Button>- </ListToolbar><GridChips {...chrome.chipProps} />diff --git a/frontend/src/hooks/useTopbarActions.js b/frontend/src/hooks/useTopbarActions.jsindex cb594cda..096205c9 100644--- a/frontend/src/hooks/useTopbarActions.js+++ b/frontend/src/hooks/useTopbarActions.js@@ -68,6 +68,14 @@ export function useTopbarChrome(chrome, { enabled = true } = {}) {return {hosted,portal: hosted && slot ? createPortal(node, slot) : null,+ // Pass straight to GridViewPicker's `actions`. Deriving it here rather+ // than leaving each caller to write `hosted ? null : node` is the point:+ // every one of the eight pages that hoists its chrome destructured only+ // `portal` and forgot the fallback, so outside a tab group the filter+ // button and "⋮" would not have gone inline — they would have gone+ // nowhere. Null when the top bar took it, and null when `enabled` is+ // false, which means "this table is not on screen, render nothing".+ actions: hosted || !enabled ? null : node,};}diff --git a/frontend/src/pages/Backups.jsx b/frontend/src/pages/Backups.jsxindex 83f1a253..1abadde6 100644--- a/frontend/src/pages/Backups.jsx+++ b/frontend/src/pages/Backups.jsx@@ -729,7 +729,7 @@ const Backups = () => {// The chrome acts on the snapshot table, so it is only published while that// section is on screen — the other tabs are forms and a KPI band, with// nothing to filter, sort or export.- const { portal: topbarChrome } = useTopbarChrome(+ const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome(<><GridFilterButtoncount={chrome.filterCount}@@ -781,7 +781,9 @@ const Backups = () => {views={chrome.views}label="snapshots"onCreate={chrome.createView}- />++ actions={chromeActions}+ /><GridChips {...chrome.chipProps} />diff --git a/frontend/src/pages/FleetProxy.jsx b/frontend/src/pages/FleetProxy.jsxindex ce18b7b3..a7fb1ec0 100644--- a/frontend/src/pages/FleetProxy.jsx+++ b/frontend/src/pages/FleetProxy.jsx@@ -379,7 +379,7 @@ const FleetProxy = () => {// Filter + "⋮" ride in the shared Servers top bar. The toolbar they used to// sit in held nothing else but a re-count of the table underneath it.- const { portal: topbarChrome } = useTopbarChrome(+ const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome(<><GridFilterButtoncount={chrome.filterCount}@@ -403,7 +403,9 @@ const FleetProxy = () => {views={chrome.views}label="servers"onCreate={chrome.createView}- />++ actions={chromeActions}+ /><GridChips {...chrome.chipProps} />diff --git a/frontend/src/pages/Incidents.jsx b/frontend/src/pages/Incidents.jsxindex f597d261..4f1f7252 100644--- a/frontend/src/pages/Incidents.jsx+++ b/frontend/src/pages/Incidents.jsx@@ -1,20 +1,20 @@// Incidents — one place for "something is wrong right now".//-// This absorbed the old Alerts tab. A CPU threshold crossing on a host and a-// monitor going down are the same question asked of two different subjects, and-// splitting them across two tabs is what made alerting look like it only ever-// described the panel's own machine. Host threshold alerting is unchanged —-// same endpoints, same ack/check actions — it just renders in this timeline-// alongside monitor outages.+// This absorbed the old Alerts tab, and then the Fleet Alerts panel that used+// to sit directly under this table with a second table and an+// Active/Acknowledged/Resolved segment row of its own. A CPU threshold crossing+// on a host and a monitor going down are the same question asked of two+// different subjects; a threshold crossing on a PAIRED host is that same+// question a third time. All three are rows here, told apart by the Source+// column, and every bucket the segment offered is a saved view below.import { useCallback, useEffect, useMemo, useState } from 'react';import { Link } from 'react-router-dom';import {- AlertTriangle, CheckCircle2, ChevronRight, Radar, RefreshCw, Siren,+ AlertTriangle, CheckCircle2, ChevronRight, Eye, Radar, RefreshCw, Siren,} from 'lucide-react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';import EmptyState from '../components/EmptyState';-import FleetAlertsPanel from '../components/monitoring/FleetAlertsPanel';import { DataTable, DataTableFooter, Drawer, Pill, SearchField } from '@/components/ds';import {useTableChrome, GridViewPicker, GridChips, GridFilterButton,@@ -25,15 +25,18 @@ import { Input } from '@/components/ui/input';import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';import { useTopbarActions, useTopbarChrome } from '@/hooks/useTopbarActions';+import { METRIC_LABELS } from '../components/monitoring/fleetMetrics';import { IMPACT_TONE, INCIDENT_STATES } from '../components/monitoring/monitorShared';-// Built-in views. This page used to carry BOTH old affordances at once — a KPI-// band whose tiles set a filter, and an Active/Resolved/All segment row — while-// having no column menu, no search and no saved views at all. Every bucket-// either of them offered is a rule here now.+// Built-in views. This page used to carry THREE old affordances at once — a KPI+// band whose tiles set a filter, an Active/Resolved/All segment row, and the+// fleet panel's own Active/Acknowledged/Resolved segment — while having no+// column menu, no search and no saved views at all. Every bucket any of them+// offered is a rule here now.//-// `resolved` is the axis both sources share: an incident is resolved when its-// status says so, a host alert when it is history rather than firing.+// `resolved` is the axis all three sources share: an incident is resolved when+// its status says so, a host alert when it is history rather than firing, a+// fleet alert when someone closed it out.const NO_RULES = { match: 'all', rules: [] };const RESOLVED_IS = (value) => ({match: 'all',@@ -49,6 +52,21 @@ const BUILTIN_VIEWS = [columnFilters: RESOLVED_IS(false), page: { search: '' },},},+ {+ // The fleet segment's middle bucket, and the only one Active/Resolved+ // could not already express. Acking does not fix anything, so these+ // rows stay in Active too — the segment's exclusive tabs are what made+ // an acknowledged alert look handled.+ name: 'Acknowledged',+ state: {+ sorts: [{ key: 'when', direction: 'desc' }], hiddenKeys: ['kind'],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'ak', field: 'state', op: 'any', value: ['acknowledged'] }],+ },+ page: { search: '' },+ },+ },{name: 'Resolved',state: {@@ -100,6 +118,9 @@ const STATE_TONE = {const SEVERITY_TONE = { critical: 'red', warning: 'amber', info: 'cyan' };+// The fleet alert lifecycle, tinted exactly as the deleted panel tinted it.+const ALERT_STATUS_TONE = { active: 'red', acknowledged: 'amber', resolved: 'green' };+function formatWhen(iso) {if (!iso) return 'unknown';const date = new Date(iso);@@ -118,12 +139,12 @@ export default function Incidents() {const [incidents, setIncidents] = useState([]);const [activeAlerts, setActiveAlerts] = useState([]);const [alertHistory, setAlertHistory] = useState([]);+ const [fleetAlerts, setFleetAlerts] = useState([]);const [monitors, setMonitors] = useState([]);const [loading, setLoading] = useState(true);const [selected, setSelected] = useState(null);const [note, setNote] = useState('');const [checking, setChecking] = useState(false);- const [hasFleet, setHasFleet] = useState(false);const { sorts, setSorts } = useTableSort({defaultSorts: [{ key: 'when', direction: 'desc' }],storageKey: 'serverkit-table-incidents-sort',@@ -134,20 +155,20 @@ export default function Incidents() {const load = useCallback(async () => {try {- const [incidentsRes, statusRes, historyRes, monitorsRes, serversRes] = await Promise.all([+ const [incidentsRes, statusRes, historyRes, monitorsRes, fleetRes] = await Promise.all([api.getIncidents({ state: 'all', limit: 200 }).catch(() => null),api.getMonitoringStatus().catch(() => null),api.getAlertHistory(50).catch(() => null),api.getMonitors().catch(() => null),- api.getServers().catch(() => null),+ // Every status, deliberately: the Active/Acknowledged/Resolved+ // split is a saved view now, not a server-side query.+ api.getFleetAlerts({ limit: 200 }).catch(() => null),]);setIncidents(incidentsRes?.incidents || []);setActiveAlerts(statusRes?.active_alerts || []);setAlertHistory(historyRes?.alerts || []);setMonitors(monitorsRes?.monitors || []);- // The fleet panel is only meaningful once there are paired servers.- const servers = Array.isArray(serversRes) ? serversRes : (serversRes?.servers || []);- setHasFleet(servers.length > 0);+ setFleetAlerts(Array.isArray(fleetRes) ? fleetRes : []);} catch {// Keep the last good list rather than blanking the page.} finally {@@ -192,32 +213,46 @@ export default function Incidents() {[monitors],);- // One list, two sources. Host alerts have no lifecycle of their own — they+ // One list, four sources. Host alerts have no lifecycle of their own — they// are either firing or historical — so they map onto the same active/resolved- // axis the incidents use.+ // axis the incidents use. Every row normalises `metric`/`value`/`threshold`+ // and a one-line `detail`, so the cells and the drawer read the merged item+ // rather than reaching back into whichever payload it came from.const items = useMemo(() => {- const fromIncidents = incidents.map((incident) => ({- kind: 'incident',- key: `incident-${incident.id}`,- id: incident.id,- title: incident.title,- subject: monitorsById[incident.component_id]?.name || 'Service',- state: incident.status,- tone: STATE_TONE[incident.status] || 'gray',- impact: incident.impact,- when: incident.created_at,- resolved: incident.status === 'resolved',- raw: incident,- }));+ const fromIncidents = incidents.map((incident) => {+ const subject = monitorsById[incident.component_id]?.name || 'Service';+ return {+ kind: 'incident',+ key: `incident-${incident.id}`,+ id: incident.id,+ title: incident.title,+ subject,+ detail: subject,+ state: incident.status,+ tone: STATE_TONE[incident.status] || 'gray',+ impact: incident.impact,+ when: incident.created_at,+ resolved: incident.status === 'resolved',+ raw: incident,+ };+ });++ const hostDetail = (alert) => (alert.type+ ? `${alert.type} ${formatValue(alert.value)} / ${alert.threshold}`+ : 'This server');const fromActive = activeAlerts.map((alert, index) => ({kind: 'alert',key: `active-${alert.type}-${index}`,title: alert.message,subject: 'This server',+ detail: hostDetail(alert),state: 'firing',tone: 'red',impact: alert.severity,+ metric: alert.type,+ value: alert.value,+ threshold: alert.threshold,when: alert.timestamp,resolved: false,raw: alert,@@ -228,17 +263,49 @@ export default function Incidents() {key: `history-${alert.timestamp || index}-${index}`,title: alert.message,subject: 'This server',+ detail: hostDetail(alert),state: alert.severity,tone: SEVERITY_TONE[alert.severity] || 'gray',impact: alert.severity,+ metric: alert.type,+ value: alert.value,+ threshold: alert.threshold,when: alert.timestamp,resolved: true,raw: alert,}));- return [...fromActive, ...fromIncidents, ...fromHistory]+ // A threshold crossing on a PAIRED host — the rows the Fleet Alerts+ // panel used to own, mapped onto these columns: server -> subject,+ // metric/value/threshold -> what happened, severity -> impact,+ // status -> state. `alertId` is what marks a row as actionable; the two+ // sources above describe the panel's own box and have no server-side+ // lifecycle to ack or resolve.+ const fromFleet = fleetAlerts.map((alert) => {+ const metric = METRIC_LABELS[alert.metric] || alert.metric;+ const subject = alert.server_name || 'Unknown server';+ return {+ kind: 'alert',+ key: `fleet-${alert.id}`,+ alertId: alert.id,+ title: `${metric} over limit on ${subject}`,+ subject,+ detail: `${metric} ${formatValue(alert.value)} / ${alert.threshold}`,+ state: alert.status,+ tone: ALERT_STATUS_TONE[alert.status] || 'gray',+ impact: alert.severity,+ metric,+ value: alert.value,+ threshold: alert.threshold,+ when: alert.created_at,+ resolved: alert.status === 'resolved',+ raw: alert,+ };+ });++ return [...fromActive, ...fromFleet, ...fromIncidents, ...fromHistory].sort((a, b) => new Date(b.when || 0) - new Date(a.when || 0));- }, [incidents, activeAlerts, alertHistory, monitorsById]);+ }, [incidents, activeAlerts, alertHistory, fleetAlerts, monitorsById]);// Search only. The active/resolved split used to live here as a segment// filter; it is a column rule now, applied inside the table.@@ -250,6 +317,20 @@ export default function Incidents() {));}, [items, search]);+ // Ack / Resolve, carried over from the deleted panel. Reloading rather than+ // patching the row in place keeps the alert's status honest even when the+ // scheduler resolved it a second earlier.+ const onAlertAction = useCallback(async (item, action) => {+ try {+ await (action === 'ack'+ ? api.acknowledgeFleetAlert(item.alertId)+ : api.resolveFleetAlert(item.alertId));+ await load();+ } catch {+ toast.error(`Failed to ${action === 'ack' ? 'acknowledge' : 'resolve'} alert`);+ }+ }, [load, toast]);+const onPostUpdate = async (state) => {if (!selected || selected.kind !== 'incident') return;try {@@ -281,11 +362,7 @@ export default function Incidents() {<span className={`incident-row__sev incident-row__sev--${item.tone}`} /><span><div>{item.title}</div>- <div className="sk-cell-sub">- {item.kind === 'alert' && item.raw.type- ? `${item.raw.type} ${formatValue(item.raw.value)} / ${item.raw.threshold}`- : item.subject}- </div>+ <div className="sk-cell-sub">{item.detail}</div></span></div>),@@ -306,7 +383,7 @@ export default function Incidents() {value: (item) => item.subject || '',},{- // The axis both sources share, and what Active/Resolved filter on.+ // The axis every source shares, and what Active/Resolved filter on.key: 'resolved',header: 'Resolved',sortable: true,@@ -342,13 +419,45 @@ export default function Incidents() {render: (item) => formatWhen(item.when),},{+ // Ack / Resolve ride in the trailing cell rather than a column of+ // their own: only a fleet alert carries a lifecycle to act on, so+ // every other row would show an empty column forever.key: 'open',header: '',sortable: false,hideable: false,- render: () => <ChevronRight size={16} className="incident-row__chev" />,+ cellClassName: 'mon-row-actions',+ render: (item) => (+ <>+ {item.alertId && !item.resolved && (+ <span+ className="incident-row__acts"+ role="presentation"+ onClick={(e) => e.stopPropagation()}+ >+ {item.state === 'active' && (+ <Button+ variant="ghost"+ size="sm"+ onClick={() => onAlertAction(item, 'ack')}+ >+ <Eye size={14} /> Ack+ </Button>+ )}+ <Button+ variant="ghost"+ size="sm"+ onClick={() => onAlertAction(item, 'resolve')}+ >+ <CheckCircle2 size={14} /> Resolve+ </Button>+ </span>+ )}+ <ChevronRight size={16} className="incident-row__chev" />+ </>+ ),},- ], []);+ ], [onAlertAction]);const viewPageState = useMemo(() => ({ search }), [search]);const applyViewPageState = useCallback((saved) => {@@ -369,15 +478,16 @@ export default function Incidents() {applyPage: applyViewPageState,});- const { portal: topbarChrome } = useTopbarChrome(+ const tableChrome = (<><GridFilterButtoncount={chrome.filterCount}onClick={() => chrome.setDrawerOpen(true)}/><GridToolsMenu {...chrome.toolsProps} onRefresh={load} />- </>,+ </>);+ const { hosted, portal: topbarChrome } = useTopbarChrome(tableChrome);if (loading) {return (@@ -398,6 +508,7 @@ export default function Incidents() {views={chrome.views}label="incidents"onCreate={chrome.createView}+ actions={hosted ? null : tableChrome}/><GridChips {...chrome.chipProps} />@@ -423,7 +534,7 @@ export default function Incidents() {emptyMessage=""footer={(<DataTableFooter- shown={shown.length}+ shown={chrome.shownCount}total={items.length}noun="incident"/>@@ -432,11 +543,6 @@ export default function Incidents() {</div>)}- {/* Per-server threshold alerts across the fleet: their own system- with its own ack/resolve lifecycle, so they keep their own panel- rather than being flattened into the timeline above. */}- {hasFleet && <FleetAlertsPanel />}-<Draweropen={Boolean(selected)}onOpenChange={(open) => { if (!open) { setSelected(null); setNote(''); } }}@@ -513,9 +619,9 @@ export default function Incidents() {</Pill></div><dl className="mon-inforows">- <div><dt>Metric</dt><dd>{selected.raw.type || '—'}</dd></div>- <div><dt>Reading</dt><dd>{formatValue(selected.raw.value)}</dd></div>- <div><dt>Limit</dt><dd>{selected.raw.threshold ?? '—'}</dd></div>+ <div><dt>Metric</dt><dd>{selected.metric || '—'}</dd></div>+ <div><dt>Reading</dt><dd>{formatValue(selected.value)}</dd></div>+ <div><dt>Limit</dt><dd>{selected.threshold ?? '—'}</dd></div><div><dt>When</dt><dd>{formatWhen(selected.when)}</dd></div></dl><p className="mon-panel-hint">diff --git a/frontend/src/pages/Jobs.jsx b/frontend/src/pages/Jobs.jsxindex 0766f372..1063e3ac 100644--- a/frontend/src/pages/Jobs.jsx+++ b/frontend/src/pages/Jobs.jsx@@ -392,7 +392,7 @@ export default function Jobs() {// SERVER query drawer, which sees rows this client never loaded, and a// second one would open a weaker drawer over the loaded page only. Gated on// the Activity tab because the chrome describes that table, not Scheduled.- const { portal: topbarChrome } = useTopbarChrome(+ const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome(<GridToolsMenu {...chrome.toolsProps} onRefresh={load} />, { enabled: isAdmin && !scheduledView },);@@ -489,7 +489,9 @@ export default function Jobs() {views={chrome.views}label="jobs"onCreate={chrome.createView}- />++ actions={chromeActions}+ /><GridChips {...chrome.chipProps} />diff --git a/frontend/src/pages/Monitors.jsx b/frontend/src/pages/Monitors.jsxindex b297530b..ce5c0871 100644--- a/frontend/src/pages/Monitors.jsx+++ b/frontend/src/pages/Monitors.jsx@@ -449,7 +449,7 @@ export default function Monitors() {// page has exactly ONE filter button and it is the top bar's, which opens// the SERVER query drawer. Column rules come from each column's own header// menu and show up in the chips.- const { portal: topbarChrome } = useTopbarChrome(+ const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome(<GridToolsMenu {...chrome.toolsProps} onRefresh={load} />,);@@ -469,6 +469,8 @@ export default function Monitors() {views={chrome.views}label="monitors"onCreate={chrome.createView}++ actions={chromeActions}/><GridChips {...chrome.chipProps} />diff --git a/frontend/src/pages/SSLCertificates.jsx b/frontend/src/pages/SSLCertificates.jsxindex 74ac62db..e7134c3e 100644--- a/frontend/src/pages/SSLCertificates.jsx+++ b/frontend/src/pages/SSLCertificates.jsx@@ -1,23 +1,92 @@-import { useState, useEffect } from 'react';+import { useState, useEffect, useMemo } from 'react';import {- ShieldCheck, ShieldOff, RefreshCw, Plus, Trash2,- Lock, Clock, Globe, CheckCircle, AlertTriangle,- Settings, Download, Upload+ ShieldCheck, RefreshCw, Plus, Lock, MoreVertical,+ Settings, Download, Upload,} from 'lucide-react';import api from '../services/api';import Modal from '@/components/Modal';-import { Pill } from '@/components/ds';+import { Pill, SearchField } from '@/components/ds';+import ResourceListPage from '../components/layouts/ResourceListPage';import { useTopbarActions } from '@/hooks/useTopbarActions';import { useToast } from '../contexts/ToastContext';import { useConfirm } from '../hooks/useConfirm';-import EmptyState from '../components/EmptyState';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import { Checkbox } from '@/components/ui/checkbox';-import { Skeleton } from '@/components/Skeleton';-import SkeletonBoundary from '@/components/SkeletonBoundary';-import { useSelfCapturedBones } from '@/hooks/useSelfCapturedBones';+import {+ DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger,+} from '@/components/ui/dropdown-menu';+import { formatExpiry } from '../utils/expiry';++const DAY = 86400000;++// The same horizon the backend's `openssl x509 -checkend 2592000` uses, so the+// Status column and /ssl/status can never disagree about what "expiring" means.+const EXPIRING_DAYS = 30;++const STATE_KIND = {+ valid: 'green',+ expiring: 'amber',+ expired: 'red',+ unknown: 'gray',+};++// Neither expiry string the API returns is ISO-8601: certbot prints+// "2024-03-15 12:00:00+00:00" and the custom-cert walker strftimes+// "%Y-%m-%d %H:%M:%S%z" ("+0000"). Normalise once, here, or every Date the+// column builds is browser-dependent.+function certExpiryIso(raw) {+ if (!raw) return null;+ const iso = String(raw).trim().replace(' ', 'T').replace(/([+-]\d{2})(\d{2})$/, '$1:$2');+ return Number.isNaN(new Date(iso).getTime()) ? null : iso;+}++// A certbot cert carries no issuer field — certbot is only ever pointed at its+// default ACME server, so the CA is known. An uploaded cert does carry one, as+// an RFC 4514 string ("CN=…,O=…"), of which only the common name is readable.+function issuerLabel(cert) {+ if (!cert.issuer) return "Let's Encrypt";+ const cn = /(?:^|,)\s*CN=([^,]+)/.exec(cert.issuer)?.[1]+ || /(?:^|,)\s*O=([^,]+)/.exec(cert.issuer)?.[1];+ return (cn || cert.issuer).replace(/\\,/g, ',').trim();+}++const STATE = (...value) => ({ match: 'all', rules: [{ id: 'ss', field: 'state', op: 'any', value }] });++// Built-in saved views — the three questions this page gets opened to answer.+// They are presets over the Status column's own rules, so each one shows a live+// count, combines with a search and can be tweaked and saved as your own.+const SSL_BUILTIN_VIEWS = [+ {+ // The one that matters: what will break if nobody touches it this month.+ name: 'Expiring soon',+ state: {+ search: '', groupBy: null, hiddenKeys: [],+ sorts: [{ key: 'expiresAt', direction: 'asc' }],+ columnFilters: STATE('expiring'),+ },+ },+ {+ name: 'Valid',+ state: {+ search: '', groupBy: null, hiddenKeys: [],+ sorts: [{ key: 'expiresAt', direction: 'desc' }],+ columnFilters: STATE('valid'),+ },+ },+ {+ // A cert certbot reports as INVALID and one whose expiry we could not+ // read at all are the same operational fact — the domain is serving+ // nothing usable — so they share a worklist instead of each getting one.+ name: 'Failed or missing',+ state: {+ search: '', groupBy: null, hiddenKeys: [],+ sorts: [{ key: 'name', direction: 'asc' }],+ columnFilters: STATE('expired', 'unknown'),+ },+ },+];const SSLCertificates = () => {const toast = useToast();@@ -26,13 +95,7 @@ const SSLCertificates = () => {const [loading, setLoading] = useState(true);const [actionLoading, setActionLoading] = useState(false);const [renewingDomain, setRenewingDomain] = useState(null);-- // Runtime self-capture: after the real page renders, snapshot its layout so a- // later load replays a pixel-accurate skeleton (falls back to sslSkeleton on- // first-ever visit). See useSelfCapturedBones / plan 50 phase 3.- const { ref: pageRef, bones: capturedBones } = useSelfCapturedBones('ssl', {- ready: !loading && !!status,- });+ const [search, setSearch] = useState('');// Modal statesconst [showObtainModal, setShowObtainModal] = useState(false);@@ -224,12 +287,175 @@ const SSLCertificates = () => {}}- const certificates = status?.certificates || [];- const expiringSoon = status?.expiring_soon || [];const certbotInstalled = status?.certbot_installed ?? false;- useTopbarActions(() =>+ // Every derived field lands on the row itself rather than in a column+ // accessor: the table renders `row[key]` when a column has no `render`, and+ // a filter rule that reads one thing while the cell shows another is how a+ // view ends up matching rows the eye says it shouldn't.+ const certificates = useMemo(() => {+ // The backend flags "expiring" by running openssl against+ // /etc/letsencrypt/live, so an uploaded cert is never in that list —+ // the date-derived horizon below is what covers those.+ const flagged = new Set(status?.expiring_soon || []);+ return (status?.certificates || []).map((cert) => {+ const source = cert.source || 'certbot';+ const expiresAt = certExpiryIso(cert.expiry);+ const days = expiresAt == null+ ? null+ : Math.round((new Date(expiresAt).getTime() - Date.now()) / DAY);++ let state;+ if (cert.expiry_valid === false || (days != null && days < 0)) state = 'expired';+ else if (days == null) state = 'unknown';+ else if (days <= EXPIRING_DAYS || flagged.has(cert.name)) state = 'expiring';+ else state = 'valid';++ return {+ ...cert,+ // certbot and the custom-cert dir can both hold a `example.com`,+ // so the name alone is not a key.+ id: `${source}:${cert.name}`,+ source,+ expiresAt,+ state,+ issuedBy: issuerLabel(cert),+ // certbot re-issues from its own renewal config; an uploaded+ // cert has none anywhere, so that one is on the operator.+ renewal: source === 'certbot' ? 'certbot' : 'manual',+ };+ });+ }, [status]);++ const rows = useMemo(() => {+ const q = search.trim().toLowerCase();+ if (!q) return certificates;+ return certificates.filter((c) => (+ c.name?.toLowerCase().includes(q)+ || c.issuedBy?.toLowerCase().includes(q)+ || (c.domains || []).some((d) => d.toLowerCase().includes(q))+ ));+ }, [certificates, search]);++ const columns = useMemo(() => [+ {+ key: 'name',+ header: 'Domain',+ sortable: true,+ hideable: false,+ value: (c) => c.name,+ render: (c) => {+ const extra = (c.domains || []).filter((d) => d !== c.name);+ const sub = [c.badge, extra.join(', ')].filter(Boolean).join(' · ');+ return (+ <div className="sk-cell-name">+ {/* The tile carries the state too. A fixed green shield+ next to an expired certificate is the row telling+ you the opposite of what its Status cell says. */}+ <span className={`ssl-row__ico is-${c.state}`}><ShieldCheck size={15} /></span>+ <span>+ <div>{c.name}</div>+ {sub && <div className="sk-cell-sub">{sub}</div>}+ </span>+ </div>+ );+ },+ },+ {+ key: 'issuedBy',+ header: 'Issuer',+ type: 'enum',+ sortable: true,+ width: 200,+ },+ {+ key: 'state',+ header: 'Status',+ type: 'enum',+ sortable: true,+ groupable: true,+ width: 130,+ enumOrder: ['valid', 'expiring', 'expired', 'unknown'],+ render: (c) => <Pill kind={STATE_KIND[c.state]}>{c.state}</Pill>,+ },+ {+ key: 'expiresAt',+ header: 'Expires',+ type: 'date',+ sortable: true,+ width: 165,+ render: (c) => {+ const exp = formatExpiry(c.expiresAt);+ if (!exp) return <span className="ssl-dash">—</span>;+ // The relative form is what you judge a cert by; the exact+ // moment is one hover away for when you need to plan around it.+ return (+ <span+ className={`ssl-expiry ssl-expiry--${exp.tone}`}+ title={new Date(c.expiresAt).toLocaleString()}+ >+ {exp.relative}+ </span>+ );+ },+ },+ {+ key: 'renewal',+ header: 'Auto-renew',+ type: 'enum',+ sortable: true,+ width: 145,+ enumOrder: ['certbot', 'manual'],+ render: (c) => (c.renewal === 'certbot'+ ? <Pill kind="green" title="Reissued by certbot — set the timer up with Auto-Renew">certbot</Pill>+ : <Pill kind="gray" title="Uploaded by hand — re-upload it before it expires">manual</Pill>),+ },+ {+ key: '__actions',+ header: '',+ sortable: false,+ hideable: false,+ width: 56,+ className: 'text-right',+ render: (c) => {+ const renewing = renewingDomain === c.name;+ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild onClick={(e) => e.stopPropagation()}>+ <Button variant="ghost" size="icon" disabled={renewing || actionLoading}>+ {renewing ? <RefreshCw size={14} className="spin" /> : <MoreVertical size={14} />}+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuItem onClick={() => handleRenewCertificate(c.name)}>+ Renew now+ </DropdownMenuItem>+ <DropdownMenuItem+ className="text-destructive"+ onClick={() => handleRevokeCertificate(c.name)}+ >+ Revoke & delete+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ );+ },+ },+ // eslint-disable-next-line react-hooks/exhaustive-deps+ ], [renewingDomain, actionLoading]);++ // Install Certbot only shows when it is missing — the certbot-only actions+ // next to it are disabled in that state, so the bar always offers the one+ // thing that can be done. Search goes last: the fixed bar order is+ // [page actions] [search] [filter] [⋮], and the table hoists the last two.+ useTopbarActions(() => (<>+ {!certbotInstalled && (+ <Button size="sm" onClick={handleInstallCertbot} disabled={actionLoading}>+ <Download size={15} />+ Install Certbot+ </Button>+ )}<Buttonvariant="outline"size="sm"@@ -258,189 +484,45 @@ const SSLCertificates = () => {<Plus size={15} />New Certificate</Button>- </>,- [actionLoading, certbotInstalled, certificates.length],- );-- const sslSkeleton = (- <>- <div className="ssl-status-bar">- {[1, 2, 3].map(i => (- <div key={i} className="ssl-status-item">- <Skeleton variant="avatar" />- <div className="skeleton-stack">- <Skeleton variant="title" width="55%" />- <Skeleton variant="line" width="35%" />- </div>- </div>- ))}- </div>- <div className="ssl-cert-list">- {[1, 2].map(i => (- <div key={i} className="ssl-cert-item">- <div className="ssl-cert-item-info">- <Skeleton variant="avatar" />- <div className="skeleton-stack">- <Skeleton variant="title" width={200} />- <Skeleton variant="line" width={280} />- </div>- </div>- </div>- ))}- </div>+ <SearchField value={search} onSearch={setSearch} placeholder="Search certificates…" /></>- );+ ), [actionLoading, certbotInstalled, certificates.length, search]);return (<>- <SkeletonBoundary- ref={pageRef}- className="sk-tabgroup__inner ssl-page"- loading={loading}- skeleton={sslSkeleton}- bones={capturedBones}- >- {(!loading || status) && (<>- {/* Status Cards */}- <div className="ssl-status-bar">- <div className="ssl-status-item">- <div className={`ssl-status-icon ${certbotInstalled ? 'active' : 'inactive'}`}>- {certbotInstalled ? <ShieldCheck size={24} /> : <ShieldOff size={24} />}- </div>- <div className="ssl-status-info">- <h4>Certbot</h4>- <span>{certbotInstalled ? 'Installed' : 'Not Installed'}</span>- </div>- {!certbotInstalled && (- <Button- size="sm"- onClick={handleInstallCertbot}- disabled={actionLoading}- className="ml-auto"- >- <Download size={14} />- Install- </Button>- )}- </div>- <div className="ssl-status-item">- <div className="ssl-status-icon active">- <Lock size={24} />- </div>- <div className="ssl-status-info">- <h4>Certificates</h4>- <span>{status?.total_certificates || 0} active</span>- </div>- </div>- <div className="ssl-status-item">- <div className={`ssl-status-icon ${expiringSoon.length > 0 ? 'warning' : 'active'}`}>- {expiringSoon.length > 0 ? <AlertTriangle size={24} /> : <CheckCircle size={24} />}- </div>- <div className="ssl-status-info">- <h4>Expiring Soon</h4>- <span>- {expiringSoon.length > 0- ? `${expiringSoon.length} certificate${expiringSoon.length > 1 ? 's' : ''}`- : 'All healthy'- }- </span>- </div>- </div>- </div>-- {/* Certificates List */}- {certificates.length === 0 ? (- <EmptyState- size="lg"- icon={Lock}- title="No SSL certificates"- description="Obtain your first Let's Encrypt certificate to secure your domains."- action={certbotInstalled ? (- <Button onClick={() => setShowObtainModal(true)}>- <Plus size={16} />- New Certificate- </Button>- ) : (- <Button onClick={handleInstallCertbot} disabled={actionLoading}>- <Download size={16} />- Install Certbot First- </Button>- )}- />- ) : (- <div className="ssl-cert-list">- {certificates.map((cert, index) => (- <div key={index} className="ssl-cert-item">- <div className="ssl-cert-item-info">- <div className={`ssl-cert-item-icon ${cert.expiry_valid ? '' : 'expiring'}`}>- <ShieldCheck size={20} />- </div>- <div className="ssl-cert-item-details">- <h3>{cert.name}</h3>- <div className="ssl-cert-item-meta">- <span>- <Globe size={12} />- {cert.domains?.join(', ') || cert.name}- </span>- {cert.expiry && (- <span className={cert.expiry_valid ? 'valid' : 'expiring'}>- <Clock size={12} />- Expires: {cert.expiry}- </span>- )}- </div>- </div>- </div>- <div className="ssl-cert-item-status">- {cert.expiry_valid- ? <Pill kind="green">Valid</Pill>- : <Pill kind="amber">Expiring</Pill>}- </div>- <div className="ssl-cert-item-actions">- <Button- variant="outline"- size="sm"- onClick={() => handleRenewCertificate(cert.name)}- disabled={renewingDomain === cert.name || actionLoading}- >- <RefreshCw size={14} className={renewingDomain === cert.name ? 'spin' : ''} />- {renewingDomain === cert.name ? 'Renewing...' : 'Renew'}- </Button>- <Button- variant="outline"- size="sm"- onClick={() => handleRevokeCertificate(cert.name)}- disabled={actionLoading}- >- <Trash2 size={14} />- Revoke- </Button>- </div>- </div>- ))}- </div>- )}-- {/* Expiring Soon Warning */}- {expiringSoon.length > 0 && (- <div className="ssl-warning-banner">- <AlertTriangle size={18} />- <div>- <strong>Certificates expiring soon:</strong>{' '}- {expiringSoon.join(', ')}- </div>- <Button- size="sm"- onClick={handleRenewAll}- disabled={actionLoading}- >- <RefreshCw size={14} />- Renew All+ <ResourceListPage+ className="ssl-page"+ loading={loading}+ loadingTitle="Loading certificates…"+ storageKey="serverkit-list-ssl"+ viewPageKey="ssl"+ noun="certificates"+ builtinViews={SSL_BUILTIN_VIEWS}+ totalCount={certificates.length}+ items={rows}+ columns={columns}+ keyField="id"+ searchTerm={search}+ onSearchChange={setSearch}+ searchInTopbar+ emptyIcon={Lock}+ emptyTitle="No SSL certificates"+ emptyDescription="Obtain your first Let's Encrypt certificate to secure your domains."+ emptyAction={certbotInstalled ? (+ <Button onClick={() => setShowObtainModal(true)}>+ <Plus size={16} />+ New Certificate</Button>- </div>- )}- </>)}- </SkeletonBoundary>+ ) : (+ <Button onClick={handleInstallCertbot} disabled={actionLoading}>+ <Download size={16} />+ Install Certbot First+ </Button>+ )}+ filteredEmptyIcon={Lock}+ filteredEmptyTitle="No certificates found"+ filteredEmptyDescription="Try adjusting your search or filters."+ />{/* Obtain Certificate Modal */}<Modal open={showObtainModal} onClose={() => setShowObtainModal(false)} title="Obtain SSL Certificate">diff --git a/frontend/src/pages/ServerTemplates.jsx b/frontend/src/pages/ServerTemplates.jsxindex 6f812b9d..f0bbb9f4 100644--- a/frontend/src/pages/ServerTemplates.jsx+++ b/frontend/src/pages/ServerTemplates.jsx@@ -15,7 +15,7 @@ import { Input } from '@/components/ui/input';import { Textarea } from '@/components/ui/textarea';import { Badge } from '@/components/ui/badge';import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';-import { DataTable, KpiBand, MetricCard, Pill } from '@/components/ds';+import { DataTable, Pill } from '@/components/ds';import {useTableChrome, GridViewPicker, GridChips, GridFilterButton,GridToolsMenu, GridFilterDrawer,@@ -61,6 +61,32 @@ const REMEDIATION_KIND = {[REMEDIATION_UNATTENDED]: 'amber',};+// Compliance used to be three fleet-wide tiles above the table. They said how+// many ASSIGNMENTS had drifted but never which template was responsible, which+// is the only version of the question you can act on — so the same three states+// are now a per-row column, and the tiles' colours moved onto the pill.+const COMPLIANCE_COMPLIANT = 'Compliant';+const COMPLIANCE_DRIFTED = 'Drifted';+const COMPLIANCE_UNKNOWN = 'Unknown';+const COMPLIANCE_NONE = 'Not assigned';++const complianceLabel = (tmpl) => {+ const assigned = tmpl.assignment_count ?? 0;+ if (assigned === 0) return COMPLIANCE_NONE;+ // One drifted server makes the template drifted: a partial pass is not a+ // pass, and the row exists to send you somewhere.+ if ((tmpl.drifted_count ?? 0) > 0) return COMPLIANCE_DRIFTED;+ if ((tmpl.compliant_count ?? 0) === assigned) return COMPLIANCE_COMPLIANT;+ return COMPLIANCE_UNKNOWN;+};++const COMPLIANCE_KIND = {+ [COMPLIANCE_COMPLIANT]: 'green',+ [COMPLIANCE_DRIFTED]: 'red',+ [COMPLIANCE_UNKNOWN]: 'amber',+ [COMPLIANCE_NONE]: 'gray',+};+function formatUpdated(value) {if (!value) return 'Never';const date = new Date(value);@@ -89,6 +115,45 @@ const BUILTIN_VIEWS = [},},},+ {+ // The two views that replace the old KPI tiles. Widest blast radius+ // first — a drifted template on twelve servers outranks one on one.+ name: 'Drifted',+ state: {+ sorts: [{ key: 'servers', direction: 'desc' }],+ hiddenKeys: ['version'],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{+ id: 'st-drift',+ field: 'compliance',+ op: 'any',+ value: [COMPLIANCE_DRIFTED],+ }],+ },+ },+ },+ {+ // Deliberately excludes 'Unknown': a template whose servers were never+ // checked is not passing, it is unmeasured, and folding the two+ // together is how the old progress bar claimed 100%.+ name: 'Compliant',+ state: {+ sorts: [{ key: 'servers', direction: 'desc' }],+ hiddenKeys: ['version'],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{+ id: 'st-ok',+ field: 'compliance',+ op: 'any',+ value: [COMPLIANCE_COMPLIANT],+ }],+ },+ },+ },{// The other half: written, then never applied. Newest edit first,// because a template you touched last week and never assigned is the@@ -142,7 +207,6 @@ const ServerTemplates = () => {const { user } = useAuth();const [templates, setTemplates] = useState([]);const [library, setLibrary] = useState({});- const [compliance, setCompliance] = useState(null);const [loading, setLoading] = useState(true);const [showCreateModal, setShowCreateModal] = useState(false);const [showAssignModal, setShowAssignModal] = useState(false);@@ -154,8 +218,8 @@ const ServerTemplates = () => {// Table sort + column visibility for the Templates tab, persisted and// handed to the chrome. `version` starts hidden nowhere — it is small and- // the card showed it — but three of the four presets drop it, since an- // auto-incrementing integer says nothing about coverage or risk.+ // the card showed it — but every preset bar "By category" drops it, since+ // an auto-incrementing integer says nothing about coverage or risk.const { sorts, setSorts } = useTableSort({defaultSorts: [{ key: 'servers', direction: 'desc' }],storageKey: 'serverkit-table-server-templates-sort',@@ -174,15 +238,13 @@ const ServerTemplates = () => {const loadData = useCallback(async () => {try {- const [tData, lData, cData] = await Promise.all([+ const [tData, lData] = await Promise.all([api.getServerTemplates(),api.getServerTemplateLibrary(),- api.getTemplateCompliance(),]);const mine = tData.templates || [];setTemplates(mine);setLibrary(lData.templates || {});- setCompliance(cData);// Pick the opening tab from the data, once. `?? ` so a reload// (after creating or deleting one) never yanks the tab out from// under whoever is reading it.@@ -333,6 +395,24 @@ const ServerTemplates = () => {// "Not assigned yet" preset's `eq 0` has something honest to match.value: (tmpl) => tmpl.assignment_count ?? 0,sortValue: (tmpl) => tmpl.assignment_count ?? 0,+ // `value` only feeds sorting and the filter rules. Without a+ // `render` DataTable falls back to row['servers'], which is not a+ // key on the payload — the cell rendered blank.+ render: (tmpl) => tmpl.assignment_count ?? 0,+ },+ {+ key: 'compliance',+ header: 'Compliance',+ sortable: true,+ type: 'enum',+ groupable: true,+ value: complianceLabel,+ groupValue: complianceLabel,+ sortValue: complianceLabel,+ render: (tmpl) => {+ const label = complianceLabel(tmpl);+ return <Pill kind={COMPLIANCE_KIND[label] || 'gray'} dot={false}>{label}</Pill>;+ },},{key: 'remediation',@@ -368,6 +448,7 @@ const ServerTemplates = () => {type: 'num',value: (tmpl) => tmpl.packages?.length ?? 0,sortValue: (tmpl) => tmpl.packages?.length ?? 0,+ render: (tmpl) => tmpl.packages?.length ?? 0,},{key: 'services',@@ -376,6 +457,11 @@ const ServerTemplates = () => {type: 'num',value: (tmpl) => tmpl.services?.length ?? 0,sortValue: (tmpl) => tmpl.services?.length ?? 0,+ // Without this the fallback printed row['services'] — a list of+ // {name, enabled, running} OBJECTS, which React refuses to render+ // ("Objects are not valid as a React child"), taking the whole tab+ // down for any template that declares a service.+ render: (tmpl) => tmpl.services?.length ?? 0,},{key: 'firewall',@@ -384,6 +470,7 @@ const ServerTemplates = () => {type: 'num',value: (tmpl) => tmpl.firewall_rules?.length ?? 0,sortValue: (tmpl) => tmpl.firewall_rules?.length ?? 0,+ render: (tmpl) => tmpl.firewall_rules?.length ?? 0,},{key: 'updated',@@ -440,18 +527,13 @@ const ServerTemplates = () => {setGroupBy,});- // How many servers the compliance figures actually cover.- const measuredServers = compliance- ? (compliance.compliant || 0) + (compliance.drifted || 0) + (compliance.unknown || 0)- : 0;-// Filter + "⋮" ride the group's top bar, so the view row is the view name// alone. Gated on the tab that owns the table: the Library is a card// catalogue these do not act on, and the drawer the filter button opens is// rendered inside the Templates tab, so hoisting it unconditionally would// leave a button whose panel does not exist.const gridIsOnScreen = activeTab === 'templates' && templates.length > 0;- const { portal: topbarChrome } = useTopbarChrome(+ const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome(<><GridFilterButtoncount={chrome.filterCount}@@ -466,31 +548,6 @@ const ServerTemplates = () => {return (<div className="sk-tabgroup__inner server-templates-page">{topbarChrome}- {/* Stays a band: these tiles count ASSIGNMENTS — a different entity- from the templates in the table below — and "Unknown" is the- remainder of the other two, not a predicate. Neither number is- a row count, so neither could become a column rule. */}- {compliance && (- <div className="compliance-bar">- <KpiBand dense>- <MetricCard label="Compliant" value={compliance.compliant} tone="green" compact />- <MetricCard label="Drifted" value={compliance.drifted} tone="red" compact />- <MetricCard label="Unknown" value={compliance.unknown} tone="amber" compact />- </KpiBand>- {measuredServers > 0 ? (- <div className="compliance-bar__progress" title={`${Math.round(compliance.compliance_pct || 0)}% compliant`}>- <div className="progress-fill" style={{ width: `${compliance.compliance_pct || 0}%` }} />- </div>- ) : (- // A full green bar above three zeroes read as "100%- // compliant" when in fact nothing had been measured.- <p className="compliance-bar__empty">- No servers are assigned to a template yet, so there is nothing to compare against.- </p>- )}- </div>- )}-{/* Library leads, because on a fresh panel Templates has nothing init — landing there showed an empty page as the first impression.The default follows the data rather than being fixed: once you@@ -521,7 +578,9 @@ const ServerTemplates = () => {views={chrome.views}label="templates"onCreate={chrome.createView}- />++ actions={chromeActions}+ /><GridChips {...chrome.chipProps} />diff --git a/frontend/src/pages/Servers.jsx b/frontend/src/pages/Servers.jsxindex a45fde76..70e7b68a 100644--- a/frontend/src/pages/Servers.jsx+++ b/frontend/src/pages/Servers.jsx@@ -360,7 +360,7 @@ const Servers = () => {// not in a toolbar under the view name. That toolbar was also repeating the// row count the view row already showed, with an "N online" tacked on that// no filter, sort or view ever referred to.- const { portal: topbarChrome } = useTopbarChrome(+ const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome(<><GridFilterButtoncount={chrome.filterCount}@@ -385,6 +385,8 @@ const Servers = () => {views={chrome.views}label="servers"onCreate={chrome.createView}++ actions={chromeActions}/><GridChips {...chrome.chipProps} />diff --git a/frontend/src/pages/Telemetry.jsx b/frontend/src/pages/Telemetry.jsxindex 8d4cf7a4..c762429c 100644--- a/frontend/src/pages/Telemetry.jsx+++ b/frontend/src/pages/Telemetry.jsx@@ -358,7 +358,7 @@ export default function Telemetry() {// view row as just the view name. It is NOT joined by a grid filter button:// this page's one filter button is the top bar's, which opens the SERVER// query drawer (eight keys, applied to the query rather than the loaded 50).- const { portal: topbarChrome } = useTopbarChrome(+ const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome(<GridToolsMenu {...chrome.toolsProps} onRefresh={() => fetchEvents(1, true)} />,);@@ -373,6 +373,8 @@ export default function Telemetry() {views={chrome.views}label="events"onCreate={chrome.createView}++ actions={chromeActions}/><GridChips {...chrome.chipProps} />diff --git a/frontend/src/styles/components/_datagrid.scss b/frontend/src/styles/components/_datagrid.scssindex 5655ce00..450df3db 100644--- a/frontend/src/styles/components/_datagrid.scss+++ b/frontend/src/styles/components/_datagrid.scss@@ -1146,24 +1146,6 @@// Settings > Recycle bin. Deliberately quiet: this is a safety net, not a// destination — the loudest thing on it should be Restore, not Delete..recyclebin {- &__toolbar {- display: flex;- align-items: center;- gap: 12px;- flex-wrap: wrap;- margin-bottom: 14px;- }-- &__retention {- display: inline-flex;- align-items: center;- gap: 6px;- font-family: var(--mono);- font-size: 11px;- color: var(--text-ghost);- margin-left: auto;- }-&__rowactions {display: flex;align-items: center;diff --git a/frontend/src/styles/components/_env-vars.scss b/frontend/src/styles/components/_env-vars.scssindex fdf4577b..f8e0f470 100644--- a/frontend/src/styles/components/_env-vars.scss+++ b/frontend/src/styles/components/_env-vars.scss@@ -3,22 +3,6 @@// ============================================.env-vars-container {- .section-header {- display: flex;- justify-content: space-between;- align-items: center;- margin-bottom: $space-4;-- h3 {- margin: 0;- }-- .header-actions {- display: flex;- gap: $space-2;- }- }-.hint {color: $text-secondary;font-size: $font-size-sm;@@ -26,55 +10,25 @@}}-// ── Panels ──────────────────────────────────────────────────────────────-// Each logical group (Add / Variables) is a bordered surface that lifts off-// the page body, so sections read as sections instead of dissolving into the-// background. Uses --border (not --border-soft) + a soft shadow because on the-// dark theme --surface sits only a hair above --bg-body.-.env-panel {- background: var(--surface);- border: 1px solid var(--border);- border-radius: var(--radius);- box-shadow: var(--shadow-sm);- overflow: hidden;- margin-bottom: $space-4;-- &__head {- display: flex;- align-items: center;- gap: $space-3;- padding: 11px $space-4;- background: var(--surface-2);- border-bottom: 1px solid var(--border-soft);- }-- &__title {- display: inline-flex;- align-items: center;- gap: 8px;- font-family: var(--mono);- font-size: 10.5px;- font-weight: $font-weight-semibold;- letter-spacing: 0.08em;- text-transform: uppercase;- color: var(--text-faint);- }+// ── Table cells ─────────────────────────────────────────────────────────+// The variables list is a shared DataTable now, so the only thing left to say+// is that keys and values are code: everything else (surface, borders, header+// menus, footer) comes from the table itself.+.env-cell-key {+ font-family: $font-mono;+}- // Count chip beside the "Variables" title- &__count {- font-family: var(--mono);- font-size: 10.5px;- font-weight: $font-weight-semibold;- letter-spacing: 0;- color: var(--accent-bright);- background: var(--accent-bg);- padding: 1px 7px;- border-radius: $radius-full;- }+.env-cell-value {+ font-family: $font-mono;+ font-size: $font-size-sm;+ color: $text-secondary;+ word-break: break-all;+}- &__body {- padding: $space-4;- }+// A cell answering "nothing here" — the same dash the Undocumented view+// filters on, dimmed so it reads as absence rather than as content.+.env-muted {+ color: $text-tertiary;}// Key input — mono, uppercase (used inside the Add Variable modal)@@ -114,39 +68,24 @@margin: $space-1 0 $space-4;}-// Filter — compact search sitting in the Variables panel head, right-aligned-.env-panel__filter {- position: relative;- margin-left: auto;+// Inline value editor — lives inside the Value cell, so it has to stay on one+// line next to a Save/Cancel pair rather than spanning a row of its own.+.env-edit-row {+ display: flex;+ align-items: center;+ gap: $space-2;+ flex-wrap: wrap;input {- width: 220px;- max-width: 46vw;- height: 32px;- padding-right: 30px;- font-size: $font-size-sm;- }-- .filter-clear {- position: absolute;- right: 6px;- top: 50%;- transform: translateY(-50%);- background: none;- border: none;- color: $text-tertiary;- cursor: pointer;- font-size: 18px;- line-height: 1;- padding: 2px 6px;-- &:hover {- color: $text-primary;- }+ flex: 1;+ min-width: 160px;+ font-family: $font-mono;}}-// Variables list+// Key/value row pattern — no longer the app's env-var surface (that is a+// DataTable now), but still the documented "list of pairs" block in the style+// guide, so it keeps its own styling..env-list {display: flex;flex-direction: column;@@ -154,7 +93,7 @@}.env-item {- // One tier brighter than the panel surface it sits on, so rows have depth+ // One tier brighter than the surface it sits on, so rows have depth// (body < panel --surface < row --surface-2) instead of blending together.background: var(--surface-2);border: 1px solid var(--border-soft);@@ -167,13 +106,6 @@background: var(--surface-3);}- .env-item-header {- display: flex;- justify-content: space-between;- align-items: center;- margin-bottom: $space-1;- }-.env-key {font-family: $font-mono;font-weight: 600;@@ -183,17 +115,6 @@gap: $space-1;}- .env-item-actions {- display: flex;- gap: $space-1;- opacity: 0;- transition: opacity 0.2s;- }-- &:hover .env-item-actions {- opacity: 1;- }-.env-value {font-family: $font-mono;font-size: $font-size-sm;@@ -201,25 +122,6 @@word-break: break-all;padding: $space-1 0;}-- .env-description {- font-size: $font-size-xs;- color: $text-tertiary;- margin-top: $space-1;- font-style: italic;- }-- .env-edit-row {- display: flex;- gap: $space-2;- margin-top: $space-2;- flex-wrap: wrap;-- input {- flex: 1;- font-family: $font-mono;- }- }}// Subtle chip showing the compose service a variable is scoped to.@@ -264,28 +166,12 @@}}-// Empty state — centered inside .env-panel__body, with a primary Add action-.env-empty {- display: flex;- flex-direction: column;- align-items: center;- gap: $space-4;- padding: $space-10 $space-6;- text-align: center;- color: var(--text-faint);- font-size: $font-size-sm;-- p { margin: 0; }-}--// Footer — Clear-all lives here, right-aligned under the list-.env-footer {+// The shared EmptyState allows a single action node; an app with no variables+// yet can start from scratch or from a file, so it gets both side by side.+.env-empty-actions {display: flex;- justify-content: flex-end;- align-items: center;- margin-top: $space-4;- padding-top: $space-4;- border-top: 1px solid var(--border-soft);+ gap: $space-2;+ justify-content: center;}// Clear-all: quiet by default, danger only on hover (no alarming red slab)diff --git a/frontend/src/styles/pages/_monitors.scss b/frontend/src/styles/pages/_monitors.scssindex e090ee0c..6dc678da 100644--- a/frontend/src/styles/pages/_monitors.scss+++ b/frontend/src/styles/pages/_monitors.scss@@ -437,6 +437,14 @@}.incident-row__chev { flex-shrink: 0; color: var(--text-faint); }++ // Ack / Resolve share the trailing cell with the chevron, so a fleet alert+ // stays actionable without earning a column that is empty on every other row.+ .incident-row__acts {+ display: flex;+ align-items: center;+ gap: 4px;+ }}// Incident drawer bodydiff --git a/frontend/src/styles/pages/_server-templates.scss b/frontend/src/styles/pages/_server-templates.scssindex 5f5e3a90..fb9ab4a2 100644--- a/frontend/src/styles/pages/_server-templates.scss+++ b/frontend/src/styles/pages/_server-templates.scss@@ -1,38 +1,6 @@// Server Templates page styles.server-templates-page {- .compliance-bar {- margin: $space-6 0;- padding: $space-4 $space-6;- background: $bg-card;- border-radius: $radius-lg;- border: 1px solid $border-default;-- .sk-kpiband-wrap {- margin-bottom: $space-4;- }-- &__empty {- margin: 0;- font-size: 0.85rem;- color: $text-tertiary;- }-- &__progress {- height: 8px;- background: $border-default;- border-radius: 4px;- overflow: hidden;-- .progress-fill {- height: 100%;- background: $success;- border-radius: 4px;- transition: width 0.3s ease;- }- }- }-.templates-grid {display: grid;grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));diff --git a/frontend/src/styles/pages/_service-detail.scss b/frontend/src/styles/pages/_service-detail.scssindex fb20c3c5..534cd0d2 100644--- a/frontend/src/styles/pages/_service-detail.scss+++ b/frontend/src/styles/pages/_service-detail.scss@@ -433,87 +433,26 @@ h3.svc-eyebrow {}// ============================================-// EVENTS TAB — dense feed-style timeline+// EVENTS TAB — the merged activity table// ============================================.events-tab {- &__header {- display: flex;- justify-content: space-between;- align-items: center;- margin-bottom: $space-4;- }-- // The timeline is one card; events are dense rows inside it- &__timeline {+ // The Event cell stacks the message over its meta line, so the ellipsis on+ // the message needs a min-width:0 flex parent to bite against.+ &__cell {display: flex;flex-direction: column;- background: var(--surface);- border: 1px solid var(--border-soft);- border-radius: var(--radius);- overflow: hidden;- }-- &__event {- display: flex;- gap: $space-4;- padding: $space-3 $space-4;- background: transparent;- cursor: pointer;- transition: background $transition-fast;-- & + & {- border-top: 1px solid var(--border-soft);- }-- &:hover {- background: var(--surface-2);- }-- &--expanded {- background: var(--surface-2);- }-- // Compact rows (config/audit entries) aren't expandable — no pointer,- // no hover affordance, tighter text.- &--compact {- cursor: default;-- &:hover { background: transparent; }- }- }-- &__event-status {- width: 8px;- height: 8px;- border-radius: 50%;- margin-top: 6px;- flex-shrink: 0;- background: var(--text-ghost);-- &--green { background: var(--green); box-shadow: 0 0 6px var(--green); }- &--red { background: var(--red); }- &--amber { background: var(--amber); box-shadow: 0 0 6px var(--amber); }- &--cyan { background: var(--cyan); }- &--gray { background: var(--text-faint); }- }-- &__event-body {- flex: 1;min-width: 0;}- &__event-header {- display: flex;- justify-content: space-between;- align-items: flex-start;- gap: $space-3;+ // Config and audit rows carry everything they have in the row itself —+ // only a deploy opens a drawer, so only a deploy gets a pointer.+ .sk-dtable tbody tr.is-static {+ cursor: default;}- &__event-commit {- display: flex;- align-items: center;- gap: $space-2;- min-width: 0;+ // A cell with genuinely nothing behind it (an audit entry has no outcome).+ &__none {+ color: var(--text-faint);}&__event-sha {@@ -535,23 +474,14 @@ h3.svc-eyebrow {text-overflow: ellipsis;}- &__event-meta {- display: flex;- align-items: center;- gap: $space-3;- margin-top: $space-1;- font-family: var(--mono);- font-size: 11px;- color: var(--text-faint);- }-+ // The build log, now shown in the deploy drawer rather than in an expanded+ // row. Flat BEM, so it styles the same block wherever it is portalled to.&__event-logs {- margin-top: $space-3;padding: $space-3;background: var(--bg-code);border: 1px solid var(--border-soft);border-radius: $radius-md;- max-height: 300px;+ max-height: 60vh;overflow-y: auto;pre {@@ -563,23 +493,6 @@ h3.svc-eyebrow {word-break: break-all;}}-- &__empty {- // Flex-center so the icon centers too — svgs are display:block (Tailwind- // preflight), so text-align:center alone left-aligns the glyph.- display: flex;- flex-direction: column;- align-items: center;- text-align: center;- gap: $space-2;- padding: $space-12 $space-8;- color: $text-tertiary;-- h3 {- color: $text-secondary;- margin: 0;- }- }}// ============================================diff --git a/frontend/src/styles/pages/_settings.scss b/frontend/src/styles/pages/_settings.scssindex 300773dd..d64432aa 100644--- a/frontend/src/styles/pages/_settings.scss+++ b/frontend/src/styles/pages/_settings.scss@@ -146,6 +146,30 @@// Settings Content Area.settings-content {min-width: 0;++ // Settings panes used to drop their table straight onto the page+ // background, so a tab read as unfinished next to /servers or /services —+ // those sit their grid on a panel (`.wp-list__card`). Same panel, declared+ // once here, so a pane gets it by rendering a table rather than by+ // remembering to wrap one. No `overflow: hidden`: the wrap's own+ // `overflow-x: auto` already clips to the radius, and hiding the y axis+ // would cut the sticky-header variant's scroll.+ .sk-dtable-wrap {+ background: var(--surface);+ border: 1px solid var(--border-soft);+ border-radius: var(--radius);+ }++ // …except where the pane already put the table on a surface of its own.+ // Two panels nested one pixel apart is the seam this rule exists to remove.+ .settings-card,+ .users-table-container {+ .sk-dtable-wrap {+ background: none;+ border: 0;+ border-radius: 0;+ }+ }}// Settings Sectiondiff --git a/frontend/src/styles/pages/_ssl.scss b/frontend/src/styles/pages/_ssl.scssindex a8c65518..251d609a 100644--- a/frontend/src/styles/pages/_ssl.scss+++ b/frontend/src/styles/pages/_ssl.scss@@ -1,157 +1,47 @@// ============================================// SSL CERTIFICATES PAGE// ============================================--// Status bar — a row of stat cards (Certbot / Certificates / Expiring Soon).-// These classes used to be borrowed from _domains.scss, but were dropped when the-// Domains page moved to MetricCard — so they're defined here now. Without them the-// status items collapsed into an unstyled vertical stack at the top-left.-.ssl-status-bar {+//+// The page is a ResourceListPage now, so the table chrome comes from the shared+// `.wp-list` scaffold and only the cell-level tone rules live here. The old+// stat-card row and certificate cards are gone: a KPI restating "3 expiring"+// above a table that can show exactly those three is a second, weaker copy of+// the "Expiring soon" view.++// Leading icon in the Domain cell.+.ssl-row__ico {display: grid;- grid-template-columns: repeat(3, 1fr);- gap: $space-4;- margin-bottom: $space-5;-- @media (max-width: $breakpoint-md) { grid-template-columns: 1fr; }-}--.ssl-status-item {- @include flex-start();- gap: $space-3;- padding: $space-4;- background: var(--surface);- border: 1px solid $border-subtle;- border-radius: $radius-lg;-}--.ssl-status-icon {- @include icon-box();- background: var(--surface-2);- color: $text-tertiary;-- &.active { background: $success-bg; color: $success; }- &.inactive { background: var(--surface-2); color: $text-tertiary; }- &.warning { background: $warning-bg; color: $warning; }-}--.ssl-status-info {- min-width: 0;-- h4 {- margin: 0 0 2px;- font-size: $font-size-sm;- font-weight: $font-weight-semibold;- color: $text-primary;- }-- span {- font-size: $font-size-xs;- color: $text-tertiary;- }-}--// Certificate list-.ssl-cert-list {- @include flex-column-gap($space-3);-}--.ssl-cert-item {- @include list-item-base();- gap: $space-4;-- @media (max-width: $breakpoint-md) {- flex-wrap: wrap;- }-}--.ssl-cert-item-info {- @include flex-start();- gap: $space-4;- flex: 1;- min-width: 0;-}--.ssl-cert-item-icon {- @include icon-box();+ place-items: center;+ width: 26px;+ height: 26px;+ flex-shrink: 0;+ border-radius: $radius-md;background: $success-bg;- border-radius: $radius-lg;color: $success;- &.expiring {- background: $warning-bg;- color: $warning;- }+ // Same four states the Status column reports, so the row does not say+ // "healthy" on its left and "expired" on its right.+ &.is-expiring { background: $warning-bg; color: $warning; }+ &.is-expired { background: $danger-bg; color: $danger; }+ &.is-unknown { background: $bg-tertiary; color: $text-tertiary; }}-.ssl-cert-item-details {- min-width: 0;+// Expiry, coloured by urgency (tones come from formatExpiry).+.ssl-expiry {+ font-size: $font-size-xs;+ font-weight: $font-weight-semibold;- h3 {- font-size: $font-size-base;- font-weight: $font-weight-semibold;- color: $text-primary;- margin-bottom: $space-1;- }+ &--green { color: $success; }+ &--amber { color: $warning; }+ &--red { color: $danger; }}-.ssl-cert-item-meta {- @include flex-start();- gap: $space-4;- font-size: $font-size-sm;+.ssl-dash {color: $text-tertiary;- flex-wrap: wrap;-- span {- @include flex-start();- gap: $space-1;-- &.valid {- color: $success;- }-- &.expiring {- color: $warning;- }- }-}--.ssl-cert-item-status {- flex-shrink: 0;-}--.ssl-cert-item-actions {- display: flex;- gap: $space-2;- flex-shrink: 0;}-// Warning banner for expiring certs-.ssl-warning-banner {- @include flex-start();- gap: $space-3;- padding: $space-4 $space-5;- background: $warning-bg;- border: 1px solid $warning-border;- border-radius: $radius-xl;- margin-top: $space-6;- color: $warning;-- div {- flex: 1;- font-size: $font-size-sm;- color: $text-secondary;-- strong {- color: $warning;- }- }-- .btn {- flex-shrink: 0;- }-}--// Spinning icon for renewal+// Spinning icon — used well beyond this page (Servers, Deployments, backups…),+// so it stays global despite living in a page partial..spin {animation: ssl-spin 1s linear infinite;}@@ -160,15 +50,3 @@from { transform: rotate(0deg); }to { transform: rotate(360deg); }}--// Skeleton loading-.skeleton-box {- background: $bg-hover;- border-radius: $radius-md;- animation: ssl-skeleton-pulse 1.5s ease-in-out infinite;-}--@keyframes ssl-skeleton-pulse {- 0%, 100% { opacity: 1; }- 50% { opacity: 0.4; }-}