merge(app): expose native run rename in live details

This commit is contained in:
2026-10-21 19:23:56 +01:00
11 changed files with 973 additions and 8 deletions
+94
View File
@@ -0,0 +1,94 @@
# R2 — title wiring into the real run detail
## Result
The already-landed `RunTitleAction` is now rendered by the real run detail under
both native hosts, and its accepted server `run_detail` is folded into the open
detail and the matching list row through `RunsController`. Nothing is sent while
typing or on Cancel, nothing is applied before the server replies, and a stale
reply cannot replace another selected run.
No server, shell, pubspec, main, dialog, repository or protocol file changed.
The action, wording and gateway are reused exactly as landed in R2d.
## Files
| File | Change |
| --- | --- |
| `lib/features/runs/screen.dart` | Passes the app's shared `ApiGateway` into `RunDetailView` |
| `lib/features/runs/ui/run_detail_view.dart` | Builds `RunTitleAction` from the current server detail; folds accepted replies through `controller.acceptRunDetail` |
| `lib/features/runs/ui/run_detail_material.dart` | Adds the action to the existing title/identity `Wrap` |
| `lib/features/runs/ui/run_detail_cupertino.dart` | Adds the action as its own native row below the title block |
| `lib/features/runs/ui/runs_controller.dart` | `acceptRunDetail`: replaces the open detail only for the selected id, updates only the matching list row's server title |
| `test/features/runs/ui/run_title_wiring_test.dart` | New: both hosts, exact Save payload, Cancel, refusal, no optimistic title |
| `test/features/runs/ui/runs_controller_test.dart` | Stale accepted reply cannot replace another run; list fold preserves other fields |
| `test/features/runs/ui/run_detail_widget_test.dart` | Existing detail tests supply the gateway |
| `tool/title_wiring_probe.dart` | Real-composition browser entrypoint |
| `tool/title_wiring_probe.mjs` | Isolated loopback protocol fixture + Chrome driver |
Production diff: 5 files, about 51 added lines and 2 replaced lines.
## Behaviour
- Material detail: `Rename` is an `OutlinedButton` inside the existing identity
`Wrap`. Cupertino detail: a `CupertinoButton` in its own row, so it remains a
separate semantics node instead of merging into the title block.
- Opening the prompt sends nothing. The prompt is seeded from
`storedRunTitle(run)`, never the prompt/output fallback.
- Save sends exactly `set_run_title {"run_id": <id>, "title": <typed text>}`
through `RunsRepository.setRunTitle`, i.e. the one shared gateway.
- Cancel sends nothing. A refusal keeps the prompt open with the typed title and
the server's words verbatim; the stored detail is unchanged.
- Only the returned `run_detail` is delivered. `RunsController.acceptRunDetail`
ignores a map without an id, replaces `detail` only when its id matches, and
updates only that list row's `title` (web `applyRunTitle` behaviour) while
preserving row fields such as `name`/`status`. A late reply for run A while
run B is selected updates A's list row but never B's detail.
## Checks actually run
```
flutter pub get
dart format lib/features/runs test/features/runs/ui/...
flutter test test/features/runs/ui/run_title_wiring_test.dart \
test/features/runs/ui/runs_controller_test.dart \
test/features/runs/ui/run_detail_widget_test.dart # 26 passed
flutter analyze # No issues found!
flutter test # 544 passed
flutter build web # Built build/web
flutter build web --target=tool/title_wiring_probe.dart \
-o build/title_probe_web # Built
OPENCODE_ARTIFACT_DIR=... node tool/title_wiring_probe.mjs \
build/title_probe_web # ok: true
```
Browser probe (real bundle, isolated loopback websocket fixture, 390×844):
- Cupertino detail shows `Rename`; the prompt seeds `Run title` with
`Fixture live run` (DOM field value).
- Cancel after typing `Discarded title` sent no `set_run_title`, left the stored
title visible, and closed the prompt.
- Cupertino Save sent exactly `{run_id: 1, title: "Cupertino renamed run"}`; the
returned server detail replaced the title in the detail and in the list row.
- Material host (Linux UA reload, same deep link `/runs/1`) seeded from the
current server title and Save sent exactly
`{run_id: 1, title: "Material renamed run"}`.
- Seven PNG captures, OCR-checked for the visible title:
`/Users/alan/.local/share/pipelines/data/artifacts/68/public/r2-title-wire/`
(`r2-title-cupertino-detail.png`, `-dialog`, `-cancelled`, `-renamed`,
`-list`, `r2-title-material-dialog.png`, `r2-title-material-renamed.png`).
## Integration note for the parallel Changes lane
Run 67 adds a Changes button to `run_detail_material.dart` and
`run_detail_cupertino.dart`. This change adds a `titleAction` parameter and one
insertion in each file. When merging main, keep both: the title action and the
Changes button are independent additions to the same detail bodies.
## Honest limits
- Mobile (Android/iOS) is unverified: no device, emulator, ADB or mobile build
was used. Source uses portable Material/Cupertino widgets only.
- No real Pipelines server or operator run was touched. The browser probe used
an isolated loopback fixture, not production data or credentials.
- Nothing was committed, pushed, merged to main or deployed.