Merge branch 'main' into lane-go

This commit is contained in:
2026-10-16 11:33:19 +01:00
9 changed files with 295 additions and 89 deletions
+79
View File
@@ -2169,3 +2169,82 @@ Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 9.7.1,
Not verified in this pass: a narrow-window frame (the fold inner display is Not verified in this pass: a narrow-window frame (the fold inner display is
851dp wide); the error state's fade-in from loading (the disconnected load failed 851dp wide); the error state's fade-in from loading (the disconnected load failed
before a loading frame could be drawn, only its fade-out was captured). before a loading frame could be drawn, only its fade-out was captured).
### Animated selection and state changes (16 Oct 2026, run 109/1)
Selection and live state changes animate instead of cutting, and every resting
state is unchanged. All of it reuses the one `Motion.kt` token file; no new
dependency, geometry or literal.
- **The destination pill's indicator travels.** `DestinationPill`
(`PipelinesApp.kt`) now draws one selection indicator behind the three icons
and animates its offset between them (`animateDpAsState`, `MotionStandard`), so
picking another destination slides the highlight across rather than each icon
swapping its own background; the glyph tint cross-fades in step
(`animateColorAsState`). The geometry comes from two named tokens,
`DESTINATION_ITEM_SIZE`/`DESTINATION_ITEM_GAP` (the existing 48dp target and
4dp gap, named once), through the pure `destinationIndicatorOffsetDp`, which is
unit-tested. The icons own the taps, so a tap registers while the indicator is
still travelling, and a rapid run of taps only retargets the one animator.
- **A selected row's highlight fades in.** The shared `ListRow` animates its
tonal container and content colour under `MotionQuick` instead of switching, so
selecting a pipeline/run row fades the `secondaryContainer` highlight in and
out; the settled row is exactly the old one.
- **Section bodies animate with their chevron.** A new shared
`CollapsibleSectionBody` (`Sections.kt`) wraps a section's body in
`AnimatedVisibility` with `expandVertically`/`shrinkVertically` + fade under
`MotionQuick` — the same token the `SectionHeader` chevron turns with — so the
content and the chevron move together. Both `collapsibleSection` (the lazy
variant) and the stage pane's `StageSection` use it; collapsed, the body is not
composed, so a resting section is unchanged. (The section *switch* was already
an in-place `Crossfade` with no lateral motion and is unchanged.)
- **A live run's status change animates.** `StatusChip` eases its container and
label colour under `MotionQuick` and `RunStatusIcon` eases its glyph tint, so a
run whose status changes while the 1s poll is running visibly transitions the
chip and the row's leading accent instead of silently swapping a colour.
- **Taps, pause and the animator scale.** These are ordinary Compose animators,
so the platform animator duration scale applies unchanged (disabled = instant),
the recomposer pauses them while the screen is not resumed, and the
selectable/clickable nodes are independent of the animators, so taps register
mid-animation.
Verified on `emulator-5554` only (fold layout, 2076x2152 / 390dpi; never the
attached Pixel, never `emulator-5556`), against the live server; each frame
captured and validated with `scripts/capture_png.sh -s emulator-5554`:
- `gradle :app:assembleDebug :app:testDebugUnitTest --offline --console=plain` →
`BUILD SUCCESSFUL`; `gradle :app:testDebugUnitTest --rerun-tasks --offline`
re-ran every result XML to **186 tests across 23 classes, 0 failures, 0 errors,
0 skipped**. The new `PipelinesNavTest` cases check the indicator offset lines
up with each slot and pins to slot 0 when nothing is selected.
- **Pill selection moving** at `animator_duration_scale 6`
(`pill_0/1/5.png`): with Pipelines selected, tapping Runs leaves `pill_0` on
Pipelines, `pill_1` freezes the highlight between the two icons, and `pill_5`
settles under Runs.
- **Section collapsing** at `animator_duration_scale 15`
(`sec2_expand_3.png`, `sec2_collapse_2.png`): the Input tab's `prompt` section
expands with the code block revealing under a down chevron, and collapses with
the block clipped and the following `pwd` header rising as the chevron returns.
- **Live status change** (`status3_post_01/02/03.png`): run 112 was started
out-of-band with `pipelines run … --pipeline 1 --prompt "… sleep 45 …"` (**not**
from the app) and watched in its open detail; its summary chip goes from
`running` (`status3_post_01`) through the mid-transition tint
(`status3_post_02`) to `succeeded` (`status3_post_03`).
- **Taps mid-animation**: at scale 15, tapping Runs and then Settings 0.2s later
(while the indicator was still travelling) landed on the Settings screen, so
the second tap registered.
- `adb -s emulator-5554 logcat -d` held 0 `FATAL EXCEPTION` / 0
`E AndroidRuntime` lines; `animator_duration_scale` was left at 1.
- **APK publish.** `app-debug.apk` (18,133,184 bytes, sha256 `567c437d…`) copied
to `~/.local/share/pipelines/data/artifacts/109/1/pipelines-debug-wip-b89ad29.apk`
(`b89ad29` = `git rev-parse --short HEAD`); `curl -I
http://10.0.0.249:8080/artifacts/109/1/pipelines-debug-wip-b89ad29.apk` returned
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18133184`, and a streamed `curl | shasum -a 256` returned the
same `567c437d…`.
Not verified in this pass: a clean *settled* frame of the selected-row highlight
(it fades in while the wide layout then covers the list with the opened pane, so
only a transient mid-fade frame was captured); resume-after-pause of an
in-flight animation on device (the pause is Compose's own recomposer behaviour,
not code here).
@@ -1,6 +1,8 @@
package net.awan.pipelines.ui package net.awan.pipelines.ui
import androidx.activity.compose.PredictiveBackHandler import androidx.activity.compose.PredictiveBackHandler
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
@@ -10,6 +12,7 @@ import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.consumeWindowInsets import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
@@ -33,10 +36,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.Role
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.compose.NavHost import androidx.navigation.compose.NavHost
@@ -46,12 +49,14 @@ import androidx.navigation.compose.rememberNavController
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
import net.awan.pipelines.data.transport.ConnectionState import net.awan.pipelines.data.transport.ConnectionState
import net.awan.pipelines.ui.components.ConnectionBanner import net.awan.pipelines.ui.components.ConnectionBanner
import net.awan.pipelines.ui.components.MotionStandard
import net.awan.pipelines.ui.components.SlidingPaneStack import net.awan.pipelines.ui.components.SlidingPaneStack
import net.awan.pipelines.ui.components.clampTabIndex import net.awan.pipelines.ui.components.clampTabIndex
import net.awan.pipelines.ui.components.paneSafeArea import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.pipelineDetailTabs import net.awan.pipelines.ui.components.pipelineDetailTabs
import net.awan.pipelines.ui.components.rememberPaneContent import net.awan.pipelines.ui.components.rememberPaneContent
import net.awan.pipelines.ui.components.runDetailTabs import net.awan.pipelines.ui.components.runDetailTabs
import net.awan.pipelines.ui.components.spec
import net.awan.pipelines.ui.graph.PipelineStagePane import net.awan.pipelines.ui.graph.PipelineStagePane
import net.awan.pipelines.ui.graph.RunStagePane import net.awan.pipelines.ui.graph.RunStagePane
import net.awan.pipelines.ui.screens.PipelineDetailScreen import net.awan.pipelines.ui.screens.PipelineDetailScreen
@@ -342,14 +347,27 @@ private fun RunsDestination(
) )
} }
/**
* The horizontal offset of the pill's travelling selection indicator for the
* destination at [index]: the pill's inner padding plus [index] item slots
* ([itemSize] + [gap]). Pure and in one place, so the indicator lines up exactly
* with the icon it selects and the geometry is unit-testable without a device.
* A missing selection (-1) pins to the first slot and the caller draws nothing.
*/
internal fun destinationIndicatorOffsetDp(index: Int, itemSize: Dp, gap: Dp): Dp =
gap + (itemSize + gap) * index.coerceAtLeast(0)
/** /**
* The Pipelines/Runs/Settings destinations as a floating rounded pill at the * The Pipelines/Runs/Settings destinations as a floating rounded pill at the
* bottom right: the three destinations as icons, inset from the bottom/right * bottom right: the three destinations as icons, inset from the bottom/right
* edges (it clears the safe area — system bars, cutout, gesture area and IME — * edges (it clears the safe area — system bars, cutout, gesture area and IME —
* via windowInsetsPadding), each a 48dp touch * via windowInsetsPadding), each a [DESTINATION_ITEM_SIZE] touch target.
* target. Selection is a tonal container plus the `Role.Tab` selected * Selection is one tonal indicator that travels between the icons
* accessibility state — never colour alone — and tapping switches destination * ([MotionStandard], so it slides rather than jumping) plus the icon's fading
* through the caller's existing navigate/popUpTo logic. * tint, while the `Role.Tab` selected accessibility state is never conveyed by
* colour alone. Tapping switches destination through the caller's existing
* navigate/popUpTo logic; the icons own the taps, so a tap registers even while
* the indicator is still travelling, and the settled pill equals the old one.
*/ */
@Composable @Composable
private fun DestinationPill( private fun DestinationPill(
@@ -358,53 +376,81 @@ private fun DestinationPill(
onSelect: (TopDestination) -> Unit, onSelect: (TopDestination) -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
val scheme = MaterialTheme.colorScheme
val selectedIndex = destinations.indexOfFirst { destinationSelected(currentRoute, it.route) }
// One long-lived animator, so a rapid run of taps only retargets it (never
// half-way) and the first composition starts already settled at the target.
val indicatorOffset by animateDpAsState(
targetValue = destinationIndicatorOffsetDp(
selectedIndex,
DESTINATION_ITEM_SIZE,
DESTINATION_ITEM_GAP,
),
animationSpec = MotionStandard.spec(),
label = "destination-indicator",
)
Surface( Surface(
modifier = modifier, modifier = modifier,
shape = RoundedCornerShape(50), shape = RoundedCornerShape(50),
color = MaterialTheme.colorScheme.surfaceContainerHigh, color = scheme.surfaceContainerHigh,
tonalElevation = 3.dp, tonalElevation = 3.dp,
shadowElevation = 6.dp, shadowElevation = 6.dp,
) { ) {
Row( Box {
modifier = Modifier.padding(4.dp), // Drawn behind the icons, so the highlight slides under whichever is
horizontalArrangement = Arrangement.spacedBy(4.dp), // selected; before the nav graph settles there is no selection and
verticalAlignment = Alignment.CenterVertically, // nothing is drawn.
) { if (selectedIndex >= 0) {
destinations.forEach { destination ->
val selected = destinationSelected(currentRoute, destination.route)
Box( Box(
modifier = Modifier Modifier
.size(48.dp) .offset(x = indicatorOffset, y = DESTINATION_ITEM_GAP)
.size(DESTINATION_ITEM_SIZE)
.clip(CircleShape) .clip(CircleShape)
.background( .background(scheme.secondaryContainer),
if (selected) { )
MaterialTheme.colorScheme.secondaryContainer }
} else { Row(
Color.Transparent modifier = Modifier.padding(DESTINATION_ITEM_GAP),
}, horizontalArrangement = Arrangement.spacedBy(DESTINATION_ITEM_GAP),
) verticalAlignment = Alignment.CenterVertically,
.selectable( ) {
selected = selected, destinations.forEach { destination ->
role = Role.Tab, val selected = destinationSelected(currentRoute, destination.route)
onClick = { onSelect(destination) }, // The glyph tint fades in step with the travelling indicator.
), val iconColor by animateColorAsState(
contentAlignment = Alignment.Center, targetValue = if (selected) scheme.onSecondaryContainer else scheme.onSurfaceVariant,
) { animationSpec = MotionStandard.spec(),
Icon( label = "destination-icon",
imageVector = destination.icon,
contentDescription = destination.label,
tint = if (selected) {
MaterialTheme.colorScheme.onSecondaryContainer
} else {
MaterialTheme.colorScheme.onSurfaceVariant
},
) )
Box(
modifier = Modifier
.size(DESTINATION_ITEM_SIZE)
.clip(CircleShape)
.selectable(
selected = selected,
role = Role.Tab,
onClick = { onSelect(destination) },
),
contentAlignment = Alignment.Center,
) {
Icon(
imageVector = destination.icon,
contentDescription = destination.label,
tint = iconColor,
)
}
} }
} }
} }
} }
} }
/** The destination pill's icon touch target and the size of its selection indicator. */
internal val DESTINATION_ITEM_SIZE = 48.dp
/** The gap between destinations, also the pill's inner padding. */
internal val DESTINATION_ITEM_GAP = 4.dp
/** Bottom space reserved for the floating destination pill, so content is never /** Bottom space reserved for the floating destination pill, so content is never
* permanently hidden behind it (pill height + its margins + a small gap). */ * permanently hidden behind it (pill height + its margins + a small gap). */
private val DESTINATION_PILL_RESERVE = 88.dp private val DESTINATION_PILL_RESERVE = 88.dp
@@ -1,5 +1,6 @@
package net.awan.pipelines.ui.components package net.awan.pipelines.ui.components
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.ColumnScope
@@ -13,6 +14,7 @@ import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
@@ -31,7 +33,9 @@ import androidx.compose.ui.unit.dp
* the bottom destinations ([MaterialTheme.colorScheme.secondaryContainer] with * the bottom destinations ([MaterialTheme.colorScheme.secondaryContainer] with
* `onSecondaryContainer` content) and exposes its selection through * `onSecondaryContainer` content) and exposes its selection through
* `selectable`'s accessibility selected state, so selection is never conveyed by * `selectable`'s accessibility selected state, so selection is never conveyed by
* colour alone. * colour alone. The highlight fades in and out under [MotionQuick] rather than
* appearing at once; the settled row is exactly the selected/unselected row, so
* the resting appearance is unchanged.
*/ */
@Composable @Composable
fun ListRow( fun ListRow(
@@ -43,8 +47,16 @@ fun ListRow(
content: @Composable ColumnScope.() -> Unit, content: @Composable ColumnScope.() -> Unit,
) { ) {
val scheme = MaterialTheme.colorScheme val scheme = MaterialTheme.colorScheme
val container = if (selected) scheme.secondaryContainer else Color.Transparent val container by animateColorAsState(
val contentColor = if (selected) scheme.onSecondaryContainer else LocalContentColor.current targetValue = if (selected) scheme.secondaryContainer else Color.Transparent,
animationSpec = MotionQuick.spec(),
label = "row-selection-container",
)
val contentColor by animateColorAsState(
targetValue = if (selected) scheme.onSecondaryContainer else LocalContentColor.current,
animationSpec = MotionQuick.spec(),
label = "row-selection-content",
)
Surface( Surface(
color = container, color = container,
contentColor = contentColor, contentColor = contentColor,
@@ -1,5 +1,6 @@
package net.awan.pipelines.ui.components package net.awan.pipelines.ui.components
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
@@ -19,6 +20,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
@@ -89,7 +91,8 @@ fun runStateIcon(state: RunState): ImageVector = when (state) {
* A state glyph with an accurate [contentDescription]. Every glyph comes from the * A state glyph with an accurate [contentDescription]. Every glyph comes from the
* standard filled material icon set (the extended pack is declared as a * standard filled material icon set (the extended pack is declared as a
* dependency), all the same weight/family, so state is never conveyed by colour * dependency), all the same weight/family, so state is never conveyed by colour
* alone. * alone. The tint eases under [MotionQuick], so a live run's status change fades
* the accent colour rather than swapping it.
*/ */
@Composable @Composable
fun RunStatusIcon( fun RunStatusIcon(
@@ -98,22 +101,37 @@ fun RunStatusIcon(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
tint: Color = runStateColor(state), tint: Color = runStateColor(state),
) { ) {
val animatedTint by animateColorAsState(
targetValue = tint,
animationSpec = MotionQuick.spec(),
label = "run-status-tint",
)
Icon( Icon(
imageVector = runStateIcon(state), imageVector = runStateIcon(state),
contentDescription = contentDescription, contentDescription = contentDescription,
tint = tint, tint = animatedTint,
modifier = modifier, modifier = modifier,
) )
} }
/** A colour-coded chip pairing a state glyph with its text label. */ /**
* A colour-coded chip pairing a state glyph with its text label. Its container,
* label and glyph all ease to the new state's colour under [MotionQuick] (the
* glyph's own tint animates in [RunStatusIcon], in step), so a run whose status
* changes while the screen is open visibly transitions instead of silently
* swapping a colour; the chip is identical to the old one once settled.
*/
@Composable @Composable
fun StatusChip( fun StatusChip(
label: String, label: String,
state: RunState, state: RunState,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
val color = runStateColor(state) val color by animateColorAsState(
targetValue = runStateColor(state),
animationSpec = MotionQuick.spec(),
label = "status-chip-color",
)
Row( Row(
modifier = modifier modifier = modifier
.clip(RoundedCornerShape(50)) .clip(RoundedCornerShape(50))
@@ -122,7 +140,7 @@ fun StatusChip(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp), horizontalArrangement = Arrangement.spacedBy(4.dp),
) { ) {
RunStatusIcon(state, contentDescription = label, modifier = Modifier.size(14.dp), tint = color) RunStatusIcon(state, contentDescription = label, modifier = Modifier.size(14.dp))
Text( Text(
text = label, text = label,
color = color, color = color,
@@ -1,6 +1,11 @@
package net.awan.pipelines.ui.components package net.awan.pipelines.ui.components
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.expandVertically
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
@@ -100,10 +105,38 @@ fun SectionHeader(
} }
} }
/**
* The one animated collapsible body: [content] expands and shrinks with a fade
* under [MotionQuick], the same token the section chevron turns with, so the
* body and the chevron move together instead of the content popping in after the
* chevron has already turned. Collapsed, [content] is not composed, so a closed
* section does no work and the resting layout is the collapsed header alone.
* With animations disabled Compose maps the platform animator duration scale
* onto the specs, so the body is at its final state at once.
*/
@Composable
fun CollapsibleSectionBody(
expanded: Boolean,
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
AnimatedVisibility(
visible = expanded,
enter = expandVertically(animationSpec = MotionQuick.spec()) +
fadeIn(animationSpec = MotionQuick.spec()),
exit = shrinkVertically(animationSpec = MotionQuick.spec()) +
fadeOut(animationSpec = MotionQuick.spec()),
modifier = modifier,
) {
content()
}
}
/** /**
* Emits a collapsible [section] into a [LazyListScope]: a sticky header for the * Emits a collapsible [section] into a [LazyListScope]: a sticky header for the
* title and, only while [expanded], the content as items of the *same* outer * title and one body item after it, wrapped in [CollapsibleSectionBody] so the
* list. Nothing ever nests a scrollable, so real laziness is preserved. * whole section animates as a unit. Nothing ever nests a scrollable, so the
* outer list keeps its own scroll and laziness.
*/ */
@OptIn(ExperimentalFoundationApi::class) @OptIn(ExperimentalFoundationApi::class)
fun LazyListScope.collapsibleSection( fun LazyListScope.collapsibleSection(
@@ -111,12 +144,12 @@ fun LazyListScope.collapsibleSection(
key: Any, key: Any,
expanded: Boolean, expanded: Boolean,
onToggle: () -> Unit, onToggle: () -> Unit,
content: LazyListScope.() -> Unit, content: @Composable () -> Unit,
) { ) {
stickyHeader(key = "section-$key") { stickyHeader(key = "section-$key") {
SectionHeader(title = title, expanded = expanded, onToggle = onToggle) SectionHeader(title = title, expanded = expanded, onToggle = onToggle)
} }
if (expanded) { item(key = "section-$key-body") {
content() CollapsibleSectionBody(expanded) { content() }
} }
} }
@@ -42,6 +42,7 @@ import net.awan.pipelines.data.protocol.Stage
import net.awan.pipelines.data.protocol.edges import net.awan.pipelines.data.protocol.edges
import net.awan.pipelines.ui.AppViewModel import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.components.CodeBlock import net.awan.pipelines.ui.components.CodeBlock
import net.awan.pipelines.ui.components.CollapsibleSectionBody
import net.awan.pipelines.ui.components.DetailTabBody import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.KeyValueRow import net.awan.pipelines.ui.components.KeyValueRow
import net.awan.pipelines.ui.components.PaneIdentity import net.awan.pipelines.ui.components.PaneIdentity
@@ -518,9 +519,10 @@ private fun StageDetailBody(
/** /**
* One collapsible section of the stage pane: its header toggles [expansion] * One collapsible section of the stage pane: its header toggles [expansion]
* under [key] and, while it is expanded, [content] is rendered. The title * under [key] and its body animates open/closed with the shared
* defaults to the capitalised key (e.g. `artifacts` → `Artifacts`), so the pane * [CollapsibleSectionBody], so the content and the chevron move together. The
* names every section the same way. * title defaults to the capitalised key (e.g. `artifacts` → `Artifacts`), so the
* pane names every section the same way.
*/ */
@Composable @Composable
private fun StageSection( private fun StageSection(
@@ -529,13 +531,14 @@ private fun StageSection(
title: String = key.capitalized(), title: String = key.capitalized(),
content: @Composable () -> Unit, content: @Composable () -> Unit,
) { ) {
val expanded = expansion.isExpanded(key)
SectionHeader( SectionHeader(
title, title,
expansion.isExpanded(key), expanded,
{ expansion.toggle(key) }, { expansion.toggle(key) },
containerColor = paneContainerColor(), containerColor = paneContainerColor(),
) )
if (expansion.isExpanded(key)) content() CollapsibleSectionBody(expanded) { content() }
} }
/** The stage pane hosted directly by the run destination, reading the run detail. */ /** The stage pane hosted directly by the run destination, reading the run detail. */
@@ -13,7 +13,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.ContentCopy import androidx.compose.material.icons.filled.ContentCopy
@@ -57,7 +56,6 @@ import net.awan.pipelines.ui.components.LoadPhase
import net.awan.pipelines.ui.components.LoadingState import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.StateCrossfade import net.awan.pipelines.ui.components.StateCrossfade
import net.awan.pipelines.ui.components.animateListItem
import net.awan.pipelines.ui.components.paneSafeArea import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.collapsibleSection import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.copyText import net.awan.pipelines.ui.components.copyText
@@ -222,16 +220,18 @@ private fun PipelineSummaryTab(detail: PipelineDetail, wide: Boolean, modifier:
onToggle = { versionsExpanded = !versionsExpanded }, onToggle = { versionsExpanded = !versionsExpanded },
) { ) {
if (detail.versions.isEmpty()) { if (detail.versions.isEmpty()) {
item(key = "versions-empty") { Text(
Text( "No versions recorded.",
"No versions recorded.", style = text.meta,
style = text.meta, modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), )
)
}
} else { } else {
items(detail.versions, key = { "version-${it.version}" }) { v -> // The version list is bounded and small, so it renders in the
VersionRow(v, animateListItem(Modifier.padding(horizontal = 16.dp, vertical = 4.dp))) // section's single animated body item; the rows are not lazy.
Column(modifier = Modifier.fillMaxWidth()) {
detail.versions.forEach { v ->
VersionRow(v, Modifier.padding(horizontal = 16.dp, vertical = 4.dp))
}
} }
} }
} }
@@ -342,15 +342,13 @@ private fun PipelineSourceTab(detail: PipelineDetail, modifier: Modifier) {
expanded = expansion.isExpanded(sectionKey), expanded = expansion.isExpanded(sectionKey),
onToggle = { expansion.toggle(sectionKey) }, onToggle = { expansion.toggle(sectionKey) },
) { ) {
item(key = "$sectionKey-body") { Column(
Column( modifier = Modifier
modifier = Modifier .fillMaxWidth()
.fillMaxWidth() .padding(horizontal = 16.dp, vertical = 8.dp),
.padding(horizontal = 16.dp, vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(4.dp),
verticalArrangement = Arrangement.spacedBy(4.dp), ) {
) { fields.forEach { field -> StageFieldRow(field) }
fields.forEach { field -> StageFieldRow(field) }
}
} }
} }
} }
@@ -61,7 +61,6 @@ import net.awan.pipelines.ui.components.LoadPhase
import net.awan.pipelines.ui.components.LoadingState import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.StateCrossfade import net.awan.pipelines.ui.components.StateCrossfade
import net.awan.pipelines.ui.components.animateListItem
import net.awan.pipelines.ui.components.paneSafeArea import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.RunStatusIcon import net.awan.pipelines.ui.components.RunStatusIcon
import net.awan.pipelines.ui.components.StatusChip import net.awan.pipelines.ui.components.StatusChip
@@ -493,13 +492,11 @@ private fun RunFieldSectionsTab(
expanded = expansion.isExpanded(sectionKey), expanded = expansion.isExpanded(sectionKey),
onToggle = { expansion.toggle(sectionKey) }, onToggle = { expansion.toggle(sectionKey) },
) { ) {
item(key = "$sectionKey-body") { CodeBlock(
CodeBlock( label = label,
label = label, text = value.displayText(),
text = value.displayText(), modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp),
modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp), )
)
}
} }
} }
} }
@@ -569,12 +566,7 @@ private fun RunEvidenceTab(
expanded = expansion.isExpanded(sectionKey), expanded = expansion.isExpanded(sectionKey),
onToggle = { expansion.toggle(sectionKey) }, onToggle = { expansion.toggle(sectionKey) },
) { ) {
item(key = "$sectionKey-body") { EvidenceDetails(record, Modifier.padding(horizontal = 16.dp, vertical = 4.dp))
EvidenceDetails(
record,
animateListItem(Modifier.padding(horizontal = 16.dp, vertical = 4.dp)),
)
}
} }
} }
} }
@@ -1,5 +1,7 @@
package net.awan.pipelines.ui package net.awan.pipelines.ui
import androidx.compose.ui.unit.Dp
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
@@ -29,4 +31,27 @@ class PipelinesNavTest {
assertFalse(destinationSelected(null, "runs")) assertFalse(destinationSelected(null, "runs"))
assertFalse(destinationSelected(null, "settings")) assertFalse(destinationSelected(null, "settings"))
} }
@Test
fun destinationIndicatorLinesUpWithItsSlot() {
// The travelling indicator sits at the pill's inner padding plus one slot
// (item + gap) per destination, so it rests exactly over the icon it
// selects.
assertDp(4f, destinationIndicatorOffsetDp(0, DESTINATION_ITEM_SIZE, DESTINATION_ITEM_GAP))
assertDp(56f, destinationIndicatorOffsetDp(1, DESTINATION_ITEM_SIZE, DESTINATION_ITEM_GAP))
assertDp(108f, destinationIndicatorOffsetDp(2, DESTINATION_ITEM_SIZE, DESTINATION_ITEM_GAP))
}
@Test
fun destinationIndicatorPinsWhenNothingIsSelected() {
// A missing selection (-1) must not index a negative offset; it pins to
// the first slot while the caller draws no indicator at all.
assertEquals(
destinationIndicatorOffsetDp(0, DESTINATION_ITEM_SIZE, DESTINATION_ITEM_GAP),
destinationIndicatorOffsetDp(-1, DESTINATION_ITEM_SIZE, DESTINATION_ITEM_GAP),
)
}
private fun assertDp(expected: Float, actual: Dp) =
assertEquals(expected, actual.value, 0.01f)
} }