/* Brain of Reese — Settings view module (phase 168, task 05): the * admin settings panel — "edit anything in .env and save it to the * database. The database value should override the env var. The * change should take effect on clicking 'save'" (TODO.md L3). * * The phase-76 shell-view-module contract (the theme.js / tokens.js * shape): the router (assets/router.js) lazy-imports this module on * FIRST show of #view-settings and calls mount(root) ONCE (mount-once, * hide-forever — root is the view's
, * every DOM lookup scoped to it). The initSharedHeader() call never * happens here: in the shell the shared header boots exactly once, * via the chat module (app.js) at shell boot. * * What the panel does: * * • gate — fetchIsAdmin() (the SAME cached /api/whoami promise * header.js exports, zero extra requests): admin hides * #settings-gate and reveals #settings-content; anonymous / * token-user keeps the gate (the #nav-settings link is already * hidden by header.js — the gate is the DIRECT-URL case, the * #tokens-gate pattern). No /api/admin/settings request is ever * made outside the admin branch (the router 403s them — the * phase-79 contract). * • load — GET /api/admin/settings → render the 75-row catalogue * in the SERVER's order (GROUPS order — the stable order the * E2E pins against): one per setting (the group band rows * are created per group) + the ship-rebuilt no-match row, all * through createElement + textContent (this file never builds * HTML — the XSS-safe-by-construction house rule). A failed * fetch keeps the last rendered catalogue (never a blanked panel) * and shows the house error line. * • rows — the Setting cell (the label in a .cell-clip ellipsis * — the phase-156 contract with the full text in the control's * aria-label — + the BOR_* name in * + the literal-text `restart required` .settings-flag for the * boot-wired fields (text, never color alone, B5, with the * title/aria-describedby copy explaining when it applies)), * the Value cell (the control by the server's `type`: int/float * → (step="any" for float), bool → a * true/false