diff --git a/.fallowrc.json b/.fallowrc.json index acf63c6cf..bbe4fe172 100644 --- a/.fallowrc.json +++ b/.fallowrc.json @@ -22,7 +22,10 @@ "react", "react-dom", "@fontsource-variable/geist", - "@fontsource-variable/geist-mono" + "@fontsource-variable/geist-mono", + "recharts", + // Recharts' peer dependency: installed for it, never imported by the console itself. + "react-is" ], "ignoreDependencyOverrides": [ // MCP SDK 1.29 transitively requires vulnerable node-server 1.x; lockfile/audit verify this patched override. diff --git a/docs/CONSOLE.md b/docs/CONSOLE.md index 34130b31d..ff053f1df 100644 --- a/docs/CONSOLE.md +++ b/docs/CONSOLE.md @@ -8,8 +8,14 @@ internet. The console is for people who operate Simlock. It needs an operator token. Coding agents keep using the CLI, the MCP server, the client and the HTTP API. -This version has sign-in and a page for each entry in the console's -navigation: Workers, Leases, Waiting, Attention and Events. +This version has sign-in and a page for each tab along the top of the +console: Workers, Leases, Waiting, Attention and Events. On a narrow screen +the row of tabs scrolls sideways. + +Each page starts with a row of cards that count what the page shows, such as +the leases held and how many expire within 15 minutes. A long id, such as a +lease's, is cut to fit its column; point at it to see it whole, or open its +page. ## Turn it on @@ -107,6 +113,14 @@ Each worker shows: A worker the gateway could not read from yet says "Not reported" where it has nothing to show. +Above the workers, **Leases, last hour** charts how many leases were held at +the end of each minute. It starts from the leases held now and counts back +through the lease events of the last hour, the same events the Events page +shows, so it can only go back as far as those. A lease that ends with no +event, such as one on a worker removed from a gateway, is not counted back. **Minute by minute** under the +chart lists each minute's number. **Busiest workers** ranks the workers by +the leases each holds now. + Select a worker to open its page. It adds: - **Devices**: every device on the worker, with its state, platform, model, @@ -212,8 +226,8 @@ The first three come from a gateway only: a single host has no gateway to lose or disagree with, and cannot be drained. The other three show on a single host too. -The navigation shows how many items there are beside **Attention**, on every -page. It shows no number while there are none. +The **Attention** tab shows how many items there are, on every page. It shows +no number while there are none. Each item shows within about a second of the daemon reporting it. A stalled device is the exception on a gateway: a device becomes stalled when its time @@ -244,6 +258,10 @@ devices, workers or components. **Other** lists the rest, such as The page keeps the newest 1000 events. Older ones drop off the end. +**Events per minute** charts how many of the events the page holds happened in +each minute of the last hour, whatever **Show** picks. **Minute by minute** +under it lists each minute's number. + When the console loses the daemon, or the tab was hidden, it loads the events it missed as soon as it is back, so the list has no gap. An event the console already shows is never shown twice, also after the daemon restarts. @@ -264,7 +282,8 @@ are off by as much. A hidden tab stops asking the daemon for anything. When you come back to it, it catches up at once. -The line under the header says how the console's connection is: +The box at the top right, beside **Sign out**, says how the console's +connection is: | It says | What it means | | --- | --- | @@ -274,7 +293,7 @@ The line under the header says how the console's connection is: While reconnecting, the console keeps the last data on screen and tries the daemon again after 1, 2, 4 and 8 seconds, then every 10 seconds. When the -daemon answers, the console refreshes the page and the line goes back to +daemon answers, the console refreshes the page and the box goes back to Connected. You do not need to reload. ## What the page loads diff --git a/docs/internal/ARCHITECTURE.md b/docs/internal/ARCHITECTURE.md index 093c04817..d181ba3ea 100644 --- a/docs/internal/ARCHITECTURE.md +++ b/docs/internal/ARCHITECTURE.md @@ -62,16 +62,17 @@ modes](#gateway-and-worker-modes-adr-0005) below for that topology. auth or request log. The console is a client of the HTTP API like any other: it reads only `/v1`, with the operator's token, through one fetch helper (`ui/src/api.ts`). Its views are listed once, in `ui/src/views/index.tsx`, - which is both the navigation and the router's table. Views read data only + which is both the tab bar and the router's table. Views read data only through the live layer (ADR 0013, `ui/src/live/`): `useLiveResource(path)` marks a route as one the screen reads, and `LiveConnection` refetches every such route on each event from `GET /v1/events/stream` and every second, one request per route at a time; it also owns the disconnect, backoff and recovery rules and the clock offset behind `useNow()`. The one exception - is the events view, whose list is not a route's latest answer: its feed - (`ui/src/views/event-feed.ts`) takes each event off the stream through the - live layer and loads `GET /v1/events` itself, for the last hour and for - each gap the stream left. See + is the last hour of events, which is not a route's latest answer: its feed + (`ui/src/views/event-feed.ts`, behind `useRecentEvents()`) takes each + event off the stream through the live layer and loads `GET /v1/events` + itself, for the last hour and for each gap the stream left. The events view + lists it, and the workers view's lease chart counts back through it. See [CONSOLE.md](../CONSOLE.md) for the user's side and [DESIGN.md](DESIGN.md) for the style. - **CLI**: by default it acquires a lease, prints one JSON result line on diff --git a/docs/internal/DESIGN.md b/docs/internal/DESIGN.md index 5f315a203..34c98241c 100644 --- a/docs/internal/DESIGN.md +++ b/docs/internal/DESIGN.md @@ -4,58 +4,74 @@ How Simlock looks. The web console follows it today, and the landing page will follow it when it is built. The tokens live in `ui/src/styles.css`; change this guide and that file together. -The style is Callstack's incubator style: plain, dense, square, quiet. Orange is -Simlock's accent. +The style is Callstack's console style, the one Apex uses: an off-white page, +square cards a shade darker, mono labels in capitals, and one accent colour. +Simlock's accent is orange where Apex's is green. ## Type -- **Geist** for everything people read. **Geist Mono** for what people copy or - compare: ids, tokens, commands, versions, timestamps, numbers in tables. -- Both are bundled with the console (`@fontsource-variable/geist`, +- **Geist** for titles and everything people read. **Geist Mono** for labels + and for what people copy or compare: ids, tokens, commands, versions, + timestamps, numbers in tables and on chart axes. +- A **label** is Geist Mono, 500, in capitals, letter-spaced `0.08em` + (`--label-tracking`): tab names, stat card labels, table headers, buttons, + the "By Callstack" chip. The capitals are CSS (`text-transform`); the text + in the page stays as written, so a screen reader and a test read "Sign out", + not "SIGN OUT". +- Both fonts are bundled with the console (`@fontsource-variable/geist`, `@fontsource-variable/geist-mono`, OFL-1.1). Nothing is loaded from a font service. - One scale, in `rem`, from a 16px base: | Token | Size | Use | | --- | --- | --- | - | `--text-xs` | 12px | badges, table footnotes | - | `--text-sm` | 14px | navigation, labels, hints, table cells | - | `--text-md` | 16px | body text | + | `--text-xs` | 12px | labels on cards and tables, the chip, a tab's count | + | `--text-sm` | 14px | tabs, buttons, captions, descriptions, table cells | + | `--text-md` | 16px | body text, page subtitles, card and panel titles | | `--text-lg` | 20px | the wordmark | - | `--text-xl` | 24px | a page's heading (`h1`) | + | `--text-xl` | 28px | a page's title (`h1`), a stat card's number | | `--text-2xl` | 32px | the landing page's headings only | -- Weights: 400 for text, 500 for labels and controls, 600 for headings. -- Headings get a small negative tracking (`-0.01em`). Body text has none. -- Line height 1.5 for text, 1.25 for headings. +- Weights: 400 for text, 500 for labels and big numbers, 600 for titles, 700 + for the wordmark. +- Titles and big numbers get a negative tracking (`-0.02em`). Body text has + none. +- Line height 1.5 for text, 1.25 for titles. ## Colour Every colour is a CSS custom property on `:root`. The light values apply by default; the dark values replace them under `prefers-color-scheme: dark`. The -console has no theme switch of its own: it follows the system. +console has no theme switch of its own: it follows the system. Both themes +have the same structure; only the values change. | Token | Light | Dark | Use | | --- | --- | --- | --- | -| `--bg` | `#ffffff` | `#0e0e0f` | the page | -| `--surface` | `#f5f5f4` | `#18181b` | panels, hovered rows | -| `--border` | `#d9d9d6` | `#2e2e33` | dividers, panel edges | -| `--text` | `#0e0e0f` | `#f2f2f0` | text | -| `--text-muted` | `#55555a` | `#a1a1a8` | secondary text, inactive nav | -| `--accent` | `#c2410c` | `#ff7a1a` | brand and interaction | -| `--accent-hover` | `#9a3412` | `#ff9442` | a hovered accent control | -| `--on-accent` | `#ffffff` | `#0e0e0f` | text on an accent fill | +| `--bg` | `#f8f8f7` | `#0e0e0f` | the page: off-white, or near-black | +| `--surface` | `#f1f1ef` | `#161618` | cards and panels, a shade darker than the page | +| `--field` | `#e9e9e7` | `#1e1e21` | an input's fill | +| `--chip` | `#e6e6e3` | `#232326` | the "By Callstack" chip | +| `--border` | `#dededb` | `#2b2b2f` | card edges, dividers, grid lines | +| `--border-strong` | `#85857f` | `#75757d` | an input's border, an outlined button | +| `--text` | `#111110` | `#f2f2f0` | text | +| `--text-muted` | `#5a5a55` | `#a1a1a8` | subtitles, captions, labels, inactive tabs | +| `--accent` | `#f76b15` | `#ff7a1a` | orange fills: the wordmark, filled buttons, the tab underline, charts | +| `--accent-hover` | `#e2560a` | `#ff9442` | a hovered filled button | +| `--on-accent` | `#111110` | `#0e0e0f` | text on an orange fill | +| `--accent-text` | `#b93d0b` | `#ff8c42` | orange as text or a line: links, the focus ring | | `--selection` | `#fed7aa` | `#7c2d12` | selected text | -The accent is a darker orange in the light theme so that it passes WCAG AA as -text and as a focus ring on white. +Orange comes in two strengths. `--accent` is bright, for fills, and carries +dark text. It is too light to be text on the page in the light theme, so +links and the focus ring use `--accent-text`, which passes AA there. ### Orange is for brand and interaction only -Use the accent for the wordmark's square, buttons, links, the focus ring, the -current page in the navigation, and selection. Never use it to say something -about state: not for "busy", not for "warning", not for "new". A reader who -sees orange should think "I can act here", nothing else. +Use the accent the way Apex uses its green: the wordmark's block, the current +tab's underline, filled buttons, links, the focus ring, selection, and the +line or columns of a chart. Never use it to say something about state: not +for "busy", not for "warning", not for "new". A reader who sees orange should +think "this is Simlock" or "I can act here", nothing else. ### Status colours @@ -71,19 +87,22 @@ one: `● connected`, not a green dot. Use the daemon's own word for the state (`leased`, `quarantined`, `drained`), so the console and the CLI agree. In the console a status is an 8px square of its colour, then the word in `--text` (`Status` in `ui/src/status.tsx`). A word the console does not know, from a -newer daemon, shows as itself in `--status-idle`. +newer daemon, shows as itself in `--status-idle`. A count, such as the one on +the Attention tab, is a number, not a status: it has neither a status colour +nor the accent. Every pair of text and background colour in both themes meets WCAG AA: 4.5:1 -for text, and 3:1 for the focus ring and an input's border. The browser lane -checks text contrast with axe in both themes; a new token must pass it too. +for text, and 3:1 for the focus ring and an input's border against what is +behind them. The browser lane checks text contrast with axe in both themes; a +new token must pass it too. ## Shape -- **Square corners** everywhere: `--radius` is `0`. No rounded buttons, panels +- **Square corners** everywhere: `--radius` is `0`. No rounded buttons, cards or inputs. -- Borders are 1px `--border`. Panels are `--surface` with a border, no shadow. -- No gradients, no illustrations. The one decoration is the wordmark's orange - square. +- Borders are 1px. Cards are `--surface` with a `--border` edge, no shadow. +- No gradients, no illustrations. The decoration is the wordmark's orange + block, and the faint orange fill under a chart's line. ## Spacing @@ -92,38 +111,79 @@ A 4px grid: `--space-1` 4px, `--space-2` 8px, `--space-3` 12px, `--space-4` scale; never a value between. - Buttons and inputs are at least 40px tall, so they are easy to hit on a phone. -- A page has 16px side padding on a phone and 32px from 768px up. +- A page has 16px side padding on a phone and 24px from 768px up. +- Cards sit 16px apart. Inside a card, 24px from its sides. + +## Components + +- **Header.** Left: the "SIMLOCK" wordmark, `--on-accent` on an `--accent` + block, then the "By Callstack" chip. Right: the connection in a bordered box, + as a status (its word and its colour), then **Sign out** as a secondary + button. The sign-in screen has the same header, without the right side. +- **Tab bar.** Under the header, one tab per view in a fixed order: Workers, + Leases, Waiting, Attention, Events. A tab is a label in `--text-muted`; the + current one is `--text` with a 2px `--accent` underline and + `aria-current="page"`. A 1px `--border` line runs under the bar. Attention + carries its count in a small bordered box, and none at zero. +- **Page header.** The view's title, a one-line subtitle in `--text-muted` + under it, and the view's actions on the right, such as **All workers** on a + worker's page. +- **Stat cards.** A row of cards under the page header: a label, a big number + (`--text-xl`), and a caption in `--text-muted` saying what it counts. A + card shows only numbers the view already has; it never makes a request of + its own. +- **Panel.** A card with a header: a title, a description in + `--text-muted`, actions on the right, and a 1px line between the header and + its body. A table, a chart or a list sits in a panel. A panel is a region + named by its title. +- **Table.** Fills its panel edge to edge. Headers are labels in + `--text-muted`. Rows are roomy, 16px above and below, with a 1px line + between them. Numbers, durations included, are mono and right-aligned. +- **Long ids** (a lease's, a worker's, a device's) stay on one line, cut with + an ellipsis. The whole id is in the element's `title`, in the text a copy or + a screen reader reads, and on the details page. +- **Buttons.** Primary: filled `--accent` with `--on-accent` text. Secondary: + outlined in `--border-strong`, `--text`. Quiet: text only. All are labels. +- **Inputs.** A `--field` fill and a 1px `--border-strong` border. +- **Charts.** Drawn with Recharts, bundled like the rest. A line or columns in + `--accent`, an area with a faint fill of it (8%), horizontal grid lines in + `--border`, axis labels in Geist Mono `--text-muted`. Every colour comes from + the stylesheet by class. Nothing moves: animation is off. Every chart has a + title, a caption saying what it counts, its numbers as a line of text under + it, and every minute as a table behind a "Minute by minute" disclosure, so + nothing is visible only in the picture. A chart can be focused, and the + arrow keys step through it. Its focus ring goes round the whole chart, for + keyboard focus only: a click on a chart draws none. ## Layout - Phone first. Every page works at 360px wide with no sideways scrolling of the - page. Under 768px a table's rows stack into blocks, each cell a line with its - column's name beside it (`data-label`), so nothing scrolls sideways. + page. When the tabs do not fit, as on a phone, the tab bar scrolls sideways inside itself. Under 768px a + table's rows stack into blocks, each cell a line with its column's name + beside it (`data-label`). A wide table, of six columns or more, stacks the + same way under 1100px. Otherwise a table has a fixed layout: a column of + numbers is 8rem wide, the others share the rest, and a long cell wraps or, + for an id, is cut, so a table is never wider than its panel. +- Stat cards fill the row, each at least 200px wide, and wrap. +- From 768px a chart and the panel beside it share a row, two thirds and one + third; two panels of the same weight share it half and half. - A list of things that each carry several facts, such as workers, is a grid - of cards: `--surface` panels, each a heading and its facts as label and value - pairs. -- One line under the header says how the console's connection is, on every - page. -- Under 768px: the header, then the navigation as a wrapping row, then the - page. From 768px: the header across the top, the navigation as a 200px - column on the left, the page beside it. -- The navigation lists every view in a fixed order. The current one has an - accent bar and `aria-current="page"`. + of cards, each a title and its facts as label and value pairs. ## Focus and keyboard -- Everything clickable is a real `` or `