5.4 KiB
A1-viewer — native in-app artifact viewer
What changed
The recorded-artifact gallery now opens a reusable native viewer for a viewer
artifact with a resolved url. Images are drawn in-app from fetched bytes,
text/plain is selectable fetched text, .md/.markdown or text/markdown
uses an injected markdown builder (default: plain selectable text), and every
other type shows an explicit cannot-preview state with the existing Open/Copy
link actions. An external origin is opened in the viewer as a marked,
unfetched page; unsafe and absent urls stay in the facts dialog.
| File | Responsibility |
|---|---|
lib/features/artifacts/domain/artifact_preview.dart |
Safe-url preview classification and exact unavailable/unsupported wording |
lib/features/artifacts/ui/artifact_viewer_page.dart |
Page, paging state, fetch generations, cache, Open/Copy |
lib/features/artifacts/ui/artifact_viewer_body.dart |
Facts, position, live status, preview surface, actions, Previous/Next |
lib/features/artifacts/ui/artifact_viewer_content.dart |
Image/text/markdown/loading/error/unsupported surface and markdown seam |
lib/features/artifacts/ui/artifact_viewer_fetch.dart |
ArtifactFetch seam, status/bytes result, network failure |
lib/features/artifacts/ui/artifact_viewer_fetch_web.dart |
Web fetch with credentials: 'same-origin' |
lib/features/artifacts/ui/artifact_viewer_fetch_stub.dart |
Native HttpClient, no cookies, no redirects |
lib/features/artifacts/ui/artifact_gallery_page.dart |
Opens the viewer for previewable same-origin rows; optional fetch/builder seams |
lib/features/artifacts/domain/artifact_kind.dart |
text/plain joins the viewer list; video stays pageable but unpresentable |
lib/features/artifacts/domain/gallery_navigation.dart |
One visit identity helper shared by rows and viewer |
tool/artifact_gallery_probe.dart / .mjs |
Gallery + viewer fixture, both hosts, 320/2x, real PNG, 404 and external states |
test/features/artifacts/domain/artifact_preview_test.dart |
Same-origin, external, unsafe, absent and unsupported plans |
test/features/artifacts/ui/artifact_viewer_page_test.dart |
Image no-tab, text content, markdown seam, external refusal, unsupported, paging/clamp, loading/404/network, Cupertino |
Behaviour
- The gallery row identity is the recorded stage/visit plus recorded url (or name), so paging starts on exactly the selected row.
- Preview pages are
pagedArtifacts(groups)in gallery order. Previous/Next usepagedIndexand are disabled at both ends; a one-page viewer has no pager. - The viewer keeps the recorded MIME/size and
stage · visit Nfacts visible on every page, along with the position label (3 of 4 · image/png). - Open/Copy link are the existing external actions and operate on the resolved url. They are not previews.
- Fetch failures report
The server answered <status>.; network failures reportCould not load preview: …; loading saysLoading preview…. An image that cannot decode says so. - Native
Back/AppBar/CupertinoNavigationBar close returns to the gallery row list and restores the row focus captured before the push.
Checks actually run
flutter analyze # No issues found! (1.2s)
flutter test test/features/artifacts \
test/features/runs/ui/run_artifacts_action_test.dart # 104 passed
flutter build web # ✓ Built build/web
flutter build web -t tool/artifact_gallery_probe.dart # ✓ Built build/probe-gallery
node tool/artifact_gallery_probe.mjs --root build/probe-gallery --out … # 21 checks, 23 captures
Browser captures: shared
artifact-viewer-captures/ (material/cupertino image, text, unsupported,
HTTP 404, external marked page, 320/2x both hosts, plus the retained gallery
states). The viewer text assertion for fetched content relies on the rendered
capture; Flutter web did not expose SelectableText content in the extracted
DOM text. The widget test asserts the fetched value directly.
Honest limits
- No HTML embed, video player, download or file-share action was added.
- Only web was built and captured. Android/iOS were not built, installed or device-tested.
- The default markdown seam is plain selectable text; the markdown lane can
inject a real renderer through
ArtifactMarkdownBuilder. - The fixture and browser evidence use loopback files only; no server, real run or operator session was touched.
Manager completion after a harness transport deadline
The Code visit ended with HARNESS TRANSPORT: context deadline exceeded; the
session was no longer active and every edit was retained. No retry was started.
The manager ran the full artifacts suite (99 tests pass) and analysis, rebuilt the
gallery/viewer fixture, and ran the probe: it passes and writes the viewer states
(text, image, unsupported, external-origin marked, HTTP error, plus 320/2x and
Cupertino variants). The Material text viewer and the Cupertino 320/2x image
viewer were inspected: recorded facts, page position, in-app image, paging at both
ends and Open/Copy link.
Deliberate limits: markdown is rendered through an injected builder that defaults to selectable plain text (the markdown lane supplies the real renderer later), external-origin urls are never fetched, and video/CSV/archives are explicitly unsupported rather than faked. Share/download/file-upload remain open items.