Skip to content

Global Settings on one page: the repo page's layout, one save bar and errors at the field, on a shared core

ADR-0073 gave repo settings one scrolling page with section chips or an outline, one save bar, errors at the field and an in-page leave dialog, and left global Settings (/settings) as it was: "Global Settings keeps all of that layout and its per-section save". That layout is the one issue #198 introduced, which no ADR recorded. On a phone the bare /settings route was an index of category rows and a section opened with a back header; from 1024px the index redirected to the first category and a section rendered beside a slim nav. The four sections were General, Agents, Notifications and Runner, and each section with fields was its own form with its own Save at the end, built on the useSettingsForm hook. Errors showed in a banner at the top of the section, a "Nothing to save." note stood where a change bar belongs, a browser confirm guarded leaving with unsaved changes, and the section remounted after a save. Switching the Runner default to host asked through a second browser confirm. Nothing about global Settings needed a Save per section, and ADR-0073's reasons against it held here as well: two pages had drifted into two ways of editing the same kind of field.

The settings PATCH made the drift visible on the server too. The repo PATCH answers a per-key refusal as {"error", "field"}, which is how the repo page lands a server refusal at its field, while handleSettingsPatch answered {"error"} only. The repo page's one-page machinery (the field table, the field wrappers, the save bar, the section navigation, the leave guard, the scroll helpers) was written against the repo patch and the repo home frame, so a second page could only copy it.

