Open artifact images in a full-screen zoomable viewer

Tapping an image artifact (run summary grid, per-visit list or stage pane,
all rendered through ArtifactGallery) now opens a new scrim-backed
full-screen viewer instead of the former small centred dialog, which is
removed rather than stacked.

- ArtifactViewer.kt renders a full-bleed Dialog (usePlatformDefaultWidth =
  false, decorFitsSystemWindows = false) whose content re-applies
  paneSafeArea() so the dark backdrop reaches the edges while respecting
  status bar, cutout and navigation bar. A top-right row keeps the
  open-in-new and copy-link actions and adds a close button over a
  translucent scrim capsule.
- Gestures: pinch zooms about the centroid, drag pans via the existing
  graph zoomAbout, double-tap toggles fit <-> 2.5x, and a downward swipe at
  fit dismisses; a plain tap does nothing. Zoom clamps to [1x, 5x] and the
  new pure clampImageOffset keeps pan inside the scaled image. Zoom state is
  keyed on the url, so closing the viewer or opening another image resets to
  fit/centred. System Back and the close button dismiss the viewer without
  closing the pane behind it.
- Loading goes through the existing cached, off-main-thread
  rememberArtifactBitmap/ArtifactImageState path with distinct loading and
  error states, drawn in the light inverseSurface role that contrasts with
  the always-black scrim.
- Pure helpers fitImageSize, clampImageOffset and toggleZoomScale are
  covered by the new ArtifactViewerTest. ArtifactImage.kt widens
  rememberArtifactBitmap/ArtifactImageState to internal and Artifacts.kt
  replaces FullSizeArtifactDialog with ArtifactViewer (openArtifact made
  internal).
- android/README.md documents the viewer, its gestures and the evidence
  gathered on emulator-5554.
