Merge branch 'main' into flutter/run-session-audit

This commit is contained in:
2026-10-22 04:44:02 +01:00
49 changed files with 3608 additions and 407 deletions
+110
View File
@@ -0,0 +1,110 @@
# A4 — turn documents in the artifact gallery
## Scope
The run-detail Artifacts page now lists a visit's turn documents beside its
stage files: `input.md`, `memory.md`, `output.md` and `session.html`. They are
entries of the visit group, not a separate run-level list.
## Behaviour
- A recorded document is a normal gallery row with the server's exact recorded
name, MIME and byte size. Selecting it uses the same `ArtifactSelectionFacts`
and URL-state rules as a stage file.
- Markdown documents (`input.md`, `memory.md`, `output.md`) open in the existing
in-app artifact viewer and join its recorded paging order.
- `session.html` is external-only by name. It always takes the selection dialog
with the existing Open/Copy actions, even when the server sniffed it as
`text/plain`; it is never fetched or drawn in the renderer.
- A document the visit did not record keeps its row with the exact audit words:
`No input recorded.`, `No memory recorded for this visit.`,
`No output recorded.`, and the web session wording (for example
`This visit has no harness session.` or
`Session ses-42 is recorded. Its export is not yet available.`). The missing
row is not tappable.
- Nothing is synthesized: a document exists only when its exact recorded name is
in the step's artifact list. Step fields named `input`/`memory`/`output` are
ignored. An absent artifact capture yields no document slots, and a visit that
recorded none of the four documents shows no document section rather than four
fabricated absences.
- The run header count now counts stage files plus recorded documents; absent
slots are never counted. Stage-only grouping (`artifactGroups`) is unchanged.
## Files
| File | Lines | Responsibility |
| --- | ---: | --- |
| `lib/features/artifacts/domain/artifact_document.dart` | 153 | Document slots, exact absence wording, exact-name lookup, external-only/viewer eligibility |
| `lib/features/artifacts/domain/artifact_groups.dart` | 160 | `galleryGroups` merging stage groups with per-visit documents; recorded count |
| `lib/features/artifacts/domain/gallery_navigation.dart` | 91 | Viewer paging includes recorded markdown documents, excludes session exports |
| `lib/features/artifacts/domain/artifact_record.dart` | 85 | Turn-file vocabulary and recorded record model |
| `lib/features/artifacts/domain/artifact_summary.dart` | 81 | Header counts recorded gallery entries |
| `lib/features/artifacts/ui/artifact_row_labels.dart` | 32 | Shared group/name/facts labels and identity |
| `lib/features/artifacts/ui/artifact_record_row.dart` | 82 | Native Material/Cupertino recorded row |
| `lib/features/artifacts/ui/artifact_document_section.dart` | 124 | Per-visit document rows and exact absence rows |
| `lib/features/artifacts/ui/artifact_visit_list.dart` | 128 | Group list composing stage rows and document sections |
| `lib/features/artifacts/ui/artifact_gallery_page.dart` | 277 | Uses gallery groups; session export bypasses the viewer |
| `lib/features/artifacts/ui/artifact_selection_facts.dart` | 71 | Same facts panel with the recorded-entry count |
| `lib/features/artifacts/ui/artifact_viewer_body.dart` | 248 | Material pager wraps instead of clipping |
| `test/features/artifacts/domain/artifact_document_test.dart` | 281 | Exact records, all absence words, no synthesis, grouping, paging |
| `test/features/artifacts/ui/artifact_gallery_documents_test.dart` | 183 | Both hosts: entries, grouping, missing wording, row semantics, viewer, external-only session |
| `tool/artifact_gallery_probe.dart` | 385 | New isolated `documents` fixture state |
| `tool/artifact_gallery_probe.mjs` | 936 | Real-browser A4 checks, contrast, pager geometry and captures |
## Fixes after the review stages
- **Material absence rows use normal text contrast.** The absent-document row is
no longer a disabled `ListTile`. It keeps no `onTap` (still non-actionable) but
paints the explanation with the theme's `onSurfaceVariant`, like every other
secondary label. Measured from 3x rasterised pixels: **8.88:1** in light mode
and **10.91:1** in dark mode (previous: 2.67:1 and 3.64:1).
- **Material viewer pager no longer clips at 320 px/2x.** The fixed `Row` became a
`Wrap`, so at 320 px with 2× text `Previous artifact` (x=8, w=236.4) and
`Next artifact` (x=8, w=186.1) each take their own line and stay inside the
viewport (previous: Next ended at 430.6 px). This also fixes the pre-existing
stage-artifact pager case.
- Quality follow-ups from the code review: the changed files are `dart format`
clean; `turnDocumentNames` is aliased to `systemArtifactNames`; `visitDocuments`
parses the capture once; the external-only session is detected by its domain
name (`sessionExportDocumentName`) instead of object identity; the stale
`artifact_summary`/`artifact_record` comments now match the gallery surface.
- Tests now pin every `sessionDocumentAbsence` branch (skipped, canceled,
interrupted, running, failed with/without diagnostic, runtime error, pending
recovery, complete-inventory, evidence diagnostic), the absent row's
non-actionable but enabled Material tile and secondary colour, and the 320 px/2×
Material pager geometry.
## Checks
- `flutter analyze`: clean (`No issues found!`).
- `dart format --output=none --set-exit-if-changed` on every changed/new Dart
file: clean.
- `flutter test test/features/artifacts`: 148 pass.
- `flutter test` (integrated): 1049 pass.
- `flutter build web`: succeeds.
- Probe build: `flutter build web --target tool/artifact_gallery_probe.dart --output build/probe-a4-fix`.
- Real headless Chrome probe: 36 checks, 41 captures, 0 failures. A4 captures:
`a4-material-documents`, `a4-material-session`, `a4-material-document-viewer`,
the same three for Cupertino, `a4-material-light-absence-row`,
`a4-material-dark-absence-row` and `a4-material-320-2x-document-viewer`.
Inspected the light/dark absence pages (legible, no disabled dimming), the
320/2× document viewer (both pager controls whole, wrapped) and the Cupertino
document list (unchanged native grouped rows).
- Evidence: `public/a4-code-fix/evidence.json` plus the captures above.
The probe serves only its own loopback fixture. No server, operator run or
authenticated production data was touched.
## Known limits
- Not committed: this stage is read-only for history, so the candidate is left
in the worktree for the landing stage.
- Repaired session exports (`session-repair-*.html`) are still not resolved; the
web client prefers the verified repair, and `PARITY.md` still lists this as
deferred. A repaired visit can show `session.html` or the
"not available in the artifact inventory" wording instead of the repair.
- The dialog still offers Download/Share for an external-only session export;
external-only here means it cannot be rendered in-app, not that its bytes are
unavailable.
- Mobile (Android/iOS) rendering and OS behavior remain unverified; only web was
tested.
+147
View File
@@ -0,0 +1,147 @@
# C5-list — shared chat session actions
The landed chat list already had rename/star/close/reopen request shapes. This
slice makes their outcome handling match the current web client (B1/B10 moved
rename and star to server-shared state) and adds the list-local hide/read state
from C13. All changes are under `lib/features/chat/ui/sessions/`, its tests,
`tool/chat_sessions_probe*`, `notes/` and one `PARITY.md` row. No thread,
composer, permission, runs, pipelines, graph, application, artifacts, schedules
or templates file changed.
## Behaviour
- **Create** is sent by the open dialog. The reply's `chat_session` is required
(a reply without one is refused with the web's exact sentence
`The server did not return the new chat session.` instead of opening an
invented row), the accepted session opens immediately and the list re-reads
`chat_sessions` in the background. A refusal keeps the dialog, its fields and
the server's words in place. The operation id is minted once per create intent
in the screen and passed back unchanged on every retry; `_submitting` plus a
disabled Creating… action makes a double submit send once.
Request: `{chat_create:{title,directory,operation_id}}`, plus `backend` only
when it is not `opencode` and `instructions` only when non-blank — the web's
exact shape. The pre-existing dialog title field remains (default `New chat`);
the web's own create pane fixes that title.
- **Rename** is sent by the open dialog, seeded with the effective current title
and sending only `{chat_rename:{session_id,title}}` (trimmed). The dialog stays
open with the server's words on refusal; an accepted reply closes it and the
rows come from a fresh `chat_sessions` read, never a guessed local update. The
refusal is shown only in the dialog — it is not duplicated under the row.
- **Star** sends only `{chat_star, chat_query:{session_id, starred:<flipped
server value>}}`. **Close** / **Reopen** keep the web's confirmation and send
`{chat_query:{session_id}}` to `chat_close` / `chat_reopen`. Every accepted
reply refreshes the rows from the server. A refusal is shown at full width
beneath its row in the host's error colour, so the whole server sentence
wraps instead of being clipped by `CupertinoListTile`'s one-line subtitle, and
a long reason cannot make one Material row taller than the viewport.
- **Local hide** (`Hide on this device`, after Rename and Close/Reopen in the
menu) removes the row without a server call and offers Undo in a floating
one-bar report (`Hidden on this device; the chat stays on the server.`, eight
seconds), the way the web's fixed report behaves. In Material it sits clear of
the New-chat FAB; both hosts keep it out of the body column so 2x text cannot
push the list off screen.
Hidden ids and the read watermark persist through `shared_preferences` under
`pipelines.chat.local.v1`. A first sight of a session seeds its baseline, and
`New` appears only for a strictly newer `updated_at`; opening the row advances
the watermark monotonically. The local store never gates the server read. A
closed row never reports `New`, matching `!session.closed` in the web list and
`!session.closed` in `ChatListPane.kt`.
- No session or title is invented. The local-only `New` marker reads the server
row's recency; explicit unseen marks arriving as pushed `chat_event`s and the
web's `Open` badge are not wired in this list slice.
## Files
- `lib/features/chat/ui/sessions/chat_session_local.dart` — pure hidden/seen
model, tolerant decoder and `SharedPreferences` store.
- `chat_sessions_controller.dart` — per-row action errors, create/rename
throw-paths, server refresh after acceptance, hide/undo, read watermark.
- `chat_sessions_screen.dart`, `chat_sessions_body.dart`,
`session_list_material.dart`, `session_list_cupertino.dart` — full-width row
refusals beneath the tile, local `New`, hide wiring and the floating Undo bar
(placed above the Material FAB and outside the body column).
- `create_chat_dialog.dart` + `chat_create_dialog_frame.dart`,
`rename_chat_dialog.dart` — in-dialog submit, refusal retention, one-shot guard.
- `chat_create_fields.dart` — expanded, ellipsised Material dropdowns with
intrinsic item height so real paths and 2x text fit.
- `session_actions.dart` — `Hide on this device`.
- `chat_adaptive.dart` — `ChatRowError` (full-width, host error colour) and the
native Undo surface.
- `tool/chat_sessions_probe_entry.dart` — stateful fixture: accepted mutations
change the next list read; `Refused title` returns the server's rename refusal;
reopening `Closed fixture` returns a multi-line refusal; `No session title`
omits `chat_session`; `?unseen=1` reports newer recency so the browser can
prove `New` (and its absence on the closed row).
- `tool/chat_sessions_probe.mjs` — real-browser flow for both hosts, including
hide/Undo at 390 and 320/2x, the `New` marker, both dialogs at 320/2x, and a
refused reopen whose full reason is captured in both hosts.
## Checks (actual)
- `flutter test test/features/chat/ui/sessions` — 47 tests pass. New coverage
this pass: a long row refusal keeps the whole sentence on both hosts at
320px/2x (`RenderParagraph.didExceedMaxLines == false`, and the message is not
inside a `CupertinoListTile`/`ListTile`), the Undo bar fits 320px/2x on both
hosts and Undo still restores the row. Earlier coverage retained: create
refusal keeps the dialog and retries the same `operation_id`; double submit
sends one create; a reply without `chat_session` shows exactly
`The server did not return the new chat session.` (no `Bad state:`); rename is
seeded and sends only its two fields; a rename refusal stays in the dialog and
not under the row; star flips one field and refreshes the icon; close refusal
is visible on the row; hide/Undo touches no server action; `New` follows the
local watermark and never appears on a closed row; Material and Cupertino
rename refusals fit 320px at 2x; both create catalogs fit a real directory
path at 320px/2x, including the Material opened menu.
- Review probes (outside the repo, not committed):
`flutter test /Users/alan/.local/share/pipelines/data/artifacts/98/public/review/review_findings_test.dart`
— 5 passed (closed `New`, exact missing-session wording, Material rename
overflow, create dialog with a real path, create dialog at 320/2x).
- `flutter test` — 1006 tests pass.
- `flutter analyze` — no issues.
- `flutter build web` — built successfully.
- Fixture bundles built with
`flutter build web -t tool/chat_sessions_probe_entry.dart --dart-define=CHAT_PROBE_STYLE={material,cupertino}`
and driven in real headless Chrome over isolated loopback ports. Each host
passed list → hide/Undo (390 and 320/2x) → `New` marker → dialogs at 320/2x →
missing-session wording → create → rename → star → close → rename refusal →
refused reopen, and captured fourteen PNGs. The probe asserts: the hidden row
leaves and returns with Undo and the report stays on screen at 320/2x; the open
row reads `New` while the closed row does not; the missing-session dialog shows
the exact web sentence and no `Bad state`; the created/renamed titles come back
from the fixture's `chat_sessions`; the star count increases; the closed row
offers `Reopen`; the rename refusal keeps the dialog with
`a title with usable text is required`; and the refused reopen shows the whole
multi-line server reason under its row on both hosts. Captures are in
`public/chat-list/`:
- `material-{list-phone,list-dark-320-2x,hidden-undo,hidden-undo-320-2x,create-320-2x,rename-320-2x,new-marker,create-missing-session,created-list,renamed-list,starred-list,rename-refusal,row-refusal,row-refusal-320-2x}.png`
- the same fourteen `cupertino-*` files
## Limits / not verified
- Mobile (Android/iOS builds, devices, installs) is unverified.
- Browser evidence uses the in-process fixture, not an authenticated live
server; no real operator chat was created, renamed, starred, closed or hidden.
- The Cupertino list truncates long *titles* at 320px/2x (standard
`CupertinoListTile` behaviour, unchanged). Row refusals are no longer in that
one-line subtitle slot.
- A star/close/reopen refusal stays under its row until a later accepted action
on that row; the web shows a dismissible action-failed report instead.
`PARITY.md` records this as remaining.
- The Undo report is offered for eight seconds; the web uses six
(`installChatSnackbar`). Wording and one-slot replacement match.
- Hiding a row does not close an already-open conversation (the web does); that
belongs to chat-shell state, outside this list slice.
- `New` is driven by the list read plus the local watermark. The web's `Open`
badge and its active/deep-linked read suppression are not in this slice; a
deep-linked conversation is not marked read until the list reopens it.
- The Material FAB can still overlap the last row's action button at 320px/2x.
That is pre-existing list layout; the browser flow filters the refused row into
view for its 320/2x capture rather than changing the list.
- The 320/2x browser dialog captures show the fixture's default
`/workspace/demo`; selecting the real long path at that size is covered by the
widget test, not by a rendered capture.
- In the real browser, the Cupertino Undo coordinate tap is swallowed by Flutter
web's semantics DOM node; the probe activates the same rendered button through
its semantics click. Material accepts the coordinate tap. Widget tests tap the
native control directly.
- The candidate is uncommitted; no merge, push or deploy was performed.