The maintainer decided in a grilling session on 2026-10-09 (issue #85) that global Settings takes the repo page's shape, and that the machinery becomes one shared implementation. Screenshots of the built page at 390px and 1280px (top of the page, a changed state, a problem state, the host-switch dialog) are in docs/reference/global-settings-screenshots/. There was no mockup round: the spec is the repo page.

The decisions, pinned:

  • Global Settings is one page. /settings renders all four sections on one scrolling page in three groups: Runs (Agents, Runner), Setup (General), This device (Notifications). Below 1024px a sticky row of section chips sits under the page heading, marks the section in view and jumps on tap. From 1024px a sticky outline with the group labels replaces it. /settings/:section keeps working for every existing slug (general, agents, notifications, runner) and opens the page scrolled to that section; an unknown slug stays at the top. ?field=<settings key> scrolls that field into view and focuses it, as on the repo page. A chip or outline entry replaces the URL with the section's, so sections leave no history entries. The phone index of category rows and the desktop redirect to the first category are gone. The More tab's Settings row (ADR-0077) opens the page directly and keeps its hint.

  • Notifications is tagged "applies immediately". Its content is unchanged: the Install app card when visible, Web Push enable and the device list. Its rows act at once and never wait for the save bar, so, like Schedules, Secrets and Imports on the repo page (ADR-0073), its heading carries the tag and the section is set apart in the group This device. Device-local state is not a setting that Save could commit.

  • One save bar for the whole page. Fields wait for Save. A bar appears while at least one field differs from the saved settings, shows the count of changed fields and the names of the changed sections as links, and offers Discard and Save. Save sends one PATCH /api/v1/settings carrying exactly the changed keys, applies the response at once and confirms in a toast ("Saved N changes"). Discard restores the saved values and offers Undo for a few seconds in the toast. A changed field is marked at its label, and a section with changes on its chip and in the outline. "Nothing to save.", the per-section Save buttons and the remount after a save are gone. Settings have no SSE event, so unlike the repo page there is no resync with a live change: the saved snapshot changes only through this page's own save.

  • Errors land at the field. The browser checks the whole-number fields before sending anything: each key's floor, the same as the server's (1 for most capacity fields, 5 seconds for the reaper and scheduler ticks, 0 for dialog auto-dismiss) and 0..365 for transcript retention (ADR-0079), the only key with a ceiling. A problem shows under its field, the save bar says how many problems and in which sections, and Save scrolls to the first problem and focuses it. A server refusal that names a field lands at that field; one that names none, and a network error, show in the save bar. Edits are kept on every failure.

  • The settings PATCH names the field. Every refusal handleSettingsPatch produces for one key (not an integer, below its floor, above its ceiling, not a string, an unknown model or effort, a dev image ref that does not resolve, a bad memory grammar, a limit below its floor) answers {"error": "<message>", "field": "<settings key>"} through writeFieldError, the helper the repo PATCH already uses. A refusal not attributable to one key (bad JSON, a read-only key sent) keeps the plain {"error"} shape. The page's promise that errors land at the field would otherwise hold for the browser's checks and not for the server's.

  • A leave dialog and a host-switch dialog, both in the page. Leaving /settings/… with pending changes opens an in-page dialog (Keep editing, Discard, Save and leave), a bottom sheet below 1024px and centered from 1024px; Save and leave stays on the page if the save fails. A tab close or reload keeps the browser's own prompt. When the pending patch switches runner_default to host, Save opens the same kind of dialog with the message the browser confirm had, naming how many repos inherit the default, and Cancel / Switch to host; Cancel sends nothing and keeps every edit. The switch never asks in any other direction. No window.confirm remains under /settings: ADR-0073 left no browser confirm in the repo list, the repo home or repo settings, and this extends the rule to global Settings. The guard against an accidental unsandboxed default stays; only where it asks changed.

  • The Agents section mirrors the repo page's, plus a Lander group. Four groups: Runs you start (agent, model, effort, remote control, dialog auto-dismiss), AFK runs (the AFK agent, model, effort and remote control, the provider's bool option bag, the seed prompt with its Customize action and done-signal hint), Lander (lander model, lander effort) and Capacity (max instances, AFK budget, reaper tick, scheduler tick, sweep interval). Where the fields match, the words match, so the same field is called the same on both pages.

  • Inheritance on this page is derived in the browser, one hop. The AFK and lander overrides use the repo page's vocabulary: an inherited field says inherited at its label and shows what it resolves to as the first pick ("Inherited · "); a field set here says set here, shows "Default: " and a Reset that returns it to inherited. Reset counts as a change and is saved as "" for the text keys and null for the AFK remote bool (a three-way control: inherit, on, off). The resolved value comes from the drafted base field on the same page, live as the draft changes. This does not contradict ADR-0073's rejection of browser-side resolution. That rule exists because the repo's values come from multi-layer chains (ADR-0021, ADR-0030, ADR-0045 and ADR-0071), where a second derivation in the browser drifts the first time the spawn path changes, so the server answers with the spawn path's own resolvers through POST /repos/{id}/inherited, drafts included. Here the override inherits the spawn default on the very same page: one hop, from a field the operator is looking at, with no chain behind it to drift from, and the value has to follow the draft before anything is saved. There is no POST /settings/inherited. The repo page keeps its server-resolved layer unchanged.

  • The Runner never folds. The Runner pick keeps the unsandboxed-host warning and the "N repos inherit this default." line; Dev image keeps the deployed-image fallback in its hint; Container limits stay. They are shown whatever runner_default is, and the hint says they apply to container runs, including repos pinned to container. ADR-0073 folds them on a repo whose effective Runner is host, where they cannot matter. The global values feed every repo pinned to container even while the default is host, so folding them would hide values those repos are reading.

  • General ends with the status cards. Git author and Transcripts come first, then the read-only Credential gateway and SSH bastion status cards at the end of the section, outside the saved fields. They do not become a Status section.

  • Credentials and Tokens stay separate pages. They are lists of objects with their own flows (login, rotation, the one-time token reveal), not fields that wait for Save, and five places deep-link to them: More, the rail, Add repository, a readiness Fix and the New-run composer. ADR-0077's route map is unchanged and needs no amendment.

  • One shared core, not a copy. The repo page's one-page machinery is extracted into web/src/components/settings/ and made generic over a patch type and its key type: the field table vocabulary and the field wrappers (fields.ts, Field.tsx), the form context both pages implement (form.tsx), the save bar, the section navigation, the leave guard and the scrolling helpers (SaveBar.tsx, SectionNav.tsx, LeaveGuard.tsx, scrolling.ts, sectionScroll.ts, SettingsSection.tsx). SettingsCategory carries the group label and the applies immediately flag, so one category type drives both pages. Each page keeps what is its own on top: the repo page its inheritance layer (server-resolved values, the effective Runner, the catalog) and its resync with the repo home frame; the global page its field table (one entry per PATCHable key of Settings, never afk_prompt_default or dev_image_fallback) and a form store without resync. The styles are shared too: web/src/styles/repo-settings.css is scoped to .settings-page, not to the repo home. A sibling copy would have been about a thousand lines that drift. SettingsLayout, useSettingsForm and their tests are deleted with their subject.

  • One change. The maintainer wants the extraction and the page reviewed together. The extraction has no visible half-state, so splitting it would only add a pull request.

  • No new dependency, no new design token, no new font (ADR-0073's rule). No dark-mode or token change.

Status

Accepted 2026-10-09. Resolves issue #85, the GitHub issue.

  • ADR-0073: amends "Global Settings keeps all of that layout and its per-section save". Global Settings now has the repo page's layout and one save bar. ADR-0073's rules for repo settings are unchanged, and so is its rejection of browser-side resolution of the repo's inherited values (see the inheritance decision above for why the one-hop override on this page is not that).
  • Issue #198's settings layout, which no ADR recorded: retired entirely. With ADR-0073 having retired it for repo settings, the category index on phones, the master-detail split from 1024px, the per-section Save, the section-level error banner and the browser-confirm leave guard no longer exist anywhere. The section slugs stay.
  • ADR-0077: unchanged. The More tab's Settings row and the redirect of /more to /settings from 1024px now land on the one page.
  • ADR-0079: unchanged. Transcript retention stays in Settings → General → Transcripts and is checked at its field; the 0..365 range is enforced as before, now with the field named in the refusal.

Considered options

  • Keep global Settings as it was and only add the field name to refusals. Rejected by the maintainer: two ways of editing the same kind of field is a cost on every future settings key, and the per-section Save is the interaction ADR-0073 already found wrong.
  • Copy the repo page's machinery for global Settings. Rejected: about a thousand lines of field table, wrappers, save bar and navigation that drift from the first change to either. One generic core is one implementation to fix.
  • Resolve the AFK and lander overrides on the server, with a POST /settings/inherited. Rejected: the override inherits a field on the same page and the value must follow the draft live. A round trip per keystroke, or a draft-carrying endpoint, adds a second resolver for a one-hop relation with no chain behind it.
  • Fold Credentials and Tokens into Settings. Rejected: they are object lists with flows of their own, not fields that wait for Save, and five places link to them.
  • Make the status cards a Status section. Rejected: a section of two read-only cards that hold no field is more outline than content, and they describe how lab reaches its forge and hosts, which is setup.
  • Fold the Runner's Dev image and Container limits while the default is host. Rejected: repos pinned to container still read those global values.
  • Keep a browser confirm for the host switch. Rejected: ADR-0073 left no browser confirm, and an in-page dialog can carry the same message. The guard itself stays.
  • Save the Notifications section with the page. Rejected: its rows are device-local actions (enable, send test, remove, install), each with its own call, so folding them would invent a transaction.

Consequences

  • /settings is one page; bookmarks to /settings/:section still work and open it scrolled to the section. The bare /settings no longer shows an index on a phone or redirects on a desktop.
  • A change to a settings key's label, floor or normalisation is made once, in the field table, and shows up in the save bar, the problem count and the changed marks without further wiring.
  • The Runner section always shows Dev image and Container limits, so with runner_default at host the page shows fields the repo page would fold. This is deliberate and their hint says so.
  • A settings refusal for a key can be shown at its field. The web client's ApiError.field already carries it for every endpoint, so no client contract changed; a client that ignores field still has error.
  • The AFK and lander "Inherited · " and "Default: " lines are computed in the browser from the drafted base field. If the spawn path ever gains another layer between the spawn default and the AFK or lander value, that derivation has to move behind the server like the repo's, and this decision is the one to revisit.
  • Leaving the page, a failed save and the host switch are in-page dialogs: they can be tested without stubbing window.confirm. grep -rn "window.confirm" web/src/routes/settings web/src/components/settings finds nothing, and keeps finding nothing.
  • The repo page runs on the extracted core with its behaviour unchanged; its suites keep their assertions. The global page is covered by web/src/routes/settings/index.test.tsx and web/src/routes/settings/sections/*.test.tsx on the harness in web/src/routes/settings/harness.tsx, and the core by its own tests beside it in web/src/components/settings/.
  • The settings handler tests assert the field on every per-key refusal and the plain shape on bad JSON and a read-only key.