Skip to content

Console: enrol and remove phones, and delete idle simulators and emulators #1131

Done
2 of 2 issues completed

Description

@leonardoxr

Request: #1130

Problem

An operator who runs a worker has to leave the console for a terminal to manage its phones. The console can release leases, cancel requests, and drain, undrain, update or remove workers, but on a device it can only show. To enrol a phone, the operator opens a terminal, finds the phone's id with xcrun devicectl list devices or adb devices -l, and runs simlock device add. To unenrol one, they run simlock device remove.

Who it is for

A developer or an operator who runs one worker for their own coding agents and keeps its console open. They plug in a phone, or want one out of the pool, and want to do it where they see it.

Outcome

From the console of a worker, the operator can:

  • see the phones plugged into the worker that Simlock has no record of, and enrol one with a click, or enrol one by a typed id;
  • remove an enrolled phone that is not in use, behind a confirm.

The CLI and the HTTP API can list those phones too: simlock device attached and GET /v1/attached-phones.

How it works for the user

flowchart TD
  A[Worker page, Fleet row or ⌘K] -->|Enrol phone…| B[Dialog reads GET /v1/attached-phones]
  B --> C{Pick}
  C -->|a listed phone| E[POST /v1/devices]
  C -->|Another id: platform and typed id| E
  E -->|enrolled| F[Toast: Enrolled iPhone 15 iOS 18.5; the phone appears]
  E -->|refused| G[Error toast with the daemon's reason, e.g. locked]
  H[A phone's row ⋯, drawer or ⌘K] -->|Remove phone| I[Confirm naming the phone]
  I --> J["DELETE /v1/devices/{udid}"]
  J -->|done| K[Toast; the row leaves the Devices tab]
  J -->|leased| L[Error toast: the phone is leased: release it first]
Loading

On a gateway, and while the console does not know the daemon's mode, none of this is offered: a gateway refuses device changes, which belong to the worker the phone is plugged into.

Before, in a terminal on the worker:

$ simlock device attached
Unknown device command: attached

After:

$ simlock device attached
ios      00008110-001A2B3C4D5E
android  R5CT1234ABC
$ simlock device attached --json
{"phones":[{"platform":"ios","id":"00008110-001A2B3C4D5E"},{"platform":"android","id":"R5CT1234ABC"}],"unreadable":[]}
$ simlock device attached        # nothing new plugged in, Android tools missing their list
No phone without a record is plugged in.
android: could not list phones: could not read the device list (adb devices -l)

Examples

Which plugged-in phones device attached lists:

Phone plugged in Today After
an iPhone on USB with no record no command listed
an Android phone on USB with no record no command listed
a network phone adb lists, with android.networkDevices on no command listed, by its address, e.g. 192.168.1.5:5555
a phone with a live record (ready, leased, absent, quarantined) no command not listed
a phone removed while still plugged in (its record is deleted) no command listed
a network phone enrolled by address, also plugged in by USB (its serial is the record's hardware serial) no command not listed
a phone enrolled by USB, also connected over Wi-Fi with android.networkDevices on no command listed by its address; Enrol is refused this phone (hardware serial …) is enrolled as …; remove that record first, shown in the error toast
a simulator or an emulator no command not listed
a platform whose list fails or takes over 8 s no command under unreadable, with the reason
on a gateway no command UNSUPPORTED_IN_GATEWAY_MODE

The id typed under Another id in Enrol phone…:

Input Today After
00008110-001A2B3C4D5E no form sent
192.168.1.5:5555 (Android) no form sent
empty no form Enrol stays disabled
R5CT 1234 (a space) no form sent; 400 BAD_REQUEST id: must not contain whitespace or control characters in the error toast
-s no form sent; 400 BAD_REQUEST id: must not start with - in the error toast

What could go wrong

  • A phone shows in the list but is locked or untrusted; Enrol is refused and the toast says why. Likely now and then.
  • The operator removes a phone an agent leases a moment later; the daemon refuses and the toast says it is leased. Rare.
  • The phone list is slow on a busy Mac and a platform shows as unreadable; the operator types the id instead. Now and then.

Words used

  • enrol: record a plugged-in phone so Simlock can lease it, e.g. simlock device add --platform ios 00008110-001A2B3C4D5E.
  • phone id: the id the phone's own tool reports: the UDID from xcrun devicectl list devices, the serial from adb devices -l, or a network phone's address.
  • record: what Simlock keeps of an enrolled phone; a removed phone's record reads deleted for an hour, then goes.
  • live record: a record in any state but deleted.
  • worker mode: the daemon runs devices itself, as opposed to a gateway, which routes to workers.
  • auto-enroll: devices.autoEnroll, the worker enrols plugged-in phones by itself; a removed phone stays out until it is unplugged and plugged in again.

Non-goals

Completion conditions

  • On a worker's console, Enrol phone… lists a plugged-in phone with no record, enrolling it lists it among the devices, and Remove phone unenrols it (its row then leaves the Devices tab).
  • On a worker's console, Enrol phone… enrols a phone by a typed platform and id.
  • simlock device attached on a worker prints the phones plugged in with no record; GET /v1/attached-phones answers the same.
  • A gateway's console offers none of these actions, and a gateway refuses device attached.
  • The website's console, phone and reference pages describe the actions and the command.

Open questions

none

Decisions

  • ADR 0095 — The console offers phone actions on a worker, and a worker lists the phones it could enrol (PR docs(adr): 0095 the console offers phone actions on a worker, and a worker lists the phones it could enrol (#1131) #1903): phones only; the list is its own operation and route, apart from /v1/devices; the actions are offered in worker mode only.
  • ADR 0037 — The console acts through the HTTP routes: one action list per kind of item, a confirm for what cannot be undone, the daemon's own message in an error toast.
  • ADR 0022 — A physical device is a second device type: device remove unenrols a phone from ready, absent or quarantined.
  • ADR 0073 — A worker may enrol the phones plugged into it: a removed phone stays out until unplugged.
  • ADR 0080 — An Android worker may enrol network phones: the id is the address.
  • ADR 0050 — device remove stays for phones only; this feature keeps that.
  • Decided in the session: Console: enrol and remove phones, and delete idle simulators and emulators #1131 covers phones only, and device attached lists the phones plugged into a worker that have no record #1134 and Console: delete an idle simulator or emulator #1135's virtual delete is dropped, because every virtual device now serves one lease and an idle one is either remade by the pool or deleted within the hour.
  • Decided in the session: Enrol phone… lists the phones plugged in with no live record from a new route of its own, GET /v1/attached-phones, never from /v1/devices, which lists Simlock's own records; a typed id stays for any phone the list misses.
  • Decided in the session: the CLI gains simlock device attached [--json].
  • Decided in the session: the list holds ids only, no model, because a model needs the phone's slow inspection, which enrolment does anyway.
  • Decided in the session: each platform's list waits at most 8 s and a slower or failed one is reported under unreadable, because the console treats a read past its 10 s limit as a lost connection.
  • Decided in the session: a phone removed while still plugged in is listed, so the operator can enrol it again from the console, while auto-enroll keeps it out.
  • Decided in the session: the dialog reads the list while it is open, again every 5 s, since plugging a phone in sends no event.
  • Decided in the session: the console waits 120 s for Enrol, because the daemon's inspection runs several phone reads of up to 30 s each; Remove keeps the 10 s default, as it touches no phone.
  • Decided in the session: Remove phone is a plain confirm, not a typed name, since a phone can be enrolled again.
  • Decided in the session (maintainer): a removed phone's row leaves the Devices tab once its event arrives, as every deleted device's does today.
  • Decided in the session: Enrol phone… sits on the worker page's actions, the Fleet table's worker row and ⌘K; not on Inbox items.
  • device.attached reads the whole attached-phone list whether devices.autoEnroll is on or off: ADR 0095 narrows ADR 0073 §5, which allowed that read under auto-enroll only (decided in delivery, pending the maintainer).
  • Neither phone action is on the Inbox, quarantined and absent phones included: ADR 0095 narrows ADR 0037 §3 (decided in delivery, pending the maintainer).
  • An older worker's plain-text 404 for the list shows the console's own fallback for that status, not a daemon message (decided in delivery, pending the maintainer).
  • Decided in the session: the comment on device attached lists the phones plugged into a worker that have no record #1134 about baselines no longer applies, since the virtual delete is dropped.

Behaviours

Id Behaviour (invoker, action, what it sees) Seam Cases Task
B1 An admin lists the phones plugged into a worker and sees each one with no live record, by platform and id Dispatcher.dispatch("device.attached") over a real core and FakeDriver an iOS and an Android phone with no record (listed, sorted by platform then id); a phone with a ready, leased, absent or quarantined record (left out); a phone whose record is deleted (listed); a USB serial equal to a live record's hardware serial (left out); nothing plugged in (phones: []) #1134
B2 An admin lists phones while a platform cannot be read and sees the other platform's phones and the reason Dispatcher.dispatch("device.attached") one driver's list throws (unreadable with its message, the other listed); one driver's list answers after 8 s (unreadable, did not answer within 8 seconds); no driver for a platform (neither listed nor unreadable) #1134
B3 A caller asks a gateway for attached phones and is refused GatewayDispatcher dispatch, modelled on its device.remove refusal test device.attached answers UNSUPPORTED_IN_GATEWAY_MODE with I6's message #1134
B4 An admin reads GET /v1/attached-phones and sees the operation's answer; an agent token is refused the HTTP app, modelled on the /v1/devices route tests admin token: 200 with I1's answer; agent token: 403; a gateway: 501 #1134
B5 A user runs simlock device attached and reads which phones they can enrol runCli in src/cli/index-device-config.test.ts; the socket case in src/daemon/server-requests.test.ts two phones (one line each, I4); none (I4's empty line); an unreadable platform (its line after the phones); --json (I1's answer); against a real daemon socket (answered, not Unknown request type) #1134
B6 An operator opens a device's menu on a worker and sees Remove phone only on an enrolled phone not in use deviceActions (new) in ui/src/model/actions.ts mode worker with a phone ready, absent, quarantined (offered, danger, I8's confirm); leased, reclaiming, deleted (not offered); mode gateway and unknown (nothing); a simulator (nothing) #1133
B7 An operator runs Remove phone and sees a confirm naming the phone, then one DELETE /v1/devices/{udid} and a toast useActions().run in ui/src/state/actions.ts confirmed and 200 (the UDID encoded in the path, I8's success toast); cancelled (no request); 409 DEVICE_BUSY (I8's failure title, the daemon's message) #1133
B8 An operator sees Enrol phone… on a worker's page, its Fleet row and ⌘K only in worker mode enrolActions (new) in ui/src/model/actions.ts, and buildResults in ui/src/model/search.ts mode worker (offered on all three, not danger, with form: "enrol-phone"); gateway and unknown (on none); chosen from the header, the Fleet row and ⌘K, it opens the Enrol dialog and sends nothing (the DOM test of B9) #1133
B9 An operator opens Enrol phone… and sees the phones the worker lists, or a way to type one a DOM test through ui/src/test/console.tsx two phones listed (the first chosen); none (I8's empty line, Another id chosen); an unreadable platform (its line); the list read refused, e.g. 404 from an older worker (I7's error line with the daemon's message, Another id chosen and still sends); while the read is out (I8's loading line); Another id with the id empty (Enrol disabled); Cancel (no request) #1133
B10 An operator sends Enrol phone… and sees one POST /v1/devices with the chosen phone, then a toast the DOM test of B9 a listed phone (its platform and id); Another id, Android, 192.168.1.5:5555 (as typed); enrolled (I8's toast); enrolled again (… again); 422 DEVICE_NOT_ENROLLABLE and 400 BAD_REQUEST (I8's failure title with the daemon's message; Retry sends the same body) #1133
B11 An operator searches on a worker and finds a phone's Remove phone buildResults in ui/src/model/search.ts worker mode with an idle phone (offered); gateway mode (not) #1133

Stored state

none

Interfaces

Id What Shape and bounds Errors and limits Where Task Used by
I1 Operation device.attached admin, effect read; input {} (strict); output { phones: { platform: "ios" | "android", id: string (1 to 200) }[] (at most 256), unreadable: { platform, message: string (1 to 200) }[] }; phones sorted by platform then id. A phone is left out when a live physical record has it as its driverDeviceId or its hardwareSerial. Bumps the protocol by one UNSUPPORTED_IN_GATEWAY_MODE on a gateway (I6); a platform's failure is an unreadable entry, never an error src/contract/operations-fleet.ts, operations.ts, protocol.ts #1134 #1133
I2 Route GET /v1/attached-phones admin; no body; 200 with I1's output; attached-phones joins CORE_ROUTE_SEGMENTS 403 for a non-admin; 501 UNSUPPORTED_IN_GATEWAY_MODE src/http/route-declarations.ts, src/http/app.ts #1134 #1133
I3 Core PhysicalEnrollment.attached() lists every platform that has a driver at once, each through driver.listAttachedPhysical(), and drops ids with a live record, reading the records under the lock after the lists each platform waits at most 8 s from the call; past that, or on a throw, its entry under unreadable holds the message, cut to 200 characters: did not answer within 8 seconds, or the driver's own message src/core/physical-enrollment.ts; called by the dispatcher's device.attached handler #1134 —
I4 CLI simlock device attached [--json] text: one line per phone, the platform padded to 9 characters, then the id; with none, No phone without a record is plugged in.; then one line per unreadable platform, <platform>: could not list phones: <message>; --json prints I1's answer; exit 0 a gateway's refusal is the usual one JSON error line on stderr src/cli/commands/device.ts, the usage lines and src/cli/index.ts help #1134 —
I5 Client method listAttachedPhones() on SimlockAdminClient; answers I1's output as I1 src/simlock-client/client-api.ts, client-impl.ts, types.ts #1134 —
I6 The gateway's refusal of device.attached message: device.attached lists the phones plugged into one machine; run it on the worker they are plugged into — src/gateway/dispatcher.ts #1134 —
I7 Console read of the list query key ['attached-phones'] on GET /v1/attached-phones, read only while the Enrol dialog is open, polled every 5 s then a refusal shows as the dialog's error line, the daemon's message ui/src/state/queries.ts, a hook in ui/src/state/ #1133 —
I8 Console action words and limits ids remove-phone, enrol-phone join ItemAction["id"]; Enrol phone… carries form: "enrol-phone" (I9) and no body. Remove phone: title Remove <model> (<udid>)?, body Simlock stops leasing it and forgets its app list. Nothing on the phone changes. To use it again, enrol it again; with auto-enroll on, unplug it and plug it back in., buttons Keep, Remove phone (busy Removing…), success Removed <model>, failure Couldn't remove <model>. Enrol: title Enrol a phone, body Pick a phone plugged into this worker, or type its id., loading Looking for phones…, empty No phone without a record is plugged in., unreadable <iOS | Android> phones could not be listed: <message>, last choice Another id with Platform (iOS, Android) and Phone id, hint The UDID from xcrun devicectl list devices, the serial from adb devices -l, or a network phone's address., buttons Cancel, Enrol (busy Enrolling…), success Enrolled <model> (<iOS | Android> <version>) or … again, description <n> user app recorded. / <n> user apps recorded., failure Couldn't enrol <id> Enrol waits 120 s for POST /v1/devices; Remove the 10 s default; past either, The daemon did not answer. and the daemon goes on ui/src/model/actions.ts #1133 —
I9 Console form host ItemAction gains optional form: "enrol-phone". useActions().run given such an action calls a new console service enrol(action, submit) instead of confirm; submit({ platform, id }) is the write with that body, and the dialog stays open showing Enrolling… until it settles, as the confirm's work does. The dialog is a ds/ component with plain props (the choices, the lines of I8, the typed values), created with createEnroller() beside createConfirmer() and passed to ConsoleProvider by app/app.tsx; its host sits inside LiveProvider, in app/, and feeds it from a state/ hook that reads I7 only while it is open. ⌘K's run target goes through the same run, so it opens the dialog too the in-flight flag is the action's itemKey, as for every action; a second open while one is shown does nothing ui/src/model/actions.ts, ui/src/state/actions.ts, ui/src/state/services.tsx, ui/src/ds/, ui/src/app/ #1133 —

Existing code

Commit 4b39322.

Searches: listAttachedPhysical (5 hits: two drivers, the fake, the port, auto-enroll), device.add / device.remove in src/ (contract, dispatcher, gateway, HTTP, client, CLI), workerActions and mode !== in ui/src (3), typeToConfirm (2 files), menu={ in ui/src/screens/fleet (2), startsWith("device.") in ui/src/model/stale-keys.ts (1), "device add" in website/ (11 pages).

Id Code (path:line) Today With this feature Handled by
X1 src/core/physical-auto-enrollment.ts:118-138 auto-enroll lists each platform's attached phones through listAttachedPhysical every run, skipping a platform it cannot list both read the same driver list at once; it is read-only on both sides, so either order is fine I3
X2 src/drivers/ios/physical.ts:297-307, src/drivers/android/physical-handler.ts:334-344 iOS lists wired, non-simulated UDIDs; Android lists USB serials, and network ones under android.networkDevices, each sorted read as they are; I3 bounds the wait I3
X3 src/core/physical-enrollment.ts:152-159, :244-261 remove unenrols a live phone record by its driverDeviceId, refusing leased, reclaiming or a claim, and states but ready, absent, quarantined unchanged; B6 offers Remove phone exactly in those states, and a race shows the daemon's refusal (B7) B6, B7
X4 src/core/physical-enrollment.ts:214-233 add refuses a phone already enrolled under another id (enrolled-under-other-id) I1 leaves such a phone out by its hardware serial, so the list does not offer what add would refuse B1
X5 src/daemon/dispatcher-devices.ts:56-87 device.add and device.remove handlers over the enrollment port a device.attached handler beside them #1134
X6 src/gateway/dispatcher.ts:288-295 the gateway refuses device.add and device.remove by design refuses device.attached the same way B3
X7 src/http/route-declarations.ts:38-53, :114-126; src/contract/protocol.ts:13, :82-88 POST /v1/devices enrols; GET /v1/devices lists Simlock's records; protocol range 105; core route segments a new route on its own segment; protocol +1 I1, I2
X8 src/cli/commands/device.ts:7-9 device add and device remove only device attached joins them I4, B5
X9 ui/src/model/actions.ts:26-34, :242-248 the action ids; worker actions only when the mode is gateway remove-phone, enrol-phone; device and enrol actions only when it is worker B6, B8
X10 ui/src/ds/confirm-dialog.tsx:8-14, :65-85 the confirm takes a title, body, buttons and one typed name Remove phone uses it as is; Enrol needs a dialog with a choice list and fields, a new ds/ component B9
X11 ui/src/screens/fleet/worker-page.tsx:411-433; ui/src/screens/fleet/device-drawer.tsx:39-42; ui/src/state/workers.ts:57-92 the device row menu only navigates; the drawer acts only on a lease; the Fleet row and the page header read workerActions the row menu and the drawer add deviceActions; the Fleet row and the header add enrolActions B6, B8
X12 ui/src/model/search.ts:93-120 ⌘K's actions come from workers, leases and requests it adds each worker's enrolActions and its devices' deviceActions B8, B11
X13 ui/src/model/stale-keys.ts:40-41 every device. event marks ['workers'] stale a phone enrolled or removed shows once its event marks the page; ['attached-phones'] is polled instead (I7) I7
X14 ui/src/data/api.ts:1, ui/src/state/actions.ts:79-99 a request waits 10 s unless the action names a time; a write with no answer shows The daemon did not answer. Enrol names 120 s I8
X16 ui/src/state/actions.ts:68-109; ui/src/state/services.tsx:8-17; ui/src/app/app.tsx:30-48; ui/src/model/search.ts:24-26; ui/src/state/search.ts:128-133 run either confirms then writes, or writes at once; the services carry notify and confirm; ConfirmHost sits outside LiveProvider; a ⌘K result either goes or runs run opens the Enrol dialog for an action with form; the services gain enrol; its host sits inside LiveProvider I9
X17 src/daemon/dispatcher-options.ts:68; src/daemon/enrollment-wake.ts:9-21; src/daemon/worker-composition.ts:583 the dispatcher's enrollment port is add and remove, wrapped to wake the queue after each the port gains attached, passed through the wrapper with no wake, since it changes nothing I3, X5
X18 ui/src/model/worker-page.ts:913-915 the worker page leaves deleted devices out a removed phone leaves the Devices tab once its device.deleted event marks the page B7
X15 website/src/content/docs/docs/reference/console.mdx:14-24; website/src/content/docs/docs/worker/enrol-phones.mdx:59, :152 the console's action table has no phone actions; the phone page enrols from the CLI only both name the console's Enrol phone… and Remove phone, and device attached #1134, #1133

Tasks

flowchart LR
  A["#1134 device attached lists unenrolled phones"] --> B["#1133 Console: enrol and remove a phone"]
Loading

Completion conditions:

Open work in the same area:

Written by an agent.

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. leonardoxr commented on Oct 31, 2026

    @leonardoxr
    ContributorAuthor

    Spec updated: every section written (Problem through Tasks), from #1130 items 1 and 2; tasks #1133, #1134, #1135 posted; ADR 0055 proposed in #1132. Spec check: all four bodies Verdict: ready after one fix round. The maintainer was not interviewed; each choice taken on their behalf is an Assumption: line under Decisions.

    Written by an agent.

  2. added
    feature:spec
    on Nov 5, 2026
  3. V3RON commented on Nov 27, 2026

    @V3RON
    Contributor

    Design posted: rewritten to today's template at 4b39322. The scope is narrowed to phones: enrol from a list of plugged-in phones or by a typed id, and remove. It adds a new device.attached read and drops the virtual delete. ADR 0095 (PR #1903) replaces draft ADR 0055 (#1132). Tasks follow after the design check and approval.

    Written by an agent.

  4. added a commit that references this issue on Nov 27, 2026
  5. V3RON commented on Nov 27, 2026

    @V3RON
    Contributor

    Spec updated: the design is approved and ADR 0095 is accepted (PR #1903). Two tasks: #1134, rewritten as device attached lists the phones plugged in with no record, and #1133, rewritten as the console's Enrol phone… (from that list or a typed id) and Remove phone. #1135 and the draft ADR 0055 (#1132) are closed: the virtual delete is dropped.

    Written by an agent.

  6. added
    feature:planned
    and removed
    feature:spec
    on Nov 27, 2026
  7. V3RON commented on Nov 30, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: none
    Parked: #1134 and #1133 — built and reviewed; their reporter cannot write to the repo, so the maintainer merges the stack (#1903, #1971, #1975) by hand, from the top
    Waiting: none
    Decided: #1131 — may the list be read with auto-enroll off → yes, ADR 0095 narrows 0073 §5; phone actions on the Inbox → no, ADR 0095 narrows 0037 §3. #1134 — a separate auto-enroll-off case → no. #1133 — what ui/AGENTS.md gains → two invariants

    Written by an agent.

  8. github-actions commented on Nov 30, 2026

    @github-actions
    Contributor

    Closing: all 2 sub-issues are closed. The PR that closed the last one walks the completion conditions (delivery rule 9); reopen this if one does not hold on main. Flip its ADRs to Accepted if delivery has not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions