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(views): the last list surfaces -- Docker, templates, backups, monitor checks, git, server detail
Juan Denisc0bb135b9edb
diff --git a/frontend/src/components/docker/ContainersTab.jsx b/frontend/src/components/docker/ContainersTab.jsxindex 353ac026..60960b08 100644--- a/frontend/src/components/docker/ContainersTab.jsx+++ b/frontend/src/components/docker/ContainersTab.jsx@@ -6,7 +6,11 @@ import LogToolbar from '../log-viewer/LogToolbar';import LogContent from '../log-viewer/LogContent';import EmptyState from '../EmptyState';import Modal from '@/components/Modal';-import { Drawer, DataTable, DataTableFooter } from '@/components/ds';+import { Drawer, DataTable, DataTableFooter, Pill } 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 { Button } from '@/components/ui/button';@@ -53,6 +57,121 @@ export const RunContainerButton = () => {);};+// Docker reports health inside the `docker ps` STATUS STRING — "Up 3 hours+// (healthy)", "Up 2 minutes (health: starting)", "Up 6 days (unhealthy)" —+// there is no health field on the list endpoint (see+// docker_service.list_containers). Deriving it here is what turns "is anything+// failing its healthcheck" into a column, and therefore into a saved view,+// instead of something you squint at in the muted status line. 'None' is a real+// answer, not a gap: it means no HEALTHCHECK is declared, so nothing is+// watching that container at all.+const HEALTH_LABELS = ['Unhealthy', 'Starting', 'None', 'Healthy'];+const HEALTH_RANK = { Unhealthy: 0, Starting: 1, None: 2, Healthy: 3 };+const HEALTH_TONE = { Unhealthy: 'red', Starting: 'amber', None: 'gray', Healthy: 'green' };++const containerHealth = (container) => {+ const status = getContainerStatus(container).toLowerCase();+ // Negative case first. '(unhealthy)' does not contain '(healthy)' — the+ // paren is what keeps them apart — but testing in this order means the+ // check never depends on noticing that again.+ if (status.includes('(unhealthy)')) return 'Unhealthy';+ if (status.includes('health: starting')) return 'Starting';+ if (status.includes('(healthy)')) return 'Healthy';+ return 'None';+};++// Built-in views. The All / Running / Stopped chip row that used to sit in the+// toolbar was three column rules wearing a segmented control; every bucket it+// offered is a preset here.+//+// Every preset carries `showAll: true`. The list endpoint is asked for+// running-only containers when "Include stopped" is off, so a view about+// stopped containers would otherwise be a preset that can only ever match zero+// rows — the rows it wants were never fetched. The chrome applies the `page`+// bag before the rules, so switching to one of these refetches first.+const NO_RULES = { match: 'all', rules: [] };+const PAGE_ALL = { showAll: true, search: '' };++const BUILTIN_VIEWS = [+ {+ // The everyday list: what is actually up right now.+ name: 'Running',+ state: {+ sorts: [{ key: 'name', direction: 'asc' }],+ hiddenKeys: [],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{ id: 'dc1', field: 'status', op: 'any', value: ['Running'] }],+ },+ page: PAGE_ALL,+ },+ },+ {+ // "is none of Running" rather than a list of Exited/Created, so paused,+ // restarting and dead land here too instead of falling through both+ // buckets the way they did under the old chip row. Newest first: the+ // container that just failed to start is the one you came here for.+ // Resources is hidden — a stopped container has no reading, so the+ // column would be a wall of empty bars.+ name: 'Not running',+ state: {+ sorts: [{ key: 'created', direction: 'desc' }],+ hiddenKeys: ['resources'],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{ id: 'dc2', field: 'status', op: 'none', value: ['Running'] }],+ },+ page: PAGE_ALL,+ },+ },+ {+ // Running containers whose healthcheck is not passing — failing, still+ // starting, or absent entirely. "is none of Healthy" covers all three+ // in one rule, and the Running clause is what keeps every stopped+ // container (which reports no health by definition) out of it.+ // Sorted by the health rank, so genuinely unhealthy tops the list.+ name: 'Unhealthy or unwatched',+ state: {+ sorts: [{ key: 'health', direction: 'asc' }],+ hiddenKeys: ['created'],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [+ { id: 'dc3', field: 'status', op: 'any', value: ['Running'] },+ { id: 'dc4', field: 'health', op: 'none', value: ['Healthy'] },+ ],+ },+ page: PAGE_ALL,+ },+ },+ {+ // No rules at all: everything, bucketed by the image it runs. This is+ // how you spot the three containers still on last month's tag.+ name: 'By image',+ state: {+ sorts: [{ key: 'name', direction: 'asc' }],+ hiddenKeys: [],+ groupBy: 'image',+ columnFilters: NO_RULES,+ page: PAGE_ALL,+ },+ },+ {+ // The way back out of any of the above.+ name: 'Everything, newest first',+ state: {+ sorts: [{ key: 'created', direction: 'desc' }],+ hiddenKeys: [],+ groupBy: null,+ columnFilters: NO_RULES,+ page: PAGE_ALL,+ },+ },+];+// Containers Tabconst ContainersTab = ({ onStatsChange }) => {const toast = useToast();@@ -66,7 +185,6 @@ const ContainersTab = ({ onStatsChange }) => {const [logsContainer, setLogsContainer] = useState(null);const [execContainer, setExecContainer] = useState(null);const [searchTerm, setSearchTerm] = useState('');- const [statusFilter, setStatusFilter] = useState('all');// Native DataTable header sorting (the old <select> + direction button is// gone). Default keeps the previous behavior: running containers first.const { sorts, setSorts } = useTableSort({@@ -76,6 +194,8 @@ const ContainersTab = ({ onStatsChange }) => {const {hiddenKeys, setHiddenKeys,} = useColumnVisibility({ storageKey: 'serverkit-table-docker-containers-cols' });+ // Not persisted on its own: a grouping worth keeping is a saved view.+ const [groupBy, setGroupBy] = useState(null);const statsRequestSeq = useRef(0);useEffect(() => {@@ -242,37 +362,48 @@ const ContainersTab = ({ onStatsChange }) => {return { cpu, memory, available: true };}- const counts = useMemo(() => {- const c = { all: containers.length, running: 0, stopped: 0 };- containers.forEach(x => { if (isContainerRunning(x)) c.running++; else c.stopped++; });- return c;- }, [containers]);-+ // Search only. The running/stopped split used to live here as a chip+ // filter; it is a column rule now, applied inside the table.const filteredContainers = useMemo(() => {const search = searchTerm.toLowerCase();- return containers.filter(c => {- if (statusFilter === 'running' && !isContainerRunning(c)) return false;- if (statusFilter === 'stopped' && isContainerRunning(c)) return false;- if (!search) return true;- return getContainerName(c).toLowerCase().includes(search) ||- getContainerId(c).toLowerCase().includes(search) ||- getContainerImage(c).toLowerCase().includes(search);- });- }, [containers, statusFilter, searchTerm]);+ if (!search) return containers;+ return containers.filter(c => (+ getContainerName(c).toLowerCase().includes(search) ||+ getContainerId(c).toLowerCase().includes(search) ||+ getContainerImage(c).toLowerCase().includes(search)+ ));+ }, [containers, searchTerm]);const selectedStats = selectedContainer? parseStats(containerStats[getContainerId(selectedContainer)]): { cpu: 0, memory: 0, available: false };+ // CPU% is the headline number behind the Resources column. A container with+ // no reading yet is null, NOT 0, so it sorts last and no numeric rule+ // claims it — see the missing-value guard on lt/gt in ds/grid/fields.js.+ const cpuPercent = (container) => {+ const stats = parseStats(containerStats[getContainerId(container)]);+ return stats.available ? stats.cpu : null;+ };+// DataTable columns. Cell markup and classNames are identical to the// hand-rolled table they replace, so _docker.scss keeps applying// (.dx-manager-table, .dx-name-stack, .dx-status-pill, .dx-row-actions...).+ //+ // Two accessors per column on purpose: `value` is what the column menu, the+ // filter rules and the export read (ds/grid/fields.js), `sortValue` is what+ // DataTable's sorter reads. Declaring only one gets the other from the+ // wrong place — and where `sortValue` is a rank NUMBER (Status, Health)+ // that would type the column `num` and make every string rule below match+ // exactly nothing.const columns = [{key: 'name',header: 'Name',sortable: true,hideable: false,+ type: 'text',+ value: (container) => getContainerName(container),sortValue: (container) => getContainerName(container),render: (container) => {const isRunning = isContainerRunning(container);@@ -302,6 +433,13 @@ const ContainersTab = ({ onStatsChange }) => {key: 'image',header: 'Image',sortable: true,+ type: 'text',+ // Grouping is the whole point of the "By image" view. `groupValue`+ // has to be spelled out as well: DataTable's grouper falls back to+ // row[key], and the remote agent spells the field `Image`.+ groupable: true,+ value: (container) => getContainerImage(container),+ groupValue: (container) => getContainerImage(container),sortValue: (container) => getContainerImage(container),render: (container) => (<span className="dx-code-pill" title={getContainerImage(container)}>@@ -313,6 +451,13 @@ const ContainersTab = ({ onStatsChange }) => {key: 'status',header: 'Status',sortable: true,+ // The pill's own text IS the filterable value, so a preset that+ // says 'Running' reads exactly the way the row does. No enumOrder:+ // the label falls through to the raw state for anything past+ // running/exited/created, and a fixed list would hide 'paused' or+ // 'dead' from the pick-list on the one host that has them.+ type: 'enum',+ value: (container) => getContainerStatusLabel(container),// Running first on asc, matching the old default sort.sortValue: (container) => (isContainerRunning(container) ? 0 : 1),render: (container) => (@@ -324,10 +469,34 @@ const ContainersTab = ({ onStatsChange }) => {</>),},+ {+ key: 'health',+ header: 'Health',+ sortable: true,+ type: 'enum',+ // A closed set of four labels this file produces, so the pick-list+ // can be ordered by severity instead of alphabetically.+ enumOrder: HEALTH_LABELS,+ value: containerHealth,+ sortValue: (container) => HEALTH_RANK[containerHealth(container)],+ render: (container) => {+ const health = containerHealth(container);+ // Spelled out rather than shown as 'None': the absence of a+ // healthcheck is a fact about the image, not a missing reading.+ if (health === 'None') return <span className="dx-muted-line">No healthcheck</span>;+ return <Pill kind={HEALTH_TONE[health]} dot={false}>{health}</Pill>;+ },+ },{key: 'ports',header: 'Ports',sortable: false,+ // Filterable even though it is not sortable: "which containers are+ // published to the host" is a `contains ->` away. The accessor has+ // to be formatPorts — the raw field is a string on the local+ // transport and an array of objects on the remote one.+ type: 'text',+ value: (container) => formatPorts(container.ports).join(', '),render: (container) => {const ports = formatPorts(container.ports);return (@@ -344,11 +513,14 @@ const ContainersTab = ({ onStatsChange }) => {key: 'resources',header: 'Resources',sortable: true,- // CPU% is the headline number; containers without stats sort last.- sortValue: (container) => {- const stats = parseStats(containerStats[getContainerId(container)]);- return stats.available ? stats.cpu : null;- },+ // Declared, not inferred: on a host where everything is stopped no+ // row has a reading at all, and an all-null sample infers no type —+ // the column would offer filtering on a busy host and not on an+ // idle one.+ type: 'num',+ unit: '%',+ value: cpuPercent,+ sortValue: cpuPercent,render: (container) => (<ContainerResourceBarsstats={parseStats(containerStats[getContainerId(container)])}@@ -360,6 +532,12 @@ const ContainersTab = ({ onStatsChange }) => {key: 'created',header: 'Created',sortable: true,+ // Declared: `sortValue` is epoch ms, and letting that number type+ // the column would offer "is under 1754…" instead of a date picker.+ // The raw value is docker's CreatedAt ("2026-08-12 09:12:33 -0400+ // EDT"), which both Date.parse and the rule engine read.+ type: 'date',+ value: (container) => container.created || container.CreatedAt || null,sortValue: (container) => {const parsed = Date.parse(container.created || container.CreatedAt || '');return Number.isNaN(parsed) ? null : parsed;@@ -417,6 +595,34 @@ const ContainersTab = ({ onStatsChange }) => {},];+ // The page-private half of a saved view. `showAll` belongs in it because it+ // is not a filter over the rows on screen — it changes the REQUEST+ // (`docker ps` vs `docker ps -a`), so a view that wants stopped containers+ // has to be able to ask for them.+ const viewPageState = useMemo(() => ({ showAll, search: searchTerm }), [showAll, searchTerm]);+ const applyViewPageState = useCallback((saved) => {+ if (saved.showAll !== undefined) setShowAll(!!saved.showAll);+ if (saved.search !== undefined) setSearchTerm(saved.search);+ }, []);++ // The only table on the /docker route (the other tabs render lists of their+ // own resources, not a second grid over these rows), so no urlScope.+ const chrome = useTableChrome({+ columns,+ rows: filteredContainers,+ viewPageKey: 'docker-containers',+ builtinViews: BUILTIN_VIEWS,+ noun: 'containers',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ groupBy,+ setGroupBy,+ pageState: viewPageState,+ applyPage: applyViewPageState,+ });+if (loading) {return (<div className="dx-tab-pane">@@ -427,33 +633,42 @@ const ContainersTab = ({ onStatsChange }) => {return (<div className="dx-tab-pane dx-containers-pane">+ {/* The view name is this pane's heading, and the table's own+ controls ride the same line. `shownCount` is the count that+ matches the body: `filteredContainers` has only been through the+ search, the column rules are applied inside DataTable. */}+ <GridViewPicker+ views={chrome.views}+ label="containers"+ total={`${chrome.shownCount} of ${containers.length} containers`}+ onCreate={chrome.createView}+ actions={(+ <>+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadContainers} />+ </>+ )}+ />++ <GridChips {...chrome.chipProps} />++ {/* What is left of the toolbar is the page's own: the fetch scope+ and the search it runs before the table sees a row. The+ All/Running/Stopped chips that used to sit here were column+ rules in disguise and are built-in views now. */}<div className="dx-tab-toolbar">- <div className="dx-filter-chips">- {[- { id: 'all', label: 'All', count: counts.all },- { id: 'running', label: 'Running', count: counts.running },- { id: 'stopped', label: 'Stopped', count: counts.stopped },- ].map(c => (- <button type="button"- key={c.id}- className={`filter-chip ${statusFilter === c.id ? 'active' : ''}`}- onClick={() => setStatusFilter(c.id)}- disabled={c.id !== 'all' && c.count === 0}- >- <span>{c.label}</span>- <span className="filter-chip-count">{c.count}</span>- </button>- ))}- </div>+ <label className="dx-toggle">+ <input+ type="checkbox"+ checked={showAll}+ onChange={(e) => setShowAll(e.target.checked)}+ />+ <span>Include stopped</span>+ </label><div className="dx-tab-toolbar-right">- <label className="dx-toggle">- <input- type="checkbox"- checked={showAll}- onChange={(e) => setShowAll(e.target.checked)}- />- <span>Include stopped</span>- </label><div className="dx-search-field"><Search size={13} className="lv-search-field-icon" /><input@@ -481,25 +696,29 @@ const ContainersTab = ({ onStatsChange }) => {</div></div>+ {/* Only the SEARCH can empty the pane outright. A column rule that+ matches nothing keeps the table mounted — the header menu that+ undoes it lives in the header. */}{filteredContainers.length === 0 ? (<EmptyStateicon={Box}title={containers.length === 0 ? 'No containers' : 'No matching containers'}description={containers.length === 0? 'Run your first container to see it here.'- : 'No containers match the current filters.'}+ : 'No containers match the current search.'}/>) : (<div className="dx-manager-layout"><section className="dx-resource-list"><DataTable- columns={columns}+ {...chrome.tableProps}+ columns={chrome.columns}data={filteredContainers}keyField={(container) => getContainerId(container)}sorts={sorts}onSortsChange={setSorts}- hiddenKeys={hiddenKeys}- onHiddenKeysChange={setHiddenKeys}+ groupBy={groupBy}+ onGroupByChange={setGroupBy}onRowClick={(container) => setSelectedContainer(container)}rowClassName={(container) => (`${isContainerRunning(container) ? 'is-running' : 'is-stopped'} ${getContainerId(selectedContainer) === getContainerId(container) ? 'is-selected' : ''}`@@ -508,7 +727,7 @@ const ContainersTab = ({ onStatsChange }) => {tableClassName="dx-manager-table"footer={(<DataTableFooter- shown={filteredContainers.length}+ shown={chrome.shownCount}total={containers.length}noun="container"/>@@ -542,6 +761,11 @@ const ContainersTab = ({ onStatsChange }) => {onClose={() => setExecContainer(null)}/>)}++ {/* The pane's only filter affordance beyond the per-column menus:+ there is no server-side filter drawer here, just the fetch-scope+ checkbox and the search. */}+ <GridFilterDrawer {...chrome.drawerProps} /></div>);};diff --git a/frontend/src/components/serverdetail/CloudflaredTab.jsx b/frontend/src/components/serverdetail/CloudflaredTab.jsxindex 574acfe5..535d3f87 100644--- a/frontend/src/components/serverdetail/CloudflaredTab.jsx+++ b/frontend/src/components/serverdetail/CloudflaredTab.jsx@@ -5,6 +5,10 @@ import { useConfirm } from '../../hooks/useConfirm';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { DataTable, DataTableFooter, Pill } from '../ds';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';import EmptyState from '../EmptyState';@@ -25,6 +29,62 @@ import {// using that cert. /status surfaces both "binary present" and// "cert present" so we can show "log in first" before users hit// CRUD actions and get confusing errors back.+// Built-in saved views. A tunnel row is { id, name, created_at?, connections[] }+// — cloudflared reports no status field of its own, so "is this thing carrying+// anything" IS the connection count, and the `state` column below is the only+// honest way to name it. Rules match that column's `value`, which is the same+// word the Pill renders.+const NO_RULES = { match: 'all', rules: [] };+const STATE_IS = (value) => ({+ match: 'all',+ rules: [{ id: 'cf1', field: 'state', op: 'any', value: [value] }],+});++const TUNNEL_VIEWS = [+ {+ // Everything, alphabetically — the landing view and the "nothing is+ // filtered" answer.+ name: 'All tunnels',+ state: {+ sorts: [{ key: 'name', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: NO_RULES,+ },+ },+ {+ // Tunnels with at least one edge connection: what is actually serving+ // traffic right now, busiest first.+ name: 'Connected',+ state: {+ sorts: [{ key: 'connections', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: STATE_IS('connected'),+ },+ },+ {+ // The cleanup list. A named tunnel with no connector attached is a+ // hostname that resolves to nothing — either the connector died or the+ // tunnel was created and never wired up.+ name: 'Idle',+ state: {+ sorts: [{ key: 'name', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: STATE_IS('idle'),+ },+ },+ {+ // "Which one did I just make?" — the question this tab's own Create+ // button leaves you with. Tunnels whose created_at the agent could not+ // read sort last: nulls always sink.+ name: 'Newest first',+ state: {+ sorts: [{ key: 'created', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: NO_RULES,+ },+ },+];+const CloudflaredTab = ({ serverId, serverStatus }) => {const toast = useToast();const { confirm: confirmCf } = useConfirm();@@ -201,52 +261,80 @@ const CloudflaredTab = ({ serverId, serverStatus }) => {setLogin(null);}- if (serverStatus !== 'online') {- return (- <div className="offline-notice">- <OfflineIcon />- <h4>Server Offline</h4>- <p>Tunnel management requires the server to be online.</p>- </div>- );- }-- if (loading) {- return <EmptyState loading loadingVariant="table" title="Loading tunnels" />;- }-- // Status banner — three distinct states the UI cares about:- // 1. binary missing → "install cloudflared"- // 2. binary, no cert → "log in once"- // 3. binary + cert → ready to manage tunnels- const notInstalled = status?.available === false;- const notAuthed = status?.available && status?.authenticated === false;-// Tunnels table columns. Cell markup and classNames are identical to the// hand-rolled table they replace so the .cron-tab__* / .data-table SCSS// keeps applying.+ //+ // Declared above the offline/loading guards: the chrome below is a hook, so+ // it cannot sit behind an early return.const tunnelColumns = [{key: 'name',header: 'Name',sortable: true,hideable: false,+ type: 'text',+ value: (t) => t.name || '',sortValue: (t) => t.name || '',render: (t) => <span className="cron-tab__name">{t.name}</span>,},{key: 'id',header: 'ID',+ // The cell shows the first 8 chars, but a rule reads the whole+ // UUID: pasting one out of a cloudflared log should find its row.+ type: 'text',+ value: (t) => t.id || '',cellClassName: 'mono',render: (t) => `${(t.id || '').substring(0, 8)}…`,},+ {+ // Its own column rather than a pill tacked onto Connections:+ // "is this tunnel carrying anything" is the question this table+ // exists to answer, and cloudflared reports no status field to read+ // it from — the connector count IS the status. Declared enum, not+ // inferred: two tunnels in the same state fail the cardinality test+ // and would fall back to text, which turns the pick-list into a+ // typed fragment and both views above into no-ops.+ key: 'state',+ header: 'State',+ sortable: true,+ type: 'enum',+ enumOrder: ['connected', 'idle'],+ value: (t) => (t.connections?.length ? 'connected' : 'idle'),+ sortValue: (t) => (t.connections?.length ? 'connected' : 'idle'),+ render: (t) => (+ <Pill kind={t.connections?.length ? 'green' : 'gray'}>+ {t.connections?.length ? 'connected' : 'idle'}+ </Pill>+ ),+ },{key: 'connections',header: 'Connections',sortable: true,+ type: 'num',+ value: (t) => t.connections?.length ?? 0,sortValue: (t) => t.connections?.length ?? 0,render: (t) => t.connections?.length || 0,},+ {+ // `created_at` is omitempty on the agent's Tunnel struct, so a row+ // may legitimately carry none — hence the em dash. Declared date+ // rather than inferred from the epoch `sortValue`, or the menu+ // would offer "is under 1754…" instead of a date picker.+ key: 'created',+ header: 'Created',+ sortable: true,+ type: 'date',+ value: (t) => t.created_at || null,+ sortValue: (t) => {+ const time = Date.parse(t.created_at);+ return Number.isNaN(time) ? null : time;+ },+ cellClassName: 'mono',+ render: (t) => (t.created_at ? new Date(t.created_at).toLocaleString() : '—'),+ },{key: 'actions',header: 'Actions',@@ -275,6 +363,43 @@ const CloudflaredTab = ({ serverId, serverStatus }) => {},];+ // Scoped to this tab, not to the server as a page: one tab is mounted at a+ // time, so a picker at the page heading would sit above whichever tab+ // happened to be open. No `urlScope` — the tunnels table is the only one on+ // this tab, so its links keep the plain ?view= names.+ const chrome = useTableChrome({+ columns: tunnelColumns,+ rows: tunnels,+ viewPageKey: 'serverdetail-tunnels',+ builtinViews: TUNNEL_VIEWS,+ noun: 'tunnels',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ });++ if (serverStatus !== 'online') {+ return (+ <div className="offline-notice">+ <OfflineIcon />+ <h4>Server Offline</h4>+ <p>Tunnel management requires the server to be online.</p>+ </div>+ );+ }++ if (loading) {+ return <EmptyState loading loadingVariant="table" title="Loading tunnels" />;+ }++ // Status banner — three distinct states the UI cares about:+ // 1. binary missing → "install cloudflared"+ // 2. binary, no cert → "log in once"+ // 3. binary + cert → ready to manage tunnels+ const notInstalled = status?.available === false;+ const notAuthed = status?.available && status?.authenticated === false;+return (<div className="cloudflared-tab"><div className="cron-tab__header">@@ -286,7 +411,8 @@ const CloudflaredTab = ({ serverId, serverStatus }) => {) : (<Pill kind="green">cloudflared ready{status?.version ? ` (${status.version})` : ''}</Pill>)}- <span className="cron-tab__count">{tunnels.length} tunnel{tunnels.length === 1 ? '' : 's'}</span>+ {/* The tunnel count moved to the view bar below, where it+ can say how many of them the active view is showing. */}</div><div className="cron-tab__actions"><Button variant="outline" onClick={loadTunnels} disabled={notInstalled}>Refresh</Button>@@ -334,26 +460,55 @@ const CloudflaredTab = ({ serverId, serverStatus }) => {description="No tunnels on this server. Use Create Tunnel to make one."/>) : (- <DataTable- columns={tunnelColumns}- data={tunnels}- keyField={(t) => t.id || t.name}- sorts={sorts}- onSortsChange={setSorts}- hiddenKeys={hiddenKeys}- onHiddenKeysChange={setHiddenKeys}- tableClassName="data-table"- footer={(- <DataTableFooter- shown={tunnels.length}- total={tunnels.length}- noun="tunnel"- />- )}- />+ <>+ {/* One row of chrome: the view name is the heading, and+ the filter button and "⋮" ride it rather than a+ second bar that would hold nothing else. */}+ <GridViewPicker+ views={chrome.views}+ label="tunnels"+ total={`${chrome.shownCount} of ${tunnels.length} tunnels`}+ onCreate={chrome.createView}+ actions={(+ <>+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadTunnels} />+ </>+ )}+ />++ <GridChips {...chrome.chipProps} />++ <DataTable+ columns={chrome.columns}+ data={tunnels}+ keyField={(t) => t.id || t.name}+ sorts={sorts}+ onSortsChange={setSorts}+ {...chrome.tableProps}+ tableClassName="data-table"+ emptyTitle="No tunnels match this view."+ emptyMessage=""+ footer={(+ <DataTableFooter+ // DataTable applies the column rules itself,+ // so the shown count comes from the chrome —+ // `tunnels` is only ever the whole list.+ shown={chrome.shownCount}+ total={tunnels.length}+ noun="tunnel"+ />+ )}+ />+ </>))}+ <GridFilterDrawer {...chrome.drawerProps} />+<Modalopen={showCreateModal}onClose={() => { if (!creating) setShowCreateModal(false); }}diff --git a/frontend/src/components/serverdetail/CronTab.jsx b/frontend/src/components/serverdetail/CronTab.jsxindex c54c43e8..e6c9ab5f 100644--- a/frontend/src/components/serverdetail/CronTab.jsx+++ b/frontend/src/components/serverdetail/CronTab.jsx@@ -6,6 +6,10 @@ import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Textarea } from '@/components/ui/textarea';import { DataTable, DataTableFooter, Pill } from '../ds';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';import EmptyState from '../EmptyState';@@ -27,6 +31,52 @@ import {TrashIcon,} from './serverDetailShared';+// Built-in saved views. A remote cron entry is only+// { id, schedule, command, enabled, name?, description? } — the agent parses+// the host crontab and there is no run history behind it — so enabled/disabled+// is the one axis worth slicing, and it is exactly the axis the row already+// renders as a pill. Every rule below matches the `status` column's `value`,+// which is the same lowercase string the Pill shows.+const NO_RULES = { match: 'all', rules: [] };+const ENABLED_IS = (value) => ({+ match: 'all',+ rules: [{ id: 'cr1', field: 'status', op: 'any', value: [value] }],+});++const CRON_VIEWS = [+ {+ // The whole crontab in the order cron itself would read it — the+ // landing view, and the one that says "nothing is filtered".+ name: 'All jobs',+ state: {+ sorts: [{ key: 'schedule', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: NO_RULES,+ },+ },+ {+ // What will actually fire. A disabled entry is still a line in the+ // crontab (commented out), so "what runs on this box" is a question+ // the unfiltered table cannot answer at a glance.+ name: 'Enabled',+ state: {+ sorts: [{ key: 'schedule', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: ENABLED_IS('enabled'),+ },+ },+ {+ // The other half: entries someone parked rather than removed. Usually+ // short, and worth reading before adding a job that duplicates one.+ name: 'Disabled',+ state: {+ sorts: [{ key: 'schedule', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: ENABLED_IS('disabled'),+ },+ },+];+const CronTab = ({ serverId, serverStatus }) => {const toast = useToast();const { confirm: confirmCron } = useConfirm();@@ -135,29 +185,22 @@ const CronTab = ({ serverId, serverStatus }) => {}}- if (serverStatus !== 'online') {- return (- <div className="offline-notice">- <OfflineIcon />- <h4>Server Offline</h4>- <p>Cron management requires the server to be online.</p>- </div>- );- }-- if (loading) {- return <EmptyState loading title="Loading cron jobs" />;- }-// Jobs table columns. Cell markup and classNames are identical to the// hand-rolled table they replace so the .cron-tab / .data-table SCSS// keeps applying (.cron-tab__name, .cron-tab__command, .mono).+ //+ // Declared above the offline/loading guards: the chrome below is a hook, so+ // it cannot sit behind an early return.const cronColumns = [{key: 'schedule',header: 'Schedule',sortable: true,hideable: false,+ // A cron expression is a fragment you type ('0 3'), not a value you+ // pick from a list — five fields make almost every row distinct.+ type: 'text',+ value: (job) => job.schedule || '',sortValue: (job) => job.schedule || '',render: (job) => (<>@@ -172,6 +215,10 @@ const CronTab = ({ serverId, serverStatus }) => {key: 'command',header: 'Command',sortable: true,+ // Paths and flags: high cardinality, so contains/starts-with is the+ // useful control here too.+ type: 'text',+ value: (job) => job.command || '',sortValue: (job) => job.command || '',render: (job) => (<>@@ -184,6 +231,13 @@ const CronTab = ({ serverId, serverStatus }) => {key: 'status',header: 'Status',sortable: true,+ // Declared, not inferred: a crontab with two entries fails the enum+ // cardinality test and would fall back to text, which turns the+ // pick-list into a typed fragment and both views above into no-ops.+ // `value` is what the rules read — the same word the Pill renders.+ type: 'enum',+ enumOrder: ['enabled', 'disabled'],+ value: (job) => (job.enabled ? 'enabled' : 'disabled'),sortValue: (job) => (job.enabled ? 'enabled' : 'disabled'),render: (job) => (<Pill kind={job.enabled ? 'green' : 'gray'}>@@ -219,6 +273,36 @@ const CronTab = ({ serverId, serverStatus }) => {},];+ // Scoped to this tab, not to the server as a page: one tab is mounted at a+ // time, so a picker at the page heading would sit above whichever tab+ // happened to be open. No `urlScope` — the jobs table is the only one on+ // this tab, so its links keep the plain ?view= names.+ const chrome = useTableChrome({+ columns: cronColumns,+ rows: jobs,+ viewPageKey: 'serverdetail-cron',+ builtinViews: CRON_VIEWS,+ noun: 'jobs',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ });++ if (serverStatus !== 'online') {+ return (+ <div className="offline-notice">+ <OfflineIcon />+ <h4>Server Offline</h4>+ <p>Cron management requires the server to be online.</p>+ </div>+ );+ }++ if (loading) {+ return <EmptyState loading title="Loading cron jobs" />;+ }+return (<div className="cron-tab"><div className="cron-tab__header">@@ -230,7 +314,8 @@ const CronTab = ({ serverId, serverStatus }) => {) : (<Pill kind="green">cron daemon active{status?.daemon ? ` (${status.daemon})` : ''}</Pill>)}- <span className="cron-tab__count">{jobs.length} job{jobs.length === 1 ? '' : 's'}</span>+ {/* The job count moved to the view bar below, where it can+ say how many of them the active view is showing. */}</div><div className="cron-tab__actions"><Button variant="outline" onClick={loadJobs}>Refresh</Button>@@ -251,26 +336,55 @@ const CronTab = ({ serverId, serverStatus }) => {description="No scheduled jobs on this server. Use Add Job to schedule one."/>) : (- <DataTable- columns={cronColumns}- data={jobs}- keyField="id"- sorts={sorts}- onSortsChange={setSorts}- hiddenKeys={hiddenKeys}- onHiddenKeysChange={setHiddenKeys}- rowClassName={(job) => (!job.enabled ? 'row-disabled' : '')}- tableClassName="data-table"- footer={(- <DataTableFooter- shown={jobs.length}- total={jobs.length}- noun="job"- />- )}- />+ <>+ {/* One row of chrome: the view name is the heading, and the+ filter button and "⋮" ride it rather than a second bar+ that would hold nothing else. */}+ <GridViewPicker+ views={chrome.views}+ label="jobs"+ total={`${chrome.shownCount} of ${jobs.length} jobs`}+ onCreate={chrome.createView}+ actions={(+ <>+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadJobs} />+ </>+ )}+ />++ <GridChips {...chrome.chipProps} />++ <DataTable+ columns={chrome.columns}+ data={jobs}+ keyField="id"+ sorts={sorts}+ onSortsChange={setSorts}+ {...chrome.tableProps}+ rowClassName={(job) => (!job.enabled ? 'row-disabled' : '')}+ tableClassName="data-table"+ emptyTitle="No jobs match this view."+ emptyMessage=""+ footer={(+ <DataTableFooter+ // DataTable applies the column rules itself, so+ // the shown count comes from the chrome — `jobs`+ // is only ever the whole crontab.+ shown={chrome.shownCount}+ total={jobs.length}+ noun="job"+ />+ )}+ />+ </>)}+ <GridFilterDrawer {...chrome.drawerProps} />+<Modalopen={showAddModal}onClose={() => { if (!submitting) setShowAddModal(false); }}diff --git a/frontend/src/components/serverdetail/ServicesTab.jsx b/frontend/src/components/serverdetail/ServicesTab.jsxindex 2021bfa7..201e8caf 100644--- a/frontend/src/components/serverdetail/ServicesTab.jsx+++ b/frontend/src/components/serverdetail/ServicesTab.jsx@@ -4,15 +4,78 @@ import { useToast } from '../../contexts/ToastContext';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Pill, DataTable, DataTableFooter, ListToolbar } from '../ds';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';import Modal from '../Modal';-const STATE_FILTERS = [- { value: '', label: 'All' },- { value: 'active', label: 'Active' },- { value: 'failed', label: 'Failed' },- { value: 'inactive', label: 'Inactive' },+// Built-in saved views. These are the four buttons that used to sit in the+// toolbar (All / Active / Failed / Inactive) — they narrowed the AGENT query+// (`systemctl --state=…`), which meant every other control on the page was+// reasoning about a partial list. The agent already passes `--all`, so the+// unfiltered response carries every state and the same buckets are exact+// client-side rules over the whole set.+//+// Every rule matches the `state` column's `value`, which is systemd's own+// ACTIVE word — the one the Pill renders.+const NO_RULES = { match: 'all', rules: [] };+const STATE_IS = (id, ...values) => ({+ match: 'all',+ rules: [{ id, field: 'state', op: 'any', value: values }],+});++// Each view clears the search box (`page: { search: '' }`) rather than leaving+// it out: an omitted key means "leave whatever is typed", and the view would+// then read as unsaved the moment it was applied on top of a search.+const SERVICE_VIEWS = [+ {+ // The worklist. A failed unit is the only row on this page that is+ // unambiguously wrong, so it leads.+ name: 'Failed units',+ state: {+ sorts: [{ key: 'unit', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: STATE_IS('sv1', 'failed'),+ page: { search: '' },+ },+ },+ {+ // What is actually up. 'activating' rides along: it is on its way to+ // active, and burying a unit stuck mid-start under "everything else" is+ // how a slow boot gets missed.+ name: 'Running',+ state: {+ sorts: [{ key: 'unit', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: STATE_IS('sv2', 'active', 'activating'),+ page: { search: '' },+ },+ },+ {+ // Installed but not running. On a `--all` listing this is most of the+ // list, and it is the half you scan when something should be up.+ name: 'Inactive',+ state: {+ sorts: [{ key: 'unit', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: STATE_IS('sv3', 'inactive'),+ page: { search: '' },+ },+ },+ {+ // Everything the agent returned, no rules — the "nothing is filtered"+ // answer, and the view a search is usually run against.+ name: 'All units',+ state: {+ sorts: [{ key: 'unit', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: NO_RULES,+ page: { search: '' },+ },+ },];// systemd active/sub state → ds Pill kind@@ -32,7 +95,6 @@ const ServicesTab = ({ serverId, serverStatus }) => {const toast = useToast();const [units, setUnits] = useState([]);const [loading, setLoading] = useState(true);- const [stateFilter, setStateFilter] = useState('');const [search, setSearch] = useState('');const [busyUnit, setBusyUnit] = useState(null);const [logsFor, setLogsFor] = useState(null); // { unit, entries, raw }@@ -41,17 +103,20 @@ const ServicesTab = ({ serverId, serverStatus }) => {hiddenKeys, setHiddenKeys,} = useColumnVisibility({ storageKey: 'serverkit-table-sd-services-cols' });+ // One unfiltered fetch. The state buckets are column rules now, so asking+ // the agent for a subset would only hide rows from the rules — and from the+ // count next to them.const loadUnits = useCallback(async () => {setLoading(true);try {- const data = await api.getRemoteServices(serverId, { state: stateFilter || null });+ const data = await api.getRemoteServices(serverId);setUnits(data?.units || []);} catch (err) {toast.error(err.message || 'Failed to load services');} finally {setLoading(false);}- }, [serverId, stateFilter, toast]);+ }, [serverId, toast]);useEffect(() => {if (serverStatus !== 'online') {@@ -67,6 +132,13 @@ const ServicesTab = ({ serverId, serverStatus }) => {return units.filter((u) => u.unit?.toLowerCase().includes(needle));}, [units, search]);+ // The page's own half of a saved view. Everything else — sorts, hidden+ // columns, rules — is captured identically on every list page.+ const viewPageState = useMemo(() => ({ search }), [search]);+ const applyViewPageState = useCallback((saved) => {+ if (saved.search !== undefined) setSearch(saved.search);+ }, []);+async function control(unit, action) {setBusyUnit(unit);try {@@ -103,23 +175,22 @@ const ServicesTab = ({ serverId, serverStatus }) => {}}- if (serverStatus !== 'online') {- return (- <div className="empty-state">- <p>Server is offline. Reconnect to manage services.</p>- </div>- );- }-// Units table columns. Cell markup and classNames are identical to the// hand-rolled table they replace so the .server-services__* SCSS keeps// applying (.server-services__desc, .server-services__row-actions, .mono).+ //+ // Declared above the offline guard: the chrome below is a hook, so it+ // cannot sit behind an early return.const unitColumns = [{key: 'unit',header: 'Unit',sortable: true,hideable: false,+ // Hundreds of distinct names on a real host — a fragment you type,+ // never a list you pick from.+ type: 'text',+ value: (u) => u.unit || '',sortValue: (u) => u.unit || '',cellClassName: 'mono',render: (u) => u.unit,@@ -128,6 +199,16 @@ const ServicesTab = ({ serverId, serverStatus }) => {key: 'state',header: 'State',sortable: true,+ // Declared, not inferred: systemd's ACTIVE vocabulary is six words+ // wide, but a host where every unit is active offers ONE distinct+ // value and the column would fall back to text — which turns the+ // pick-list into a typed fragment and every view above into a+ // no-op. `value` is what the rules read: the same word the Pill+ // renders, `sub` standing in only when the agent's plain-text+ // fallback left ACTIVE empty.+ type: 'enum',+ enumOrder: ['active', 'activating', 'failed', 'inactive'],+ value: (u) => u.active || u.sub || 'unknown',sortValue: (u) => u.active || u.sub || 'unknown',render: (u) => (<Pill kind={STATE_PILL[u.active] || STATE_PILL[u.sub] || 'gray'}>@@ -139,6 +220,8 @@ const ServicesTab = ({ serverId, serverStatus }) => {key: 'description',header: 'Description',sortable: true,+ type: 'text',+ value: (u) => u.description || '',sortValue: (u) => u.description || '',cellClassName: 'server-services__desc',render: (u) => u.description,@@ -175,8 +258,54 @@ const ServicesTab = ({ serverId, serverStatus }) => {},];+ // `rows` is the SEARCHED list — the column rules are applied inside+ // DataTable, and the counts below come back through `chrome.shownCount`.+ // The search box is the page's own state, so it rides `page` in the+ // envelope and a saved view carries it. No `urlScope`: the units table is+ // the only one on this tab, so its links keep the plain ?view= names.+ const chrome = useTableChrome({+ columns: unitColumns,+ rows: filtered,+ viewPageKey: 'serverdetail-services',+ builtinViews: SERVICE_VIEWS,+ noun: 'units',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ pageState: viewPageState,+ applyPage: applyViewPageState,+ });++ if (serverStatus !== 'online') {+ return (+ <div className="empty-state">+ <p>Server is offline. Reconnect to manage services.</p>+ </div>+ );+ }+return (<div className="server-services">+ {/* The view name is the heading and carries the counts; the filter+ button and "⋮" ride it. The toolbar below keeps only what is+ the PAGE's rather than the table's: search, and the two systemd+ actions. */}+ <GridViewPicker+ views={chrome.views}+ label="units"+ total={`${chrome.shownCount} of ${units.length} units`}+ onCreate={chrome.createView}+ actions={(+ <>+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadUnits} />+ </>+ )}+ /><ListToolbartools={(<div className="server-services__actions">@@ -197,37 +326,28 @@ const ServicesTab = ({ serverId, serverStatus }) => {placeholder="Filter by unit name…"className="server-services__search"/>- <div className="server-services__filters">- {STATE_FILTERS.map((f) => (- <Button- key={f.value || 'all'}- variant={stateFilter === f.value ? 'default' : 'outline'}- size="sm"- onClick={() => setStateFilter(f.value)}- >- {f.label}- </Button>- ))}- </div></ListToolbar>+ <GridChips {...chrome.chipProps} />+{loading ? (<p className="text-muted-foreground">Loading…</p>) : filtered.length === 0 ? (<p className="text-muted-foreground">No matching units.</p>) : (<DataTable- columns={unitColumns}+ columns={chrome.columns}data={filtered}keyField="unit"sorts={sorts}onSortsChange={setSorts}- hiddenKeys={hiddenKeys}- onHiddenKeysChange={setHiddenKeys}+ {...chrome.tableProps}tableClassName="server-services__table"+ emptyTitle="No units match this view."+ emptyMessage=""footer={(<DataTableFooter- shown={filtered.length}+ shown={chrome.shownCount}total={units.length}noun="unit"/>@@ -235,6 +355,8 @@ const ServicesTab = ({ serverId, serverStatus }) => {/>)}+ <GridFilterDrawer {...chrome.drawerProps} />+<Modalopen={!!logsFor}onClose={() => setLogsFor(null)}diff --git a/frontend/src/pages/Backups.jsx b/frontend/src/pages/Backups.jsxindex c72eebb9..9407cb57 100644--- a/frontend/src/pages/Backups.jsx+++ b/frontend/src/pages/Backups.jsx@@ -1,4 +1,4 @@-import { useState, useEffect } from 'react';+import { useState, useEffect, useCallback, useMemo } from 'react';import useTabParam from '../hooks/useTabParam';import { Upload, Check, AlertTriangle, Archive, Clock, Database, Package, FolderArchive, HardDrive, History, Cloud, RefreshCw, Trash2, Plus, FileArchive, DollarSign } from 'lucide-react';import api from '../services/api';@@ -12,9 +12,12 @@ import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Textarea } from '@/components/ui/textarea';import {- Pill, SearchField, SegControl, DataTable, SortChipBar, DataTableFooter,- ListToolbar,+ Pill, SearchField, SegControl, DataTable, DataTableFooter,} from '@/components/ds';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';import BackupsOverview from '../components/backups/BackupsOverview';import SchedulesTable from '../components/backups/SchedulesTable';import StorageDestinations from '../components/backups/StorageDestinations';@@ -29,6 +32,91 @@ const TAB_ALIASES = { backups: 'snapshots' };const PROVIDER_LABELS = { local: 'Local only', s3: 'S3-Compatible', b2: 'Backblaze B2' };+// Where a snapshot actually lives, as the one word the Storage pill prints.+// The filter rules read the same map, so a preset that says 'Local' means the+// rows whose cell says Local — never the raw `remote_status` behind it.+const REMOTE_STATUS_LABEL = { synced: 'Synced', 'remote-only': 'Remote' };+const remoteStatusLabel = (status) => REMOTE_STATUS_LABEL[status] || 'Local';++// Built-in views for the snapshot archive. Every rule matches against a+// column's `value` accessor, so 'application' below is the raw type the Type+// tag prints and 'Local' is the word the Storage pill prints.+//+// The first four replace the All/Applications/Databases/Files segment row that+// used to sit above the table. A segment that buckets rows IS a column rule,+// and as a view each bucket can also carry the sort and the columns it wants+// instead of only narrowing the list.+const NO_RULES = { match: 'all', rules: [] };++const SNAPSHOT_VIEWS = [+ {+ // The archive's natural read: what was captured most recently.+ name: 'Newest first',+ state: {+ sorts: [{ key: 'created', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: NO_RULES,+ page: { search: '' },+ },+ },+ {+ // Site snapshots. Type is hidden — every row under this view is one,+ // so the column would be the same tag repeated down the page.+ name: 'Applications',+ state: {+ sorts: [{ key: 'created', direction: 'desc' }],+ hiddenKeys: ['type'],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'bs1', field: 'type', op: 'any', value: ['application'] }],+ },+ page: { search: '' },+ },+ },+ {+ // Dump files, newest first — the ones a restore actually reaches for.+ name: 'Databases',+ state: {+ sorts: [{ key: 'created', direction: 'desc' }],+ hiddenKeys: ['type'],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'bs2', field: 'type', op: 'any', value: ['database'] }],+ },+ page: { search: '' },+ },+ },+ {+ // A files snapshot is a list of paths, so it has no site to name and+ // Site/Service would be a column of em-dashes.+ name: 'Files',+ state: {+ sorts: [{ key: 'created', direction: 'desc' }],+ hiddenKeys: ['type', 'site'],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'bs3', field: 'type', op: 'any', value: ['files'] }],+ },+ page: { search: '' },+ },+ },+ {+ // The risk list: snapshots that exist ONLY on this box, biggest first.+ // If the disk goes they go with it, and the biggest are the ones worth+ // copying off. Storage is hidden because every row here says Local.+ name: 'Local only',+ state: {+ sorts: [{ key: 'size', direction: 'desc' }],+ hiddenKeys: ['storage'],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'bs4', field: 'storage', op: 'any', value: ['Local'] }],+ },+ page: { search: '' },+ },+ },+];+const Backups = () => {const toast = useToast();const { confirm } = useConfirm();@@ -43,7 +131,6 @@ const Backups = () => {const [error, setError] = useState(null);const [rawTab, setActiveTab] = useTabParam('/backups', VALID_TABS);const activeTab = TAB_ALIASES[rawTab] || rawTab;- const [filterType, setFilterType] = useState('all');const [search, setSearch] = useState('');const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-backups-sort' });const {@@ -397,26 +484,45 @@ const Backups = () => {}};+ // The pill text comes from the same map the filter rules do, so the word in+ // the cell and the word in a rule can never drift apart.const getRemoteStatusPill = (status) => {+ const label = remoteStatusLabel(status);switch (status) {case 'synced':- return <Pill kind="green" dot={false}><Cloud size={11} /> Synced</Pill>;+ return <Pill kind="green" dot={false}><Cloud size={11} /> {label}</Pill>;case 'remote-only':- return <Pill kind="cyan" dot={false}><Cloud size={11} /> Remote</Pill>;+ return <Pill kind="cyan" dot={false}><Cloud size={11} /> {label}</Pill>;default:- return <Pill kind="gray" dot={false}><HardDrive size={11} /> Local</Pill>;+ return <Pill kind="gray" dot={false}><HardDrive size={11} /> {label}</Pill>;}};+ // $/month to keep one snapshot at the local rate — the same number the Cost+ // cell prints, so the column's value and its cell can never disagree.+ const monthlyCost = (backup) => (+ ((backup.size || 0) / (1024 ** 3)) * (costSummary?.cost_rates?.local || 0)+ );+// DataTable columns for the snapshot archive. Cell markup and classNames// are identical to the hand-rolled table they replace, so _backups.scss// keeps applying (.bk-name, .bk-ico, .bk-when, .bk-actions).+ //+ // Two accessors per column on purpose: `value` is what the column menu, the+ // filter rules and the export read (ds/grid/fields.js), `sortValue` is what+ // DataTable's sorter reads — it does NOT fall back to `value`, so a+ // sortable column needs both. `type` is declared rather than inferred+ // wherever a built-in view filters the column: inference is a guess made+ // from the rows that happen to be loaded, and a preset written against the+ // wrong guess silently matches nothing.const snapshotColumns = [{key: 'name',header: 'Name',sortable: true,hideable: false,+ type: 'text',+ value: (b) => b.name || b.app_name || '',sortValue: (b) => b.name || b.app_name || '',render: (backup) => (<div className="sk-cell-name bk-name">@@ -430,23 +536,43 @@ const Backups = () => {),},{+ // The three buckets the old segment row offered. They are column+ // rules now, and this column's own menu carries the pick-list.+ // No `enumOrder`: the options are built from the rows that are+ // actually loaded, so the menu never offers a bucket that would+ // come back empty — which is exactly what the old "Databases (0)"+ // segment did on a box that only backs up files.key: 'type',header: 'Type',sortable: true,+ type: 'enum',+ groupable: true,+ value: (b) => b.type || '',+ groupValue: (b) => b.type || '',sortValue: (b) => b.type || '',render: (backup) => <span className="sk-tag">{backup.type}</span>,},{+ // Text, not a pick-list: retention keeps many snapshots per site,+ // so this column has as many distinct values as the operator has+ // sites. You type a fragment of a name rather than scroll a list.key: 'site',header: 'Site/Service',sortable: true,+ type: 'text',+ value: (b) => b.app_name || b.name?.split('_')[0] || '',sortValue: (b) => b.app_name || b.name?.split('_')[0] || null,render: (backup) => backup.app_name || backup.name?.split('_')[0] || '—',},{+ // Raw bytes: rules compare numbers while the cell prints the human+ // string. Filtering on the rendered "464 MB" would compare text,+ // and "over 100" would then match 99 GB.key: 'size',header: 'Size',sortable: true,+ type: 'num',+ value: (b) => b.size || 0,sortValue: (b) => b.size || 0,cellClassName: 'sk-cell-mono',render: (backup) => formatBytes(backup.size, { defaultValue: '0 B' }),@@ -455,13 +581,26 @@ const Backups = () => {key: 'storage',header: 'Storage',sortable: true,- sortValue: (b) => b.remote_status || 'local',+ type: 'enum',+ groupable: true,+ // The LABEL, not the raw `remote_status`, so the 'Local only' view+ // reads the way its rows do. Sorting the label also puts the+ // at-risk local-only copies together instead of alphabetising+ // 'remote-only' between 'local' and 'synced'.+ value: (b) => remoteStatusLabel(b.remote_status),+ groupValue: (b) => remoteStatusLabel(b.remote_status),+ sortValue: (b) => remoteStatusLabel(b.remote_status),render: (backup) => getRemoteStatusPill(backup.remote_status),},{+ // Declared, not inferred: the sorter wants epoch ms, and letting+ // that number type the column would offer "is under 1754…" instead+ // of a date picker — and make every date rule match nothing.key: 'created',header: 'Created',sortable: true,+ type: 'date',+ value: (b) => b.timestamp || null,sortValue: (b) => (b.timestamp ? new Date(b.timestamp).getTime() : null),cellClassName: 'bk-when',render: (backup) => formatTimestamp(backup.timestamp),@@ -470,9 +609,11 @@ const Backups = () => {key: 'cost',header: 'Cost',sortable: true,- sortValue: (b) => ((b.size || 0) / (1024 ** 3)) * (costSummary?.cost_rates?.local || 0),+ type: 'num',+ value: monthlyCost,+ sortValue: monthlyCost,cellClassName: 'sk-cell-mono',- render: (backup) => formatMoney(((backup.size || 0) / (1024 ** 3)) * (costSummary?.cost_rates?.local || 0)),+ render: (backup) => formatMoney(monthlyCost(backup)),},{key: 'actions',@@ -523,8 +664,8 @@ const Backups = () => {},];- // Search narrows first so the segment counts always describe what a click- // on that segment would actually show.+ // Search only. The type split used to live here as a segment filter; it is+ // a column rule now, applied inside <DataTable> on top of this list.const searchedBackups = (() => {const q = search.trim().toLowerCase();if (!q) return backups;@@ -534,9 +675,29 @@ const Backups = () => {|| (b.type || '').toLowerCase().includes(q)));})();- const filteredBackups = filterType === 'all'- ? searchedBackups- : searchedBackups.filter(b => b.type === filterType);++ const viewPageState = useMemo(() => ({ search }), [search]);+ const applyViewPageState = useCallback((saved) => {+ if (saved.search !== undefined) setSearch(saved.search);+ }, []);++ // The snapshot archive is the only saved-view surface on this route — the+ // schedules table lives in its own component with its own sort state, and+ // the remaining tabs are forms — so there is no second chrome to fight over+ // `?view=` and no `urlScope` to hand out.+ const chrome = useTableChrome({+ columns: snapshotColumns,+ rows: searchedBackups,+ viewPageKey: 'backups-snapshots',+ builtinViews: SNAPSHOT_VIEWS,+ noun: 'snapshots',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ pageState: viewPageState,+ applyPage: applyViewPageState,+ });// One primary action per section, the way the mock does it: Schedules// offers "New schedule", everything else offers "Back up now". A Create@@ -598,29 +759,34 @@ const Backups = () => {{activeTab === 'snapshots' && (<>- {/* Search lives in the top bar with every other list page;- the segments carry the counts. */}- <ListToolbar- filters={(- <SegControl- value={filterType}- onChange={setFilterType}- options={[- { value: 'all', label: 'All', count: searchedBackups.length },- { value: 'application', label: 'Applications', count: searchedBackups.filter(b => b.type === 'application').length },- { value: 'database', label: 'Databases', count: searchedBackups.filter(b => b.type === 'database').length },- { value: 'files', label: 'Files', count: searchedBackups.filter(b => b.type === 'files').length },- ]}- />- )}- tools={(- <Button size="sm" variant="outline" onClick={loadData}>- <RefreshCw size={14} />- Refresh- </Button>+ {/* One row of chrome: the view name IS the heading, it+ carries the count, and the filter button and "⋮" ride+ the same line. Search stays in the top bar with every+ other list page, and Refresh moved into the "⋮" — a+ whole toolbar holding one button was a second header.++ The count is `chrome.shownCount`, not the length of the+ array handed to the table: the column rules are applied+ inside <DataTable>, so counting the input array here+ would read "12 of 12" above a table showing 3. */}+ <GridViewPicker+ views={chrome.views}+ label="snapshots"+ total={`${chrome.shownCount} of ${backups.length} snapshot${backups.length === 1 ? '' : 's'}`}+ onCreate={chrome.createView}+ actions={(+ <>+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadData} />+ </>)}/>- <SortChipBar columns={snapshotColumns} sorts={sorts} onChange={setSorts} />++ <GridChips {...chrome.chipProps} />+{backups.length === 0 ? (<EmptyStateicon={FileArchive}@@ -628,27 +794,28 @@ const Backups = () => {description="No backups found. Create your first backup to get started."action={<Button onClick={() => setShowBackupModal(true)}>Create Backup</Button>}/>- ) : filteredBackups.length === 0 ? (+ ) : searchedBackups.length === 0 ? (+ /* Only the SEARCH can empty the list here — a column+ rule that matches nothing keeps the table on screen+ with its own "clear filters" row, because the control+ that undoes it lives in the header menu. */<EmptyStateicon={FileArchive}- title={search.trim()- ? `No snapshots match “${search.trim()}”.`- : 'No snapshots match the current filter.'}+ title={`No snapshots match “${search.trim()}”.`}/>) : (<div className="bk-card"><DataTable- columns={snapshotColumns}- data={filteredBackups}+ {...chrome.tableProps}+ columns={chrome.columns}+ data={searchedBackups}keyField="path"sorts={sorts}onSortsChange={setSorts}- hiddenKeys={hiddenKeys}- onHiddenKeysChange={setHiddenKeys}tableClassName="bk-table"footer={(<DataTableFooter- shown={filteredBackups.length}+ shown={chrome.shownCount}total={backups.length}noun="snapshot"/>@@ -656,6 +823,8 @@ const Backups = () => {/></div>)}++ <GridFilterDrawer {...chrome.drawerProps} /></>)}diff --git a/frontend/src/pages/Git.jsx b/frontend/src/pages/Git.jsxindex f114ace4..360ad60c 100644--- a/frontend/src/pages/Git.jsx+++ b/frontend/src/pages/Git.jsx@@ -10,6 +10,10 @@ import {Pill, MetricCard, SegControl, Drawer, DataTable, DataTableFooter,ListToolbar,} 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 PageLayout from '../layouts/PageLayout';@@ -51,12 +55,23 @@ const formatDate = (dateString) => {// Columns for the shared DataTable. Cell markup and classNames are identical// to the hand-rolled tables they replace, so _git.scss keeps applying// (.sk-cell-name, .git-reponame, .git-branch-chip, .git-url, .dom-chev).+//+// Two accessors per column on purpose: `value` is what the column MENU, the+// filter rules and the export read (ds/grid/fields.js), `sortValue` is what+// DataTable's sorter reads. A column declaring only `sortValue` silently types+// itself from it — which is how a numeric sort key turns a status column into+// a number and makes every string rule match nothing.const REPO_COLUMNS = [{key: 'name',header: 'Repository',sortable: true,hideable: false,+ // Rules read `owner/name`, which is what the cell shows and what you+ // would paste in from Gitea; the SORT stays on the bare repo name so+ // the list is not silently grouped by owner.+ type: 'text',+ value: (repo) => repo.full_name || `${repo.owner?.login || ''}/${repo.name || ''}`,sortValue: (repo) => repo.name || '',render: (repo) => (<div className="sk-cell-name">@@ -70,18 +85,62 @@ const REPO_COLUMNS = [<div className="git-repocell"><div className="git-reponame"><span className="own">{repo.owner.login}/</span>{repo.name}- {repo.private && <span className="git-chip git-chip--amber">private</span>}- {repo.fork && <span className="git-chip git-chip--cyan">fork</span>}</div>{repo.description && <div className="sk-cell-sub git-repo-desc">{repo.description}</div>}</div></div>),},+ {+ // Promoted out of the name cell, where the same fact rode as a chip:+ // "what is private" was the whole point of one of the segments this+ // table used to carry, and inside another cell it could not be sorted,+ // grouped or filtered. Declared enum — two repos on a fresh server+ // fail the cardinality test and the column would fall back to text.+ key: 'visibility',+ header: 'Visibility',+ sortable: true,+ type: 'enum',+ groupable: true,+ enumOrder: ['Private', 'Public'],+ value: (repo) => (repo.private ? 'Private' : 'Public'),+ groupValue: (repo) => (repo.private ? 'Private' : 'Public'),+ sortValue: (repo) => (repo.private ? 'Private' : 'Public'),+ render: (repo) => (+ <span className={`git-chip git-chip--${repo.private ? 'amber' : 'cyan'}`}>+ {repo.private ? 'private' : 'public'}+ </span>+ ),+ },+ {+ // The other promoted chip. Fork is tested BEFORE mirror so this column+ // keeps the exact meaning the old "Forks" segment had (`repo.fork`) —+ // a repo that is both reads as a fork, as it did then.+ key: 'kind',+ header: 'Kind',+ sortable: true,+ type: 'enum',+ groupable: true,+ enumOrder: ['Source', 'Fork', 'Mirror'],+ value: (repo) => (repo.fork ? 'Fork' : repo.mirror ? 'Mirror' : 'Source'),+ groupValue: (repo) => (repo.fork ? 'Fork' : repo.mirror ? 'Mirror' : 'Source'),+ sortValue: (repo) => (repo.fork ? 'Fork' : repo.mirror ? 'Mirror' : 'Source'),+ render: (repo) => (repo.fork ? (+ <span className="git-chip git-chip--cyan">fork</span>+ ) : repo.mirror ? (+ <span className="git-chip git-chip--cyan">mirror</span>+ ) : (+ <span className="sk-cell-sub">source</span>+ )),+ },{key: 'branch',header: 'Branch',sortable: true,+ // main/master/develop on nearly every server — a pick-list, not a+ // fragment you type.+ type: 'enum',+ value: (repo) => repo.default_branch || '',sortValue: (repo) => repo.default_branch || '',render: (repo) => (<span className="git-branch-chip">@@ -94,6 +153,8 @@ const REPO_COLUMNS = [key: 'stars',header: 'Stars',sortable: true,+ type: 'num',+ value: (repo) => repo.stars ?? 0,sortValue: (repo) => repo.stars ?? 0,cellClassName: 'sk-cell-mono',},@@ -101,6 +162,8 @@ const REPO_COLUMNS = [key: 'forks',header: 'Forks',sortable: true,+ type: 'num',+ value: (repo) => repo.forks ?? 0,sortValue: (repo) => repo.forks ?? 0,cellClassName: 'sk-cell-mono',},@@ -108,6 +171,11 @@ const REPO_COLUMNS = [key: 'updated',header: 'Updated',sortable: true,+ // Declared, not inferred: the sorter wants epoch ms, and letting that+ // number type the column would offer "is under 1754…" instead of a+ // date picker — and make any date rule match nothing.+ type: 'date',+ value: (repo) => repo.updated_at || null,sortValue: (repo) => (repo.updated_at ? new Date(repo.updated_at).getTime() : null),cellClassName: 'sk-cell-mono',render: (repo) => formatDate(repo.updated_at),@@ -128,6 +196,8 @@ const WEBHOOK_COLUMNS = [header: 'Webhook',sortable: true,hideable: false,+ type: 'text',+ value: (webhook) => webhook.name || '',sortValue: (webhook) => webhook.name || '',render: (webhook) => (<div className="sk-cell-name">@@ -140,9 +210,13 @@ const WEBHOOK_COLUMNS = [),},{+ // The clone URL carries the host, so `contains github.com` is how you+ // slice by provider without a column of its own.key: 'repository',header: 'Repository',sortable: true,+ type: 'text',+ value: (webhook) => webhook.source_repo_url || '',sortValue: (webhook) => webhook.source_repo_url || '',cellClassName: 'sk-cell-mono git-url',render: (webhook) => <span title={webhook.source_repo_url}>{webhook.source_repo_url}</span>,@@ -151,6 +225,8 @@ const WEBHOOK_COLUMNS = [key: 'branch',header: 'Branch',sortable: true,+ type: 'enum',+ value: (webhook) => webhook.source_branch || '',sortValue: (webhook) => webhook.source_branch || '',render: (webhook) => (<span className="git-branch-chip">@@ -163,6 +239,11 @@ const WEBHOOK_COLUMNS = [key: 'lastSync',header: 'Last sync',sortable: true,+ // Declared date, not inferred from the epoch `sortValue`. A hook that+ // never ran has none, and a date rule can only compare two real dates —+ // "never synced" is therefore a rule on `syncState`, not on this column.+ type: 'date',+ value: (webhook) => webhook.last_sync_at || null,sortValue: (webhook) => (webhook.last_sync_at ? new Date(webhook.last_sync_at).getTime() : null),cellClassName: 'sk-cell-mono',render: (webhook) => (@@ -171,10 +252,35 @@ const WEBHOOK_COLUMNS = [</span>),},+ {+ // The health of the last delivery, which the table never showed:+ // `last_sync_status` is written by the sync worker ('success' |+ // 'failed' | 'pending') and is null until a hook has fired once, which+ // is the 'never' bucket below. A configured-but-broken hook used to be+ // indistinguishable from a working one on this page.+ key: 'syncState',+ header: 'Last result',+ sortable: true,+ type: 'enum',+ enumOrder: ['success', 'failed', 'pending', 'never'],+ value: (webhook) => webhook.last_sync_status || 'never',+ sortValue: (webhook) => webhook.last_sync_status || 'never',+ render: (webhook) => {+ const state = webhook.last_sync_status || 'never';+ const kind = { success: 'green', failed: 'red', pending: 'amber' }[state] || 'gray';+ return (+ <Pill kind={kind} dot={false} title={webhook.last_sync_message || undefined}>+ {state}+ </Pill>+ );+ },+ },{key: 'sync_count',header: 'Syncs',sortable: true,+ type: 'num',+ value: (webhook) => webhook.sync_count ?? 0,sortValue: (webhook) => webhook.sync_count ?? 0,cellClassName: 'sk-cell-mono',},@@ -182,6 +288,12 @@ const WEBHOOK_COLUMNS = [key: 'status',header: 'Status',sortable: true,+ // Declared enum with a STRING `value`: `sortValue` is 1/0 so that a+ // sort puts the live hooks together, and letting that number type the+ // column would have made every 'Active' rule match zero rows.+ type: 'enum',+ enumOrder: ['Active', 'Inactive'],+ value: (webhook) => (webhook.is_active ? 'Active' : 'Inactive'),sortValue: (webhook) => (webhook.is_active ? 1 : 0),render: (webhook) => <Pill kind={webhook.is_active ? 'green' : 'gray'}>{webhook.is_active ? 'Active' : 'Inactive'}</Pill>,},@@ -195,6 +307,125 @@ const WEBHOOK_COLUMNS = [},];+// Built-in saved views for the two list surfaces. Every rule matches a+// column's `value` accessor, so the strings below are the LABELS the cells+// render ('Private', 'Fork', 'Active') — never a raw backend boolean.+//+// These replace the two segment rows the tabs used to carry: every bucket+// either offered (All / Private / Forks, All / Active / Inactive) is a rule+// here, and the per-column "⋮" now offers the same slices on every other+// column for free.+const NO_RULES = { match: 'all', rules: [] };++const REPO_VIEWS = [+ {+ // The landing view: what has moved lately. Gitea's `updated_at` covers+ // pushes and settings changes alike, which is exactly "has anyone+ // touched this".+ name: 'Recently updated',+ state: {+ sorts: [{ key: 'updated', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: NO_RULES,+ },+ },+ {+ // The old "Private" segment.+ name: 'Private',+ state: {+ sorts: [{ key: 'name', direction: 'asc' }],+ hiddenKeys: ['visibility'],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'rv1', field: 'visibility', op: 'any', value: ['Private'] }],+ },+ },+ },+ {+ // The inverse, and the one worth reading on a self-hosted server:+ // anything here is readable by every Gitea account, and by anonymous+ // visitors if the instance allows them.+ name: 'Public',+ state: {+ sorts: [{ key: 'name', direction: 'asc' }],+ hiddenKeys: ['visibility'],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'rv2', field: 'visibility', op: 'any', value: ['Public'] }],+ },+ },+ },+ {+ // The old "Forks" segment. Stalest first: a fork nobody has pushed to+ // since it was made is usually the one to delete.+ name: 'Forks',+ state: {+ sorts: [{ key: 'updated', direction: 'asc' }],+ hiddenKeys: ['kind'],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'rv3', field: 'kind', op: 'any', value: ['Fork'] }],+ },+ },+ },+];++const WEBHOOK_VIEWS = [+ {+ // The old "Active" segment, most recently synced first — the hooks that+ // will actually fire on the next push.+ name: 'Active',+ state: {+ sorts: [{ key: 'lastSync', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'wv1', field: 'status', op: 'any', value: ['Active'] }],+ },+ },+ },+ {+ // The old "Inactive" segment: configured, disabled, still listed.+ name: 'Inactive',+ state: {+ sorts: [{ key: 'name', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'wv2', field: 'status', op: 'any', value: ['Inactive'] }],+ },+ },+ },+ {+ // An exception list — empty is the right answer. A hook whose last+ // delivery failed is silently not deploying anything, and nothing else+ // on this page says so.+ name: 'Failing syncs',+ state: {+ sorts: [{ key: 'lastSync', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'wv3', field: 'syncState', op: 'any', value: ['failed'] }],+ },+ },+ },+ {+ // Created but never fired once — usually a webhook that was added here+ // and never registered on the provider side, so the push it is waiting+ // for never arrives.+ name: 'Never synced',+ state: {+ sorts: [{ key: 'name', direction: 'asc' }],+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'wv4', field: 'syncState', op: 'any', value: ['never'] }],+ },+ },+ },+];+// Recent deployments table inside the webhook drawer.const HOOK_DEPLOY_COLUMNS = [{@@ -240,7 +471,6 @@ function Git({ basePath = '/git' }) {const [webhooksLoading, setWebhooksLoading] = useState(false);const [showWebhookModal, setShowWebhookModal] = useState(false);const [drawerWebhook, setDrawerWebhook] = useState(null);- const [webhookFilter, setWebhookFilter] = useState('all');const [webhookDeployments, setWebhookDeployments] = useState([]);const [webhookForm, setWebhookForm] = useState({name: '',@@ -269,7 +499,6 @@ function Git({ basePath = '/git' }) {const [files, setFiles] = useState([]);const [currentPath, setCurrentPath] = useState('');const [repoDetailTab, setRepoDetailTab] = useState('files');- const [repoFilter, setRepoFilter] = useState('all');// Deployment stateconst [applications, setApplications] = useState([]);@@ -290,6 +519,37 @@ function Git({ basePath = '/git' }) {hiddenKeys: webhookHiddenKeys, setHiddenKeys: setWebhookHiddenKeys,} = useColumnVisibility({ storageKey: 'serverkit-table-git-webhooks-cols' });+ // Repositories and Webhooks live on different tabs and only one RENDERS at+ // a time, but both chromes are hooks on this one component, so both are+ // MOUNTED at all times — and each would write `?view=`/`?sort=` over the+ // other's. Hence a urlScope apiece: the params become `repos.view` and+ // `hooks.view`, and a link to one tab's view means nothing to the other.+ const repoChrome = useTableChrome({+ columns: REPO_COLUMNS,+ rows: repositories,+ viewPageKey: 'git-repositories',+ urlScope: 'repos',+ builtinViews: REPO_VIEWS,+ noun: 'repositories',+ sorts: repoSorts,+ setSorts: setRepoSorts,+ hiddenKeys: repoHiddenKeys,+ setHiddenKeys: setRepoHiddenKeys,+ });++ const webhookChrome = useTableChrome({+ columns: WEBHOOK_COLUMNS,+ rows: webhooks,+ viewPageKey: 'git-webhooks',+ urlScope: 'hooks',+ builtinViews: WEBHOOK_VIEWS,+ noun: 'webhooks',+ sorts: webhookSorts,+ setSorts: setWebhookSorts,+ hiddenKeys: webhookHiddenKeys,+ setHiddenKeys: setWebhookHiddenKeys,+ });+const toast = useToast();useEffect(() => {@@ -724,18 +984,9 @@ function Git({ basePath = '/git' }) {};// ── Filters ───────────────────────────────────────────────- const filteredRepos = repositories.filter(repo => {- if (repoFilter === 'private') return repo.private;- if (repoFilter === 'forks') return repo.fork;- return true;- });-- const filteredWebhooks = webhooks.filter(w => {- if (webhookFilter === 'active') return w.is_active;- if (webhookFilter === 'inactive') return !w.is_active;- return true;- });-+ // Repositories and Webhooks filter themselves now: their segment rows are+ // column rules, applied inside <DataTable> and counted by the chrome.+ // Deployments is still a card list rather than a table, so it keeps its own.const filteredDeployments = deployments.filter(d => {if (deploymentFilter === 'all') return true;return d.status === deploymentFilter;@@ -853,44 +1104,55 @@ function Git({ basePath = '/git' }) {}return (<>- <ListToolbar- title="Repositories"- filters={(- <SegControl- value={repoFilter}- onChange={setRepoFilter}- options={[- { value: 'all', label: 'All', count: repositories.length },- { value: 'private', label: 'Private', count: repoPrivateCount },- { value: 'forks', label: 'Forks', count: repoForkCount },- ]}- />+ {/* The view name replaces the old "Repositories" <h2>: it is the+ same heading slot, and it now says WHICH repositories you+ are looking at. The filter button and "⋮" ride that line —+ a ListToolbar here would be a second bar holding nothing+ else. */}+ <GridViewPicker+ views={repoChrome.views}+ label="repositories"+ total={`${repoChrome.shownCount} of ${repositories.length} repositories`}+ onCreate={repoChrome.createView}+ actions={(+ <>+ <GridFilterButton+ count={repoChrome.filterCount}+ onClick={() => repoChrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...repoChrome.toolsProps} onRefresh={loadRepositories} />+ </>)}/>- {filteredRepos.length === 0 ? (- <EmptyState icon={FolderGit2} title="No repositories match this filter." />- ) : (- <div className="dom-card">- <DataTable- columns={REPO_COLUMNS}- data={filteredRepos}- keyField="id"- sorts={repoSorts}- onSortsChange={setRepoSorts}- hiddenKeys={repoHiddenKeys}- onHiddenKeysChange={setRepoHiddenKeys}- onRowClick={openRepoDrawer}- tableClassName="git-repos-table"- footer={(- <DataTableFooter- shown={filteredRepos.length}- total={repositories.length}- noun="repo"- />- )}- />- </div>- )}++ <GridChips {...repoChrome.chipProps} />++ <div className="dom-card">+ <DataTable+ columns={repoChrome.columns}+ data={repositories}+ keyField="id"+ sorts={repoSorts}+ onSortsChange={setRepoSorts}+ {...repoChrome.tableProps}+ onRowClick={openRepoDrawer}+ tableClassName="git-repos-table"+ emptyTitle="No repositories match this view."+ emptyMessage=""+ footer={(+ <DataTableFooter+ // DataTable applies the column rules itself, so+ // the shown count comes from the chrome —+ // `repositories` is only ever the whole list.+ shown={repoChrome.shownCount}+ total={repositories.length}+ noun="repo"+ />+ )}+ />+ </div>++ <GridFilterDrawer {...repoChrome.drawerProps} /></>);};@@ -939,45 +1201,48 @@ function Git({ basePath = '/git' }) {}return (<>- <ListToolbar- title="External repository webhooks"- filters={(- <SegControl- value={webhookFilter}- onChange={setWebhookFilter}- options={[- { value: 'all', label: 'All', count: webhooks.length },- { value: 'active', label: 'Active', count: webhookActiveCount },- { value: 'inactive', label: 'Inactive', count: webhookInactiveCount },- ]}- />+ <GridViewPicker+ views={webhookChrome.views}+ label="webhooks"+ total={`${webhookChrome.shownCount} of ${webhooks.length} webhooks`}+ onCreate={webhookChrome.createView}+ actions={(+ <>+ <GridFilterButton+ count={webhookChrome.filterCount}+ onClick={() => webhookChrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...webhookChrome.toolsProps} onRefresh={loadWebhooks} />+ </>)}/>- {filteredWebhooks.length === 0 ? (- <EmptyState icon={Webhook} title="No webhooks match this filter." />- ) : (- <div className="dom-card">- <DataTable- columns={WEBHOOK_COLUMNS}- data={filteredWebhooks}- keyField="id"- sorts={webhookSorts}- onSortsChange={setWebhookSorts}- hiddenKeys={webhookHiddenKeys}- onHiddenKeysChange={setWebhookHiddenKeys}- onRowClick={setDrawerWebhook}- rowClassName={(webhook) => (!webhook.is_active ? 'is-disabled' : '')}- tableClassName="git-webhooks-table"- footer={(- <DataTableFooter- shown={filteredWebhooks.length}- total={webhooks.length}- noun="webhook"- />- )}- />- </div>- )}++ <GridChips {...webhookChrome.chipProps} />++ <div className="dom-card">+ <DataTable+ columns={webhookChrome.columns}+ data={webhooks}+ keyField="id"+ sorts={webhookSorts}+ onSortsChange={setWebhookSorts}+ {...webhookChrome.tableProps}+ onRowClick={setDrawerWebhook}+ rowClassName={(webhook) => (!webhook.is_active ? 'is-disabled' : '')}+ tableClassName="git-webhooks-table"+ emptyTitle="No webhooks match this view."+ emptyMessage=""+ footer={(+ <DataTableFooter+ shown={webhookChrome.shownCount}+ total={webhooks.length}+ noun="webhook"+ />+ )}+ />+ </div>++ <GridFilterDrawer {...webhookChrome.drawerProps} /></>);};diff --git a/frontend/src/pages/MonitorDetail.jsx b/frontend/src/pages/MonitorDetail.jsxindex aa81607c..5201610a 100644--- a/frontend/src/pages/MonitorDetail.jsx+++ b/frontend/src/pages/MonitorDetail.jsx@@ -23,6 +23,10 @@ import {AreaChart, DataTable, DataTableFooter, KpiBand, MetricCard,Pill, SegControl,} from '@/components/ds';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';import PageLayout from '../layouts/PageLayout';import { Button } from '@/components/ui/button';import { useTableSort } from '@/hooks/useTableSort';@@ -44,6 +48,69 @@ const RANGES = [{ value: 720, label: '30d' },];+// Built-in views for the check log. Every rule matches against a column's+// `value` accessor, so 'up' below is the word the Result cell prints and '200'+// is the string the Code cell prints.+//+// Nothing here names a monitor. The route already scopes the log to one, and+// the same view key is shared by every monitor that renders this page — a+// preset that mentioned a host or an id would be dead on all the others.+const NO_RULES = { match: 'all', rules: [] };++const CHECK_VIEWS = [+ {+ // How a log is read by default: the most recent probe on top.+ name: 'Newest first',+ state: {+ sorts: [{ key: 'checked_at', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: NO_RULES,+ },+ },+ {+ // Everything that did not come back up — a 5xx, a timeout, a TLS+ // failure, a keyword that went missing. `none: ['up']` rather than+ // `any: ['down']` because HealthCheck.status also records 'degraded',+ // and a worklist that silently dropped those would be the wrong list.+ name: 'Failed checks',+ state: {+ sorts: [{ key: 'checked_at', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'mc1', field: 'status', op: 'none', value: ['up'] }],+ },+ },+ },+ {+ // What the p95 tile is made of. Sort-only on purpose: "slow" is+ // relative to the target, so a fixed millisecond threshold would be+ // wrong on a static page and useless on a heavy API.+ name: 'Slowest first',+ state: {+ sorts: [{ key: 'response_time', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: NO_RULES,+ },+ },+ {+ // Redirects, 4xx, 5xx — and the probes that never answered at all,+ // which read '—' and are exactly what this view is for: a check that+ // timed out did not return 200 either. On a ping or port monitor,+ // where no row carries a code, it shows the whole log; that is the+ // honest answer to "which of these was not a 200".+ name: 'Non-200 responses',+ state: {+ sorts: [{ key: 'checked_at', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'mc2', field: 'status_code', op: 'none', value: ['200'] }],+ },+ },+ },+];+function percentile(values, p) {if (!values.length) return null;const sorted = [...values].sort((a, b) => a - b);@@ -127,6 +194,103 @@ export default function MonitorDetail() {};}, [series]);+ // The rows the log renders: the held snapshot while frozen, else the live+ // list. It and the columns below sit ABOVE the early returns so the chrome+ // hook runs on every render, including the loading and not-found ones.+ const rows = frozen || checks;++ // Check-log columns. `value` is what the column menu, the filter rules and+ // the export read; `sortValue` is what DataTable's sorter reads — it does+ // NOT fall back to `value`, so a sortable column needs both. Types are+ // declared rather than inferred: a window in which every check passed would+ // type Result from a single distinct value, and the 'Failed checks' preset+ // would then be filtering a column the engine calls plain text.+ const checkColumns = useMemo(() => [+ {+ key: 'checked_at',+ header: 'Time',+ sortable: true,+ hideable: false,+ type: 'date',+ value: (c) => c.checked_at || null,+ sortValue: (c) => (c.checked_at ? new Date(c.checked_at).getTime() : null),+ render: (c) => new Date(c.checked_at).toLocaleTimeString(),+ },+ {+ // Split from the HTTP code beside it. This cell used to print the+ // code while sorting on the status, which left "failed" and "500"+ // sharing one column — so one of the two was always filtering on+ // something the row did not show.+ key: 'status',+ header: 'Result',+ sortable: true,+ type: 'enum',+ // No `enumOrder`: the pick-list is built from the statuses this+ // window actually contains, so it never offers 'down' on a log+ // with nothing but successes in it.+ value: (c) => c.status || 'unknown',+ sortValue: (c) => c.status || '',+ render: (c) => (+ <span className={`mon-code mon-code--${c.status === 'up' ? 'ok' : 'bad'}`}>+ {c.status}+ </span>+ ),+ },+ {+ // Enum, not num: status codes are a short repeating set, so the+ // menu offers the ones this window actually contains as a+ // pick-list. A probe that never answered has no code and reads+ // '—', which is a value you can filter on rather than a blank.+ key: 'status_code',+ header: 'Code',+ sortable: true,+ type: 'enum',+ value: (c) => (c.status_code == null ? '—' : String(c.status_code)),+ sortValue: (c) => c.status_code ?? null,+ cellClassName: 'sk-cell-mono',+ render: (c) => (c.status_code == null ? '—' : c.status_code),+ },+ {+ key: 'response_time',+ header: 'Latency',+ sortable: true,+ type: 'num',+ unit: ' ms',+ // Null for a check that timed out, never 0 — a zero would sort as+ // the fastest probe in the window and satisfy "is under 200".+ value: (c) => c.response_time ?? null,+ sortValue: (c) => c.response_time ?? null,+ render: (c) => (c.response_time == null ? '—' : `${c.response_time} ms`),+ },+ {+ // The error text only. The cell falls back to the request line,+ // which is identical on every row of one monitor's log, so a rule+ // reading what the cell renders would match all rows or none.+ key: 'error',+ header: 'Detail',+ type: 'text',+ value: (c) => c.error || '',+ cellClassName: 'mon-checkdetail',+ render: (c) => c.error || `${monitor?.check_method || 'GET'} ${monitor?.check_target}`,+ },+ ], [monitor]);++ // No `pageState`: the two things this page owns are the fetch window (a+ // SegControl in the Performance section, shared with the chart) and the+ // freeze, which is a transient hold on a streaming table. Neither is state+ // a saved view should change under the operator from another section.+ const chrome = useTableChrome({+ columns: checkColumns,+ rows,+ viewPageKey: 'monitor-checks',+ builtinViews: CHECK_VIEWS,+ noun: 'checks',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ });+// Both pre-load states keep the shell, so the bar is in place from the// first paint rather than appearing once the monitor resolves.if (loading && !monitor) {@@ -153,7 +317,6 @@ export default function MonitorDetail() {const state = monitorStateOf(monitor);const certDays = certDaysLeft(monitor.cert_expires_at);const isHttpish = ['http', 'keyword'].includes(monitor.check_type);- const rows = frozen || checks;const newSinceFreeze = frozen? checks.filter((c) => !frozen.some((f) => f.id === c.id)).length: 0;@@ -163,39 +326,6 @@ export default function MonitorDetail() {), 0): null;- const checkColumns = [- {- key: 'checked_at',- header: 'Time',- sortable: true,- hideable: false,- render: (c) => new Date(c.checked_at).toLocaleTimeString(),- },- {- key: 'status',- header: 'Result',- sortable: true,- sortValue: (c) => c.status,- render: (c) => (- <span className={`mon-code mon-code--${c.status === 'up' ? 'ok' : 'bad'}`}>- {c.status_code ?? c.status}- </span>- ),- },- {- key: 'response_time',- header: 'Latency',- sortable: true,- render: (c) => (c.response_time == null ? '—' : `${c.response_time} ms`),- },- {- key: 'error',- header: 'Detail',- cellClassName: 'mon-checkdetail',- render: (c) => c.error || `${monitor.check_method || 'GET'} ${monitor.check_target}`,- },- ];-const act = async (fn, successMessage) => {setBusy(true);try {@@ -435,43 +565,66 @@ export default function MonitorDetail() {</div>)}+ {/* The chrome belongs to the log, so it renders only in this+ section — a view picker above the chart or the config panes+ would be naming something they do not show. The old panel+ header is gone with it: its <h3> repeated the segment that is+ already lit above, and its "N results · live" is the picker's+ count line, so keeping both was two headers for one table. */}{section === 'checks' && (- <div className="mon-panel mon-panel--flush">- <div className="mon-panel__header">- <div>- <h3>Check log</h3>- <span className="mon-panel-sub">- {rows.length} result{rows.length === 1 ? '' : 's'} · {frozen ? 'frozen' : 'live'}- </span>- </div>- <div className="mon-panel__actions">- {frozen && newSinceFreeze > 0 && (- <Pill kind="cyan">{newSinceFreeze} new</Pill>- )}- <Button variant="outline" size="sm" onClick={() => setFrozen(frozen ? null : checks)}>- {frozen ? <><Play size={14} /> Resume</> : <><Pause size={14} /> Hold</>}- </Button>- </div>- </div>- <DataTable- tableClassName="sk-dtable monitor-checks-table"- data={rows}- keyField="id"- sorts={sorts}- onSortsChange={setSorts}- hiddenKeys={hiddenKeys}- onHiddenKeysChange={setHiddenKeys}- rowClassName={(c) => (c.status === 'up' ? undefined : 'is-bad')}- emptyState={(- <EmptyState- icon={Activity}- title="No checks in this window yet."- />+ <>+ <GridViewPicker+ views={chrome.views}+ label="checks"+ total={`${chrome.shownCount} of ${rows.length} check${rows.length === 1 ? '' : 's'} · ${frozen ? 'frozen' : 'live'}`}+ onCreate={chrome.createView}+ actions={(+ <>+ {frozen && newSinceFreeze > 0 && (+ <Pill kind="cyan">{newSinceFreeze} new</Pill>+ )}+ <Button variant="outline" size="sm" onClick={() => setFrozen(frozen ? null : checks)}>+ {frozen ? <><Play size={14} /> Resume</> : <><Pause size={14} /> Hold</>}+ </Button>+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={load} />+ </>)}- columns={checkColumns}- footer={<DataTableFooter shown={rows.length} total={rows.length} noun="check" />}/>- </div>++ <GridChips {...chrome.chipProps} />++ <div className="mon-panel mon-panel--flush">+ <DataTable+ {...chrome.tableProps}+ tableClassName="sk-dtable monitor-checks-table"+ data={rows}+ keyField="id"+ sorts={sorts}+ onSortsChange={setSorts}+ rowClassName={(c) => (c.status === 'up' ? undefined : 'is-bad')}+ emptyState={(+ <EmptyState+ icon={Activity}+ title="No checks in this window yet."+ />+ )}+ columns={chrome.columns}+ footer={(+ <DataTableFooter+ shown={chrome.shownCount}+ total={rows.length}+ noun="check"+ />+ )}+ />+ </div>++ <GridFilterDrawer {...chrome.drawerProps} />+ </>)}{section === 'config' && (diff --git a/frontend/src/pages/ServerTemplates.jsx b/frontend/src/pages/ServerTemplates.jsxindex 73f7fda8..cde42172 100644--- a/frontend/src/pages/ServerTemplates.jsx+++ b/frontend/src/pages/ServerTemplates.jsx@@ -1,5 +1,7 @@-import { useState, useEffect, useCallback } from 'react';+import { useState, useEffect, useCallback, useMemo } from 'react';import { useTopbarActions } from '@/hooks/useTopbarActions';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';import api from '../services/api';import { useToast } from '../contexts/ToastContext';import { useAuth } from '../contexts/AuthContext';@@ -13,7 +15,127 @@ 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 { KpiBand, MetricCard } from '@/components/ds';+import { DataTable, KpiBand, MetricCard, Pill } from '@/components/ds';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';++// Two surfaces, two treatments — on purpose.+//+// The Library is a catalogue you shop: half a dozen fixed blueprints you read+// the description of and pick one, so it stays a card grid.+//+// Your own templates are an inventory you administer, and the card was a table+// row wearing a box — six labelled scalars and two buttons, no image, no+// hierarchy — while hiding the two fields that decide anything: whether the+// template is allowed to rewrite a server on its own, and when it last changed.+// The questions actually asked here ("which of these am I running?", "which+// one is unassigned?", "which can edit a box without asking?") are sorts and+// filters, so that half is a table with the shared grid chrome.+const CATEGORY_LABELS = {+ general: 'General', web: 'Web Server', database: 'Database', mail: 'Mail Server', custom: 'Custom',+};++const categoryLabel = (tmpl) => CATEGORY_LABELS[tmpl.category] || tmpl.category || 'General';++// Auto-remediation is three states, not two booleans, and the difference is+// the whole risk story: Manual never touches a server, "on approval" waits for+// a human, "unattended" rewrites the box by itself. Collapsed into one enum so+// it is a single sortable, filterable column rather than two yes/no ones that+// only mean something read together.+const REMEDIATION_MANUAL = 'Manual';+const REMEDIATION_APPROVAL = 'Auto, on approval';+const REMEDIATION_UNATTENDED = 'Auto, unattended';++const remediationLabel = (tmpl) => {+ if (!tmpl.auto_remediate) return REMEDIATION_MANUAL;+ return tmpl.remediation_approval_required ? REMEDIATION_APPROVAL : REMEDIATION_UNATTENDED;+};++const REMEDIATION_KIND = {+ [REMEDIATION_MANUAL]: 'gray',+ [REMEDIATION_APPROVAL]: 'cyan',+ // Amber rather than green: a template that edits servers without asking is+ // the one setting on this page worth spotting from across the room.+ [REMEDIATION_UNATTENDED]: 'amber',+};++function formatUpdated(value) {+ if (!value) return 'Never';+ const date = new Date(value);+ if (Number.isNaN(date.getTime())) return 'Never';+ return date.toLocaleString();+}++// Built-in saved views. Every rule matches a column's `value` accessor, so the+// strings below are the LABELS the cells render — never a raw backend field.+// `auto_remediate` is a boolean nobody would recognise in a filter chip.+const NO_RULES = { match: 'all', rules: [] };++const BUILTIN_VIEWS = [+ {+ // "Which templates am I actually running?" The card grid could not+ // answer it: the assignment count was a line of grey text and nothing+ // sorted on it. Widest coverage first.+ name: 'In use',+ state: {+ sorts: [{ key: 'servers', direction: 'desc' }],+ hiddenKeys: ['version'],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{ id: 'st-used', field: 'servers', op: 'gt', value: 0 }],+ },+ },+ },+ {+ // The other half: written, then never applied. Newest edit first,+ // because a template you touched last week and never assigned is the+ // one you meant to finish.+ name: 'Not assigned yet',+ state: {+ sorts: [{ key: 'updated', direction: 'desc' }],+ hiddenKeys: ['version'],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{ id: 'st-free', field: 'servers', op: 'eq', value: 0 }],+ },+ },+ },+ {+ // The safety review. Both auto states are listed rather than filtering+ // "is none of Manual", so a fourth remediation label added later has to+ // be considered here instead of silently joining this view.+ name: 'Auto-remediating',+ state: {+ sorts: [{ key: 'servers', direction: 'desc' }],+ hiddenKeys: ['version'],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{+ id: 'st-auto',+ field: 'remediation',+ op: 'any',+ value: [REMEDIATION_APPROVAL, REMEDIATION_UNATTENDED],+ }],+ },+ },+ },+ {+ // No rules at all: everything you own, bucketed the way the category+ // badge already implied, with every column showing.+ name: 'By category',+ state: {+ sorts: [{ key: 'name', direction: 'asc' }],+ hiddenKeys: [],+ groupBy: 'category',+ columnFilters: NO_RULES,+ },+ },+];const ServerTemplates = () => {const toast = useToast();@@ -25,12 +147,25 @@ const ServerTemplates = () => {const [showCreateModal, setShowCreateModal] = useState(false);const [showAssignModal, setShowAssignModal] = useState(false);const [selectedTemplate, setSelectedTemplate] = useState(null);- const [selectedDetail, setSelectedDetail] = useState(null);const [deleteConfirm, setDeleteConfirm] = useState(null);const [servers, setServers] = useState([]);// null until the first load decides; see loadData.const [activeTab, setActiveTab] = useState(null);+ // 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.+ const { sorts, setSorts } = useTableSort({+ defaultSorts: [{ key: 'servers', direction: 'desc' }],+ storageKey: 'serverkit-table-server-templates-sort',+ });+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({+ storageKey: 'serverkit-table-server-templates-cols',+ });+ // Not persisted separately: a grouping worth keeping is a saved view now.+ const [groupBy, setGroupBy] = useState(null);+const [form, setForm] = useState({name: '', description: '', category: 'general',packages: '', services: [], firewall_rules: [],@@ -131,10 +266,6 @@ const ServerTemplates = () => {}};- const categoryLabels = {- general: 'General', web: 'Web Server', database: 'Database', mail: 'Mail Server', custom: 'Custom'- };-// Publish the admin "Create Template" action to the shared tab-group top bar.useTopbarActions(() =>user?.is_admin ? (@@ -143,6 +274,172 @@ const ServerTemplates = () => {[user?.is_admin]);+ // Two accessors per column where they differ: `value` is what the column+ // menu, the filter rules, the grouping and the export read, `sortValue` is+ // what DataTable's sorter reads. Every filterable column declares an+ // explicit `type` too — a `sortValue` returning epoch milliseconds would+ // otherwise type "Updated" as a number and offer "is under 1754…" instead+ // of a date, making every date rule match nothing.+ const columns = useMemo(() => [+ {+ key: 'name',+ header: 'Template',+ sortable: true,+ hideable: false,+ type: 'text',+ value: (tmpl) => tmpl.name || '',+ render: (tmpl) => {+ // The description and the inherited parent share the sub-line+ // the way the card stacked them — both are context for the+ // name, and neither is worth a column of its own (nothing in+ // this UI can set a parent, so that column would be empty).+ const sub = [+ tmpl.description,+ tmpl.parent_name ? `inherits ${tmpl.parent_name}` : null,+ ].filter(Boolean).join(' · ');+ return (+ <div className="sk-cell-name">+ <span>+ <div>{tmpl.name}</div>+ {sub && <div className="sk-cell-sub">{sub}</div>}+ </span>+ </div>+ );+ },+ },+ {+ key: 'category',+ header: 'Category',+ sortable: true,+ type: 'enum',+ groupable: true,+ // Filter, group and sort on the LABEL the badge shows, so a preset+ // reads the way the row does ('Web Server', not 'web'). `groupValue`+ // is spelled out because DataTable's grouping otherwise falls back+ // to row[key] — and the raw row key holds the backend enum.+ value: categoryLabel,+ groupValue: categoryLabel,+ sortValue: categoryLabel,+ // Badge, not Pill: the library cards label this exact field with a+ // Badge, and the same datum should not change shape between tabs.+ render: (tmpl) => <Badge variant="outline">{categoryLabel(tmpl)}</Badge>,+ },+ {+ key: 'servers',+ header: 'Servers',+ sortable: true,+ type: 'num',+ // A template with no assignments reads 0 rather than a dash, so the+ // "Not assigned yet" preset's `eq 0` has something honest to match.+ value: (tmpl) => tmpl.assignment_count ?? 0,+ sortValue: (tmpl) => tmpl.assignment_count ?? 0,+ },+ {+ key: 'remediation',+ header: 'Remediation',+ sortable: true,+ type: 'enum',+ groupable: true,+ value: remediationLabel,+ groupValue: remediationLabel,+ sortValue: remediationLabel,+ render: (tmpl) => {+ const label = remediationLabel(tmpl);+ return <Pill kind={REMEDIATION_KIND[label] || 'gray'} dot={false}>{label}</Pill>;+ },+ },+ {+ key: 'version',+ header: 'Version',+ sortable: true,+ type: 'num',+ value: (tmpl) => tmpl.version ?? 1,+ sortValue: (tmpl) => tmpl.version ?? 1,+ cellClassName: 'sk-cell-mono',+ render: (tmpl) => `v${tmpl.version ?? 1}`,+ },+ // The three spec counts the card showed as chips. Separate columns+ // because they are separate questions — "declares no firewall rules"+ // is a real gap, and inside one merged cell it could not be sorted.+ {+ key: 'packages',+ header: 'Packages',+ sortable: true,+ type: 'num',+ value: (tmpl) => tmpl.packages?.length ?? 0,+ sortValue: (tmpl) => tmpl.packages?.length ?? 0,+ },+ {+ key: 'services',+ header: 'Services',+ sortable: true,+ type: 'num',+ value: (tmpl) => tmpl.services?.length ?? 0,+ sortValue: (tmpl) => tmpl.services?.length ?? 0,+ },+ {+ key: 'firewall',+ header: 'Firewall',+ sortable: true,+ type: 'num',+ value: (tmpl) => tmpl.firewall_rules?.length ?? 0,+ sortValue: (tmpl) => tmpl.firewall_rules?.length ?? 0,+ },+ {+ key: 'updated',+ header: 'Updated',+ sortable: true,+ type: 'date',+ value: (tmpl) => tmpl.updated_at || null,+ sortValue: (tmpl) => {+ const time = Date.parse(tmpl.updated_at);+ return Number.isNaN(time) ? null : time;+ },+ cellClassName: 'sk-cell-mono',+ render: (tmpl) => formatUpdated(tmpl.updated_at),+ },+ {+ key: 'actions',+ header: '',+ sortable: false,+ hideable: false,+ render: (tmpl) => (+ <div className="flex gap-2">+ <Button+ size="sm"+ onClick={() => { setSelectedTemplate(tmpl); setShowAssignModal(true); }}+ >+ Assign+ </Button>+ {user?.is_admin && (+ <Button size="sm" variant="destructive" onClick={() => setDeleteConfirm(tmpl)}>+ Delete+ </Button>+ )}+ </div>+ ),+ },+ ], [user?.is_admin]);++ // No `pageState`: the list is this endpoint's whole response, with no+ // search and no server-side filter of its own, so there is nothing+ // page-private for a view to carry. The Library/Templates tab is+ // deliberately NOT in it either — that is navigation, and a saved view+ // should not be able to move you to a different tab.+ const chrome = useTableChrome({+ columns,+ rows: templates,+ viewPageKey: 'server-templates',+ builtinViews: BUILTIN_VIEWS,+ noun: 'templates',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ groupBy,+ setGroupBy,+ });+// How many servers the compliance figures actually cover.const measuredServers = compliance? (compliance.compliant || 0) + (compliance.drifted || 0) + (compliance.unknown || 0)@@ -152,6 +449,10 @@ const ServerTemplates = () => {return (<div className="sk-tabgroup__inner server-templates-page">+ {/* 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>@@ -186,47 +487,61 @@ const ServerTemplates = () => {</TabsList><TabsContent value="templates">- <div className="templates-grid">- {templates.map(tmpl => (- <div key={tmpl.id} className="template-card card" onClick={() => setSelectedDetail(selectedDetail?.id === tmpl.id ? null : tmpl)}>- <div className="template-card__header">- <h3>{tmpl.name}</h3>- <Badge variant="outline">{categoryLabels[tmpl.category] || tmpl.category}</Badge>- </div>- {tmpl.description && <p className="template-card__desc">{tmpl.description}</p>}- <div className="template-card__meta">- <span>v{tmpl.version}</span>- <span>{tmpl.assignment_count} server{tmpl.assignment_count !== 1 ? 's' : ''}</span>- {tmpl.parent_name && <span>Inherits: {tmpl.parent_name}</span>}- </div>- <div className="template-card__spec">- {tmpl.packages?.length > 0 && <span>{tmpl.packages.length} packages</span>}- {tmpl.services?.length > 0 && <span>{tmpl.services.length} services</span>}- {tmpl.firewall_rules?.length > 0 && <span>{tmpl.firewall_rules.length} firewall rules</span>}- </div>- <div className="template-card__actions" onClick={e => e.stopPropagation()}>- <Button size="sm" onClick={() => { setSelectedTemplate(tmpl); setShowAssignModal(true); }}>- Assign- </Button>- {user?.is_admin && (- <Button size="sm" variant="destructive" onClick={() => setDeleteConfirm(tmpl)}>Delete</Button>- )}- </div>- </div>- ))}- {templates.length === 0 && (- <EmptyState- icon={LayoutTemplate}- title="No templates yet"- description="Start from a ready-made library template, or create one from scratch."- action={(- <Button size="sm" onClick={() => setActiveTab('library')}>- Browse the library- </Button>+ {templates.length === 0 ? (+ <EmptyState+ icon={LayoutTemplate}+ title="No templates yet"+ description="Start from a ready-made library template, or create one from scratch."+ action={(+ <Button size="sm" onClick={() => setActiveTab('library')}>+ Browse the library+ </Button>+ )}+ />+ ) : (+ <>+ {/* One row of chrome: the view name carries the+ count, and the filter button and "⋮" ride the+ same line rather than a second, otherwise empty+ toolbar. `shownCount` is the count AFTER the+ column rules, which are applied inside the+ table — `templates.length` here would read "4+ of 4" while the table showed 2. */}+ <GridViewPicker+ views={chrome.views}+ label="templates"+ total={`${chrome.shownCount} of ${templates.length} template${templates.length === 1 ? '' : 's'}`}+ onCreate={chrome.createView}+ actions={(+ <>+ {/* This page has no server-side filter+ drawer, so the grid one is the only+ filter affordance here. */}+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadData} />+ </>)}/>- )}- </div>++ <GridChips {...chrome.chipProps} />++ <DataTable+ {...chrome.tableProps}+ columns={chrome.columns}+ data={templates}+ keyField="id"+ sorts={sorts}+ onSortsChange={setSorts}+ groupBy={groupBy}+ onGroupByChange={setGroupBy}+ />++ <GridFilterDrawer {...chrome.drawerProps} />+ </>+ )}</TabsContent><TabsContent value="library">@@ -235,7 +550,7 @@ const ServerTemplates = () => {<div key={key} className="template-card card"><div className="template-card__header"><h3>{tmpl.name}</h3>- <Badge variant="outline">{categoryLabels[tmpl.category] || tmpl.category}</Badge>+ <Badge variant="outline">{CATEGORY_LABELS[tmpl.category] || tmpl.category}</Badge></div><p className="template-card__desc">{tmpl.description}</p><div className="template-card__spec">@@ -277,7 +592,7 @@ const ServerTemplates = () => {<div className="form-group"><label>Category</label><select className="form-select" value={form.category} onChange={e => setForm({...form, category: e.target.value})}>- {Object.entries(categoryLabels).map(([k, v]) => <option key={k} value={k}>{v}</option>)}+ {Object.entries(CATEGORY_LABELS).map(([k, v]) => <option key={k} value={k}>{v}</option>)}</select></div><div className="form-group">