Show per-visit artifacts in the Android client and fix the top inset

Implements four Android-only client changes (no server, Go, installer or
Docker changes; nothing under android/ was left uncommitted).

- Per-visit artifacts: model StageArtifact{name, size_bytes, content_type,
  url} plus artifacts/artifacts_skipped/artifacts_truncated on RunStep with the
  exact internal/protocol/runs.go wire names, covered by ProtocolModelTest.
  Add a dedicated artifacts section to the stage detail sheet: one row per
  file with name, humanBytes size and content type, open (ACTION_VIEW) and
  copy-link actions, resolving the server-relative url against the configured
  server URL (never a hardcoded host) and disabling those actions with a hint
  when none is set. Images render an inline thumbnail with a full-size view on
  tap; other types get a type icon. Empty/partial copy matches the TUI
  ("capture pending", "not recorded for this visit", partial-capture notes).
  Timeline rows carry a subtle AttachFile indicator via a pure hasArtifacts
  helper. Pure helpers (humanBytes, resolveArtifactUrl, isImageContentType,
  artifactsSummary, artifactCaptureNotes, artifactMetaLine) carry unit tests.
- Collapsed defaults and self-describing titles: rememberSectionExpansion now
  tracks the set of expanded keys (default emptySet) so every inner section in
  the run detail and pipeline detail starts collapsed while operator choices
  still persist across configuration changes. Evidence sections are titled
  from the correlated step/stage/visit and backend identity instead of a bare
  index; field sections fall back to their prefix so a blank key never yields
  an empty title. Covered by DetailTabsTest.
- Single top inset: zero the outer Scaffold contentWindowInsets so the inner
  Material 3 app bars own the status-bar inset once; the connection banner
  owns the status-bar inset while visible (NavHost consumes it below), and the
  floating destinations pill clears the navigation bar.
- Publish the debug APK as a run artifact named by the short SHA, documented
  with the verified LAN URL and sha in android/README.md.

