Files
alan c53dedc544 feat(app): wire retry and restart into the native run detail
Render Retry beside Rename on a stopped failed run under both native
hosts, send only {run_id, request_key} for resume and add
retry_mode=restart for a fresh start, and open the run the accepted
reply names. Keep hidden actions out of the Wrap so native 8/4 dp
spacing is not doubled, and use a literal 2^32 entropy bound because
dart2js evaluates 1 << 32 as 0.

Adds wiring, guard and layout tests, a browser-only key regression and
the retry probe; notes/R2c-wire.md records the checks and limits.
2026-10-21 22:49:26 +01:00

9.4 KiB
Raw Permalink Blame History

R2c-wire — Retry/restart in the real run detail

Result

The already-landed RetryRunAction now renders in the real run detail action row under both native hosts, beside Rename and Cancel/decision wiring. Only a loaded, stopped failed run offers it. Resume sends exactly run_id and request_key; restart additionally sends retry_mode: "restart". Keep sends nothing. The accepted reply is delivered through RunsController.acceptRunDetail like cancel/title, and the new run is opened only when the reply itself carries a numeric, different run id. A reply without an id, a reply naming the source run, a late reply, or a reply after leaving never guesses a run or moves the route.

The action row now uses the detail's native 8 dp / 4 dp Wrap spacing. It previously used the default zero spacing, so the outlined Rename border met the filled Retry button at 320 px (browser-measured gap 0.008 CSS px). Only actions that render are included in the Wrap: a hidden action still consumed spacing and would have doubled the visible gap.

The browser probe found one real web-only defect in the landed key generator: dart2js evaluates 1 << 32 as 0, so Random.nextInt raised every retry before the request left the app. The bound is now a literal 0x100000000; a browser-compiled test and the web probe both exercise the real generator.

Files

File Change
lib/features/runs/ui/run_detail_actions.dart Renders RetryRunAction in the action row, forwards the reply-id callback, uses 8/4 dp spacing, includes only eligible actions
lib/features/runs/ui/run_detail_view.dart Passes an optional server-identified run opener through to the actions
lib/features/runs/screen.dart Opens the reply-named run through the existing _select path (controller selection + route)
lib/features/runs/actions/retry_action.dart After the accepted detail callback, opens only a different numeric reply id
lib/features/runs/actions/retry_intent.dart Web-safe 2^32 entropy literal instead of 1 << 32
test/features/runs/ui/run_retry_wiring_support.dart New: fixture gateway and both-host detail mount
test/features/runs/ui/run_retry_wiring_test.dart New: real screen wiring, exact resume/restart payloads, server-named navigation
test/features/runs/ui/run_retry_guard_test.dart New: no-id/same-id/refusal/late reply and eligibility gates
test/features/runs/ui/run_retry_layout_test.dart New: action-row spacing at 320 px and 2x, no doubled gap from a hidden action
test/features/runs/actions/retry_action_test.dart Full-width entropy regression for the request key
test/features/runs/actions/retry_intent_web_test.dart New browser-only (@TestOn('browser')) regression for the dart2js entropy defect
tool/retry_wiring_probe.dart, tool/retry_wiring_probe.mjs Normal-app browser probe; CHROME_PATH/TESSERACT/PROBE_THEME envs; measures the 8 dp action gap

No dialog, repository protocol, server, web, shell, main, pubspec, Android or iOS file changed. No new server command or API.

Behaviour

  • Action order in the detail Wrap is Rename, Retry, Cancel; Retry renders nothing unless canRetryRun(run) holds (!executing && status == "failed"). Both Material (FilledButton) and Cupertino (CupertinoButton.filled) use their native controls and host typography. The row uses spacing: 8 and runSpacing: 4, matching the detail's other action rows.
  • Opening the prompt and choosing Keep send nothing. Resume sends exactly {run_id, request_key}; restart sends {run_id, request_key, retry_mode: "restart"}. The key is app-retry-<runId>-…, bounded at 128 characters, fresh per deliberate intent, and retained across an uncertain resend by the landed dialog.
  • The accepted run_detail goes through onRunChanged, i.e. controller.acceptRunDetail: it folds an existing list row and replaces the open detail only when its id still matches. A refusal stays in the prompt with the server words and a bounded get_run recheck, as landed.
  • The new run is opened only when retryRunId(reply) is numeric and differs from the source id. RunsScreen._select then uses the existing controller select generation guard and reports the route change, so the URL becomes /runs/<reply id>. No id or same id, no navigation; a later reply after leaving is ignored by the action's ownership check and never reaches the controller. The accepted reply for the source run is still folded normally.
  • The reply is not used to invent a title, status or id. The opened detail is the server's get_run for the id the retry reply named.

