Fleet device dialog — edit name/kind/location in place (#2061) #2171

Closed
matou-build-agent wants to merge 0 commits from agent/issue-2061 into main

closes #2061

Build slice 3/4 of the Fleet device dialog (device-facts-edit), from app report #2046 / design pass #2050 (DDR 0295). Resolves the build of #1432 — the device dialog now edits a device's own facts (name · kind · location) in place; before this they were read-only off the enrol code (fleetstate.go:167).

What this adds

  • The one new seam — PATCH /api/v1/fleet/nodes/{node_id} with optional name/kind/location (OpenAPI patchFleetNode + FleetNodeEdit, generated client regenerated). The Go handler (internal/controlapi/fleet.go, FleetEditor/WithFleetEdit) rejects the pure refusals before any write (empty name, unknown kind — keyed controlapi.fleet.edit.*, DDR 0234) and maps the editor's refusals to name_in_use (409) / unknown device (404) (P9-D6). The whole-composition editor writes through the enroll ledger's new EditDeviceFacts + the one fleet-state projection, so the next /fleet read reflects it (one source, DDR 0155 §3).
  • The screens (P9-D4 / D6) — DeviceDialog.vue gains the edit mode and the fail-loud refusal, built to the wireframe's data-field/data-action contract (device-name-input / kind-server|machine / device-location-input / save-device-<id> / cancel-edit / edit-refused), reusing the device-add field names (ADR 0237). Edit facts opens it; Save calls HttpFleetClient.updateNode; a refusal stays open with the reason and the field marked; Cancel writes nothing. A saved edit re-reads the list so Overview, Fleet and the dialog all show the new value.

Acceptance criteria

  • Edit facts opens an edit state with name, the kind picker (server/machine) and location pre-filled.
  • A valid Save calls PATCH /fleet/nodes/{id} and the next read shows the new value (DDR 0155 §3).
  • A refused Save (empty name / unknown kind / name in use) keeps the dialog open with the reason, the field marked, nothing written (P9-D6).
  • Cancel writes nothing and returns to the summary.

Tests

  • Go handler seam: internal/controlapi/fleet_edit_integration_test.go (write-through + the four refusals; rejected-before-write proven).
  • Dashboard: tests/unit/fleetDeviceDialog.test.ts (+6: edit / cancel / refusal + the surface re-read), tests/unit/fleetLive.test.ts (+3: client refusal mapping over real HTTP).
  • CI browser drive: tests/e2e/preview-harness/fleetDeviceDialogEdit.spec.ts (edit → refused → saved, with screenshots).

Full dashboard suite green (2320); go test ./internal/controlapi/ ./internal/enroll/ ./control-plane/cmd/control-plane/ + vet + gofmt clean; vue-tsc + eslint clean; openapi check:client in sync.

Unproven by the seam: the real ledger/clan persistence of an edited fact across a restart (a live leg); gateway (no enrolled request) edits are not covered.

Screenshots: none — the sandcastle sandbox cannot run Chromium (the Playwright browser's system libs / glibc do not match this host, same wall as #377/#471), so the visible P9-D4/D6 surface is driven by the committed CI harness spec tests/e2e/preview-harness/fleetDeviceDialogEdit.spec.ts (which screenshots edit / refused / saved under pnpm e2e:harness) and the dashboard unit drives; a reviewer running the harness sees the shots.

closes #2061 Build slice 3/4 of the Fleet device dialog (`device-facts-edit`), from app report #2046 / design pass #2050 (DDR 0295). **Resolves the build of #1432** — the device dialog now edits a device's own facts (name · kind · location) in place; before this they were read-only off the enrol code (`fleetstate.go:167`). ## What this adds - **The one new seam** — `PATCH /api/v1/fleet/nodes/{node_id}` with optional `name`/`kind`/`location` (OpenAPI `patchFleetNode` + `FleetNodeEdit`, generated client regenerated). The Go handler (`internal/controlapi/fleet.go`, `FleetEditor`/`WithFleetEdit`) rejects the pure refusals **before any write** (empty name, unknown kind — keyed `controlapi.fleet.edit.*`, DDR 0234) and maps the editor's refusals to `name_in_use` (409) / unknown device (404) (P9-D6). The whole-composition editor writes through the enroll ledger's new `EditDeviceFacts` + the one fleet-state projection, so the next `/fleet` read reflects it (one source, DDR 0155 §3). - **The screens (P9-D4 / D6)** — `DeviceDialog.vue` gains the edit mode and the fail-loud refusal, built to the wireframe's `data-field`/`data-action` contract (`device-name-input` / `kind-server|machine` / `device-location-input` / `save-device-<id>` / `cancel-edit` / `edit-refused`), reusing the device-add field names (ADR 0237). *Edit facts* opens it; *Save* calls `HttpFleetClient.updateNode`; a refusal stays open with the reason and the field marked; *Cancel* writes nothing. A saved edit re-reads the list so Overview, Fleet and the dialog all show the new value. ## Acceptance criteria - [x] *Edit facts* opens an edit state with name, the kind picker (server/machine) and location pre-filled. - [x] A valid *Save* calls `PATCH /fleet/nodes/{id}` and the next read shows the new value (DDR 0155 §3). - [x] A refused *Save* (empty name / unknown kind / name in use) keeps the dialog open with the reason, the field marked, nothing written (P9-D6). - [x] *Cancel* writes nothing and returns to the summary. ## Tests - Go handler seam: `internal/controlapi/fleet_edit_integration_test.go` (write-through + the four refusals; rejected-before-write proven). - Dashboard: `tests/unit/fleetDeviceDialog.test.ts` (+6: edit / cancel / refusal + the surface re-read), `tests/unit/fleetLive.test.ts` (+3: client refusal mapping over real HTTP). - CI browser drive: `tests/e2e/preview-harness/fleetDeviceDialogEdit.spec.ts` (edit → refused → saved, with screenshots). Full dashboard suite green (2320); `go test ./internal/controlapi/ ./internal/enroll/ ./control-plane/cmd/control-plane/` + vet + gofmt clean; `vue-tsc` + eslint clean; openapi `check:client` in sync. **Unproven by the seam:** the real ledger/clan persistence of an edited fact across a restart (a live leg); gateway (no enrolled request) edits are not covered. **Screenshots:** none — the sandcastle sandbox cannot run Chromium (the Playwright browser's system libs / glibc do not match this host, same wall as #377/#471), so the visible P9-D4/D6 surface is driven by the committed CI harness spec `tests/e2e/preview-harness/fleetDeviceDialogEdit.spec.ts` (which screenshots edit / refused / saved under `pnpm e2e:harness`) and the dashboard unit drives; a reviewer running the harness sees the shots.
sandcastle: #2061 — Fleet device dialog edits name/kind/location in place (device-facts-edit, slice 3/4, resolves the build of #1432)
All checks were successful
ci / seam (pull_request) Successful in 17m57s
ci / publish (pull_request) Has been skipped
ci / publish-broker (pull_request) Has been skipped
ci / deploy-broker (pull_request) Has been skipped
cf7ff42867
The device dialog now EDITS a device's own facts — name, kind, location — in
place (P9-D4, DDR 0295), the promised edit that did not exist (fleetstate.go:167
read these off the enrol code read-only). Landing-pr (ADR 0267), from app report
#2046 / design pass #2050.

The one new seam — PATCH /api/v1/fleet/nodes/{node_id} (optional name/kind/location):
- packages/openapi-spec/openapi.yaml: patchFleetNode + FleetNodeEdit; generated
  client (dashboard/src/lib/api/generated.ts) regenerated.
- internal/controlapi/fleet.go: FleetEditor + WithFleetEdit + the handler. The
  pure refusals are rejected BEFORE any write (empty name -> name_empty, unknown
  kind -> kind_unknown; each keyed controlapi.fleet.edit.* per DDR 0234); the
  editor's refusals map to a name_in_use 409 / a 404 unknown device (P9-D6).
- control-plane: fleetFactsEditor writes through the enroll ledger's new
  EditDeviceFacts (internal/enroll/ledger.go + persisted.go) + the ONE fleet-state
  projection (name-in-use read + updated-node read); the next /fleet read reflects
  it (one source, DDR 0155 §3). Wired in the whole composition; nil at rest
  (WithFleetEdit skips a nil editor, so the route stays unwired).

Dashboard (the wireframe-bearing screens, built to the data-field/data-action
contract):
- DeviceDialog.vue: the edit mode (D4) + the fail-loud refusal (D6) — a name
  field, the two-option kind picker (kind-server/kind-machine) and a location
  field reusing the device-add names (device-name-input/device-location-input,
  ADR 0237), pre-filled from the row. Edit facts (edit-device-<id>) opens it,
  Save (save-device-<id>) calls the seam, Cancel writes nothing.
- fleet.ts FleetEditor/FleetNodeEdit/FleetEditOutcome; fleetClient.ts
  HttpFleetClient.updateNode maps a 4xx Problem -> a rendered reason + the marked
  field, never a swallow (#298 fail-loud).
- FleetSurface.vue forwards the editor + re-reads the list on save so Overview,
  Fleet and the dialog all show the new value; mountRegistry wires the editor
  (the same generated client, ADR 0037).
- i18n: shell + controlapi keys across en/es/fr/nl/pt (key-parity).

Seams/tests:
- internal/controlapi/fleet_edit_integration_test.go — write-through + the four
  refusals, rejected-before-write proven.
- dashboard tests/unit/fleetDeviceDialog.test.ts (+6), tests/unit/fleetLive.test.ts
  (+3 client), tests/e2e/preview-harness/fleetDeviceDialogEdit.spec.ts (CI drive).

Verified: go test ./internal/controlapi/ ./internal/enroll/
./control-plane/cmd/control-plane/ + vet + gofmt clean; full dashboard suite 2320
green, vue-tsc + eslint clean; openapi check:client in sync.

Unproven by the seam: the real ledger/clan persistence of an edited fact across a
restart — only a live leg exercises it; gateway (no enrolled request) edits are
not covered. Out of scope (sibling slices): dialog-action-routes (#2060),
device-remove-entry (ready-for-human).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Factory-Account: d631bd58e1e9
Author
Member
close-report gates passed for #2061 — every claim verified; this PR is cleared for merge.
<!-- close-report: gates-passed --> close-report gates passed for #2061 — every claim verified; this PR is cleared for merge.
ben referenced this pull request from a commit 2026-11-16 17:31:44 +00:00
Owner

Merged — merge commit 5947156f. Merged to main by hand at Ben's request (main now at 1776d784), stacked with #2170, #2171, #2172, #2173 and #1897. Forgejo did not auto-detect the pushed merge and manually-merged is disabled on this repo, so this PR is closed by hand — the code IS on main. Conflicts with #2170 (DeviceDialog, FleetSurface, shell i18n) resolved by keeping both sides; the Edit facts button kept in the main actions row as #2171 placed it. Verified on the merged stack: dashboard 2339/2339, app 2394/2394, both vue-tsc clean, touched Go + broker packages green.

**Merged** — merge commit 5947156f. Merged to `main` by hand at Ben's request (main now at 1776d784), stacked with #2170, #2171, #2172, #2173 and #1897. Forgejo did not auto-detect the pushed merge and `manually-merged` is disabled on this repo, so this PR is closed by hand — the code IS on main. Conflicts with #2170 (DeviceDialog, FleetSurface, shell i18n) resolved by keeping both sides; the Edit facts button kept in the main actions row as #2171 placed it. Verified on the merged stack: dashboard 2339/2339, app 2394/2394, both `vue-tsc` clean, touched Go + broker packages green.
ben closed this pull request 2026-11-16 17:33:13 +00:00
All checks were successful
ci / seam (pull_request) Successful in 17m57s
ci / publish (pull_request) Has been skipped
ci / publish-broker (pull_request) Has been skipped
ci / deploy-broker (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss!2171
No description provided.