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
@@ -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),
)
}
}