Checks actually run

dart format lib/features/runs test/features/runs tool/retry_wiring_probe.dart
                                                     # Formatted 61 files (0 changed)
flutter analyze                                      # No issues found!
flutter test test/features/runs/ui/run_retry_guard_test.dart \
  test/features/runs/ui/run_retry_layout_test.dart \
  test/features/runs/ui/run_retry_wiring_test.dart    # 13 passed
flutter test test/features/runs test/application/runs_destination_test.dart
                                                     # 134 passed
flutter test                                         # 708 passed
flutter test --platform chrome \
  test/features/runs/actions/retry_intent_web_test.dart
                                                     # 1 passed (dart2js)
flutter build web                                    # Built build/web
flutter build web --target=tool/retry_wiring_probe.dart -o build/retry_probe_web_code
                                                     # Built
OPENCODE_ARTIFACT_DIR=.../public/r2c-retry-wire-code-fix \
  node tool/retry_wiring_probe.mjs build/retry_probe_web_code
                                                     # ok: true, 9 checks, 10 captures
OPENCODE_ARTIFACT_DIR=.../public/r2c-retry-wire-code-fix PROBE_THEME=light \
  node tool/retry_wiring_probe.mjs build/retry_probe_web_code
                                                     # ok: true, 9 checks, 10 captures

Regression guards were mutation-checked: with spacing: 0 the 320 px spacing test fails, and with Random().nextInt(1 << 32) the browser test fails with the dart2js RangeError; both were restored.

Real-browser probe (normal app composition, isolated loopback websocket, 320×480 CSS at DPR 2, both themes and hosts):

  • The action row measures 8.016 CSS px (Cupertino) and 8.008 CSS px (Material) between Rename and Retry in both themes, versus 0.008–0.016 px before the fix. Failed and running rows are visually separated in dark and light.
  • Cupertino: failed run shows Rename and Retry; Keep recorded zero retry requests; restart sent {run_id: 7, request_key: "app-retry-7-…", retry_mode: "restart"} and opened only /runs/8, the reply's run. Resume from the still-failed source sent only {run_id: 7, request_key: "app-retry-7-…"}, omitted retry_mode, and opened only /runs/9.
  • Material: the same failed run and action row; Keep sent nothing; resume sent the same two-field payload and opened only /runs/10.
  • All retry request keys started with app-retry-7-, fit 128 characters, and no navigation occurred before a reply. Back listed the source and retried runs.
  • Twenty PNGs in /Users/alan/.local/share/pipelines/data/artifacts/80/public/r2c-retry-wire-code-fix/ cover both themes and both hosts (failed, prompt, kept, restart prompt, restart run, list, resume run; seven Cupertino and three Material each). OCR asserted the source/new-run titles; the failed captures were inspected for the restored native gap and readable 320 px layout.

Before the key fix, the same probe failed with ZONE ERROR: RangeError: max must be in range 0 < max ≤ 2^32, was 0 and recorded zero retry requests.

Honest limits

  • Mobile unverified. No Android/iOS build, emulator, ADB or device was used; sources stay portable Material/Cupertino.
  • No production server, operator run or real retry was touched. The probe used an isolated fixture with no credentials or shared data.
  • Browser text scaling cannot be driven from CDP; 2x text at 320 px is covered by the widget tests, while the browser probe covers 320 CSS px at DPR 2 in dark and light.
  • The browser entropy test is not part of the default flutter test VM run; it needs flutter test --platform chrome and a Chrome install. No CI wiring exists in this repository to add it to.
  • The app opens the reply-named new run, while web/src/views/dialogs.js silently re-selects the source run. The reply is genuinely the new run, so this remains an intended improvement rather than pure parity; the product decision is unchanged in this turn.
  • The accepted reply's own detail is discarded when navigating and one get_run follows, briefly showing the loading placeholder. Correct, one extra round trip; not changed in this focused fix.
  • tool/retry_wiring_probe.mjs remains long and requires Chrome; it now honours CHROME_PATH, TESSERACT and PROBE_THEME, but is not otherwise split.
  • The post-Keep Cupertino capture is identical to the failed state; the "sent nothing" claim rests on the probe's zero-request fixture state.
  • A pre-existing Cupertino detail-header defect was observed at 320 px/2x: the landed Changes button's internal Row overflows by 14 px. It reproduces with Retry absent and belongs to the Changes lane, so it was not edited here.
  • Nothing was committed, pushed, merged to main or deployed.