Skip to content

Console: a Settings page that edits settings and restarts the daemon #1156

Open

Description

@leonardoxr

Part of #1151.

Scope

An operator sees and changes every setting from the console, on a worker or a gateway, and restarts the daemon from there. A new Settings page, in a new Configure group last in the sidebar, reads GET /v1/config (#1153), saves with PUT /v1/config/{key} (#1154) and restarts with POST /v1/restart (#1155). The page keeps no state of its own. It adds the form fields the design system lacks (a text field, a number field, a select, a switch and a JSON text area), since no page has edited a value before.

In short

After this PR the sidebar ends with a Configure group holding Settings. The page lists the settings by section, headed by the key's first segment as written (capacity, downloads, idle, lease, http, gateway, …). Each row shows its key, its running value (a secret reads Set or Not set), on a pending row also Saved: <value>, its default, and Live, On restart or Restart pending. Edit opens the row's field. Save sends the value. A key that can cut the console off (http.enabled, http.host, http.port, http.proxyAuth) asks first. A pending row brings a Restart daemon button to the top of the page.

Words on the page, word for word (<key>, <url>, <message> are the variable parts):

Where Text
success toast, live key title Saved <key>, line Applied now.
success toast, restart key title Saved <key>, line Applies when the daemon restarts.
error toast title Couldn't save <key>, line <message> (the daemon's)
JSON that does not parse, under the field Not valid JSON.
confirm, http.host or http.port title Change <key>?, body After the restart, the console is at <url>. Keep that address to reach it., buttons Keep, Save
every lock-out confirm buttons Keep, Save; busy Saving…
confirm, http.enabled false title Turn HTTP off?, body After the restart, this console stops. Turn it back on with simlock config set http.enabled true.
confirm, http.proxyAuth title Change sign-in?, body After the restart, the console asks for the new sign-in. A wrong value locks every person out.
after a lock-out save, above the rows After the restart, the console is at <url>., After the restart, HTTP is off and this console stops., or for http.proxyAuth After the restart, the console asks for the new sign-in.
restart success toast title Restarting the daemon, line The console reconnects when it is back.
restart error toast title Couldn't restart the daemon, line <message>
section heading the first segment of the key as written: capacity, diskPressure, warmPool, http
restart confirm title Restart the daemon?, body Leases are kept. Lease requests still waiting fail and must be sent again., buttons Keep, Restart daemon, busy Restarting…
fileProblem, above the rows config.json does not load: <fileProblem>. Saving a setting fixes nothing until the file loads.
warmPool.targets, warmPool.learn value shown, no Edit, link Change on the Warm pool tab
flowchart LR
  P["Settings page (new)"] -->|GET /v1/config| D[daemon]
  P -->|"PUT /v1/config/key (confirm first for a lock-out key)"| D
  P -->|"POST /v1/restart (confirm)"| D
  D -->|config.changed| S["stale ['config'] (new)"]
  S --> P
Loading

If this goes wrong, an operator saves a lock-out key with no warning, sees a secret, or edits the warm-pool targets in two places.

Technical spec

Facts

Commit bcedd2f.

