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
refactor(list): full chrome on Email, DeliveryLog, FleetProxy and the queue pages
Juan Denis6347292e7fa0
diff --git a/frontend/src/pages/DeliveryLog.jsx b/frontend/src/pages/DeliveryLog.jsxindex 0a29a4eb..91d11a54 100644--- a/frontend/src/pages/DeliveryLog.jsx+++ b/frontend/src/pages/DeliveryLog.jsx@@ -1,7 +1,15 @@-import { useState, useEffect, useCallback, useRef } from 'react';-import { Send, RefreshCw, Inbox } from 'lucide-react';+import { useState, useEffect, useCallback, useMemo, useRef } from 'react';+import { Send, Inbox } from 'lucide-react';import api from '../services/api';-import { MetricCard, KpiBand, FilterDrawer, FilterButton, DataTable, DataTableFooter } from '@/components/ds';+import {+ FilterDrawer, FilterButton, 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';import EmptyState from '../components/EmptyState';import { Button } from '@/components/ui/button';@@ -14,6 +22,59 @@ const STATUSES = ['all', 'pending', 'sent', 'failed', 'skipped'];const CHANNELS = ['all', 'inapp', 'email', 'discord', 'slack', 'telegram', 'webhook'];const POLL_MS = 5000;+// Built-in saved views.+//+// This list is SERVER-filtered and SERVER-paginated: GET /admin/deliveries+// takes `status` and `channel` and returns only the newest page of matches+// (50 by default), while `stats` is a group-by over every row in the table.+// A client-side column rule can therefore only narrow the page already loaded+// — it can never reach the rows the server left behind. So every status preset+// drives the SERVER filter through the `page` bag instead, which is what makes+// a preset's row set the same set the old "Sent / Pending / Failed" tiles were+// counting rather than a per-page shadow of it.+//+// Both `status` and `channel` are spelled out on every preset even when one is+// 'all': `capture()` always emits both, so a preset that omits one can never+// compare equal to the live state and the view would read as permanently+// unsaved.+const SERVER = (status, channel = 'all') => ({+ sorts: [],+ hiddenKeys: [],+ columnFilters: { match: 'all', rules: [] },+ page: { status, channel },+});++const DELIVERY_BUILTIN_VIEWS = [+ // What broke. The server already returns newest-first, so no sort is needed+ // to put the most recent failure at the top.+ { name: 'Failed', state: SERVER('failed') },+ // Still in the queue — nothing has been handed to a channel yet.+ { name: 'Pending', state: SERVER('pending') },+ { name: 'Sent', state: SERVER('sent') },+ // Deliberately not sent, almost always because the recipient has the+ // channel enabled but no target on file (no email address, no chat id).+ // A misconfiguration bucket, not a failure one.+ { name: 'Skipped', state: SERVER('skipped') },+ {+ // The only preset that has to be a client rule: the server's channel+ // filter is equality, so "everything except in-app" has no server-side+ // equivalent. It narrows the loaded page rather than the whole table,+ // which is the right trade here — in-app rows are the bulk of the log+ // (one per admin per notification) and drown out the channels that can+ // actually fail on the wire.+ name: 'External channels',+ state: {+ sorts: [],+ hiddenKeys: [],+ page: { status: 'all', channel: 'all' },+ columnFilters: {+ match: 'all',+ rules: [{ id: 'ex1', field: 'channel', op: 'none', value: ['inapp'] }],+ },+ },+ },+];+export default function DeliveryLog() {const { isAdmin } = useAuth();const toast = useToast();@@ -57,34 +118,51 @@ export default function DeliveryLog() {}};- if (!isAdmin) {- return (- <PageLayout icon={<Send size={18} />} title="Notification Delivery Log">- <div className="sk-dlog"><EmptyState title="Admins only." /></div>- </PageLayout>- );- }+ // Table sort + column visibility, now controlled so the saved views can+ // capture and restore them (they were DataTable-internal before).+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-delivery-log-sort' });+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({+ storageKey: 'serverkit-table-delivery-log-cols',+ });- const byStatus = stats?.by_status || {};+ // The page's own half of a view: the two SERVER query params. Changing+ // either re-runs `load`, which is exactly what a status preset needs.+ const viewPageState = useMemo(() => ({ status, channel }), [status, channel]);+ const applyViewPageState = useCallback((saved) => {+ if (saved.status !== undefined) setStatus(saved.status);+ if (saved.channel !== undefined) setChannel(saved.channel);+ }, []);// DataTable columns. Cell markup and classNames are identical to the// hand-rolled table they replace, so _notification-center.scss keeps// applying (.sk-dlog__table, .sk-dlog__status, .sk-dlog__target, ...).- // Runs uncontrolled (storageKey only): the page's own controls live in the- // shared topbar + FilterDrawer, not in an in-page toolbar row.+ //+ // `sortValue` stays on every column because useTableSort reads it (and only+ // it) — `value` is the grid's accessor, used by the header menus, the chips+ // and the filter rules.const columns = [{key: 'status',header: 'Status',sortable: true,+ type: 'enum',+ // Explicit rather than leaning on the sortValue fallback: without it+ // the type inference is free to read this column as plain text, and+ // then an `is any of` rule from a preset or the header menu matches+ // nothing at all.+ value: (d) => d.status || '',sortValue: (d) => d.status || '',+ groupable: true,render: (d) => <span className={`sk-dlog__status is-${d.status}`}>{d.status}</span>,},{key: 'channel',header: 'Channel',sortable: true,+ type: 'enum',+ value: (d) => d.channel || '',sortValue: (d) => d.channel || '',+ groupable: true,render: (d) => d.channel,},{@@ -118,6 +196,11 @@ export default function DeliveryLog() {key: 'when',header: 'When',sortable: true,+ // `date`, declared: the sortValue below is epoch milliseconds, and+ // left to infer, the header menu would offer "is under 1723…" on a+ // column whose cells read "3m ago".+ type: 'date',+ value: (d) => d.created_at || null,sortValue: (d) => (d.created_at ? new Date(d.created_at).getTime() : null),cellClassName: 'sk-dlog__when',render: (d) => timeAgo(d.created_at),@@ -135,33 +218,83 @@ export default function DeliveryLog() {},];+ const chrome = useTableChrome({+ columns,+ rows: deliveries,+ viewPageKey: 'delivery-log',+ builtinViews: DELIVERY_BUILTIN_VIEWS,+ noun: 'deliveries',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ pageState: viewPageState,+ applyPage: applyViewPageState,+ });++ if (!isAdmin) {+ return (+ <PageLayout icon={<Send size={18} />} title="Notification Delivery Log">+ <div className="sk-dlog"><EmptyState title="Admins only." /></div>+ </PageLayout>+ );+ }++ const serverFilterCount = (status !== 'all' ? 1 : 0) + (channel !== 'all' ? 1 : 0);+return (<PageLayouticon={<Send size={18} />}title="Notification Delivery Log"meta="Outbound deliveries across all channels"actions={(- <>- <FilterButton- count={(status !== 'all' ? 1 : 0) + (channel !== 'all' ? 1 : 0)}- onClick={() => setFiltersOpen(true)}- />- <Button variant="outline" size="sm" onClick={load}>- <RefreshCw size={14} /> Refresh- </Button>- </>+ // Labelled "Server filters" to keep it apart from the toolbar's+ // filter icon: this one re-queries the whole table, that one+ // narrows the rows already on screen.+ <FilterButton+ label="Server filters"+ count={serverFilterCount}+ onClick={() => setFiltersOpen(true)}+ />)}><div className="sk-dlog"><EmailProviders />- <KpiBand>- <MetricCard label="Total" value={stats?.total ?? 0} tone="accent" />- <MetricCard label="Sent" value={byStatus.sent ?? 0} tone="green" />- <MetricCard label="Pending" value={byStatus.pending ?? 0} tone="amber" />- <MetricCard label="Failed" value={byStatus.failed ?? 0} tone="red" />- </KpiBand>+ {/* The KPI band is gone: Sent / Pending / Failed are the first+ three built-in views, and "Total" — the one number that was a+ true whole-table aggregate rather than a count of the loaded+ page — is the second half of the meta line below. */}+ <GridViewPicker+ views={chrome.views}+ label="deliveries"+ total={`${deliveries.length} of ${stats?.total ?? deliveries.length} deliveries`}+ onCreate={chrome.createView}+ />+ <ListToolbar+ // The chips below only ever show CLIENT rules, so the server+ // query the whole list was fetched under needs saying here —+ // otherwise a status preset silently changes what is loaded+ // with nothing on screen to explain it.+ count={(+ <>+ {status === 'all' ? 'all statuses' : status}+ <i>·</i>+ {channel === 'all' ? 'all channels' : channel}+ </>+ )}+ tools={(+ <>+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={load} />+ </>+ )}+ />+ <GridChips {...chrome.chipProps} />{loading && deliveries.length === 0 ? (<EmptyState loading loadingVariant="table" title="Loading…" />@@ -169,7 +302,7 @@ export default function DeliveryLog() {<EmptyStateicon={Inbox}title="No deliveries match these filters."- action={(status !== 'all' || channel !== 'all') ? (+ action={serverFilterCount > 0 ? (<Button variant="outline" onClick={() => { setStatus('all'); setChannel('all'); }}>Clear filters</Button>@@ -177,10 +310,12 @@ export default function DeliveryLog() {/>) : (<DataTable- columns={columns}+ columns={chrome.columns}data={deliveries}keyField="id"- storageKey="serverkit-table-delivery-log"+ sorts={sorts}+ onSortsChange={setSorts}+ {...chrome.tableProps}className="sk-dlog__table-wrap"tableClassName="sk-dlog__table"footer={(@@ -198,7 +333,7 @@ export default function DeliveryLog() {open={filtersOpen}onOpenChange={setFiltersOpen}title="Filter deliveries"- activeCount={(status !== 'all' ? 1 : 0) + (channel !== 'all' ? 1 : 0)}+ activeCount={serverFilterCount}groups={[{ key: 'status', label: 'Status', type: 'single',options: STATUSES.filter((v) => v !== 'all').map((v) => ({ value: v, label: v })) },@@ -214,6 +349,8 @@ export default function DeliveryLog() {setChannel(next.channel || 'all');}}/>++ <GridFilterDrawer {...chrome.drawerProps} /></PageLayout>);}diff --git a/frontend/src/pages/Email.jsx b/frontend/src/pages/Email.jsxindex 187f0ff6..17a38db0 100644--- a/frontend/src/pages/Email.jsx+++ b/frontend/src/pages/Email.jsx@@ -14,7 +14,7 @@ import {} from 'lucide-react';import api from '../services/api';import useTabParam from '../hooks/useTabParam';-import { Pill, MetricCard, KpiBand, DataTable, SortMenu, ColumnsMenu, DataTableFooter, ViewMenu, ListToolbar } from '@/components/ds';+import { Pill, MetricCard, KpiBand, DataTable, DataTableFooter, ListToolbar } from '@/components/ds';import PageLayout from '../layouts/PageLayout';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';@@ -23,10 +23,18 @@ import { useToast } from '../contexts/ToastContext';import { useConfirm } from '../hooks/useConfirm';import { useTableSort } from '../hooks/useTableSort';import { useColumnVisibility } from '../hooks/useColumnVisibility';-import { useTableViews } from '../hooks/useTableViews';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';const VALID_TABS = ['overview', 'domains', 'accounts', 'relay', 'spam', 'webmail', 'queue'];+// A sort-only preset still has to say so: `apply` clears the live rules from+// whatever was selected before, and an absent `columnFilters` would leave the+// previous view's filters silently in place.+const NO_RULES = { match: 'all', rules: [] };+// DNS record checks surfaced as presence pills. `state` is one of// 'ok' | 'missing' | 'unknown' and maps to a DS Pill colour + dot.const DNS_RECORDS = [@@ -379,6 +387,55 @@ function DomainsTab({ domains, onChange }) {}// ---------- Accounts ----------++// Percent of an account's own quota in use, so a 200 MB mailbox on a 250 MB+// quota outranks a 2 GB one on 20 GB. null — not 0 — when no quota is set:+// an unlimited mailbox can never be "nearly full", and the rule engine drops+// nulls from every numeric comparison rather than reading them as empty.+function quotaPercent(account) {+ const total = account?.quota_mb ?? 0;+ if (!total) return null;+ return Math.round(((account.quota_used_mb ?? 0) / total) * 100);+}++// Built-in saved views for the accounts table.+//+// The rules match on what the State column's `value` accessor returns (the+// label the pill shows), NOT on the 1/0 its sortValue produces — filtering a+// string against a numeric rank is the one mistake that makes a preset match+// zero rows while looking perfectly correct.+const ACCOUNT_VIEWS = [+ { name: 'Active first', state: { search: '', sorts: [{ key: 'state', direction: 'desc' }], hiddenKeys: [], columnFilters: NO_RULES } },+ { name: 'Largest quota', state: { search: '', sorts: [{ key: 'quota', direction: 'desc' }], hiddenKeys: [], columnFilters: NO_RULES } },+ {+ // A disabled mailbox still exists and still holds its mail — it just+ // cannot authenticate. This is the list you audit after an offboarding.+ name: 'Disabled',+ state: {+ search: '', hiddenKeys: [],+ sorts: [{ key: 'email', direction: 'asc' }],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'ac1', field: 'state', op: 'any', value: ['Disabled'] }],+ },+ },+ },+ {+ // Mailboxes about to start rejecting deliveries. Same 85% threshold the+ // fleet uses for disk pressure, and `gt` on a null keeps the unlimited+ // mailboxes out instead of ranking them as 0%.+ name: 'Nearly full',+ state: {+ search: '', hiddenKeys: [],+ sorts: [{ key: 'used', direction: 'desc' }],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'ac2', field: 'used', op: 'gt', value: 85 }],+ },+ },+ },+];+function AccountsTab({ domains }) {const toast = useToast();const { confirm } = useConfirm();@@ -388,32 +445,17 @@ function AccountsTab({ domains }) {const [search, setSearch] = useState('');const [form, setForm] = useState({ username: '', password: '', quota_mb: 1024 });const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-email-accounts-sort' });- const { hiddenKeys, setHiddenKeys, toggleColumn, showAllColumns } = useColumnVisibility({ storageKey: 'serverkit-table-email-accounts-cols' });-- // Saved views: capture/apply the table chrome state (search, sort levels,- // hidden columns). There is no status filter here — state only enters via- // sorting, so the built-in views are sort presets.- const captureView = useCallback(() => ({- search,- sorts,- hiddenKeys,- }), [search, sorts, hiddenKeys]);-- const applyViewState = useCallback((state) => {- if (state.search !== undefined) setSearch(state.search);- if (Array.isArray(state.sorts)) setSorts(state.sorts);- if (Array.isArray(state.hiddenKeys)) setHiddenKeys(state.hiddenKeys);- }, [setSorts, setHiddenKeys]);-- const tableViews = useTableViews({- page: 'email-accounts',- builtinViews: [- { name: 'Active first', state: { search: '', sorts: [{ key: 'state', direction: 'desc' }], hiddenKeys: [] } },- { name: 'Largest quota', state: { search: '', sorts: [{ key: 'quota', direction: 'desc' }], hiddenKeys: [] } },- ],- capture: captureView,- apply: applyViewState,- });+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({ storageKey: 'serverkit-table-email-accounts-cols' });++ // The only view state this tab owns privately. Everything else — sorts,+ // hidden columns, column order, the column rules — is the shared envelope+ // useTableChrome captures for us. The selected domain deliberately stays+ // OUT of it: it is which list you are looking at, not how you are looking+ // at it, and a saved view that silently jumped domains would be a trap.+ const viewPageState = useMemo(() => ({ search }), [search]);+ const applyViewPageState = useCallback((saved) => {+ if (saved.search !== undefined) setSearch(saved.search);+ }, []);const load = useCallback(async () => {if (!domainId) { setAccounts([]); return; }@@ -479,13 +521,35 @@ function AccountsTab({ domains }) {key: 'quota',header: 'Quota',sortable: true,+ type: 'num',+ unit: ' MB',+ // The allocation, which is what "Largest quota" orders by. How full+ // it is lives in its own column below.+ value: (a) => a.quota_mb ?? 0,sortValue: (a) => a.quota_mb ?? 0,render: (a) => `${a.quota_used_mb ?? 0} / ${a.quota_mb ?? 0} MB`,},+ {+ key: 'used',+ header: 'Used',+ sortable: true,+ type: 'num',+ unit: '%',+ value: quotaPercent,+ sortValue: quotaPercent,+ render: (a) => {+ const pct = quotaPercent(a);+ return pct == null ? '—' : `${pct}%`;+ },+ },{key: 'state',header: 'State',sortable: true,+ // Filter on the label the pill shows; keep the 1/0 sortValue so+ // "Active first" still puts active first when the column sorts desc.+ type: 'enum',+ value: (a) => (a.is_active ? 'Active' : 'Disabled'),sortValue: (a) => (a.is_active ? 1 : 0),render: (a) => <Pill kind={a.is_active ? 'green' : 'gray'}>{a.is_active ? 'Active' : 'Disabled'}</Pill>,},@@ -505,6 +569,22 @@ function AccountsTab({ domains }) {},];+ // Each tab is its own route, so only one picker is ever mounted — this+ // chrome is scoped to the accounts table alone and keeps its own page key.+ const chrome = useTableChrome({+ columns: accountColumns,+ rows: filtered,+ viewPageKey: 'email-accounts',+ builtinViews: ACCOUNT_VIEWS,+ noun: 'accounts',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ pageState: viewPageState,+ applyPage: applyViewPageState,+ });+if (domains.length === 0) {return (<div className="sk-email__empty">@@ -516,18 +596,21 @@ function AccountsTab({ domains }) {return (<section className="sk-email__section">+ <GridViewPicker+ views={chrome.views}+ label="accounts"+ total={`${filtered.length} of ${accounts.length} accounts`}+ onCreate={chrome.createView}+ /><ListToolbarclassName="sk-email__filters"tools={(<>- <ViewMenu views={tableViews} />- <SortMenu columns={accountColumns} sorts={sorts} onChange={setSorts} />- <ColumnsMenu- columns={accountColumns}- hiddenKeys={hiddenKeys}- onToggle={toggleColumn}- onShowAll={showAllColumns}+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}/>+ <GridToolsMenu {...chrome.toolsProps} onRefresh={load} /></>)}>@@ -549,6 +632,8 @@ function AccountsTab({ domains }) {</label></ListToolbar>+ <GridChips {...chrome.chipProps} />+<form className="sk-email__add" onSubmit={create}><Inputvalue={form.username}@@ -574,17 +659,19 @@ function AccountsTab({ domains }) {</form><DataTable- columns={accountColumns}+ columns={chrome.columns}data={filtered}keyField="id"sorts={sorts}onSortsChange={setSorts}- hiddenKeys={hiddenKeys}+ {...chrome.tableProps}loading={loading}footer={<DataTableFooter shown={filtered.length} total={accounts.length} noun="account" />}emptyTitle={accounts.length === 0 ? 'No accounts in this domain.' : 'No accounts match this search.'}emptyMessage=""/>++ <GridFilterDrawer {...chrome.drawerProps} /></section>);}@@ -777,38 +864,46 @@ function WebmailTab() {}// ---------- Mail queue ----------++// Built-in saved views for the queue.+//+// The queue payload is `mailq` output — a queue id, a byte size, a sender and+// its recipients. There is no status field, so nothing here pretends there is+// one: the only rule-based preset filters on `size`, which is a real integer on+// every row (see PostfixService.get_queue).+const QUEUE_VIEWS = [+ { name: 'Largest first', state: { search: '', sorts: [{ key: 'size', direction: 'desc' }], hiddenKeys: [], columnFilters: NO_RULES } },+ { name: 'By sender', state: { search: '', sorts: [{ key: 'sender', direction: 'asc' }], hiddenKeys: [], columnFilters: NO_RULES } },+ {+ // What a backed-up queue is usually full of. 100 KB is the line between+ // a plain message (a few KB) and one carrying an attachment; Postfix's+ // own message_size_limit is 25 MB, so this is well inside real traffic.+ name: 'Large messages',+ state: {+ search: '', hiddenKeys: [],+ sorts: [{ key: 'size', direction: 'desc' }],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'q1', field: 'size', op: 'gt', value: 102400 }],+ },+ },+ },+];+function QueueTab() {const toast = useToast();const [queue, setQueue] = useState([]);const [loading, setLoading] = useState(true);const [search, setSearch] = useState('');const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-email-queue-sort' });- const { hiddenKeys, setHiddenKeys, toggleColumn, showAllColumns } = useColumnVisibility({ storageKey: 'serverkit-table-email-queue-cols' });+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({ storageKey: 'serverkit-table-email-queue-cols' });- // Saved views: capture/apply the table chrome state (search, sort levels,- // hidden columns). No time column exists in the queue payload, so the- // built-in views are sort presets over the real columns.- const captureView = useCallback(() => ({- search,- sorts,- hiddenKeys,- }), [search, sorts, hiddenKeys]);-- const applyViewState = useCallback((state) => {- if (state.search !== undefined) setSearch(state.search);- if (Array.isArray(state.sorts)) setSorts(state.sorts);- if (Array.isArray(state.hiddenKeys)) setHiddenKeys(state.hiddenKeys);- }, [setSorts, setHiddenKeys]);-- const tableViews = useTableViews({- page: 'email-queue',- builtinViews: [- { name: 'Largest first', state: { search: '', sorts: [{ key: 'size', direction: 'desc' }], hiddenKeys: [] } },- { name: 'By sender', state: { search: '', sorts: [{ key: 'sender', direction: 'asc' }], hiddenKeys: [] } },- ],- capture: captureView,- apply: applyViewState,- });+ // Search is all this tab owns privately; the rest of the view state is the+ // shared envelope useTableChrome captures.+ const viewPageState = useMemo(() => ({ search }), [search]);+ const applyViewPageState = useCallback((saved) => {+ if (saved.search !== undefined) setSearch(saved.search);+ }, []);const load = useCallback(async () => {setLoading(true);@@ -863,7 +958,19 @@ function QueueTab() {},{ key: 'sender', header: 'Sender', sortable: true, sortValue: (item) => item.sender || null, render: (item) => item.sender || '-' },{ key: 'recipient', header: 'Recipient', sortable: true, sortValue: (item) => item.recipient || null, render: (item) => item.recipient || '-' },- { key: 'size', header: 'Size', sortable: true, sortValue: (item) => item.size ?? null, render: (item) => item.size || '-' },+ {+ key: 'size',+ header: 'Size',+ sortable: true,+ // Bytes, straight off mailq. Typed explicitly because a preset+ // filters on it — inference would land on 'num' here anyway, but+ // only for as long as every loaded row happens to carry a size.+ type: 'num',+ unit: ' bytes',+ value: (item) => item.size ?? null,+ sortValue: (item) => item.size ?? null,+ render: (item) => item.size || '-',+ },{key: 'actions',header: '',@@ -880,20 +987,37 @@ function QueueTab() {},];+ const chrome = useTableChrome({+ columns: queueColumns,+ rows: filtered,+ viewPageKey: 'email-queue',+ builtinViews: QUEUE_VIEWS,+ noun: 'messages',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ pageState: viewPageState,+ applyPage: applyViewPageState,+ });+return (<section className="sk-email__section">+ <GridViewPicker+ views={chrome.views}+ label="messages"+ total={`${filtered.length} of ${queue.length} messages`}+ onCreate={chrome.createView}+ /><ListToolbarclassName="sk-email__filters"tools={(<>- <ViewMenu views={tableViews} />- <SortMenu columns={queueColumns} sorts={sorts} onChange={setSorts} />- <ColumnsMenu- columns={queueColumns}- hiddenKeys={hiddenKeys}- onToggle={toggleColumn}- onShowAll={showAllColumns}+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}/>+ <GridToolsMenu {...chrome.toolsProps} onRefresh={load} /><div className="sk-email__actions"><Button variant="outline" size="sm" onClick={load}><RefreshCw size={14} /> Refresh</Button><Button variant="outline" size="sm" onClick={flush}>Flush queue</Button>@@ -913,18 +1037,22 @@ function QueueTab() {</label></ListToolbar>+ <GridChips {...chrome.chipProps} />+<DataTable- columns={queueColumns}+ columns={chrome.columns}data={filtered}keyField={(item) => item.id || item.queue_id}sorts={sorts}onSortsChange={setSorts}- hiddenKeys={hiddenKeys}+ {...chrome.tableProps}loading={loading}footer={<DataTableFooter shown={filtered.length} total={queue.length} noun="message" />}emptyTitle={queue.length === 0 ? 'The mail queue is empty.' : 'No messages match this search.'}emptyMessage=""/>++ <GridFilterDrawer {...chrome.drawerProps} /></section>);}diff --git a/frontend/src/pages/FleetProxy.jsx b/frontend/src/pages/FleetProxy.jsxindex c70faf37..f44eff05 100644--- a/frontend/src/pages/FleetProxy.jsx+++ b/frontend/src/pages/FleetProxy.jsx@@ -4,8 +4,14 @@ import { AlertTriangle, Network, RefreshCw, Server as ServerIcon } from 'lucide-import api from '../services/api';import { useToast } from '../contexts/ToastContext';import { useTopbarActions } from '@/hooks/useTopbarActions';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';import { Button } from '@/components/ui/button';-import { DataTable, Pill } from '@/components/ds';+import { DataTable, ListToolbar, Pill } from '@/components/ds';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';import EmptyState from '../components/EmptyState';// Fleet-wide reverse-proxy dashboard (Phase 4 of C6). Aggregates every@@ -49,6 +55,11 @@ const RECOMMENDATION_KIND = {warn: 'amber',};+// Urgency order for the Recommendation column, so sorting it puts what needs+// doing on top instead of alphabetising the sentence (every mismatch text+// starts with its own count, which scattered those rows across the list).+const RECOMMENDATION_RANK = { warn: 0, info: 1, ok: 2 };+function formatTimestamp(value) {if (!value) return 'Never';const date = new Date(value);@@ -60,12 +71,264 @@ function typeMeta(type) {return PROXY_TYPE_META[type] || { label: type || 'Unknown', kind: 'gray' };}+const statusLabel = (row) => STATUS_LABEL[row.status] || row.status || 'Unknown';++// Columns for the shared DataTable. 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+// that declares only one of them silently gets the other from the wrong place.+const FLEET_COLUMNS = [+ {+ key: 'server',+ header: 'Server',+ sortable: true,+ hideable: false,+ type: 'text',+ value: (row) => row.server_name || 'Unnamed server',+ sortValue: (row) => row.server_name || '',+ render: (row) => (+ <Link to={`/servers/${row.server_id}/proxy`} className="fleet-proxy__server">+ <ServerIcon size={14} />+ <span>{row.server_name || 'Unnamed server'}</span>+ </Link>+ ),+ },+ {+ key: 'type',+ header: 'Proxy type',+ sortable: true,+ type: 'enum',+ groupable: true,+ // Filter, group and sort on the LABEL the pill shows, so a preset that+ // says 'Traefik' reads the same way the row does. `groupValue` has to+ // be spelled out too — DataTable's grouping falls back to row[key],+ // and there is no `row.type`.+ value: (row) => typeMeta(row.proxy_type).label,+ groupValue: (row) => typeMeta(row.proxy_type).label,+ sortValue: (row) => typeMeta(row.proxy_type).label,+ render: (row) => {+ const meta = typeMeta(row.proxy_type);+ return <Pill kind={meta.kind} dot={false}>{meta.label}</Pill>;+ },+ },+ {+ key: 'status',+ header: 'Status',+ sortable: true,+ type: 'enum',+ groupable: true,+ value: statusLabel,+ groupValue: statusLabel,+ sortValue: statusLabel,+ render: (row) => (+ <Pill kind={STATUS_KIND[row.status] || 'gray'}>{statusLabel(row)}</Pill>+ ),+ },+ {+ key: 'apps',+ header: 'Apps',+ sortable: true,+ type: 'num',+ value: (row) => row.app_count ?? 0,+ sortValue: (row) => row.app_count ?? 0,+ cellClassName: 'fleet-proxy__muted',+ render: (row) => row.app_count ?? 0,+ },+ {+ // Its own column rather than a pill tacked onto Apps: "how many apps+ // are pointed at the wrong ingress plane" is the one number on this+ // page you act on, and inside another cell it could not be sorted or+ // filtered. A row without a count reads 0 here, so the `gt 0` preset+ // below needs a real, positive mismatch — a missing count can never+ // look like a fault.+ key: 'mismatches',+ header: 'Mismatches',+ sortable: true,+ type: 'num',+ value: (row) => row.mismatch_count ?? 0,+ sortValue: (row) => row.mismatch_count ?? 0,+ render: (row) => (row.mismatch_count > 0 ? (+ <span className="fleet-proxy__apps">+ <Pill kind="amber" dot={false}>+ <AlertTriangle size={12} />+ {row.mismatch_count}+ </Pill>+ </span>+ ) : (+ <span className="fleet-proxy__muted">0</span>+ )),+ },+ {+ key: 'recommendation',+ header: 'Recommendation',+ sortable: true,+ type: 'enum',+ // The LEVEL is the filterable dimension — the text carries a per-row+ // count, so it is four sentences on paper and N distinct values in+ // practice. No built-in view filters it: level 'warn' is exactly+ // `mismatches > 0`, and the number sorts by severity as well.+ value: (row) => row.recommendation?.level || 'none',+ sortValue: (row) => RECOMMENDATION_RANK[row.recommendation?.level] ?? 3,+ render: (row) => (+ row.recommendation ? (+ <Pill+ kind={RECOMMENDATION_KIND[row.recommendation.level] || 'gray'}+ dot={false}+ className="fleet-proxy__recommendation"+ title={row.recommendation.text}+ >+ {row.recommendation.text}+ </Pill>+ ) : (+ <span className="fleet-proxy__muted">—</span>+ )+ ),+ },+ {+ key: 'lastRegenerated',+ header: 'Last regenerated',+ 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: (row) => row.last_regenerated_at || null,+ sortValue: (row) => {+ const time = Date.parse(row.last_regenerated_at);+ return Number.isNaN(time) ? null : time;+ },+ cellClassName: 'fleet-proxy__muted',+ render: (row) => formatTimestamp(row.last_regenerated_at),+ },+ {+ key: 'networks',+ header: 'Networks',+ sortable: true,+ type: 'num',+ value: (row) => row.networks_count ?? 0,+ sortValue: (row) => row.networks_count ?? 0,+ cellClassName: 'fleet-proxy__muted',+ render: (row) => row.networks_count ?? 0,+ },+ {+ key: 'actions',+ header: '',+ className: 'fleet-proxy__col-actions',+ cellClassName: 'fleet-proxy__col-actions',+ render: (row) => (+ <Button asChild variant="ghost" size="sm">+ <Link to={`/servers/${row.server_id}/proxy`}>Manage</Link>+ </Button>+ ),+ },+];++// Built-in saved views. Every rule matches against a column's `value`+// accessor, so the strings below are the LABELS the cells render ('Traefik',+// 'Host default') — never the raw backend enum ('traefik', 'host').+//+// The first two are deliberately exception lists: an aligned, healthy fleet+// shows nothing under them, which is the answer they exist to give.+const NO_RULES = { match: 'all', rules: [] };++const FLEET_BUILTIN_VIEWS = [+ {+ // The worklist. An app tagged for the other ingress plane than its+ // server's proxy is either unreachable or colliding on 80/443, so the+ // worst server goes on top. Networks is hidden — it says nothing about+ // which app is misrouted.+ name: 'Ingress mismatches',+ state: {+ sorts: [{ key: 'mismatches', direction: 'desc' }],+ hiddenKeys: ['networks'],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{ id: 'fm1', field: 'mismatches', op: 'gt', value: 0 }],+ },+ },+ },+ {+ // A managed stack that is not running means that server is serving+ // nothing. 'Unknown' belongs here: it is the status a stack row starts+ // at, so it means "never confirmed up", not "fine". 'Host default' is+ // absent on purpose — that is the healthy default, not an outage.+ name: 'Proxy not running',+ state: {+ sorts: [{ key: 'server', direction: 'asc' }],+ hiddenKeys: [],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{+ id: 'fp1',+ field: 'status',+ op: 'any',+ value: ['Stopped', 'Error', 'Unknown'],+ }],+ },+ },+ },+ {+ // Who opted out of host nginx, stalest generated config first (a row+ // that was never regenerated sorts last — nulls always sink).+ name: 'Managed stacks',+ state: {+ sorts: [{ key: 'lastRegenerated', direction: 'asc' }],+ hiddenKeys: [],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{ id: 'ms1', field: 'type', op: 'any', value: ['Traefik', 'Caddy'] }],+ },+ },+ },+ {+ // The other half of the fleet: still on host nginx, busiest first —+ // those are the servers where a managed stack would buy something.+ // Last regenerated and Networks are hidden because a host row has+ // neither, so both columns would be a wall of "Never" and 0.+ name: 'Still on host Nginx',+ state: {+ sorts: [{ key: 'apps', direction: 'desc' }],+ hiddenKeys: ['lastRegenerated', 'networks'],+ groupBy: null,+ columnFilters: {+ match: 'all',+ rules: [{ id: 'hn1', field: 'status', op: 'any', value: ['Host default'] }],+ },+ },+ },+ {+ // No rules at all: the whole fleet, bucketed by what it actually runs.+ // The group headers carry the counts the old KPI band used to.+ name: 'By proxy type',+ state: {+ sorts: [{ key: 'server', direction: 'asc' }],+ hiddenKeys: [],+ groupBy: 'type',+ columnFilters: NO_RULES,+ },+ },+];+const FleetProxy = () => {const toast = useToast();const [rows, setRows] = useState([]);const [loading, setLoading] = useState(true);const [error, setError] = useState(null);+ // Table sort + column visibility, persisted and handed to the chrome.+ // Hiding a column is only safe now that the rows render from the column+ // descriptors: the old renderRow escape hatch always emitted every <td>,+ // so dropping a header would have misaligned the body.+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-fleet-proxy-sort' });+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({+ storageKey: 'serverkit-table-fleet-proxy-cols',+ });+ // Not persisted separately: a grouping worth keeping is a saved view now.+ const [groupBy, setGroupBy] = useState(null);+const load = useCallback(async () => {setLoading(true);try {@@ -95,28 +358,26 @@ const FleetProxy = () => {// No KPI band and no page title: every tile it held was a re-count of a// column already on the table below, and the tab strip names the page.- // Sorting is safe with the renderRow escape hatch below (DataTable sorts- // the data before rows render; headers still come from `columns`). Column- // visibility is not — renderRow always emits every <td>, so hiding a- // header would misalign the body — so no storageKey/ColumnsMenu here.- const columns = [- { key: 'server', header: 'Server', sortable: true, sortValue: (row) => row.server_name || '' },- { key: 'type', header: 'Proxy type', sortable: true, sortValue: (row) => typeMeta(row.proxy_type).label },- { key: 'status', header: 'Status', sortable: true, sortValue: (row) => STATUS_LABEL[row.status] || row.status || '' },- { key: 'apps', header: 'Apps', sortable: true, sortValue: (row) => row.app_count ?? 0 },- { key: 'recommendation', header: 'Recommendation', sortable: true, sortValue: (row) => row.recommendation?.text || null },- {- key: 'lastRegenerated',- header: 'Last regenerated',- sortable: true,- sortValue: (row) => {- const time = Date.parse(row.last_regenerated_at);- return Number.isNaN(time) ? null : time;- },- },- { key: 'networks', header: 'Networks', sortable: true, sortValue: (row) => row.networks_count ?? 0 },- { key: 'actions', header: '', className: 'fleet-proxy__col-actions' },- ];+ //+ // No `pageState` either — the list is the fleet overview endpoint's whole+ // response, unpaginated and with no search or server-side filter of its+ // own, so there is nothing page-private for a view to carry and every rule+ // in a preset narrows the same rows the operator is looking at.+ const chrome = useTableChrome({+ columns: FLEET_COLUMNS,+ rows,+ viewPageKey: 'fleet-proxy',+ builtinViews: FLEET_BUILTIN_VIEWS,+ noun: 'servers',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ groupBy,+ setGroupBy,+ });++ const managed = rows.filter((row) => row.proxy_type && row.proxy_type !== 'nginx').length;return (<div className="sk-tabgroup__inner fleet-proxy">@@ -126,80 +387,61 @@ const FleetProxy = () => {<Button variant="outline" size="sm" onClick={load}>Retry</Button></div>) : (- <div className="fleet-proxy__table">- <DataTable- loading={loading}- columns={columns}- data={rows}- keyField="server_id"- emptyState={(- <EmptyState- icon={Network}- title="No servers in the fleet"- description="This is where each server's reverse-proxy posture lands: which proxy it runs, whether it's healthy, and when its config was last regenerated. Host Nginx is the default; a server can opt into a managed Traefik or Caddy stack from its Proxy tab. Add a server to start."- />+ <>+ <GridViewPicker+ views={chrome.views}+ label="servers"+ total={loading ? null : `${rows.length} server${rows.length === 1 ? '' : 's'}`}+ onCreate={chrome.createView}+ />+ <ListToolbar+ // Null while the fetch is in flight: an empty `rows` is+ // "not known yet", and "0 servers" is a claim.+ count={loading ? null : (+ <>+ {rows.length} server{rows.length === 1 ? '' : 's'}+ <i>·</i>+ <b>{managed} managed stack{managed === 1 ? '' : 's'}</b>+ </>+ )}+ tools={(+ <>+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu {...chrome.toolsProps} onRefresh={load} />+ </>)}- renderRow={(row, { key }) => {- const meta = typeMeta(row.proxy_type);- return (- <tr key={key} className="fleet-proxy__row">- <td>- <Link- to={`/servers/${row.server_id}/proxy`}- className="fleet-proxy__server"- >- <ServerIcon size={14} />- <span>{row.server_name || 'Unnamed server'}</span>- </Link>- </td>- <td>- <Pill kind={meta.kind} dot={false}>{meta.label}</Pill>- </td>- <td>- <Pill kind={STATUS_KIND[row.status] || 'gray'}>- {STATUS_LABEL[row.status] || row.status || 'Unknown'}- </Pill>- </td>- <td>- <div className="fleet-proxy__apps">- <span className="fleet-proxy__muted">{row.app_count ?? 0}</span>- {row.mismatch_count > 0 && (- <Pill kind="amber" dot={false}>- <AlertTriangle size={12} />- {row.mismatch_count} ingress mismatch{row.mismatch_count === 1 ? '' : 'es'}- </Pill>- )}- </div>- </td>- <td>- {row.recommendation ? (- <Pill- kind={RECOMMENDATION_KIND[row.recommendation.level] || 'gray'}- dot={false}- className="fleet-proxy__recommendation"- title={row.recommendation.text}- >- {row.recommendation.text}- </Pill>- ) : (- <span className="fleet-proxy__muted">—</span>- )}- </td>- <td className="fleet-proxy__muted">- {formatTimestamp(row.last_regenerated_at)}- </td>- <td className="fleet-proxy__muted">{row.networks_count ?? 0}</td>- <td className="fleet-proxy__col-actions">- <Button asChild variant="ghost" size="sm">- <Link to={`/servers/${row.server_id}/proxy`}>Manage</Link>- </Button>- </td>- </tr>- );- }}/>- </div>++ <GridChips {...chrome.chipProps} />++ <div className="fleet-proxy__table">+ <DataTable+ loading={loading}+ columns={chrome.columns}+ data={rows}+ keyField="server_id"+ sorts={sorts}+ onSortsChange={setSorts}+ {...chrome.tableProps}+ groupBy={groupBy}+ onGroupByChange={setGroupBy}+ rowClassName="fleet-proxy__row"+ emptyState={(+ <EmptyState+ icon={Network}+ title="No servers in the fleet"+ description="This is where each server's reverse-proxy posture lands: which proxy it runs, whether it's healthy, and when its config was last regenerated. Host Nginx is the default; a server can opt into a managed Traefik or Caddy stack from its Proxy tab. Add a server to start."+ />+ )}+ />+ </div>+ </>)}++ <GridFilterDrawer {...chrome.drawerProps} /></div>);};diff --git a/frontend/src/pages/QueueDetail.jsx b/frontend/src/pages/QueueDetail.jsxindex 3a6fc5cd..94713b8d 100644--- a/frontend/src/pages/QueueDetail.jsx+++ b/frontend/src/pages/QueueDetail.jsx@@ -1,4 +1,4 @@-import { useState, useEffect, useRef, useCallback } from 'react';+import { useState, useEffect, useRef, useCallback, useMemo } from 'react';import { useParams, useNavigate } from 'react-router-dom';import {ArrowLeft,@@ -19,8 +19,12 @@ import { Label } from '@/components/ui/label';import { Input } from '@/components/ui/input';import { Textarea } from '@/components/ui/textarea';import {- ColumnsMenu, DataTable, DataTableFooter, MetricCard, Pill, SortChipBar, SortMenu,+ DataTable, DataTableFooter, MetricCard, Pill, SortChipBar,} from '@/components/ds';+import {+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,+ GridToolsMenu, GridFilterDrawer,+} from '@/components/ds/grid';import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';@@ -44,6 +48,68 @@ const STATUS_ORDER = ['pending', 'in_flight', 'completed', 'failed', 'dead_letteconst POLL_INTERVAL = 3000;+// Built-in saved views.+//+// These views are shared by EVERY queue this route renders, so nothing here may+// name a queue or a group — each one is a statement about messages.+//+// The status presets drive the page's own `statusFilter` (the `page` bag)+// rather than a column rule. /messages is filtered SERVER side and capped at+// 100 rows, so a client-side rule could only narrow the page that already+// loaded; asking the server for `dead_letter` is the only way to see a dead+// letter that sits past row 100 of a busy queue.+const PAGE = (statusFilter) => ({ statusFilter });+const NO_RULES = { match: 'all', rules: [] };++const BUILTIN_VIEWS = [+ {+ // Head of line first — the oldest pending message is the one holding+ // up everything behind it.+ name: 'Waiting',+ state: {+ page: PAGE('pending'), hiddenKeys: [], columnFilters: NO_RULES,+ sorts: [{ key: 'created', direction: 'asc' }],+ },+ },+ {+ // Leased to a consumer. Oldest first: a message that has been in+ // flight for a long time is a consumer that died holding the lease.+ name: 'In flight',+ state: {+ page: PAGE('in_flight'), hiddenKeys: [], columnFilters: NO_RULES,+ sorts: [{ key: 'created', direction: 'asc' }],+ },+ },+ {+ // Erroring but still inside max_attempts. Most-attempted first, which+ // is the order they will give up in.+ name: 'Failed',+ state: {+ page: PAGE('failed'), hiddenKeys: [], columnFilters: NO_RULES,+ sorts: [{ key: 'attempts', direction: 'desc' }],+ },+ },+ {+ // Retries exhausted: the requeue worklist.+ name: 'Dead letter',+ state: {+ page: PAGE('dead_letter'), hiddenKeys: [], columnFilters: NO_RULES,+ sorts: [{ key: 'created', direction: 'desc' }],+ },+ },+ {+ // A first-time delivery leaves attempts at 1, so `> 1` is exactly the+ // set that needed redelivering — a flaky consumer shows up here across+ // every status, including the messages that eventually completed.+ name: 'Retried',+ state: {+ page: PAGE('all'), hiddenKeys: [],+ sorts: [{ key: 'attempts', direction: 'desc' }],+ columnFilters: { match: 'all', rules: [{ id: 'retry', field: 'attempts', op: 'gt', value: 1 }] },+ },+ },+];+const QueueDetail = () => {const { groupSlug, queueSlug } = useParams();const navigate = useNavigate();@@ -60,9 +126,16 @@ const QueueDetail = () => {const [sendForm, setSendForm] = useState({ payload: '{}', priority: 0, delay_ms: 0 });const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-queue-messages-sort' });const {- hiddenKeys, toggleColumn, showAllColumns,+ hiddenKeys, setHiddenKeys,} = useColumnVisibility({ storageKey: 'serverkit-table-queue-messages-cols' });+ // The one narrowing control this page owns, as the envelope's `page` bag.+ // It is a SERVER filter — restoring it refetches rather than re-slicing.+ const viewPageState = useMemo(() => ({ statusFilter }), [statusFilter]);+ const applyViewPageState = useCallback((saved) => {+ if (saved.statusFilter !== undefined) setStatusFilter(saved.statusFilter);+ }, []);+const pollRef = useRef(null);const viewOnly = group?.owner_type === 'system';@@ -172,6 +245,13 @@ const QueueDetail = () => {key: 'status',header: 'Status',sortable: true,+ // `value` is not optional here. The rule engine falls back to+ // sortValue when a column has none, and this sortValue is a+ // lifecycle RANK — a status rule would then compare 'failed'+ // against 3 and match nothing at all.+ type: 'enum',+ value: (msg) => msg.status,+ enumOrder: STATUS_ORDER,// Lifecycle order, not alphabet.sortValue: (msg) => STATUS_ORDER.indexOf(msg.status),render: (msg) => <Pill kind={STATUS_KINDS[msg.status] || 'gray'}>{msg.status}</Pill>,@@ -180,12 +260,22 @@ const QueueDetail = () => {key: 'payload',header: 'Payload',sortable: false,+ // The raw payload is an object, and `contains` over one stringifies+ // to '[object Object]' for every row. Match the text the cell+ // actually shows instead, so "payload contains order_id" works.+ type: 'text',+ value: (msg) => JSON.stringify(msg.payload),render: (msg) => <code className="queue-payload-preview">{JSON.stringify(msg.payload).slice(0, 80)}</code>,},{key: 'attempts',header: 'Attempts',sortable: true,+ // Declared rather than inferred: the "Retried" preset compares+ // against this, and an inference that saw only zeroes on a fresh+ // queue would type the column and then the rule differently.+ type: 'num',+ value: (msg) => msg.attempts,sortValue: (msg) => msg.attempts,render: (msg) => <>{msg.attempts} / {msg.max_attempts}</>,},@@ -193,6 +283,10 @@ const QueueDetail = () => {key: 'created',header: 'Created',sortable: true,+ // Same split as elsewhere: epoch ms sorts, the ISO string filters.+ // Without `value` the column menu would offer "is under 1755…".+ type: 'date',+ value: (msg) => msg.created_at,sortValue: (msg) => new Date(msg.created_at).getTime(),render: (msg) => new Date(msg.created_at).toLocaleString(),},@@ -218,6 +312,22 @@ const QueueDetail = () => {}] : []),];+ // Shared list chrome: view picker + filter chips + filter drawer + tools.+ // Declared before the loading return so the hook order is stable.+ const chrome = useTableChrome({+ columns,+ rows: messages,+ viewPageKey: 'queue-messages',+ builtinViews: BUILTIN_VIEWS,+ noun: 'messages',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ pageState: viewPageState,+ applyPage: applyViewPageState,+ });+if (loading) {return (<div className="queue-page queue-page--loading">@@ -273,6 +383,16 @@ const QueueDetail = () => {<div className={`queue-detail-body ${selectedMessage ? 'has-panel' : ''}`}><div className="queue-detail-main">+ {/* The view name heads the message list. The queue's own+ name stays in the detail header above — a view here is+ about the messages, and is shared by every queue. */}+ <GridViewPicker+ views={chrome.views}+ label="messages"+ total={`${messages.length} loaded`}+ onCreate={chrome.createView}+ />+<div className="queue-messages-toolbar"><div className="queue-messages-selects"><select@@ -289,16 +409,22 @@ const QueueDetail = () => {<strong>{messages.length}</strong><span>{messages.length === 1 ? 'message' : 'messages'}</span></span>- <SortMenu columns={columns} sorts={sorts} onChange={setSorts} />- <ColumnsMenu- columns={columns}- hiddenKeys={hiddenKeys}- onToggle={toggleColumn}- onShowAll={showAllColumns}+ {/* Sort and hide live in each column's own "⋮" menu+ now. What stays here is what has no per-column+ equivalent: the multi-rule drawer and export. */}+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu+ {...chrome.toolsProps}+ onRefresh={() => { loadMeta(); loadMessages(statusFilter); }}/></div></div>+ <GridChips {...chrome.chipProps} />+<SortChipBar columns={columns} sorts={sorts} onChange={setSorts} />{messages.length === 0 ? (@@ -311,12 +437,12 @@ const QueueDetail = () => {/>) : (<DataTable- columns={columns}+ columns={chrome.columns}data={messages}keyField="id"sorts={sorts}onSortsChange={setSorts}- hiddenKeys={hiddenKeys}+ {...chrome.tableProps}onRowClick={(msg) => setSelectedMessage(msg)}rowClassName={(msg) => (selectedMessage?.id === msg.id ? 'is-selected' : '')}className="queue-table-wrap"@@ -390,6 +516,8 @@ const QueueDetail = () => {</div></form></Modal>++ <GridFilterDrawer {...chrome.drawerProps} /></div>);};diff --git a/frontend/src/pages/QueueOperations.jsx b/frontend/src/pages/QueueOperations.jsxindex 64e6803f..030dc04c 100644--- a/frontend/src/pages/QueueOperations.jsx+++ b/frontend/src/pages/QueueOperations.jsx@@ -23,8 +23,12 @@ import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import { Textarea } from '@/components/ui/textarea';import {- ColumnsMenu, DataTable, DataTableFooter, MetricCard, Pill, SortChipBar, SortMenu,+ DataTable, DataTableFooter, MetricCard, Pill, SortChipBar,} 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 { formatCompact, formatFull } from '../utils/formatNumber';@@ -49,6 +53,57 @@ const STATUS_ORDER = ['pending', 'in_flight', 'completed', 'failed', 'dead_letteconst POLL_INTERVAL = 3000;+// Built-in saved views.+//+// The per-status presets go through the rail's OWN Message Status filter (the+// `page` bag) instead of a column rule: a queue carries five separate counts+// that all render inside the single Messages cell, and one column can only+// expose one number to the rule engine — `total`. "Has a dead-lettered+// message" is therefore only expressible as page state.+//+// Every preset also resets the group to All. `selectedGroup` decides which+// group's queues are FETCHED, so a preset that left it alone would show a+// different set depending on what happened to be selected when it was clicked.+const PAGE = (messageFilter) => ({ selectedGroup: '', messageFilter, searchTerm: '' });+const NO_RULES = { match: 'all', rules: [] };+const BY_SIZE = [{ key: 'messages', direction: 'desc' }];++const BUILTIN_VIEWS = [+ {+ // Queues holding work nobody has picked up yet, biggest first.+ name: 'Backlog',+ state: { page: PAGE('pending'), sorts: BY_SIZE, hiddenKeys: [], columnFilters: NO_RULES },+ },+ {+ // A consumer is erroring here, but these messages still have retries.+ name: 'Failing',+ state: { page: PAGE('failed'), sorts: BY_SIZE, hiddenKeys: ['created'], columnFilters: NO_RULES },+ },+ {+ // Retries exhausted — nothing moves these without a manual requeue.+ name: 'Dead letter',+ state: { page: PAGE('dead_letter'), sorts: BY_SIZE, hiddenKeys: ['created'], columnFilters: NO_RULES },+ },+ {+ // Where the traffic actually is, across every status.+ name: 'Busiest',+ state: {+ page: PAGE('all'), sorts: BY_SIZE, hiddenKeys: [],+ columnFilters: { match: 'all', rules: [{ id: 'busy', field: 'messages', op: 'gt', value: 0 }] },+ },+ },+ {+ // Declared but never written to: the queues to wire up or delete.+ // Newest first, because a queue created minutes ago being empty is+ // expected and one created months ago being empty is the finding.+ name: 'Never used',+ state: {+ page: PAGE('all'), sorts: [{ key: 'created', direction: 'desc' }], hiddenKeys: [],+ columnFilters: { match: 'all', rules: [{ id: 'unused', field: 'messages', op: 'eq', value: 0 }] },+ },+ },+];+const QueueOperations = () => {const toast = useToast();const { confirm } = useConfirm();@@ -72,9 +127,22 @@ const QueueOperations = () => {const [sendForm, setSendForm] = useState({ payload: '{}', priority: 0, delay_ms: 0 });const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-queue-ops-sort' });const {- hiddenKeys, toggleColumn, showAllColumns,+ hiddenKeys, setHiddenKeys,} = useColumnVisibility({ storageKey: 'serverkit-table-queue-ops-cols' });+ // The three narrowing controls this page owns, as the envelope's `page`+ // bag. Group and status are what the rail clicks set, so a saved view+ // restores the rail to the state it was captured in.+ const viewPageState = useMemo(+ () => ({ selectedGroup, messageFilter, searchTerm }),+ [selectedGroup, messageFilter, searchTerm],+ );+ const applyViewPageState = useCallback((saved) => {+ if (saved.selectedGroup !== undefined) setSelectedGroup(saved.selectedGroup);+ if (saved.messageFilter !== undefined) setMessageFilter(saved.messageFilter);+ if (saved.searchTerm !== undefined) setSearchTerm(saved.searchTerm);+ }, []);+const pollRef = useRef(null);const navigate = useNavigate();@@ -302,6 +370,12 @@ const QueueOperations = () => {key: 'messages',header: 'Messages',sortable: true,+ // The cell renders five per-status pills, but a rule can only ever+ // mean one number — the total. Declared explicitly so the "Busiest"+ // and "Never used" presets compare against it rather than against+ // whatever the type inference makes of the pill markup.+ type: 'num',+ value: (queue) => queue.stats?.total ?? 0,sortValue: (queue) => queue.stats?.total ?? 0,render: (queue) => (<div className="queue-row-counts" onClick={e => e.stopPropagation()}>@@ -320,6 +394,12 @@ const QueueOperations = () => {key: 'created',header: 'Created',sortable: true,+ // The sort wants epoch ms, but that number is also what the filter+ // would infer from — leaving the column menu offering "is under+ // 1755…". `value` hands the rule engine the ISO string instead, so+ // the menu offers before/after with a date picker.+ type: 'date',+ value: (queue) => queue.created_at,sortValue: (queue) => new Date(queue.created_at).getTime(),render: (queue) => new Date(queue.created_at).toLocaleString(),},@@ -350,6 +430,23 @@ const QueueOperations = () => {},];+ // Shared list chrome: view picker + filter chips + filter drawer + tools,+ // driven off this page's existing sorts/hiddenKeys state. Declared before+ // the loading return so the hook order never changes between renders.+ const chrome = useTableChrome({+ columns,+ rows: filteredQueues,+ viewPageKey: 'queue-operations',+ builtinViews: BUILTIN_VIEWS,+ noun: 'queues',+ sorts,+ setSorts,+ hiddenKeys,+ setHiddenKeys,+ pageState: viewPageState,+ applyPage: applyViewPageState,+ });+if (loading) {return (<div className="queue-page queue-page--loading">@@ -463,6 +560,15 @@ const QueueOperations = () => {</div></div>+ {/* The view name is the page's heading for the list, above+ the bar that narrows it. */}+ <GridViewPicker+ views={chrome.views}+ label="queues"+ total={`${filteredQueues.length} of ${queues.length} queues`}+ onCreate={chrome.createView}+ />+<div className="queue-command-bar"><div className="queue-toolbar"><label className="search-box">@@ -482,12 +588,17 @@ const QueueOperations = () => {<option value="">All groups</option>{groups.map(g => <option key={g.id} value={g.slug}>{g.name}</option>)}</select>- <SortMenu columns={columns} sorts={sorts} onChange={setSorts} />- <ColumnsMenu- columns={columns}- hiddenKeys={hiddenKeys}- onToggle={toggleColumn}- onShowAll={showAllColumns}+ {/* Sort and hide moved into each column's own "⋮"+ menu, next to the column they act on. What is+ left here is the pair that has no per-column+ equivalent: the multi-rule drawer and export. */}+ <GridFilterButton+ count={chrome.filterCount}+ onClick={() => chrome.setDrawerOpen(true)}+ />+ <GridToolsMenu+ {...chrome.toolsProps}+ onRefresh={() => { loadData(); loadQueues(selectedGroup); }}/></div><div className="queue-results-summary">@@ -509,6 +620,8 @@ const QueueOperations = () => {</div></div>+ <GridChips {...chrome.chipProps} />+<SortChipBar columns={columns} sorts={sorts} onChange={setSorts} />{filteredQueues.length === 0 ? (@@ -534,12 +647,12 @@ const QueueOperations = () => {/>) : (<DataTable- columns={columns}+ columns={chrome.columns}data={filteredQueues}keyField="id"sorts={sorts}onSortsChange={setSorts}- hiddenKeys={hiddenKeys}+ {...chrome.tableProps}onRowClick={(queue) => openQueue(queue)}className="queue-table-wrap"tableClassName="queue-table"@@ -649,6 +762,8 @@ const QueueOperations = () => {</form>)}</Modal>++ <GridFilterDrawer {...chrome.drawerProps} /></div>);};