feat(app): add deliberate human-decision action for run detail
Adds HumanDecisionAction plus its native prompt, wording constants and tests. The action renders only while pendingDecision() reports a genuine human wait, sends decide_run only after an option is chosen and Confirm pressed, sends the pending stage/trimmed option/optional feedback, blocks double submits, shows server refusals verbatim with the draft intact, and re-reads the run so the owner always receives server truth.
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
# R2a — native human-decision action
|
||||
|
||||
## What changed
|
||||
|
||||
New `lib/features/runs/actions/` slice (no existing source file edited):
|
||||
|
||||
| File | Lines | Responsibility |
|
||||
| --- | --- | --- |
|
||||
| `decision_action.dart` | 141 | `HumanDecisionAction`, gating, submit/refusal/resync orchestration |
|
||||
| `decision_dialog.dart` | 248 | Material `AlertDialog` / Cupertino `CupertinoAlertDialog` prompt |
|
||||
| `decision_wording.dart` | 24 | Web-verbatim words, meta/target formatting and test keys |
|
||||
| `test/.../decision_action_test.dart` | 237 | Material/Cupertino deliberate send and gating |
|
||||
| `test/.../decision_resilience_test.dart` | 240 | refusal resync, double submit, disposal, 2x/narrow |
|
||||
|
||||
`HumanDecisionAction` takes the run, the shared `ApiGateway` and an
|
||||
`onRunChanged` callback. It renders one `FilledButton` (`Decide`) on Material
|
||||
and one `CupertinoButton.filled` on Cupertino, and nothing at all when
|
||||
`pendingDecision(run)` is null. Recorded waiting-step options therefore win over
|
||||
the pinned graph, and a pending session export suppresses the action through the
|
||||
existing domain rule without duplicating it here.
|
||||
|
||||
Opening the prompt sends nothing. The prompt uses the web wording
|
||||
(`Waiting for your decision`, `Feedback (optional)`, `Cancel`,
|
||||
`Confirm decision`, `Sending…`), shows the stage/run meta line and each option's
|
||||
`→ target` when declared. Confirm is disabled until an option is selected;
|
||||
selecting itself only updates the draft. Confirm calls `RunsRepository.decideRun`
|
||||
with the exact stage, trimmed option and trimmed optional feedback (blank
|
||||
feedback is omitted by the repository).
|
||||
|
||||
A refusal is shown verbatim inside the kept-open prompt; the option selection
|
||||
and feedback controller are untouched. The action then calls
|
||||
`RunsRepository.getRun` and passes the refreshed run to `onRunChanged`. A
|
||||
successful decision passes the server's `run_detail` to `onRunChanged` and
|
||||
closes the prompt. Both sends are guarded in the prompt and in the owner state;
|
||||
buttons are disabled while `Sending…`. Every asynchronous resume checks
|
||||
`mounted` before `setState` or `onRunChanged`, so a late reply after disposal is
|
||||
ignored.
|
||||
|
||||
Platform style follows the enclosing app: `MaterialApp` gets the Material
|
||||
dialog and controls, `CupertinoApp` gets the Cupertino dialog with native
|
||||
buttons/radios/field. No custom palette, font family, fixed button/row size,
|
||||
dependency or CSS token was added; the theme's error color and default control
|
||||
spacing are used. The one optional `cupertino` override exists for
|
||||
callers/tests that do not wrap in either app.
|
||||
|
||||
## Checks actually run
|
||||
|
||||
```
|
||||
flutter pub get # dependencies resolved
|
||||
dart format lib/features/runs/actions test/features/runs/actions
|
||||
flutter analyze # No issues found!
|
||||
flutter test test/features/runs # 18 passed
|
||||
flutter test # 36 passed
|
||||
flutter test test/features/runs/actions # 7 passed
|
||||
flutter build web # Built build/web (14.2s)
|
||||
```
|
||||
|
||||
Focused coverage maps to the requested acceptance:
|
||||
|
||||
- material: action visible, dialog open, selection does not send, Confirm is
|
||||
disabled before selection, exact `decide_run` stage/option/`looks good`
|
||||
feedback, callback gets the decided run and the action disappears;
|
||||
- cupertino: native `CupertinoAlertDialog`, disabled Confirm first, blank
|
||||
feedback omitted, exact request fields;
|
||||
- gating: running, export-pending and non-human runs render no action;
|
||||
- refusal: `decide_run` then `get_run`, verbatim error still visible, selected
|
||||
option and typed feedback retained, refreshed failed run delivered to owner;
|
||||
- double submit: two Confirm taps produce one `decide_run`, Cancel is disabled
|
||||
while sending;
|
||||
- stale disposal: completing the decision after the tree is replaced produces
|
||||
no exception and no owner callback;
|
||||
- 320×480 at 2x text on both apps: prompt opens with no rendering exception.
|
||||
|
||||
## Honest limits
|
||||
|
||||
- **Not wired into a run-detail screen.** `lib/features/runs/` has no screen or
|
||||
controller on this branch; the manager owns that integration. There is
|
||||
therefore no real browser interaction or capture for this widget. The
|
||||
`flutter build web` result proves compilation only, not rendered behavior.
|
||||
- **Mobile unverified.** No Android/iOS build, emulator, ADB or device was used.
|
||||
Source uses only portable Flutter/Cupertino/Material widgets.
|
||||
- No real server or run was mutated. Tests use a local fake gateway.
|
||||
- No repository/domain/controller/screen/main, `web/`, Go server, installer or
|
||||
deployment file was changed. Nothing was committed, pushed or deployed.
|
||||
Reference in New Issue
Block a user