# Visit Session export-only repair ## Delivered The Timeline visit pane's Session section offers the web client's export-only session repair for that exact visit: - **Control** — `Retry export only` in a native `TextButton` (Material) or `CupertinoButton` (Cupertino); `Exporting…` while the request is pending. Disabled while the visit/run is active or a request is pending, so one choice sends one request. - **Request** — `RunsRepository.repairSessionExport` sends `repair_session_export` with exactly `run_id` and the visit's recorded `export_sequence` and requires `run_detail` in the reply, matching `web/src/repository.js` and the Go protocol. No choice id is invented: the visit's own recorded sequence is the choice. - **Reply** — the accepted run detail is folded through `RunsController.acceptRunDetail`, so the pane re-reads the recorded repair/export facts. Nothing is mutated optimistically. - **Refusal** — the server's reason is shown verbatim beside the unchanged recorded state; the control remains available and no success word appears. - **Scope of state** — in-flight/refusal state is per `run:sequence`; changing visits clears it and a late reply for another visit is ignored. ## Availability rule (recorded decision) The web inserts the control in two places of `auditSession` (`web/src/views/runDetail.js:361-388`): when there is no openable artifact at all, and when recorded evidence exists with a non-complete status or a truncated document. The app now mirrors that: - no document at all plus the web's identity (`step.session_id` or `step.session_export.session_id`) and a positive sequence → offered; - present document → offered only when `visitSessionExportNeedsRepair(export)` is true (truncated, or a recorded status that is not verified complete); - a legacy `session.html` selected only by the no-evidence fallback → **not** offered, matching the web (nothing to compare, and the server's ownership join would likely refuse it). Deliberate difference from the web, preserved: this client treats a recorded `complete` status without the server's positive `messages`/`html_bytes`, untruncated and diagnostic-free evidence as `partial`, so that document keeps the control. The app does not widen identity to an id read only from repair evidence; the web does not either. ## Review fixes (visit 2) - Suppressed the control for the legacy no-evidence `session.html` and added Material/Cupertino regression coverage. - Fixed the two analyzer findings: `?repair,` null-aware element and a private test helper. - `dart format` applied to the changed files. - Updated `PARITY.md` and `notes/R4-session-export.md`, which still said the command was unwired. - Added coverage for active/`waiting` gating, complete-export suppression, visit-change state clearing, the Cupertino control and "no other request". ## Known nonblocking gaps - In-flight state is widget-local: leaving the Session section and returning before the reply allows a second tap. The web keeps a page-level `run:seq` pending set. The normal live path still converges through the server's `session_export_updated` event and the scheduled `get_run`. - A reply completing after the pane unmounts is dropped; the same server event re-reads the run. - Artifact matching is by name only, ignoring `size_bytes == html_bytes` and repair session/backend/directory filters (documented in `notes/R4-session-export.md`). Inherited. - Full per-visit repair choices remain unwired. ## Verification - `flutter analyze` — No issues found. - `flutter test test/features/runs` — 212 passed. - `flutter test` — 1335 passed. - `flutter build web` — built. - No browser interaction/capture, Android/iOS build or device check was run. Mobile remains unverified.