Migrate the graph, panes, rail and sheet onto the geometry tokens

Move the workflow-graph package (WorkflowGraph, the StageDetailPane sheet,
Artifacts, ArtifactViewer, ArtifactImage) off its remaining raw dp literals
and onto the geometry tokens, all substitutions value-equal so the visuals
are unchanged.

- ui/theme/Dimens.kt gains the off-scale component and graph-chrome sizes:
  the run legend's GRAPH_LEGEND_PAD_X/PAD_Y/GAP, the collapsed
  GRAPH_PANEL_MIN_HEIGHT (moved off WorkflowGraph.kt, now imported by its
  test), the gallery's ARTIFACT_TILE_DP/THUMB_DP/BADGE_DP/PROGRESS_DP/
  PROGRESS_STROKE_DP, and the stage-type chip's STAGE_CHIP_PAD_H.
- Artifact tile/row and thumbnail corner radii derive from the Material
  shape scale (MaterialTheme.shapes.medium/.small), matching the graph's
  existing node corners.
- DimensTest.kt's allow-list shrinks from 24 to 21 entries: 24.dp, 56.dp and
  96.dp are gone now that their last call sites migrated. The structural
  hairlines/zeros, the not-yet-migrated app shell and Settings literals, and
  the sp type values owned by Typography.kt remain.
- WorkflowGraphTest.kt imports the moved GRAPH_PANEL_MIN_HEIGHT.
- android/README.md documents the change and its verification evidence.

