Console: Add device… from the catalog keeps one more warm

オープン
#1,146 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript

調査の方向性

Start with ui/src/model/actions.ts and ui/src/state/actions.ts, then read the ActionConfirm flow in ui/src/ds/confirm-dialog.tsx and the listed Actions guidance in ui/AGENTS.md. Run the model and state tests named in the issue, then the browser lane in e2e/console/actions.spec.ts. Done means the specified catalog-driven dialog and warm-pool update work on all three surfaces, with the described errors and tests passing.

索引モデルが issue の本文から書いたものです。

説明

task:draft

Part of #1137.

Scope

After this PR an operator on a worker's console adds a simulator or emulator of a model, OS and mode picked from the worker's catalog. Add device… sits beside #1133's Enrol phone… on every surface that offers it (the Fleet table's worker row, the worker page, ⌘K). It raises that kind's runtime count by one, and the warm pool creates and boots the device on its next pass. Nothing new on the daemon: it is #1143's warm.set through #1144's route.

In short

Add device… reads GET /v1/catalog, then opens a dialog built from it. The operator picks a Platform, a Model from that platform's models, an OS from the runtimes the catalog pairs with the model, and on iOS a Mode. Add then reads GET /v1/warm-pool and sends one PUT /v1/warm-pool/targets. That PUT raises the matching row by one, or adds a row at the end counted from a matching learned kind's peak, else from 0 (#1137's "Count a client raises from"), and keeps the rest of the runtime list and runtime.learn. The matching row is, in order: the effective row whose key is the one Add would write (iOS: platform, model, OS, mode; Android: platform, model, OS); else the first effective row whose platform, model and resolved equal the picked kind; else none. Android's mode counts as full when matching resolved and learned kinds. The effective list holds one row per key (#1137), so the added row never repeats one. The toast says how many of the kind the pool now keeps.

flowchart LR
  A["Add device… (new), beside Enrol phone…, worker mode"] --> B["GET /v1/catalog"]
  B --> C[Dialog: Platform, Model, OS, Mode]
  C -->|Add| D[GET /v1/warm-pool]
  D --> E[PUT /v1/warm-pool/targets, one row raised]
  E --> F[Toast]
  style A stroke-width:3px
  style B stroke-width:3px
  style C stroke-width:3px
  style D stroke-width:3px
  style E stroke-width:3px

Words, exactly (<kind> is the Kind spelling in #1137's Shared values for the picked platform, model, OS and, on iOS, mode; <n> the count sent; <model> the picked model; <message> the daemon's or the client's):

Where Text
action label Add device…
dialog title Add a device
its body The warm pool keeps one more of this kind booted and ready, and boots it on its next pass.
its fields Platform (the catalog's platforms that list a model, iOS first and chosen when listed), Model (the platform's models, in catalog order, none chosen), OS (the model's modelRuntimes, in catalog order, the first chosen), Mode (iOS only, Full chosen, Slim; Android shows no Mode field)
while the catalog is read Add device… is busy, as any action in flight; no dialog yet
a catalog read that fails no dialog; error toast Couldn't read the catalog, with the message below and Retry
a catalog with no platform that lists a model (a driver whose catalog read failed is left out of a 200 answer) no dialog; error toast This worker's catalog lists no devices
a model with no paired runtime No runtime is installed for <model>., Add disabled
the fresh read at submit finds the matching row's base at 256 or more no PUT; error toast Couldn't add <kind>, description This kind is already kept at 256.
buttons Cancel, Add (busy: Adding…)
success toast Keeping <n> <kind> warm, description The pool boots one on its next pass.
error toast title Couldn't add <kind>, with the message below and Retry

Which row Add raises (learnedCount and resolved from warm.list):

Picked Effective list Learned Sends
iOS iPhone 17 26.0 Full runtime {ios, iPhone 17, 26.0, mode full, count 1} — that row, 2
iOS iPhone 17 26.0 Full configured {ios, iPhone 17, osVersion 26.0, count 2}, resolved 26.0, full — a runtime row of that key (no mode), 3
iOS iPhone 16 18.5 Full none ios iPhone 16 18.5 (full), peak 2 new row {ios, iPhone 16, 18.5, mode full}, 3
Android Pixel 8 35 none — new row {android, Pixel 8, 35}, 1
Android Pixel 8 35 none android Pixel 8 35 (full, google_apis), peak 2 new row, 1 (a learned kind with an image tag is not this kind)
iOS iPhone 17 26.0 Full, the second time before any pass runtime {ios, iPhone 17, 26.0, mode full, count 1}, no resolved yet — that row by its key, 2
iOS iPhone 17 26.0 Full configured {ios, iPhone 17, 26.0} counts 2 and 1 in config.json, one row of count 3 in warm.list — a runtime row of that key, 4

If this goes wrong, an operator sees Add device… keep two more instead of one, or offer an OS the catalog does not pair with the model.

Technical spec

Facts

Commit ce8fea85.

# Fact Source
F1 GET /v1/catalog (role agent) answers {platforms: [{platform, models, runtimes, modelRuntimes, …}]} src/http/route-declarations.ts:44-52, src/contract/operations.ts:81-87, src/contract/schemas.ts:683-713
F2 iOS modelRuntimes pairs each model with the installed runtimes it fits; Android pairs each model with the API levels of the images that fit its profile, none for a model with no profile src/drivers/ios/index.ts:1215-1217, src/drivers/android/index.ts:1446-1451
F3 The console reads /v1/catalog nowhere today search v1/catalog in ui/src (no hit); e2e/http-api.test.ts:98-114 is the daemon's test
F4 A request with no mode gets the platform's default mode, ios.defaultMode (default full), configurable src/core/config.ts:365-370, :989
F5 A target's mode is slim or full; Android makes no slim device src/core/warm-pool/config.ts:63-64; search slim in src/drivers/android/ (no hit)
F6 useActions().run sends one write and shows the success or error toast with Retry ui/src/state/actions.ts:72-108
F7 The Pager already uses a native <select> ui/src/ds/pager.tsx:29
F8 DESIGN.md styles a select at 40 px tall, in mono docs/internal/DESIGN.md:238-243
F9 The browser lane's "the console acts" drives dialogs and toasts against a real daemon with a fake driver e2e/console/actions.spec.ts:78, e2e/console/fixtures.ts:52
F10 Learned kinds carry an image tag that targets cannot name src/core/warm-pool/learned.ts:6-16, src/core/warm-pool/config.ts:20-28
F11 With no platform query, the daemon leaves out a platform whose catalog read fails and still answers 200 src/core/driver-catalog.ts:127-146, src/daemon/dispatcher.ts:346
F12 ds/ imports nothing from the rest of the console; a confirm's spec is fixed when it opens ui/AGENTS.md (Layers), ui/src/ds/confirm-dialog.tsx:31-56

#1133 (not merged at this commit) adds enrolActions, the form fields on ActionConfirm (a choice and a text field) and the worker-mode gate this task builds on; #1145 adds PUT to the console's write, the ['warm-pool'] read and the raise rule.

Modules touched

Searches: enrolActions (#1133), ActionConfirm, confirm-dialog, v1/catalog, <select in ui/src/.

  • ui/src/model/actions.ts: id add-device; Add device… joins the list enrolActions answers; a pure addDeviceTargets(list, picked) (new) that answers the runtime list and learn to send and the count <n>.
  • ui/src/ds/confirm-dialog.tsx and its CSS: a select field whose options come from a pure function of the earlier fields' values, given in the spec, and a line under the fields that keeps the confirm disabled (F12).
  • ui/src/state/actions.ts: Add device… reads GET /v1/catalog (not polled), then opens the confirm with the fields built from it; at submit it reads GET /v1/warm-pool and builds the PUT's body from that answer. Its in-flight key is warm-pool, shared with #1145's controls.
  • ui/AGENTS.md (Actions), docs/internal/DESIGN.md (the select field in the dialog), website/src/content/docs/docs/worker/console.mdx.
flowchart LR
  SV[surfaces: Fleet row, worker page, ⌘K] --> MA[model/actions *]
  SV --> AC[state/actions *]
  AC --> CAT[catalog read *]
  AC --> CD[ds/confirm-dialog *]
  AC --> API[data/api]
sequenceDiagram
  participant O as Operator
  participant C as Console
  participant D as Daemon (worker)
  O->>C: Add device…
  C->>D: GET /v1/catalog
  alt error or no answer
    C-->>O: error toast Couldn't read the catalog, message, Retry
  else 200, no platform lists a model
    C-->>O: error toast This worker's catalog lists no devices
  else 200
    O->>C: pick, Add
    C->>D: GET /v1/warm-pool
    C->>D: PUT /v1/warm-pool/targets
    alt 200
      C-->>O: toast Keeping n kind warm
    else error (either call)
      C-->>O: error toast Couldn't add kind, message, Retry
    end
  end
Contract and event changes

none: the console sends #1143's warm.set input through #1144's route and reads catalog.get as it is.

Other code on the same state

Searches: writers of the runtime list (#1144's CLI, #1145's tab, this dialog).

Component Both act Wins
#1145's tab or a CLI warm set between this dialog's GET /v1/warm-pool and its PUT the dialog sends the list it read at submit with its one change the later PUT (#1137's Assumption on two writers)
A second Add while the first is in flight Add is disabled while busy the first
Failure modes
Call Outcome What happens Limit, counted from
GET /v1/catalog 200 the dialog opens with its fields 10 s, from the click
GET /v1/catalog 200 with no platform that lists a model no dialog; This worker's catalog lists no devices 10 s
GET /v1/catalog error or no answer no dialog; Couldn't read the catalog with the message (The daemon did not answer. with no answer) and Retry 10 s
GET /v1/warm-pool at submit error or no answer error toast Couldn't add <kind>, nothing sent; Retry reads again 10 s, from Add
PUT /v1/warm-pool/targets 200 success toast 10 s, from the read's answer
PUT 400, 501, no answer error toast with the message and Retry 10 s

The console writes no state of its own.

Rules in play
  • ADR 0037 §3: Add device… is one entry of the list enrolActions answers, read by every surface that offers Enrol phone….
  • ADR 0037 §4: offered only in worker mode.
  • ADR 0037 §5: the toasts.
  • ADR 0056 §6: "Add device…" raises one row's count by one.
  • Documentation rule 9: worker/console.mdx describes Add device….
Tests

Seam: enrolActions and addDeviceTargets (ui/src/model/actions.test.ts), useActions().run (ui/src/state/actions.test.tsx), and the browser lane's "the console acts" (e2e/console/actions.spec.ts) for the dialog.

  • An operator sees Add device… beside Enrol phone… on the Fleet row, the worker page and ⌘K only in worker mode: mode worker / gateway / unknown.
  • An operator opens Add device… and picks platform, model, OS and mode from the worker's catalog: iOS offers full and slim, Android no Mode field; a model lists only its runtimes; a model with no runtime shows No runtime is installed for <model>. and Add stays disabled; Add disabled until all are picked; a catalog read that fails or lists no device opens no dialog and shows its toast; Cancel sends nothing.
  • An operator adds a device and sees one PUT /v1/warm-pool/targets raising that kind's count by one, then a toast: a kind with a runtime row; the same kind again before a pass, matched by key; a kind with only a configured target written with no mode, matched by resolved; a kind only learned, peak 2, sends 3; a new iOS kind writes its mode, a new Android kind none; a runtime learn kept; the warm-pool read at submit fails (error toast, nothing sent, Retry reads again); a matching row already at 256 sends nothing and shows This kind is already kept at 256.; 400 and 501 show 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, each Tests line but the dialog's a test there.
  • pnpm test:console --project=chromium e2e/console/actions.spec.ts passes with the dialog's Tests line and one more test: on a worker, Add device… with a picked kind sends one PUT /v1/warm-pool/targets and the toast shows.
  • website/src/content/docs/docs/worker/console.mdx describes Add device….

Out of scope

  • A device of an Android image type.
  • Creating a device outside the warm pool, or one that is not kept warm.
  • Add device… on a gateway's console.

Depends on

  • #1145
  • #1133
  • #1135

Written by an agent.

主要言語
TypeScript
スター
705
フォーク
40
平均マージ
12時間 9分
マージ済み PR(30日)
376

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

callstackincubator/simlock のほかの issue

callstackincubator/simlock の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。