# Fact Source
F1 The route table: path, label, icon, optional group; groups are Operate and Observe ui/src/app/routes.ts:12-36
F2 The sidebar order is fixed in the design doc: Overview, Inbox, Operate (Fleet, Leases, Queue), Observe (Activity, Usage) docs/internal/DESIGN.md:134-137
F3 Icons are a closed table; there is no settings icon ui/src/ds/icon.tsx:1-20
F4 The design system has no text field, number field, select, switch or text area; it has ChoiceChips, Tabs, SearchField ui/src/ds/choice.tsx:5-44, ui/src/ds/search-field.tsx:4
F5 Inputs: a --field fill and a 1px --border-strong border; a select 40px tall, mono, its own chevron docs/internal/DESIGN.md:238-241
F6 A confirm is a modal alert dialog, Keep first, the action named by its verb, busy text while it runs; toasts: success leaves after 6 s, error stays docs/internal/DESIGN.md:175-185
F7 An action is a model entry with confirm, method, path, success, failure; the runner sends it, shows the toasts and a Retry on error ui/src/model/actions.ts:62-88, ui/src/state/actions.ts:67-123
F8 Layers: a screen never fetches; state/ hooks return view models; model/ is pure ui/AGENTS.md:13-24
F9 routeKey('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/v1/config') is ['config']; a key with no TIMES entry never polls and is fresh 2 s ui/src/state/queries.ts:40-50, :66-71
F10 Events mark keys stale through staleKeys; an unknown name marks none ui/src/model/stale-keys.ts:17-40
F11 A lost connection shows Reconnecting, then Daemon is starting; coming back reads each key on screen once ui/src/state/shell.ts:65-77, ui/AGENTS.md:62-68
F12 The Warm pool tab is /fleet/<workerId>?tab=warm-pool ui/src/model/worker-page.ts:614-625, ui/src/screens/fleet/worker-page.tsx:96
F13 consoleUrl(http) gives the address status.get reports, or undefined with HTTP off; the console may import contract files by path src/contract/console-url.ts:21-29, src/contract/AGENTS.md Files table
F14 Console unit tests run in Node with no DOM; screens through renderToStaticMarkup; browser tests in e2e/console/ with stubbed answers ui/AGENTS.md:161-163, e2e/console/update.spec.ts:33
F15 The sidebar draws ungrouped entries first, then each group ui/src/ds/sidebar.tsx:96-103, e2e/console/fixtures.ts:749-762
F16 api.write and ItemAction.method take only DELETE and POST; ItemAction.id is a closed union; run resolves with nothing ui/src/data/api.ts:106, ui/src/model/actions.ts:26-38, ui/src/state/actions.ts:36, :72-106
F17 Every <select> is already styled once, chevron included ui/src/ds/foundation.css:175-179, ui/src/ds/pager.tsx:29
F18 gateway.url and gateway.token are refused one without the other, and with HTTP on src/core/config.ts:803-835
F19 Restarting the daemon already reads the page's data again on return, in the browser lane e2e/console/workers.spec.ts:1216-1240

Modules touched