Verified: gradle :app:assembleDebug :app:testDebugUnitTest --rerun-tasks
BUILD SUCCESSFUL, 30 XMLs / 259 tests, 0 failures/errors/skipped; the
enforcement test fails on a deliberately introduced literal and passes once
removed; before/after captures at both window widths differ only on the
status-bar clock and live relative-time text.
This commit is contained in:
2026-10-16 13:08:54 +01:00
parent 3765fdfdf6
commit d546bc7a3a
9 changed files with 179 additions and 48 deletions
@@ -23,9 +23,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import net.awan.pipelines.ui.theme.ARTIFACT_PROGRESS_DP
import net.awan.pipelines.ui.theme.ARTIFACT_PROGRESS_STROKE_DP
import net.awan.pipelines.ui.theme.ARTIFACT_THUMB_DP
/**
* Encoded artifact bytes, fetched at most once per url and kept in memory so a
@@ -85,7 +87,7 @@ internal fun ArtifactImage(
maxDim: Int,
fetchBytes: suspend (String) -> ByteArray?,
modifier: Modifier = Modifier,
size: Dp = 56.dp,
size: Dp = ARTIFACT_THUMB_DP,
) {
val state = rememberArtifactBitmap(url, maxDim, fetchBytes)
Box(modifier.size(size), contentAlignment = Alignment.Center) {
@@ -173,7 +175,3 @@ private fun decodeSampled(bytes: ByteArray, maxDim: Int): Bitmap? = try {
} catch (_: Throwable) {
null
}
/** The loading indicator's size and stroke, a small inline spinner. */
private val ARTIFACT_PROGRESS_DP = 24.dp
private val ARTIFACT_PROGRESS_STROKE_DP = 2.dp
@@ -49,12 +49,14 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.window.DialogWindowProvider
import net.awan.pipelines.ui.components.copyText
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.theme.SPACING_M
import net.awan.pipelines.ui.theme.SPACING_XL
import net.awan.pipelines.ui.theme.SPACING_XS
import net.awan.pipelines.ui.theme.pipelinesText
import kotlin.math.abs
@@ -250,9 +252,9 @@ private fun ZoomableArtifact(
private fun ViewerMessage(text: String, spinner: Boolean = false) {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Column(
modifier = Modifier.padding(24.dp),
modifier = Modifier.padding(SPACING_XL),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(12.dp),
verticalArrangement = Arrangement.spacedBy(SPACING_M),
) {
if (spinner) CircularProgressIndicator()
Text(
@@ -282,7 +284,7 @@ private fun ArtifactViewerActions(
color = MaterialTheme.colorScheme.scrim.copy(alpha = ARTIFACT_ACTION_SCRIM_ALPHA),
shape = CircleShape,
),
horizontalArrangement = Arrangement.spacedBy(4.dp),
horizontalArrangement = Arrangement.spacedBy(SPACING_XS),
) {
IconButton(onClick = { openArtifact(context, url) }) {
Icon(Icons.AutoMirrored.Filled.OpenInNew, contentDescription = "Open $name externally")
@@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.InsertDriveFile
import androidx.compose.material.icons.automirrored.filled.OpenInNew
@@ -55,6 +54,13 @@ import net.awan.pipelines.ui.artifactMetaLine
import net.awan.pipelines.ui.artifactsSummary
import net.awan.pipelines.ui.components.copyText
import net.awan.pipelines.ui.isImageContentType
import net.awan.pipelines.ui.theme.ARTIFACT_BADGE_DP
import net.awan.pipelines.ui.theme.ARTIFACT_THUMB_DP
import net.awan.pipelines.ui.theme.ARTIFACT_TILE_DP
import net.awan.pipelines.ui.theme.SPACING_M
import net.awan.pipelines.ui.theme.SPACING_S
import net.awan.pipelines.ui.theme.SPACING_XS
import net.awan.pipelines.ui.theme.SPACING_XXS
import net.awan.pipelines.ui.theme.pipelinesText
/**
@@ -81,7 +87,7 @@ internal fun ArtifactsSection(
val artifacts = remember(step) { step.artifacts.orEmpty() }
val summary = remember(step) { artifactsSummary(step) }
val notes = remember(step) { artifactCaptureNotes(step) }
Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(4.dp)) {
Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(SPACING_XS)) {
Text(summary, style = text.label, color = MaterialTheme.colorScheme.primary)
if (configuredServerUrl.isBlank()) {
Text(
@@ -135,7 +141,7 @@ internal fun ArtifactGallery(
preferred = ARTIFACT_TILE_DP,
spacing = ARTIFACT_TILE_SPACING_DP,
)
Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) {
Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(SPACING_S)) {
groups.forEach { group ->
if (showHeaders) {
Text(
@@ -240,10 +246,10 @@ private fun ArtifactTile(
Box(
Modifier
.size(tile)
.clip(RoundedCornerShape(12.dp))
.clip(MaterialTheme.shapes.medium)
.then(
if (selected) {
Modifier.border(3.dp, MaterialTheme.colorScheme.secondary, RoundedCornerShape(12.dp))
Modifier.border(3.dp, MaterialTheme.colorScheme.secondary, MaterialTheme.shapes.medium)
} else {
Modifier
},
@@ -279,7 +285,7 @@ private fun ArtifactTile(
Box(
Modifier
.align(Alignment.TopStart)
.padding(4.dp)
.padding(SPACING_XS)
.background(MaterialTheme.colorScheme.secondaryContainer, CircleShape),
contentAlignment = Alignment.Center,
) {
@@ -287,7 +293,7 @@ private fun ArtifactTile(
imageVector = Icons.Default.Check,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSecondaryContainer,
modifier = Modifier.padding(4.dp).size(16.dp),
modifier = Modifier.padding(SPACING_XS).size(ARTIFACT_BADGE_DP),
)
}
}
@@ -346,7 +352,7 @@ private fun ArtifactRow(
val selected = selection.contains(artifact.url)
Surface(
shape = RoundedCornerShape(12.dp),
shape = MaterialTheme.shapes.medium,
color = if (selected) {
MaterialTheme.colorScheme.secondaryContainer
} else {
@@ -373,12 +379,12 @@ private fun ArtifactRow(
.semantics { this.selected = selected },
) {
Row(
modifier = Modifier.padding(horizontal = 8.dp, vertical = 8.dp),
modifier = Modifier.padding(horizontal = SPACING_S, vertical = SPACING_S),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
horizontalArrangement = Arrangement.spacedBy(SPACING_M),
) {
Box(
Modifier.size(56.dp).clip(RoundedCornerShape(8.dp)),
Modifier.size(ARTIFACT_THUMB_DP).clip(MaterialTheme.shapes.small),
contentAlignment = Alignment.Center,
) {
Icon(
@@ -387,7 +393,7 @@ private fun ArtifactRow(
tint = LocalContentColor.current,
)
}
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(SPACING_XXS)) {
Text(
artifact.name.ifBlank { "(unnamed artifact)" },
style = text.cardTitle,
@@ -410,7 +416,7 @@ private fun ArtifactRow(
Icon(
imageVector = Icons.Default.Check,
contentDescription = null,
modifier = Modifier.padding(horizontal = 12.dp),
modifier = Modifier.padding(horizontal = SPACING_M),
)
}
} else {
@@ -485,8 +491,5 @@ internal fun openArtifact(context: Context, url: String?) {
/** Longest edge of a list thumbnail decode. */
private const val THUMBNAIL_MAX_DIM = 160
/** Preferred side of one square gallery thumbnail tile (the named size token). */
private val ARTIFACT_TILE_DP = 96.dp
/** Gap between gallery thumbnails; shared by the row arrangement and the fitting. */
private val ARTIFACT_TILE_SPACING_DP = 8.dp
private val ARTIFACT_TILE_SPACING_DP = SPACING_S
@@ -56,6 +56,10 @@ import net.awan.pipelines.ui.fileChangesSummary
import net.awan.pipelines.ui.formatDuration
import net.awan.pipelines.ui.notificationLine
import net.awan.pipelines.ui.screens.runTimeline
import net.awan.pipelines.ui.theme.SPACING_L
import net.awan.pipelines.ui.theme.SPACING_S
import net.awan.pipelines.ui.theme.SPACING_XS
import net.awan.pipelines.ui.theme.STAGE_CHIP_PAD_H
import net.awan.pipelines.ui.theme.pipelinesText
/**
@@ -439,8 +443,8 @@ private fun StageDetailBody(
Column(
modifier = columnModifier
.verticalScroll(rememberScrollState())
.padding(horizontal = 16.dp, vertical = 8.dp),
verticalArrangement = Arrangement.spacedBy(4.dp),
.padding(horizontal = SPACING_L, vertical = SPACING_S),
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
) {
Text(
GraphSemantics.nodeLabel(stageKey),
@@ -453,7 +457,7 @@ private fun StageDetailBody(
selectedTabIndex = clampedVisit,
edgePadding = 0.dp,
containerColor = paneContainerColor(),
modifier = Modifier.fillMaxWidth().padding(top = 8.dp),
modifier = Modifier.fillMaxWidth().padding(top = SPACING_S),
) {
runSteps.forEachIndexed { index, _ ->
Tab(
@@ -619,7 +623,7 @@ internal fun StageTypeChip(label: String) {
text = label,
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSecondaryContainer,
modifier = Modifier.padding(horizontal = 10.dp, vertical = 4.dp),
modifier = Modifier.padding(horizontal = STAGE_CHIP_PAD_H, vertical = SPACING_XS),
)
}
}
@@ -101,6 +101,9 @@ import net.awan.pipelines.ui.theme.GRAPH_EDGE_LANE_SPACING
import net.awan.pipelines.ui.theme.GRAPH_EDGE_TRACK_STEP
import net.awan.pipelines.ui.theme.GRAPH_ELAPSED_INSET
import net.awan.pipelines.ui.theme.GRAPH_FIT_PADDING
import net.awan.pipelines.ui.theme.GRAPH_LEGEND_GAP
import net.awan.pipelines.ui.theme.GRAPH_LEGEND_PAD_X
import net.awan.pipelines.ui.theme.GRAPH_LEGEND_PAD_Y
import net.awan.pipelines.ui.theme.GRAPH_LEGEND_SWATCH_HEIGHT
import net.awan.pipelines.ui.theme.GRAPH_LEGEND_SWATCH_WIDTH
import net.awan.pipelines.ui.theme.GRAPH_MIN_VISIBLE
@@ -111,9 +114,11 @@ import net.awan.pipelines.ui.theme.GRAPH_NODE_MIN_HEIGHT
import net.awan.pipelines.ui.theme.GRAPH_NODE_PORT_SPACING
import net.awan.pipelines.ui.theme.GRAPH_NODE_WIDTH
import net.awan.pipelines.ui.theme.GRAPH_PAD
import net.awan.pipelines.ui.theme.GRAPH_PANEL_MIN_HEIGHT
import net.awan.pipelines.ui.theme.GRAPH_ROUTE_CORNER_RADIUS
import net.awan.pipelines.ui.theme.GRAPH_TERMINAL_ROW_GAP
import net.awan.pipelines.ui.theme.PipelinesTextStyles
import net.awan.pipelines.ui.theme.SPACING_XS
import net.awan.pipelines.ui.theme.pipelinesText
internal data class NodeLayout(
@@ -428,16 +433,16 @@ fun WorkflowGraph(
Row(
modifier = Modifier
.align(Alignment.TopStart)
.padding(4.dp)
.padding(SPACING_XS)
.background(MaterialTheme.colorScheme.surface.copy(alpha = 0.85f))
.padding(horizontal = 6.dp, vertical = 3.dp),
.padding(horizontal = GRAPH_LEGEND_PAD_X, vertical = GRAPH_LEGEND_PAD_Y),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(10.dp),
horizontalArrangement = Arrangement.spacedBy(GRAPH_LEGEND_GAP),
) {
GRAPH_LEGEND.forEach { entry ->
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp),
horizontalArrangement = Arrangement.spacedBy(SPACING_XS),
) {
LegendSwatch(entry.executed, colors)
Text(entry.label, style = MaterialTheme.typography.labelSmall)
@@ -446,7 +451,7 @@ fun WorkflowGraph(
}
}
Row(
modifier = Modifier.align(Alignment.TopEnd).padding(4.dp),
modifier = Modifier.align(Alignment.TopEnd).padding(SPACING_XS),
) {
IconButton(
onClick = {
@@ -1819,6 +1824,3 @@ internal fun collapsedGraphHeight(screenHeightDp: Int): Dp =
/** Expanded graph-panel height: (approximately) the full available window height. */
internal fun expandedGraphHeight(screenHeightDp: Int): Dp = (screenHeightDp * 0.92f).dp
/** Floor that still fits a 4-stage graph with its terminal row (see above). */
internal val GRAPH_PANEL_MIN_HEIGHT = 320.dp
@@ -166,3 +166,41 @@ internal val GRAPH_FIT_PADDING = 16.dp
/** Least graph span kept visible when clamping pan. */
internal val GRAPH_MIN_VISIBLE = 48.dp
/** Horizontal padding inside the run legend chip (tighter than the spacing scale). */
internal val GRAPH_LEGEND_PAD_X = 6.dp
/** Vertical padding inside the run legend chip (tighter than the spacing scale). */
internal val GRAPH_LEGEND_PAD_Y = 3.dp
/** Gap between the run legend's entries. */
internal val GRAPH_LEGEND_GAP = 10.dp
/** Collapsed graph-panel floor: fits a 4-stage layout plus its terminal row. */
internal val GRAPH_PANEL_MIN_HEIGHT = 320.dp
// ---- Artifacts gallery (ui/graph/Artifacts.kt, ArtifactImage.kt) -----------
// The gallery's tile geometry. Like the graph's, it is named here so the
// artifact files import tokens instead of writing raw dp literals; the values are
// unchanged. Corner radii derive from the app's Material shape scale (the graph
// does the same for its nodes), so only the sizes live here.
/** Preferred side of one square gallery thumbnail tile. */
internal val ARTIFACT_TILE_DP = 96.dp
/** Side of an inline artifact thumbnail and a non-image row's leading glyph box. */
internal val ARTIFACT_THUMB_DP = 56.dp
/** Check-badge glyph on a selected gallery tile. */
internal val ARTIFACT_BADGE_DP = 16.dp
/** Size of the inline artifact loading spinner. */
internal val ARTIFACT_PROGRESS_DP = 24.dp
/** Stroke of the inline artifact loading spinner. */
internal val ARTIFACT_PROGRESS_STROKE_DP = 2.dp
// ---- Stage detail sheet (ui/graph/StageDetailPane.kt) ----------------------
/** Horizontal padding inside the stage-type chip (wider than the shared chip). */
internal val STAGE_CHIP_PAD_H = 10.dp
@@ -9,6 +9,7 @@ import net.awan.pipelines.data.protocol.Protocol
import net.awan.pipelines.data.protocol.RunGraphState
import net.awan.pipelines.data.protocol.Stage
import net.awan.pipelines.data.protocol.edges
import net.awan.pipelines.ui.theme.GRAPH_PANEL_MIN_HEIGHT
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
@@ -26,8 +26,8 @@ class DimensTest {
private val allowList: Map<String, String> = mapOf(
// Structural / hairline values that are not design dimensions.
"0.dp" to "Structural zero: no inset, clamped-to-zero, or an empty-guard comparison.",
"2.dp" to "Progress/divider hairline strokes (progress indicators, graph hairlines); half the 4dp base step.",
"3.dp" to "Tonal and border hairline (elevation/border), not a layout dimension.",
"2.dp" to "Progress-indicator hairline stroke (the run row's spinner); half the 4dp base step.",
"3.dp" to "Tonal and border hairline (a selected tile's ring, elevation), not a layout dimension.",
"6.dp" to "Pill shadow elevation only; not layout geometry.",
// Members of the 4dp spacing scale (see Dimens' SPACING_* tokens).
@@ -35,19 +35,17 @@ class DimensTest {
"8.dp" to "Two 4dp steps (SPACING_S): standard stack/row gap and icon inset.",
"12.dp" to "Three 4dp steps (SPACING_M): standard inter-item arrangement gap.",
"16.dp" to "Four 4dp steps (SPACING_L): standard screen, card and app-bar padding.",
"24.dp" to "Artifact progress glyph and artifact-viewer padding (ui/graph); not yet migrated.",
"10.dp" to "Dense row padding finer than the 4dp scale (10dp vertical); kept verbatim.",
// Component glyph sizes still outside the token file (the list/detail
// screens' 14/18/20/24dp glyphs moved onto Dimens' ICON_* tokens).
"48.dp" to "Minimum touch target and graph minimum visible span (48dp).",
"48.dp" to "The destination pill's icon touch target (DESTINATION_ITEM_SIZE).",
// Workflow-graph pixel geometry now lives in ui/theme/Dimens.kt as the
// GRAPH_* tokens, so no graph literal remains here.
// Workflow-graph, artifact-gallery and stage-sheet pixel geometry now
// lives in ui/theme/Dimens.kt as named tokens, so no graph/artifact
// literal remains here.
// Component container sizes.
"56.dp" to "Artifact thumbnail size (coincides with PEEK_WIDTH_DP but is content size here).",
"96.dp" to "Artifact grid preferred tile edge (ARTIFACT_TILE_DP).",
// The one container size still outside the token file.
"320.dp" to "Code block maximum height (CODE_BLOCK_MAX_HEIGHT).",
// Typography (sp), which is owned by Typography.kt, not the dimension file.