Repository navigation
Description
Part of #1131.
Scope
On a worker's console, an operator can delete an idle simulator or emulator: the Devices tab's ⋯ menu, the device's drawer and ⌘K offer Delete device on a virtual device that is ready or shutdown, behind a confirm. It calls DELETE /v1/devices/{id} with the device's dev_… id, which #1134 makes delete it. On a gateway, or before the mode is known, it is not offered.
In short
Delete device asks first, then the device goes, and its row reads deleted once the daemon's device.deleted event arrives, as every deleted device's row does today. A device that an agent leased in the meantime is refused by the daemon, and the error toast says so in the daemon's words.
flowchart LR
R["Simulator row ⋯, drawer, ⌘K (Delete device, new)"] --> C["Confirm: Delete Pixel 9 (Android 16)?"]
C --> D["DELETE /v1/devices/dev_7f3a"]
D --> T[Toast; the row reads deleted on device.deleted]
D --> E[Error toast: dev_7f3a is leased: release it first]
Words, exactly (<model> and <version> are the device's, <os> is iOS or Android, <id> its dev_… id):
| Where | Text |
|---|---|
| Menu label | Delete device (danger, last after a line) |
| Confirm title | Delete <model> (<os> <version>)? |
| Confirm body | It is shut down and removed from disk. If the warm pool keeps this kind, it boots a new one. |
| Buttons | Keep, Delete device (busy: Deleting…) |
| Success toast | Deleted <model> (<os> <version>) |
| Error toast title | Couldn't delete <model> (<os> <version>), with the daemon's message below, e.g. <id> is leased: release it first |
If this goes wrong, an operator would notice Delete device on a device the daemon then refuses, or no Delete device on an idle one.
Technical spec
Facts
Commit ce8fea8. #1133 and #1134 add what this task reads; their rows are the feature's Shared values.
| # | Fact | Source |
|---|---|---|
| F1 | Action ids are a closed union; a danger action carries a confirm and a failure title | ui/src/model/actions.ts:12-51 |
| F2 | useActions().run confirms, writes, toasts the outcome, and shows the ApiError's message under the failure title |
ui/src/state/actions.ts:68-123; ui/src/data/api.ts:15-25 |
| F3 | The status device shape carries id (dev_… for a virtual device), spec (model, OS version), state, physical |
src/contract/schemas.ts:214-231; src/core/registry.ts:248 |
| F4 | Virtual states are provisioning, ready, leased, reclaiming, quarantined, shutdown, deleted |
src/contract/schemas.ts:17-26 |
| F5 | Every device. event marks ['workers'] stale |
ui/src/model/stale-keys.ts:36-37 |
| F6 | The model and state tests sit in actions.test.ts and actions.test.tsx |
ui/src/model/actions.test.ts:1-30; ui/src/state/actions.test.tsx:1-40 |
| F7 | The warm pool keeps a device of each configured target and learned kind, and boots one when a kept kind has none | src/core/warm-pool/converger.ts:246, :454 |
Modules touched
Searches: deviceActions, ItemAction["id"], "remove-phone" in ui/src (#1133 adds them), and "Delete device", "simulator" in website/src/content/docs/docs/worker/console.mdx.
ui/src/model/actions.ts:deviceActionsgains Delete device for a virtual device; the iddelete-device.ui/src/model/actions.test.ts,ui/src/state/actions.test.tsx.website/.../worker/console.mdx: Delete device.e2e/console/actions.spec.ts.
The row menu, the drawer and ⌘K already read deviceActions, and its input already carries the model, platform name and OS version (#1133's Modules touched), so no screen, state or other model file changes.
flowchart LR
surfaces[Row menu, drawer, ⌘K] --> list["model/actions.ts deviceActions *"]
list --> run[state/actions.ts run]
run --> route["DELETE /v1/devices/dev_… (#1134)"]
sequenceDiagram
participant O as Operator
participant C as Console
participant D as Worker daemon
O->>C: Delete device on dev_7f3a, confirm
C->>D: DELETE /v1/devices/dev_7f3a
alt 200
D-->>C: { id, driverDeviceId, physical: false }
D-->>C: events device.shutdown, device.deleted
C-->>O: toast Deleted Pixel 9 (Android 16)
else 409 DEVICE_BUSY
C-->>O: error toast with dev_7f3a is leased: release it first, Retry
else 404 from an older daemon
C-->>O: error toast with dev_7f3a is not an enrolled device
end
Contract and event changes
none. #1134 changes the route's answer; this task reads none of it.
Other code on the same state
Searches: inFlight (1 writer) and itemKey device/ (#1133's key).
| Component | Both act | Who wins |
|---|---|---|
| #1133's Remove phone | same list, same itemKey form; a device is a phone or not, so never both |
— |
| An agent's lease | the daemon's claim decides (#1134) | the first; the console shows the refusal |
| The warm pool | may boot a new device of the kind after the delete | both happen; the confirm says so |
Failure modes
| Call | Outcome | What happens | Limit, counted from |
|---|---|---|---|
DELETE /v1/devices/{dev id} |
200 | Deleted <model> (<os> <version>) |
200 s from the send (feature Shared values) |
| same | 409 DEVICE_BUSY |
error toast with the daemon's message, Retry | same |
| same | 404 (an older daemon) | error toast with the daemon's message | same |
| same | 401 | no toast; the session signs out | same |
| same | no answer | The daemon did not answer.; the daemon goes on, and the row reads deleted when its event arrives |
same |
The console writes no state.
Rules in play
- ADR 0055 §3: "a virtual device
readyorshutdown" in worker mode. - ADR 0037 §3: "Dangerous actions sit last in a menu, after a line, in the error colour."
- ADR 0037 §5: "An error toast shows the daemon's own
message". - documentation rule 9:
worker/console.mdxnames Delete device.
Tests
Seam: deviceActions in ui/src/model/actions.ts (modelled on ui/src/model/actions.test.ts) and useActions().run (modelled on ui/src/state/actions.test.tsx).
- An operator opens a simulator's or emulator's menu and sees Delete device only when it is idle, on a worker: mode
workerwithreadyandshutdown(offered, danger, last, confirm as worded);leased,reclaiming,provisioning,quarantined,deleted(not offered); modegatewayand unknown (nothing); a phone (no Delete device). - An operator runs Delete device and sees a confirm naming the model, then one
DELETE /v1/devices/dev_…and a toast: confirmed and 200 (path with thedev_…id,timeoutMs200000,Deleted Pixel 9 (Android 16)); cancelled (no request); 409DEVICE_BUSY(Couldn't delete Pixel 9 (Android 16)with the daemon's message).
Done when
pnpm exec vitest run --project unit ui/src/model/actions.test.ts ui/src/state/actions.test.tsxpasses with the Tests lines above.pnpm test:console --project=chromium e2e/console/actions.spec.tspasses with a new test: on a worker, Delete device on an idle emulator asks, sends oneDELETE /v1/devices/dev_…, and shows the toast.website/.../worker/console.mdxnames Delete device and when it is offered.
Out of scope
- The daemon's delete (device attached lists the phones plugged into a worker that have no record #1134).
- Deleting a quarantined simulator or emulator.
- Device actions on a gateway's console.
Depends on
- Console: enrol a phone from the plugged-in list or by id, and remove an enrolled one #1133
- device attached lists the phones plugged into a worker that have no record #1134
Written by an agent.
Activity
V3RON commentedon Nov 27, 2026
Closed as not planned. #1131 now covers phones only. Every simulator and emulator serves one lease, so an idle one is either remade by the warm pool within a minute or deleted by the idle rules within the hour. Changing what the pool keeps is #1137's. See ADR 0095 (PR #1903).
Written by an agent.