Verification (unit tests, assembleDebug, live-server APK and run 55 step 4
artifact fetches, emulator narrow/wide drives) is recorded in android/README.md.
This commit is contained in:
2026-10-15 21:16:18 +01:00
parent 914345cb31
commit 059c85add8
21 changed files with 938 additions and 25 deletions
+103
View File
@@ -443,3 +443,106 @@ physical device was not re-installed by this pass either).
with `adb emu kill` plus `kill -9` of any surviving
`qemu-system-aarch64-headless`.
## Per-visit artifacts, collapsed defaults, single top inset, APK publish (15 Oct 2026)
Four changes were implemented in `android/` only. Nothing in the Pipelines
server, its Go source, Docker/compose files or the installer was touched, no run
was started from the app, and the 8 MiB per-file artifact cap
(`internal/server/artifacts.go` `maxArtifactFileBytes`) was left unchanged.
- **Artifacts.** `RunStep` now models the server's `artifacts`
(`StageArtifact{name, size_bytes, content_type, url}`), `artifacts_skipped` and
`artifacts_truncated` with the exact `internal/protocol/runs.go` wire names.
`ui/graph/Artifacts.kt` renders one row per file (name, `humanBytes` size,
content type) with an open (`ACTION_VIEW`) and a copy-link action, an inline
image thumbnail (OkHttp + `BitmapFactory` with `inSampleSize` off the main
thread, bytes cached once per URL) and a full-size view on tap; other types get
a type icon. URLs are resolved by `ServerUrl.resolveArtifactUrl` against the
configured server URL (ws→http/wss→https, `/connect` dropped), never a
hardcoded host; with no URL configured the actions are disabled and a hint is
shown. Empty/partial states reuse the TUI strings from
`internal/tui/file_changes.go`. The Timeline rows carry a subtle `AttachFile`
indicator (`hasArtifacts`) with a per-visit `contentDescription`.
- **Collapsed defaults + self-describing titles.** `SectionExpansionState` now
persists the set of *expanded* keys (default empty), so every inner section in
the run detail (input/output/evidence) and pipeline detail (Versions, Source)
starts collapsed while operator choices still survive configuration changes.
Evidence section titles are built by `evidenceSectionTitle`, e.g.
`Evidence - step 4, ui_reviewer visit 1, opencode`, correlating
`SessionEvidence.sequence` with the run's steps once per data change; a blank
field key already falls back to its prefix and never yields an empty title.
- **Top inset.** The outer `Scaffold` in `PipelinesApp` now uses
`contentWindowInsets = WindowInsets(0, 0, 0, 0)` so the inner Material 3 app
bars own the status-bar inset exactly once (removing the duplicate top band);
the floating pill clears the navigation bar via
`windowInsetsPadding(WindowInsets.navigationBars)`. While the connection banner
is visible it owns the status-bar inset (padding inside its `Surface`) and the
`NavHost` below consumes `statusBars` so the app bar is not double-padded.
- **APK publish.** `:app:assembleDebug` produced
`app/build/outputs/apk/debug/app-debug.apk` (18,181,943 bytes, sha256
`41c9df314da40bb19df7e3d90f27a83339a275768cefee537c4ba796efe01eab`, rebuilt
after the follow-up fixes below), copied to
`~/.local/share/pipelines/data/artifacts/58/1/pipelines-debug-d00bd37.apk`
(`d00bd37` = short SHA of the last commit touching `android/`) with a matching
`shasum -a 256`. At 17.3 MiB it exceeds the 8 MiB per-file inventory cap
(`internal/server/artifacts.go` `maxArtifactFileBytes = 8 << 20`), so it is
served by direct URL but deliberately absent from the step inventory.
### Follow-up fixes (code review of the first pass)
- `ui/graph/Artifacts.kt` hoists its derivations with `remember(step)` /
`remember(artifact.url, configuredServerUrl)` / `remember(artifact)` so the
summary text, the partial-capture notes, the resolved URL, the image test and
the meta line are computed once per data change, never per recomposition.
- `ArtifactBytesCache` is a byte-bounded `LruCache` (16 MiB) rather than an
unbounded map, so a long session cannot retain every fetched artifact.
- `artifactCaptureNotes` returns no notes for an empty artifact list, matching
`internal/tui/file_changes.go` `artifactLines` (which returns nothing when the
list is empty); the empty-state summary is unchanged.
- The field-section title fallback is the pure `fieldSectionTitle`, covered by
`TimelineTest#fieldSectionTitleFallsBackToPrefixAndIsNeverEmpty`.
Evidence actually 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`):
- `:app:testDebugUnitTest` reported **103 tests, 0 failures** (new
`ProtocolModelTest#runStepArtifactsParseWithExactWireNamesOrAbsent`,
`FormatTest` cases for `humanBytes`/`artifactMetaLine`/`artifactsSummary`/
`artifactCaptureNotes`, `ServerUrlTest#resolvesArtifactUrlAgainstTheConfiguredServerUrl`
and `resolveArtifactUrlReturnsNullWhenUnconfiguredOrBlank`,
`DetailTabsTest#sectionsStartCollapsedAndToggleIsRemembered`, and `TimelineTest`
cases for `hasArtifacts`/`evidenceSectionTitle`/`fieldSectionTitle`).
- `:app:assembleDebug` succeeded (18,181,943-byte debug APK).
- `:app:lintDebug` still reports the two pre-existing `NewApi` errors for
`android:windowLightNavigationBar` (minSdk 26) in `res/values/themes.xml` and
`res/values-night/themes.xml`; those files were not modified by this change.
Verified against the live server (running as
`pipelines-server -addr 0.0.0.0:8080`, the app configured
`ws://10.0.2.2:8080/connect`; LAN address `10.0.0.249` from `ipconfig getifaddr en0`):
- The published APK is served at
`http://10.0.0.249:8080/artifacts/58/1/pipelines-debug-d00bd37.apk` (LAN), not a
hardcoded `localhost`/`10.0.2.2` host. `curl -I` returned `HTTP/1.1 200 OK`,
`Content-Type: application/vnd.android.package-archive`, `Content-Length:
18181943`; a streamed `GET` piped to `shasum -a 256` returned
`41c9df314da40bb19df7e3d90f27a83339a275768cefee537c4ba796efe01eab`, equal to the
local `app-debug.apk`.
- Run 55 step 4's real artifacts are served:
`curl -I http://10.0.0.249:8080/artifacts/55/4/graph_crop_error_rejected.png`
→ 200, `image/png`, 52,168 bytes and
`.../swatch_error_vs_rejected.png` → 200, `image/png`, 5,008 bytes.
- The server has no HTTP inventory endpoint (only `GET /artifacts/…`,
`GET /healthz`, `GET /connect`); the step inventory is delivered over the
websocket and clips entries larger than `maxArtifactFileBytes` (8 MiB), so the
17.3 MiB APK is intentionally absent from it.
Not verified in this pass — no device was attached (`adb devices` listed no
devices, and no emulator was running): the on-device/emulator narrow/wide
before/after screenshots for the top inset and the collapsed sections, the
`logcat` sweep and the install on the Pixel 10 Pro Fold. The previous pass's
emulator screenshots for the artifacts sheet (narrow/wide run detail) are in
`~/.local/share/pipelines/data/artifacts/58/3/`.