Make the run summary's artifacts gallery a collapsed section

The run summary led with the artifacts gallery, but it was always open, so a
long run's grid pushed the run's own facts below the fold. The gallery now
sits in one collapsed-by-default section in the same place, with a header that
describes itself while collapsed.

- RunDetailScreen.kt: RunSummaryTab renders the gallery through the shared
  LazyListScope.collapsibleSection, keyed "artifacts" and seeded with
  rememberSectionExpansion(run.id), so a run opened fresh starts collapsed and
  the operator's choice persists per run across tab switches and config
  changes. Order is unchanged: the section still leads the summary and the
  facts item follows it. Expanding composes the unchanged ArtifactGallery;
  collapsing composes nothing.
- ArtifactGroups.kt: new pure runArtifactsHeader(steps, executing) builds the
  self-describing header - singular/plural title, recorded count and
  "· partial capture" when any visit excluded or omitted files; empty runs
  reuse the shared artifactsEmptyMessage. Its count equals runArtifactGroups'
  tile total, so the header and the expanded gallery cannot disagree.
- ArtifactGroupsTest.kt: four header tests covering count, singular vs plural,
  the partial-capture notes and the empty case, plus a count-matches-gallery
  assertion.
- android/README.md: records the change and its verification evidence.

Android only; no new dependency, no run started from the app, device work on
the operator's Pixel 10 Pro Fold (58281FDCG000JF). Verified: 269/0/0/0 unit
tests, clean assembleDebug and published APK LAN URL 200.
This commit is contained in:
2026-10-16 17:51:56 +01:00
parent 95150c79c5
commit e1c531a537
4 changed files with 236 additions and 13 deletions
+82
View File
@@ -3580,3 +3580,85 @@ matched `2adaf03e…`), so any capture could not be attributed to this build. Th
wide/narrow captures above predate the refactor; the refactor changes no UI
pixels, so they remain representative of the gallery this code renders.
## Collapsible artifacts gallery in the run summary (16 Oct 2026)
The artifacts gallery led the run summary but was always open, so a long run's
grid pushed the run's own facts below the fold. It is now one
collapsed-by-default section in the same place. `android/` only; no dependency
was added (the chevron is the existing `material-icons-extended`
`KeyboardArrowDown` the shared `SectionHeader` already uses), no run was started
from the app, and every device command targeted the operator's Pixel 10 Pro Fold
(`58281FDCG000JF`), never an emulator.
- **One collapsed section, same place.** `RunDetailScreen.kt`'s `RunSummaryTab`
renders the gallery through the shared `LazyListScope.collapsibleSection`,
keyed `"artifacts"` and seeded with `rememberSectionExpansion(run.id)`, so a
run opened fresh starts collapsed and the operator's expand/collapse choice
survives Summary↔tab switches, configuration changes and rotation exactly like
every other section. The order is unchanged: the artifacts section still leads
the summary and the facts item follows it.
- **A self-describing header.** The new pure `runArtifactsHeader(steps,
executing)` (`ui/ArtifactGroups.kt`) builds the header text — the title (its
singular form for exactly one artifact), how many the run recorded, and
`· partial capture` when any visit excluded or omitted files; with no artifacts
it reuses the shared `artifactsEmptyMessage`. Its count is exactly
`runArtifactGroups`'s tile total, so the header and the expanded gallery can
never disagree.
- **The gallery itself is unchanged.** Expanding composes the same
`ArtifactGallery` (the width-derived thumbnail grid, tap for full size, the
non-media tiles with name, size and content type plus their open/copy/share
actions); collapsing composes nothing. The stage pane's per-visit artifacts
section and every other summary section are untouched.
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 8.11.1 from the
wrapper cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--offline`,
every Gradle command with `--no-daemon`):
- `gradle --no-daemon --offline :app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the
test-result XMLs aggregate to **269 tests, 0 failures, 0 errors, 0 skipped**.
`ArtifactGroupsTest` gained `headerReportsTheCountWithASingularTitleForOne`,
`headerAddsPartialCaptureOnlyWhenFilesWereExcludedOrOmitted`,
`headerEmptyCaseUsesTheSharedEmptyWording` and
`headerCountMatchesTheGalleryRecordedTotal`.
- `gradle --no-daemon --offline :app:assembleDebug` → `app-debug.apk`
**18,011,393 bytes**, sha256
`c5655269e490db34cbacccf68eaec468a3a41c46c661b41e6ad2d92295235247`; installed
with `adb -s 58281FDCG000JF install -r`, and the pulled `base.apk` sha matched
the local build, so the captures below are attributed to this exact build.
- Run **136** (pipeline id 11 v1, `succeeded`, 17 artifacts) on the Pixel:
- **Wide** (inner display, 2152×2076 @330 ≈ 1043dp):
`summary_wide_collapsed.png` shows the summary led by a lone collapsed
`Artifacts · 17 recorded · partial capture` header (right chevron) with the
run's facts immediately below and no gallery; `summary_wide_expanded.png`
shows the same header expanded to the unchanged gallery — the
`implementer · visit 1` and `ui_reviewer · visit 1` groups of image
thumbnails plus the `chat_stub_approval.py` (`<>` code glyph) and `stub.log`
(log glyph) tiles with their names, `9.3 KiB`/`220 B` sizes and share/copy
actions.
- **Narrow** (`wm size 1080x2152` on the inner display ≈ 524dp, reset to the
native size afterwards): `summary_narrow_collapsed.png` and
`summary_narrow_expanded.png` show the same collapsed header and, expanded,
the same gallery re-flowed to four cells per row (wide uses five).
- **Persistence.** `uiautomator dump` reported `Artifacts · 17 recorded ·
partial capture, collapsed` on a freshly opened run; toggling it and
round-tripping Summary → Graph → Summary, and a `wm size` configuration
change, both kept the operator's expanded/collapsed choice.
- `adb -s 58281FDCG000JF logcat -d | grep -cE 'FATAL EXCEPTION|E
AndroidRuntime'` returned 0; the screen stayed awake (`svc power stayon usb`
+ `KEYCODE_WAKEUP`) and every capture used `screencap -p -d <display-id>` +
`adb pull`. Screenshots, `uiautomator` dumps and the APK are in
`…/artifacts/155/1/`.
- **APK publish.** `app-debug.apk` copied to
`…/artifacts/155/1/pipelines-debug-wip-95150c7.apk` (`95150c7` = short `HEAD`;
the working tree is uncommitted WIP on top of it); `shasum -a 256` matched.
`curl -I http://10.0.0.249:8080/artifacts/155/1/pipelines-debug-wip-95150c7.apk`
returned `HTTP/1.1 200 OK`, `Content-Type:
application/vnd.android.package-archive`, `Content-Length: 18011393`.
Not verified in this pass: no device capture exercises the empty or the
single-artifact header wording (both are covered by the `runArtifactsHeader`
unit tests); the narrow window was produced with a `wm size` override on the
inner display rather than a physical fold, then reset; `:app:lintDebug` was not
re-run (its only known findings remain the two pre-existing `NewApi` errors for
`android:windowLightNavigationBar`).
@@ -54,3 +54,27 @@ fun artifactsEmptyMessage(executing: Boolean): String =
} else {
"No artifacts recorded for this run."
}
/**
* The run summary's Artifacts section header, complete on its own while the
* section is collapsed: the title, how many artifacts the run recorded (the
* title takes its singular form for exactly one) and "partial capture" when any
* visit excluded or omitted files. It mirrors the per-visit [artifactsSummary]
* vocabulary at run level and reuses the shared [artifactsEmptyMessage] for the
* empty case, so a run with nothing recorded still gets a self-describing
* collapsed header. The recorded count is exactly the number of tiles
* [runArtifactGroups] yields, so the header and the expanded gallery can never
* disagree. Pure.
*/
fun runArtifactsHeader(steps: List<RunStep>, executing: Boolean): String {
val recorded = steps.sumOf { it.artifacts.orEmpty().size }
if (recorded == 0) return artifactsEmptyMessage(executing)
val partial = steps.any { it.artifactsSkipped > 0 || it.artifactsTruncated > 0 }
return buildString {
append(if (recorded == 1) "Artifact" else "Artifacts")
append(" · ")
append(recorded)
append(" recorded")
if (partial) append(" · partial capture")
}
}
@@ -52,7 +52,6 @@ import net.awan.pipelines.data.protocol.SessionEvidence
import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.ArtifactGroup
import net.awan.pipelines.ui.LoadState
import net.awan.pipelines.ui.artifactsEmptyMessage
import net.awan.pipelines.ui.components.CodeBlock
import net.awan.pipelines.ui.components.ColoredChip
import net.awan.pipelines.ui.components.DetailTabBody
@@ -84,6 +83,7 @@ import net.awan.pipelines.ui.graph.graphColors
import net.awan.pipelines.ui.graph.outcomeColor
import net.awan.pipelines.ui.graph.rememberArtifactSelection
import net.awan.pipelines.ui.runArtifactGroups
import net.awan.pipelines.ui.runArtifactsHeader
import net.awan.pipelines.ui.theme.ICON_INLINE_DP
import net.awan.pipelines.ui.theme.ICON_STATUS_DP
import net.awan.pipelines.ui.theme.SPACING_L
@@ -338,6 +338,7 @@ private fun ConfirmDialog(
* id/version, current stage, workspace, content hash, start/finish/duration and
* the failure diagnostic.
*/
@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun RunSummaryTab(
run: RunDetail,
@@ -351,23 +352,35 @@ private fun RunSummaryTab(
) {
val text = pipelinesText()
val state = runStateOf(run.status)
// The artifacts section starts collapsed and its expand/collapse choice is
// remembered/saved per run id, so a different run reseeds it and a run opened
// fresh starts collapsed. Both the header and the gallery read the same
// snapshot, so they can never disagree.
val artifactsExpansion = rememberSectionExpansion(run.id)
val artifactsHeader = remember(run.steps, run.executing) {
runArtifactsHeader(run.steps, run.executing)
}
DetailTabBody(wide, modifier) { columnModifier ->
LazyColumn(
modifier = columnModifier,
contentPadding = PaddingValues(vertical = SPACING_L),
) {
// The artifacts gallery leads the summary: the captured screenshots
// are the first thing the operator sees, with the run's own facts
// below it.
item(key = "run-artifacts") {
Column(
modifier = Modifier.fillMaxWidth().padding(horizontal = SPACING_L, vertical = SPACING_S),
verticalArrangement = Arrangement.spacedBy(SPACING_S),
) {
Text("Artifacts", style = text.sectionHeader)
if (artifactGroups.isEmpty()) {
Text(artifactsEmptyMessage(run.executing), style = text.meta)
} else {
// The artifacts gallery still leads the summary, but inside one
// collapsed section: its header alone carries the run's capture
// wording until the operator expands it, and expanding reveals the
// unchanged gallery (nothing when no artifacts were recorded).
collapsibleSection(
title = artifactsHeader,
key = SUMMARY_ARTIFACTS_KEY,
expanded = artifactsExpansion.isExpanded(SUMMARY_ARTIFACTS_KEY),
onToggle = { artifactsExpansion.toggle(SUMMARY_ARTIFACTS_KEY) },
) {
if (artifactGroups.isNotEmpty()) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = SPACING_L, vertical = SPACING_S),
) {
ArtifactGallery(
groups = artifactGroups,
configuredServerUrl = configuredServerUrl,
@@ -748,4 +761,9 @@ private fun EvidenceDetails(evidence: SessionEvidence, modifier: Modifier = Modi
}
}
// The run summary's artifacts section key: stable so its expand/collapse choice
// is remembered consistently (it is namespaced under the summary tab's saved
// state and reseeded by run id).
private const val SUMMARY_ARTIFACTS_KEY = "artifacts"
private const val POLL_INTERVAL_MILLIS = 1_000L
@@ -15,11 +15,15 @@ class ArtifactGroupsTest {
sequence: Int,
visit: Int = 0,
artifacts: List<StageArtifact>? = null,
skipped: Int = 0,
truncated: Int = 0,
) = RunStep(
sequence = sequence,
stage = stage,
control = ControlEvidence(visit = visit),
artifacts = artifacts,
artifactsSkipped = skipped,
artifactsTruncated = truncated,
)
private fun artifact(name: String, url: String = "/artifacts/$name") =
@@ -95,4 +99,99 @@ class ArtifactGroupsTest {
assertTrue(pending.startsWith("Artifacts · "))
assertTrue(pending.contains(ARTIFACT_CAPTURE_PENDING))
}
@Test
fun headerReportsTheCountWithASingularTitleForOne() {
assertEquals(
"Artifact · 1 recorded",
runArtifactsHeader(
listOf(step("planner", sequence = 1, visit = 1, artifacts = listOf(artifact("a")))),
executing = false,
),
)
assertEquals(
"Artifacts · 3 recorded",
runArtifactsHeader(
listOf(
step("planner", sequence = 1, visit = 1, artifacts = listOf(artifact("a"), artifact("b"))),
step("build", sequence = 2, visit = 1, artifacts = listOf(artifact("c"))),
),
executing = false,
),
)
}
@Test
fun headerAddsPartialCaptureOnlyWhenFilesWereExcludedOrOmitted() {
assertEquals(
"Artifact · 1 recorded",
runArtifactsHeader(
listOf(step("planner", 1, 1, listOf(artifact("a")))),
executing = false,
),
)
assertEquals(
"Artifacts · 2 recorded · partial capture",
runArtifactsHeader(
listOf(step("planner", 1, 1, listOf(artifact("a"), artifact("b")), skipped = 1)),
executing = false,
),
)
assertEquals(
"Artifacts · 2 recorded · partial capture",
runArtifactsHeader(
listOf(step("planner", 1, 1, listOf(artifact("a"), artifact("b")), truncated = 3)),
executing = false,
),
)
// A visit that recorded nothing but excluded files still marks the run's
// capture as partial.
assertEquals(
"Artifact · 1 recorded · partial capture",
runArtifactsHeader(
listOf(
step("planner", 1, 1, listOf(artifact("a"))),
step("build", 2, 1, artifacts = emptyList(), skipped = 2),
),
executing = false,
),
)
}
@Test
fun headerEmptyCaseUsesTheSharedEmptyWording() {
assertEquals(
artifactsEmptyMessage(executing = true),
runArtifactsHeader(emptyList(), executing = true),
)
assertEquals(
artifactsEmptyMessage(executing = false),
runArtifactsHeader(emptyList(), executing = false),
)
// Excluded/omitted counts with no recorded artifacts still read as empty:
// the partial-capture note never accompanies the empty summary.
assertEquals(
artifactsEmptyMessage(executing = false),
runArtifactsHeader(
listOf(step("planner", 1, 1, artifacts = emptyList(), skipped = 2, truncated = 1)),
executing = false,
),
)
}
@Test
fun headerCountMatchesTheGalleryRecordedTotal() {
val steps = listOf(
step("planner", 1, 1, listOf(artifact("a"), artifact("b"))),
step("planner", 2, 2, artifacts = emptyList()),
step("build", 3, 1, listOf(artifact("c"))),
)
// Every recorded artifact is exactly one gallery tile; the header can
// never announce a count the expanded gallery does not render.
assertEquals(3, runArtifactGroups(steps).sumOf { it.artifacts.size })
assertEquals(
"Artifacts · 3 recorded",
runArtifactsHeader(steps, executing = false),
)
}
}