This commit is contained in:
2026-10-16 06:35:08 +01:00
parent 7b61906e1b
commit d339827b5f
5 changed files with 575 additions and 45 deletions
+87
View File
@@ -1673,3 +1673,90 @@ image validated):
http://10.0.0.249:8080/artifacts/86/1/pipelines-debug-wip-5ad4b58.apk` returned
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18029402`.
## Full-screen artifact image viewer (16 Oct 2026)
Tapping an image artifact now opens a full-screen viewer (in the run summary
grid, the per-visit artifacts list and the stage pane, which all render through
`ArtifactGallery`), replacing the former small centred dialog rather than stacking
on it. `android/` only; no dependency was added, no run was started from the app,
and every device command targeted `emulator-5554` (never the attached Pixel, never
`emulator-5556`).
- **Viewer.** New `ui/graph/ArtifactViewer.kt` renders a scrim-backed full-screen
`Dialog` (`usePlatformDefaultWidth = false`, `decorFitsSystemWindows = false`);
a `SideEffect` stretches the dialog window to `MATCH_PARENT`, fits no system
insets and draws into the display cutout (each API-guarded), so the dark backdrop
reaches every edge while the content re-applies `paneSafeArea()` (status bar,
cutout, navigation bar) itself. A top-right row keeps the open-in-new and
copy-link actions and adds a close button, backed by a translucent scrim
capsule so the light icons stay legible over a bright image. `dumpsys window`
confirms the dialog
window frame is `[0,0][2076,2152]` (previously inset to `[0,136][2076,2074]`).
- **Gestures.** Pinch zooms about the centroid and a drag pans via the existing
graph `zoomAbout`; a double-tap toggles between fit and 2.5x; a downward swipe at
fit dismisses; a plain tap does nothing. Zoom is clamped to `[1x, 5x]` of fit and
pan is clamped by the new pure `clampImageOffset` so the scaled image can never
be dragged off screen (each axis centred when smaller than the viewport, pinned
to `[viewport - content, 0]` when larger). Zoom state is remembered on the url,
so closing the viewer or opening another image starts again at fit/centred.
System Back and the close button dismiss the viewer without closing the pane
behind it (verified: 0 `Close viewer` nodes and the run detail still shown after
Back). The image loads through the existing cached, off-main-thread
`rememberArtifactBitmap` (now `internal`, reusing the shared fetch/decode path),
with a "Loading image…" spinner and a distinct "Couldn't load image." state. The
loading/error/unavailable message is drawn in the light `inverseSurface` role,
which contrasts with the always-black scrim (the previous `inverseOnSurface`
was a dark colour on the scrim, measured ~1.6:1).
- **Pure helpers.** `fitImageSize`, `clampImageOffset` and `toggleZoomScale` in
`ArtifactViewer.kt`; `ArtifactViewerTest` covers them (fitting, centre/edge
clamping, the toggle, and an anchored-zoom-then-clamp invariant). `zoomAbout`
and the loading path are the existing shared ones, not copies.
Evidence obtained in this pass (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle
8.11.1 from the wrapper cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:testDebugUnitTest :app:assembleDebug --console=plain` →
`BUILD SUCCESSFUL`; the result XMLs aggregate to **149 tests, 0 failures, 0
errors, 0 skipped** (up from 140: the new `ArtifactViewerTest`).
`app/build/outputs/apk/debug/app-debug.apk` is 18,043,579 bytes, sha256
`1b3653dbdce9d62fc8dcfdcb986635829b70db38437d6769c77f91d16b7d6b3a`.
- `gradle :app:lintDebug` → only the two **pre-existing** `windowLightNavigationBar`
NewApi errors (`values/themes.xml`, `values-night/themes.xml`); no new lint
finding is attributed to `ArtifactViewer.kt` (39 warnings, down from 40 once the
cutout constant was API-guarded).
- On `emulator-5554` against the live server, the run 90 summary artifacts grid
was opened and `captures/viewer/` (git-ignored, every PNG validated by
`scripts/capture_png.sh -s emulator-5554`) holds: `01_viewer_open`,
`02_doubletap_zoom`, `03_pinch_zoom`, `04_pan`, `05_clamp_1..3`,
`06_fit_reset`, `07_swipedown_dismissed`, `08_back_dismissed`, `09_loading`,
`10_error`, `contact_sheet.png` and `viewer_gestures.mp4` (29 s). Pairwise
pixel diffs (`captures/imgdiff.py`): open→double-tap 19.72, double-tap→pinch
6.72, pinch→pan 5.29, and `05_clamp_1→2` 0.75 → `05_clamp_2→3` **0.0** (the
image is pinned at its bound and cannot be panned further off screen);
fit-reset diff 0.01 (double-tap restores fit exactly). After a swipe-down and
after Back the UI dump has 0 `Close viewer` nodes and the run detail is shown;
a single tap leaves the viewer open (diff 0.02). `Loading image…` and
`Couldn't load image.` were produced against a hanging and a 404 endpoint.
- `adb shell input` cannot synthesise a two-finger pinch (it injects one pointer)
and the shell cannot write `/dev/input` (`sendevent` is permission-denied on
this production image), so pinch and the timed double-tap were driven with a
test-only `app_process` injector (`captures/viewer/tools/Injector.java` →
`Injector.jar`) that injects multi-pointer `MotionEvent`s via the hidden
`InputManager.injectInputEvent`, the same mechanism the platform `input` command
uses. It is verification tooling only, not part of the app or its dependencies.
- `adb -s emulator-5554 logcat -d` held 0 `FATAL EXCEPTION` / 0 `E AndroidRuntime`
lines.
- **APK publish.** Copied to
`~/.local/share/pipelines/data/artifacts/91/1/pipelines-debug-wip-7b61906.apk`
(`7b61906` = `git rev-parse --short HEAD`). `curl -I
http://10.0.0.249:8080/artifacts/91/1/pipelines-debug-wip-7b61906.apk` returned
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18043579`, and a streamed `GET | shasum -a 256` equalled the
local file's `1b3653db…`. At 17.2 MiB it exceeds the 8 MiB per-file inventory
cap, so it is served by direct URL only.
Not verified in this pass: a real hardware fold (the emulator is the 2076x2152
inner display at 390 dpi); an Android 8/9 device branch (the `layoutInDisplayCutout
Mode = SHORT_EDGES` fallback is compiled and lint-guarded but only the API 36 path
ran).