Console: a Settings page that edits settings and restarts the daemon
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start with ui/src/app/routes.ts and the existing action, state, model, and screen patterns named in the spec; then review ui/src/model/actions.test.ts and ui/src/screens/leases/leases.test.tsx. The work spans new settings UI, form components, actions, state handling, end-to-end coverage, and documentation, and depends on the config and restart endpoints from related issues. Done means the specified settings flows and confirms work, with the relevant unit and e2e tests passing.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
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 bcedd2fa.
| # | 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('/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:NavGroupgainsConfigure; the/settingsroute in it, last (F15).ui/src/model/actions.ts: idssave-settingandrestart-daemon(F16;PUTcomes from #1145).ui/src/state/actions.ts:runresolves 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 #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:NAVandNAV_GROUPSgain Settings.ui/src/ds/icon.tsx,ui/src/ds/field.tsxandui/src/ds/field.css(new): a settings icon;TextField,NumberField,Select(the existing<select>style, F17; the one select #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.changedmarks['config'].ui/src/state/settings.ts(new):useSettings(); reads/v1/configand/v1/workers(for the Warm pool link's worker id).ui/src/screens/settings/(new): the page.e2e/console/settings.spec.tsand 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"]
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 setsaves between this page's read and its save: each save sends one key, so it changes only that key;config.changedmarks['config']and the page reads the rows again. - The Warm pool tab (#1145) edits
warmPool.targetsandlearnat 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, andconfig.changedmarks it stale. - ADR 0057 §6: grouped rows, Live or On restart, lock-out confirms (four
httpkeys;gateway.urlandgateway.tokenare 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.mdlayers: the screen draws a view model; rules live inmodel/settings.ts.docs/internal/DESIGN.mdInputs 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;
fileProblemshown above the rows;warmPool.targetsread-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.tokenalone 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.enabledfalse (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/restartand the success toast; a 503 shows the daemon's message. config.changedmarks the settings read stale:config.changedmarks['config']; another event does not.
Done when
- The sidebar ends with the Configure group and Settings, and
docs/internal/DESIGN.mdlists it in the fixed order. pnpm test:consolepassese2e/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
- A worker's settings through the gateway's console.
- Editing
warmPool.targetsandwarmPool.learn(the Warm pool tab, #1145). - Undo of a save.
Depends on
- #1155
- #1145
- #1135
- #1146 (the same
ItemActionid list,run, and a select control)
Written by an agent.
- Ngôn ngữ chính
- TypeScript
- Star
- 705
- Fork
- 40
- Merge trung bình
- 12 giờ 9 phút
- Pull request đã merge (30 ngày)
- 376
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của callstackincubator/simlock
-
request:new
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
callstackincubator/simlock#1806 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug:new
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
callstackincubator/simlock#1780 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
task:draft
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
callstackincubator/simlock#1441 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug:new
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
callstackincubator/simlock#1805 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug:new
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
callstackincubator/simlock#1804 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của callstackincubator/simlock
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Update project links after the repository renamesCó thể đã có người làm @JonathanTSilva đã nhận hôm nay. Đang mởai-generated priority: p2 size: xs type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
JonathanTSilva/jts-website#119 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
promplate/code-review#158 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Docs] CONTRIBUTING points the Backend Remake milestone at a branch that does not existCó thể đã có người làm @franpts2 đã nhận hôm nay. Đang mởdocs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 3 ngày