fix(app): offer the session export repair only where the web does

Suppress the export-only repair for a legacy session.html with no recorded
evidence, narrow the identity check to the web's own, and keep the stricter
partial rule for an unverified complete status. Fix the analyzer findings,
add gating/legacy/Cupertino coverage, format, and correct the parity docs.
This commit is contained in:
2026-10-22 10:52:36 +01:00
parent d78712aa77
commit 776afcacea
8 changed files with 265 additions and 41 deletions
+5 -3
View File
@@ -21,7 +21,8 @@ Completeness is not inferred: it requires `status == "complete"`, positive
`messages` and `html_bytes`, no truncation and no diagnostic. A complete status
without that evidence is `partial`; a legacy `session.html` with no evidence is
`unknown`, never `complete`. Repairs are shown even when the main export is
complete. No `repair_session_export` request is sent or advertised.
complete. This slice sent no request; the export-only `repair_session_export`
control landed later (see `notes/session-export-repair.md`).
## Review fixes (visit 2)
@@ -143,8 +144,9 @@ narrow-layout constraint recorded in `notes/R4-visit.md`, not new to this change
remains portable (Material/Cupertino theme roles and plain text layout only).
- No authenticated server or production run was touched; fixtures only. The
preview is not published to 8096.
- `repair_session_export` remains unwired, and the repair-option label remains
inert text by design.
- The export-only `repair_session_export` control landed later and is described
in `notes/session-export-repair.md`; full per-visit repair choices remain
unwired, and the repair-option label remains inert text by design.
- Artifact matching still selects by recorded name only, as it did before this
change; web additionally filters repairs by session/backend/directory and
checks `size_bytes == html_bytes`. Inherited, not changed here.
+79
View File
@@ -0,0 +1,79 @@
# 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.