Repository navigation
Description
Part of #1131.
Scope
On a worker's console, an operator can enrol a phone by picking it from the phones plugged in with no record, or by a typed platform and id, and can remove an enrolled phone that is not in use. On a gateway, or before the console knows the daemon's mode, neither is offered. The console's action table on the website names both.
If this goes wrong, an operator would notice a Remove phone on a phone in use (the daemon then refuses it), an Enrol phone… missing from one of its places, or a dialog that never lists a plugged-in phone.
Technical spec
Commit 4b39322.
Rows
- Behaviours: B6, B7, B8, B9, B10, B11
- Interfaces: I7, I8, I9
- Existing code: X3, X9, X10, X11, X12, X13, X14, X15, X16, X18
Facts
| # | Fact | Source |
|---|---|---|
| F1 | A device row keeps physical, the model, the platform name and the UDID, but the state only as a toned word |
ui/src/model/worker-page.ts:417, :444-468 |
| F2 | The model tests build actions directly and assert each mode | ui/src/model/actions.test.ts:249 |
| F3 | The page tests run the whole App against a route table in "the console acts" |
ui/src/app/actions.dom.test.tsx:66 |
| F4 | ⌘K's DOM tests sit in search.dom.test.tsx |
ui/src/app/search.dom.test.tsx |
| F5 | A read past 10 s outside startup counts as a lost connection | ui/src/data/api.ts:1; ui/src/data/live/connection.ts:205 |
| F6 | The console imports the contract for types only, beside two value files | ui/AGENTS.md Rules; .dependency-cruiser.mjs ui-* rules |
Modules touched
Searches: workerActions, useWorkerMenu, useWorkerPageMenu, ItemAction, ConfirmSpec, createConfirmer, ConsoleProvider, actionResults, menu={, LeaseActions, TIMES in ui/src; "The console mostly shows", "device add" in website/.
ui/src/model/actions.ts:deviceActions(device, mode),enrolActions(worker, mode), the ids andform.ui/src/model/worker-page.ts: the row keeps the raw statedeviceActionsreads.ui/src/model/search.ts: ⌘K reads both lists.ui/src/state/actions.ts,services.tsx,queries.ts, a hook reading['attached-phones'],workers.ts(the row, page and Fleet menus).ui/src/ds/: the Enrol dialog andcreateEnroller, with its CSS.ui/src/app/app.tsx: the service, and the host insideLiveProvider.ui/src/screens/fleet/worker-page.tsx,device-drawer.tsx: the row menu and the drawer's actions.ui/src/test/fixtures.ts: an attached-phones answer;ui/src/state/test-support.tsxand the tests that buildConsoleProvidergain theenrolservice.ui/AGENTS.md(Actions: the first worker-mode actions, the form host),docs/internal/DESIGN.md(the dialog's form).website/src/content/docs/docs/reference/console.mdx,worker/enrol-phones.mdx.
flowchart LR
screens["screens/fleet *"] --> state["state actions, workers, hook *"]
app["app/app.tsx host *"] --> state
app --> ds["ds enrol dialog (new)"]
state --> model["model actions, search, worker-page *"]
state --> data[data/api]
data --> daemon["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/v1/attached-phones, /v1/devices"]
Rules in play
- ADR 0095 §2: worker mode only; the typed id is checked only for being empty.
- ADR 0037 §3: one list per kind of item, read by the row, the drawer and ⌘K; a confirm names what it ends.
- ADR 0037 §5: an error toast shows the daemon's own message.
ui/AGENTS.mdLayers: offering rules inmodel/; ads/component takes plain props; screens import onlydsandstate.ui/AGENTS.mdReads:['attached-phones']is read only while the dialog is on screen, with its times inqueries.ts.- documentation rule 9: the console and phone pages change in this PR.
Tests
Seam: deviceActions, enrolActions and buildResults in ui/src/model/ (modelled on ui/src/model/actions.test.ts), useActions().run (on ui/src/state/actions.test.tsx), and the whole App (on ui/src/app/actions.dom.test.tsx).
- B6: Remove phone on a worker:
ready,absent,quarantinedoffered with I8's confirm;leased,reclaiming,deletednot;gatewayand unknown modes nothing; a simulator nothing. - B7: Remove phone runs: confirmed and 200 with the UDID encoded and I8's toast; cancelled sends nothing; 409
DEVICE_BUSYshows I8's failure title and the daemon's message. - B8: Enrol phone… on the worker page, the Fleet row and ⌘K in worker mode only, with
form; chosen from each, it opens the dialog and sends nothing. - B9: the dialog lists two phones (the first chosen), none (I8's empty line), an unreadable platform, a refused read (404 from an older worker), the loading line; Another id empty keeps Enrol disabled; Cancel sends nothing.
- B10: Enrol sends one
POST /v1/devices: a listed phone; Another id, Android,192.168.1.5:5555; enrolled and enrolled-again toasts; 422 and 400 show the daemon's message, and Retry sends the same body. - B11: ⌘K on a worker offers an idle phone's Remove phone; on a gateway it does not.
Done when
pnpm exec vitest run --project unit ui/src/model/actions.test.ts ui/src/model/search.test.ts ui/src/state/actions.test.tsxpasses with B6, B7, B8's offering cases and B11.pnpm exec vitest run --project ui-dom ui/src/app/actions.dom.test.tsx ui/src/app/search.dom.test.tsxpasses with B8's opening cases, B9 and B10.reference/console.mdx's action table names Enrol phone… and Remove phone, on a worker;worker/enrol-phones.mdxnames both anddevice attached.
Out of scope
- The daemon's list (device attached lists the phones plugged into a worker that have no record #1134).
- Deleting a simulator or emulator.
- Device actions on a gateway's console.
- Showing deleted devices on the worker page.
Depends on
Written by an agent.
Activity
[-]Console: enrol a phone and remove an enrolled one[/-][+]Console: enrol a phone from the plugged-in list or by id, and remove an enrolled one[/+]