Searches: ROUTES, NavGroup, IconName, staleKeys, TIMES, ItemAction, ConfirmHost, Settings and settings in ui/, e2e/console/, docs/internal/DESIGN.md and website/.

  • ui/src/app/routes.ts: NavGroup gains Configure; the /settings route in it, last (F15).
  • ui/src/model/actions.ts: ids save-setting and restart-daemon (F16; PUT comes from Console: edit the warm pool's targets on a worker's Warm pool tab #1145).
  • ui/src/state/actions.ts: run resolves with the answer, or with the failure, so the page can keep a refused field's text (F16). A save's answer is merged into the ['config'] data by key, never into another key (the ['warm-pool'] write Console: edit the warm pool's targets on a worker's Warm pool tab #1145 adds keys on its own action id), so the page holds no state of its own.
  • e2e/console/fixtures.ts, e2e/console/shell.spec.ts: NAV and NAV_GROUPS gain Settings.
  • ui/src/ds/icon.tsx, ui/src/ds/field.tsx and ui/src/ds/field.css (new): a settings icon; TextField, NumberField, Select (the existing <select> style, F17; the one select Console: Add device… from the catalog keeps one more warm #1146 adds to the confirm dialog, moved here if it lives inside the dialog, so one control has one component), Switch, JsonArea.
  • ui/src/model/settings.ts (new): rows by section, words, the field kind, lock-out keys and their confirm, the address after restart (F13), the save and restart actions.
  • ui/src/model/stale-keys.ts: config.changed marks ['config'].
  • ui/src/state/settings.ts (new): useSettings(); reads /v1/config and /v1/workers (for the Warm pool link's worker id).
  • ui/src/screens/settings/ (new): the page.
  • e2e/console/settings.spec.ts and stub answers (new).
  • docs/internal/DESIGN.md, ui/AGENTS.md: the sidebar order, the field components, the page.
  • website/src/content/docs/docs/worker/console.mdx: the Settings page.
flowchart LR
  A["app/routes *"] --> S["screens/settings *"]
  S --> ST["state/settings *"]
  S --> DS["ds/field *"]
  ST --> M["model/settings *"]
  ST --> Q["state/queries"]
  ST --> AC["state/actions"]
  Q --> SK["model/stale-keys *"]
  M --> CU["contract/console-url"]
Loading

Contract and event changes

none: the page reads #1153's answer and sends #1154's and #1155's inputs; it adds no contract shape.

Other code on the same state

Searches: readers of ['config'] (none today; this page only), writers of config.json (the daemon's config.set, #1154), readers of the Warm pool tab path (writeWorkerTab, 1 hit).

  • Another console or simlock config set saves between this page's read and its save: each save sends one key, so it changes only that key; config.changed marks ['config'] and the page reads the rows again.
  • The Warm pool tab (Console: edit the warm pool's targets on a worker's Warm pool tab #1145) edits warmPool.targets and learn at runtime; this page never edits them, only links there.
  • A restart: the shell's banner (F11) shows while the daemon is away; the page shows its last rows and reads them once on return.

Failure modes

Call Outcome What happens Limit, counted from
GET /v1/config ok the rows the console's read limit, from the read
GET /v1/config 403 or 404 (an older daemon) the page's refusal, as every page shows it —
GET /v1/config connection lost the last rows stay; the shell shows Reconnecting —
PUT /v1/config/{key} 200 success toast; the row from the answer is shown until the read after the event —
PUT /v1/config/{key} 400 error toast with the daemon's message; the field keeps the typed value —
PUT /v1/config/{key} connection lost error toast with Retry, as every action —
POST /v1/restart 202 the connection drops; the shell shows Reconnecting, then Daemon is starting, then the rows are read again —
POST /v1/restart 503 DAEMON_UPDATING error toast Couldn't restart the daemon with the daemon's message —
the daemon does not come back — the shell stays on Reconnecting; the toast said only that a restart began —

Rules in play

  • ADR 0037: the console acts through the HTTP routes, with a confirm for what is hard to undo and toasts; Save and Restart are actions in the model, sent by the runner.
  • ADR 0044: the page reads ['config'] only while shown, and config.changed marks it stale.
  • ADR 0057 §6: grouped rows, Live or On restart, lock-out confirms (four http keys; gateway.url and gateway.token are refused alone, F18), the address after the restart, warm-pool keys read-only with a link.
  • ADR 0057 §4: a secret's field starts empty and the page never shows a secret.
  • ui/AGENTS.md layers: the screen draws a view model; rules live in model/settings.ts.
  • docs/internal/DESIGN.md Inputs and Dialog: the fields and confirms above.
  • Documentation rule 9: the console page on the website describes Settings in this PR.

Tests

Seam (the reconnect and read-again after a restart are already proven by e2e/console/workers.spec.ts:1216-1240, F19; this task's browser test covers the confirm and the one POST /v1/restart): the settings model and screen markup (model: ui/src/model/actions.test.ts, ui/src/screens/leases/leases.test.tsx), the runner (ui/src/state/actions.test.tsx), the event map (ui/src/state/queries.test.ts), and the browser lane (model: e2e/console/update.spec.ts).

  • An operator opens Settings and sees the rows grouped by section: a value (the running one; a pending row adds the saved one); a secret (Set, Not set); Live, On restart, Restart pending; fileProblem shown above the rows; warmPool.targets read-only with its link; a gateway's rows.
  • An operator edits a row and saves it: boolean, number, string, enum, json; json that does not parse is refused on the page and nothing is sent; a refusal shows the daemon's message and keeps the typed value (gateway.token alone is refused this way); a secret's field starts empty; after a 200 the answer's rows replace those keys in ['config'] until the next read.
  • A lock-out key asks first and then shows where the console will be: http.port (new address); http.enabled false (console stops); http.proxyAuth (sign-in line); Keep sends nothing.
  • An operator restarts the daemon from Settings: Restart daemon shown only with a pending row; confirm, then one POST /v1/restart and the success toast; a 503 shows the daemon's message.
  • config.changed marks the settings read stale: config.changed marks ['config']; another event does not.

Done when

  • The sidebar ends with the Configure group and Settings, and docs/internal/DESIGN.md lists it in the fixed order.
  • pnpm test:console passes e2e/console/settings.spec.ts.
  • A secret row renders Set or Not set and an empty field, never a value.
  • The website's console page describes Settings, its confirms and Restart daemon.

Out of scope

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    task:draft

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions