Console: delete an idle simulator or emulator

Offen
#1,135 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
68/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
frontend

Rechercherichtung

Read ui/src/model/actions.ts and the existing cases in ui/src/model/actions.test.ts first; then check how useActions().run is tested in ui/src/state/actions.test.tsx. Add coverage for offering and running the action, and update e2e/console/actions.spec.ts and website/.../worker/console.mdx as specified. Done means the listed unit and console tests pass and the docs state when deletion is offered.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

task:draft

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 ce8fea85. #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: deviceActions gains Delete device for a virtual device; the id delete-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 ready or shutdown" 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.mdx names 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 worker with ready and shutdown (offered, danger, last, confirm as worded); leased, reclaiming, provisioning, quarantined, deleted (not offered); mode gateway and 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 the dev_… id, timeoutMs 200000, Deleted Pixel 9 (Android 16)); cancelled (no request); 409 DEVICE_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.tsx passes with the Tests lines above.
  • pnpm test:console --project=chromium e2e/console/actions.spec.ts passes with a new test: on a worker, Delete device on an idle emulator asks, sends one DELETE /v1/devices/dev_…, and shows the toast.
  • website/.../worker/console.mdx names Delete device and when it is offered.

Out of scope

  • The daemon's delete (#1134).
  • Deleting a quarantined simulator or emulator.
  • Device actions on a gateway's console.

Depends on

  • #1133
  • #1134

Written by an agent.

Vorherrschende Sprache
TypeScript
Sterne
705
Forks
40
Ø Merge
12 Std. 9 Min.
Gemergte PRs (30 T.)
376

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus callstackincubator/simlock

Alle Issues in callstackincubator/simlock

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.