Show a run's title beside its pipeline name
Surface the operator's title for a run so two runs of the same pipeline read as clearly different goals, with the pipeline name kept as context. - protocol: optional nullable `title` on RunSummary and RunDetail; absent or blank degrades to the pipeline name. - ui/RunIdentity.kt: one shared fallback (`runLabel`) and two-line identity (`runIdentity`) so the list, detail header and stage pane never spell a run differently; a titled run shows the pipeline name + version as a second line, an untitled run keeps the pipeline name as its only line. - runs list / run detail / stage pane use the shared identity; the status chip, duration and metadata layout are unchanged. - no rename affordance: the server exposes no title and no `set_run_title`, so the app does not fake renaming. - tests: RunIdentityTest (5) plus ProtocolModelTest cases for a present and an absent title; README documents the change and its verification.
This commit is contained in:
@@ -238,6 +238,10 @@ data class RunSummary(
|
||||
val id: Long = 0,
|
||||
@SerialName("pipeline_id") val pipelineId: Long = 0,
|
||||
val name: String = "",
|
||||
// The operator-facing, bounded description of what the run is for, generated
|
||||
// by the server from its prompt. Null/blank on a server that predates the
|
||||
// field, so the UI falls back to [name] rather than showing an empty line.
|
||||
val title: String? = null,
|
||||
val version: Int = 0,
|
||||
@SerialName("content_hash") val contentHash: String = "",
|
||||
val status: String = "",
|
||||
@@ -283,6 +287,8 @@ data class RunDetail(
|
||||
val id: Long = 0,
|
||||
@SerialName("pipeline_id") val pipelineId: Long = 0,
|
||||
val name: String = "",
|
||||
// Mirrors the embedded RunSummary.title (see internal/protocol/runs.go).
|
||||
val title: String? = null,
|
||||
val version: Int = 0,
|
||||
@SerialName("content_hash") val contentHash: String = "",
|
||||
val status: String = "",
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.awan.pipelines.ui
|
||||
|
||||
/**
|
||||
* The operator-facing name of a run: the server's stored title when it sent one,
|
||||
* otherwise the pipeline name (a run predating the title field, or one the server
|
||||
* could not title). Mirrors the server's `RunSummary.Label`, so the runs list, the
|
||||
* run detail header and the stage pane never spell the same run differently.
|
||||
*/
|
||||
fun runLabel(title: String?, name: String): String {
|
||||
val stored = title?.trim().orEmpty()
|
||||
return if (stored.isEmpty()) name else stored
|
||||
}
|
||||
|
||||
/**
|
||||
* The runs list's two identity lines: [label] is the run's primary line and
|
||||
* [pipeline] is the pipeline the run belongs to, shown as a second line only when
|
||||
* the label is a stored title (so two runs of one pipeline read as different
|
||||
* goals). A run with no title falls back to the pipeline name as its only line —
|
||||
* never a title line followed by an empty one.
|
||||
*/
|
||||
data class RunIdentity(val label: String, val pipeline: String?)
|
||||
|
||||
fun runIdentity(title: String?, name: String): RunIdentity {
|
||||
val stored = title?.trim().orEmpty()
|
||||
return if (stored.isEmpty()) RunIdentity(name, null) else RunIdentity(stored, name)
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.heading
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import net.awan.pipelines.data.protocol.ControlEvidence
|
||||
@@ -55,6 +56,7 @@ import net.awan.pipelines.ui.fileChangeLine
|
||||
import net.awan.pipelines.ui.fileChangesSummary
|
||||
import net.awan.pipelines.ui.formatDuration
|
||||
import net.awan.pipelines.ui.notificationLine
|
||||
import net.awan.pipelines.ui.runLabel
|
||||
import net.awan.pipelines.ui.screens.runTimeline
|
||||
import net.awan.pipelines.ui.theme.SPACING_L
|
||||
import net.awan.pipelines.ui.theme.SPACING_S
|
||||
@@ -326,6 +328,7 @@ fun StageDetailPane(
|
||||
modifier: Modifier = Modifier,
|
||||
covered: Boolean = false,
|
||||
runContext: Boolean = false,
|
||||
runLabel: String? = null,
|
||||
) {
|
||||
// A covered pane shows its compact identity only; the visit tab row and the
|
||||
// stage body must never be drawn squeezed into the peek strip.
|
||||
@@ -366,7 +369,26 @@ fun StageDetailPane(
|
||||
containerColor = paneContainerColor(),
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(GraphSemantics.nodeLabel(stageKey)) },
|
||||
title = {
|
||||
// The stage's own name leads, with the run it belongs to on a
|
||||
// second line when the caller has one, so opening a stage never
|
||||
// loses which run it is a visit of.
|
||||
Column {
|
||||
Text(
|
||||
GraphSemantics.nodeLabel(stageKey),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
runLabel?.takeIf { it.isNotBlank() }?.let { label ->
|
||||
Text(
|
||||
label,
|
||||
style = pipelinesText().meta,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
||||
@@ -575,6 +597,7 @@ fun RunStagePane(
|
||||
modifier = modifier,
|
||||
covered = covered,
|
||||
runContext = true,
|
||||
runLabel = run?.let { runLabel(it.title, it.name) },
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ 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.runIdentity
|
||||
import net.awan.pipelines.ui.runLabel
|
||||
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
|
||||
@@ -159,7 +161,7 @@ fun RunDetailScreen(
|
||||
// graphs must never be drawn squeezed into the peek strip.
|
||||
if (covered) {
|
||||
PaneIdentity(
|
||||
title = run?.name ?: "Run",
|
||||
title = run?.let { runLabel(it.title, it.name) } ?: "Run",
|
||||
subtitle = run?.status?.takeIf { it.isNotBlank() },
|
||||
modifier = modifier.fillMaxSize(),
|
||||
)
|
||||
@@ -178,7 +180,28 @@ fun RunDetailScreen(
|
||||
enabled = summaryTab == "summary",
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(run?.let { "Run ${it.id}" } ?: "Run") },
|
||||
title = {
|
||||
// The header names the run by its title and keeps the pipeline
|
||||
// it belongs to on a second line, so a stage pane opened from
|
||||
// here carries the same context. Without a title the pipeline
|
||||
// name is the single identity, never a blank first line.
|
||||
val identity = run?.let { runIdentity(it.title, it.name) }
|
||||
Column {
|
||||
Text(
|
||||
identity?.label ?: "Run",
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
identity?.pipeline?.let { pipeline ->
|
||||
Text(
|
||||
"$pipeline · v${run?.version}",
|
||||
style = pipelinesText().meta,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
||||
@@ -396,7 +419,7 @@ private fun RunSummaryTab(
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = SPACING_L),
|
||||
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
|
||||
) {
|
||||
Text(run.name, style = text.screenTitle)
|
||||
Text(runLabel(run.title, run.name), style = text.screenTitle)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||
|
||||
@@ -67,6 +67,7 @@ import net.awan.pipelines.ui.components.paneSafeArea
|
||||
import net.awan.pipelines.ui.components.runStateColor
|
||||
import net.awan.pipelines.ui.components.runStateOf
|
||||
import net.awan.pipelines.ui.formatDuration
|
||||
import net.awan.pipelines.ui.runIdentity
|
||||
import net.awan.pipelines.ui.theme.ICON_LIST_DP
|
||||
import net.awan.pipelines.ui.theme.ICON_STATUS_DP
|
||||
import net.awan.pipelines.ui.theme.PipelinesTextStyles
|
||||
@@ -376,10 +377,12 @@ private fun Metric(label: String, value: String, color: Color, text: PipelinesTe
|
||||
}
|
||||
|
||||
/**
|
||||
* One run as a row of the shared real list: a leading status glyph, the run name
|
||||
* as the title with its version chip, and a secondary line carrying the status
|
||||
* chip, progress and id/start/duration. The row is selected when its run is the
|
||||
* one open in the detail pane.
|
||||
* One run as a row of the shared real list: a leading status glyph, the run's
|
||||
* title as the primary line (falling back to the pipeline name when the server
|
||||
* stored no title) with its version chip, the pipeline name on a second line only
|
||||
* when a title exists, then a secondary line carrying the status chip, progress
|
||||
* and id/start/duration. The row is selected when its run is the one open in the
|
||||
* detail pane.
|
||||
*/
|
||||
@Composable
|
||||
private fun RunRow(
|
||||
@@ -390,6 +393,7 @@ private fun RunRow(
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
val state = runStateOf(run.status)
|
||||
val identity = runIdentity(run.title, run.name)
|
||||
ListRow(
|
||||
selected = selected,
|
||||
onClick = onClick,
|
||||
@@ -407,13 +411,32 @@ private fun RunRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||
) {
|
||||
Text(
|
||||
run.name,
|
||||
identity.label,
|
||||
style = text.cardTitle,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
VersionChip("v${run.version}")
|
||||
// Without a title the pipeline name is the only identity line, so the
|
||||
// version stays beside it; with one the pipeline drops to the second
|
||||
// line and takes the version with it.
|
||||
if (identity.pipeline == null) VersionChip("v${run.version}")
|
||||
}
|
||||
|
||||
if (identity.pipeline != null) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||
) {
|
||||
Text(
|
||||
identity.pipeline,
|
||||
style = text.meta,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
VersionChip("v${run.version}")
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
|
||||
@@ -257,4 +257,37 @@ class ProtocolModelTest {
|
||||
assertEquals(2, pipeline.succeeded)
|
||||
assertEquals(3.5, pipeline.averageSeconds, 0.0)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun runSummariesAndDetailsCarryTheOperatorTitleWhenTheServerSendsIt() {
|
||||
val json = """
|
||||
{
|
||||
"type": "runs",
|
||||
"runs": [
|
||||
{"id": 1, "pipeline_id": 7, "name": "demo", "title": "Add a dark mode toggle", "version": 2, "status": "succeeded"}
|
||||
],
|
||||
"run_detail": {
|
||||
"id": 1,
|
||||
"pipeline_id": 7,
|
||||
"name": "demo",
|
||||
"title": "Add a dark mode toggle",
|
||||
"version": 2,
|
||||
"steps": []
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val message = PipelinesJson.decodeFromString(Message.serializer(), json)
|
||||
assertEquals("Add a dark mode toggle", message.runs!!.single().title)
|
||||
assertEquals("Add a dark mode toggle", message.runDetail!!.title)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anAbsentRunTitleStaysNullSoTheUiFallsBackToThePipelineName() {
|
||||
val json = """
|
||||
{"type": "runs", "runs": [{"id": 1, "name": "demo"}], "run_detail": {"id": 1, "name": "demo"}}
|
||||
""".trimIndent()
|
||||
val message = PipelinesJson.decodeFromString(Message.serializer(), json)
|
||||
assertNull(message.runs!!.single().title)
|
||||
assertNull(message.runDetail!!.title)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.awan.pipelines.ui
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class RunIdentityTest {
|
||||
|
||||
@Test
|
||||
fun aStoredTitleIsThePrimaryLineWithThePipelineOnASecondLine() {
|
||||
val identity = runIdentity("Add a dark mode toggle", "android-app")
|
||||
assertEquals("Add a dark mode toggle", identity.label)
|
||||
assertEquals("android-app", identity.pipeline)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun twoRunsOfOnePipelineReadAsDifferentGoals() {
|
||||
val first = runIdentity("Add a dark mode toggle", "android-app")
|
||||
val second = runIdentity("Fix the crash on rotate", "android-app")
|
||||
// Same pipeline on the second line, different title on the first.
|
||||
assertEquals("android-app", first.pipeline)
|
||||
assertEquals(first.pipeline, second.pipeline)
|
||||
assertNotEquals(first.label, second.label)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aMissingOrBlankTitleFallsBackToThePipelineNameWithNoSecondLine() {
|
||||
for (title in listOf(null, "", " ", "\t")) {
|
||||
val identity = runIdentity(title, "android-app")
|
||||
assertEquals("android-app", identity.label)
|
||||
assertNull(identity.pipeline)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theStoredTitleIsTrimmed() {
|
||||
val identity = runIdentity(" Add a dark mode toggle ", "android-app")
|
||||
assertEquals("Add a dark mode toggle", identity.label)
|
||||
assertEquals("android-app", identity.pipeline)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun runLabelMirrorsTheRowsPrimaryLine() {
|
||||
assertEquals("Add a dark mode toggle", runLabel("Add a dark mode toggle", "android-app"))
|
||||
assertEquals("Add a dark mode toggle", runLabel(" Add a dark mode toggle ", "android-app"))
|
||||
assertEquals("android-app", runLabel(null, "android-app"))
|
||||
assertEquals("android-app", runLabel(" ", "android-app"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user