Merge branch 'main' into lane-go

This commit is contained in:
2026-10-16 10:45:56 +01:00
14 changed files with 749 additions and 159 deletions
+158
View File
@@ -2011,3 +2011,161 @@ Not verified in this pass: the link fallback on-device (the reachable server ran
the file path); a narrow-window layout of the selection bar; receiving the bulk
share in a third-party app (the chooser was observed, not an import).
### Named motion tokens and animated list changes (16 Oct 2026, run 104/1)
Every animation duration and easing now lives in one file, and the pipelines and
runs lists animate per item instead of cutting.
- **One motion token file.** `ui/components/Motion.kt` (beside the pane's
dimension tokens in `SlidingPaneStack.kt`) defines two named tokens, each a
duration + easing pair: `MotionQuick` (120ms) for small in-place state changes
(the section chevron, a list row appearing/leaving) and `MotionStandard`
(220ms) for content moving or swapping (a pane sliding, a section
cross-fading, an item taking a new place in a re-sorted list). Nothing exceeds
the `MAX_MOTION_MILLIS` (300ms) cap and both easings are monotonic
ease-in-out curves; `MotionStandard` is symmetric, which is what keeps a pane
close the exact reverse of its open. A call site asks a token for its concrete
spec via `spec()`; it never writes a duration. The pane slide, the section
`Crossfade` and the chevron now use the tokens (`PANE_SLIDE_*` /
`SECTION_SWAP_MILLIS` are gone), and the pane pop stagger moved in as
`MOTION_STAGGER_MILLIS`.
- **Per-item list animation.** A single shared `LazyItemScope.animateListItem()`
(`ListRow.kt`) wraps Compose's supported `Modifier.animateItem(fadeInSpec,
placementSpec, fadeOutSpec)` with the tokens: an item fades in as it appears
and out as it leaves (`MotionQuick`), and the items still on screen slide to
their new positions when the list is refreshed, filtered or re-sorted
(`MotionStandard`) rather than jumping. Pipelines rows, run rows, pipeline
version rows and run evidence rows all use it. Because it is the supported
lazy-list item animation the list keeps its own scroll/measure state; the
modifier only drives the transition, so a resting list is unchanged.
- **System animation setting.** The tokens map onto Compose's standard
animations, so the platform animator duration scale applies unchanged: with
animations disabled each spec runs for zero time and an item is at its final
state at once, no special case.
- **No per-frame allocation.** Specs are built at composition time, not per
frame, and the chevron reads its animating angle inside the layer
(`graphicsLayer { rotationZ = … }`) so it turns without recomposing the header
each frame.
Verified on `emulator-5554` only (fold layout, 2076x2152 / 390dpi ≈ 852dp,
against the live server; never the attached Pixel):
- `gradle :app:assembleDebug :app:testDebugUnitTest --offline --console=plain`
(Gradle 9.7.1, JDK 17, `ANDROID_HOME` set) → `BUILD SUCCESSFUL`.
`gradle :app:testDebugUnitTest --rerun-tasks --offline` re-ran every result XML
to **174 tests across 22 classes, 0 failures, 0 errors, 0 skipped**; the new
`MotionTest` (6 cases) checks the token ordering (quick shorter than standard),
the per-token bands (quick 100-150ms, standard 200-250ms), the ≤300ms cap, that
every easing is monotonic `0→1`, that `MotionStandard` reverses itself, and
that a spec carries its token's timing. `SlidingPaneStackTest` now reads the
pane's timing from the token.
- **Filter change** (`filter.mp4`, frames `sheet1.png`/`sheet2.png`): at
`animator_duration_scale 5`, typing `docker` into the pipelines search fades
the non-matching rows out and moves the survivors up; deleting it brings the
rows back in.
- **A new run arriving** (`newrun.mp4`, frames `newrun_arrival.png` /
`newrun_sheet1.png`): run 105 was admitted out-of-band with
`pipelines run --json --pipeline 8 … --yes` (**not** from the app); tapping
Refresh in the Runs list shows run 105 fade in at the top while every existing
row slides down to make room. Run 105 then failed (its stage returned
`blocked`), so nothing had to be reclaimed.
- **Reduced motion** (`red_sheet.png`): at `animator_duration_scale 0`, typing
`d`/`do`/`doc`/`dock` leaves each captured frame fully settled — no ghosted or
half-placed rows — i.e. the change is instant with no partial state.
- `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` (17,913,089 bytes, sha256 `4bc1b781…`) copied
to `~/.local/share/pipelines/data/artifacts/104/1/pipelines-debug-wip-0b74903.apk`
(`0b74903` = `git rev-parse --short HEAD`); `curl -I
http://10.0.0.249:8080/artifacts/104/1/pipelines-debug-wip-0b74903.apk` returned
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 17913089`, and a streamed `curl | shasum -a 256` returned the
same `4bc1b781…`.
Not verified in this pass: a narrow-window frame of the item animation; an item
leaving a list (a run being deleted is not a client action), only the
appear/move halves driven above.
## Loading, empty and error states cross-fade (16 Oct 2026)
A data-backed pane used to swap its loading spinner, empty message, error message
and content with a plain `when`, so content flashed from empty to full and an
empty or error state popped. Every pane now swaps through one shared
`StateCrossfade` (`ui/components/States.kt`) — a `Crossfade` on the pane's
classified state using the already-named `MotionStandard` token. No dependency,
geometry token or literal was added.
- **`LoadPhase`** is the mutually exclusive presentation state: `Loading`,
`Error(message)`, `Empty(message)`, `Content`. The message-carrying phases keep
the text they were classified with, so the branch that is fading out is never
recomposed against a since-cleared error or a since-changed filter.
- **`listLoadPhase(loading, error, hasData, emptyMessage)`** and
**`detailLoadPhase(error, hasData)`** are the pure classifiers. A list pane
reports a failed load with no data, then a load with no data, then empty, else
content; a detail pane has no empty state, so data present is content, then a
reported error, then loading. Stale data keeps a pane on `Content` (the screen
shows the error inline), exactly as before — only the presentation changed.
- **`StateCrossfade(phase)`** wraps the branch in a `Crossfade` with
`MotionStandard.spec()`; both branches are laid out in one box, so the resting
layout is exactly the branch's own layout and the outgoing phase fades under
the incoming one. Applied to `PipelineListScreen`, `RunHistoryScreen`,
`PipelineDetailScreen` and `RunDetailScreen`. `LoadingState`, `ErrorState` and
`EmptyState` themselves are unchanged.
- The detail panes render the fading-out branch from the last non-null item
(`rememberPaneContent`, the same helper the closing pane uses), so selecting
another pipeline/run fades the old content out instead of blanking it.
- The Runs pane has no pane-level empty state — an empty list keeps its usage
block and sticky headers and shows its `No runs have been recorded yet.` line
inside the list, where it now fades in/out through the existing
`animateListItem()`, as does its inline error line.
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 9.7.1,
`ANDROID_HOME=~/Library/Android/sdk`, `--offline`):
- `gradle :app:assembleDebug :app:testDebugUnitTest --console=plain` →
`BUILD SUCCESSFUL`; `--rerun-tasks` re-ran all 23 result XMLs to **184 tests, 0
failures, 0 errors, 0 skipped** (up from 174; the new `LoadPhaseTest` adds 10
pure cases for the classifiers and the message-carrying phases).
`app/build/outputs/apk/debug/app-debug.apk` is 17,913,089 bytes, sha256
`e99bb970…`.
- On `emulator-5554` only (fold AVD, 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`, `animator_duration_scale`
used only to slow the capture:
- **Loading → content** at `animator_duration_scale 10`
(`load-to-content-10x.mp4`, `load-to-content-10x-sheet.png`): selecting a
pipeline shows `Loading pipeline…` and the summary then fades in;
`load-to-content-10x-overlap.png` freezes the cross-fade with the loading text
(`…ding pip…`) and the dimmed summary visible together, instead of a flash.
- **Empty appearing and going away** at scale 10
(`empty-appear-disappear-10x-sheet.png`): typing `zzz` into the pipelines
search makes `No pipelines match "zzz".` fade in, and clearing it fades the
list back.
- **Error → content** at scale 10 (`error-to-content-recovery-10x-sheet.png`):
with the connection down the Runs pane showed the error state; after the
connection returned, pressing Retry fades the error out and the loaded runs
(usage block, day groups) in.
- **Animations disabled** (`animator_duration_scale 0`): `disabled-empty-sheet.png`
(same type/clear) and `disabled-content-sheet.png` (open a pipeline) are each
fully settled on every frame — no ghosted or half-placed state, i.e. the swap
is instant with no special case.
- **Resting layout**: a settled Pipelines list captured at scale 1 and at scale
0 is pixel-identical (`captures/imgdiff.py` → `([0.0, 0.0, 0.0], 0.0)`), so the
cross-fade never alters the settled layout.
- `adb -s emulator-5554 logcat -d` held 0 `FATAL EXCEPTION` / 0
`E AndroidRuntime` lines; `animator_duration_scale` was left at 1; no run was
started from the app.
- **APK publish.** `app-debug.apk` copied to
`~/.local/share/pipelines/data/artifacts/106/1/pipelines-debug-wip-934994d.apk`
(`934994d` = `git rev-parse --short HEAD`; the working tree is uncommitted WIP on
top of it), sha256 `e99bb970…`. `curl
http://10.0.0.75:8080/artifacts/106/1/pipelines-debug-wip-934994d.apk` returned
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 17913089`, and a streamed `GET | shasum -a 256` returned the
same `e99bb970…` (`10.0.0.249` served it too; at 17.1 MiB it exceeds the 8 MiB
per-file inventory cap, so it is served by direct URL only).
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
before a loading frame could be drawn, only its fade-out was captured).
@@ -1,7 +1,6 @@
package net.awan.pipelines.ui.components
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -115,7 +114,7 @@ fun DetailTabs(
val swap: @Composable (Modifier) -> Unit = { contentModifier ->
Crossfade(
targetState = selected,
animationSpec = tween(durationMillis = SECTION_SWAP_MILLIS),
animationSpec = MotionStandard.spec(),
modifier = contentModifier,
label = "section-swap",
) { index ->
@@ -277,8 +276,5 @@ fun rememberSectionExpansion(
/** The always-visible wide section rail's width (icons with labels). */
private const val WIDE_RAIL_WIDTH_DP = 200
/** The in-place section swap's cross-fade duration in milliseconds (short). */
private const val SECTION_SWAP_MILLIS = 180
/** Comfortable max text width for a tab body on a wide window. */
const val DETAIL_MAX_WIDTH_DP = 840
@@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.foundation.selection.selectable
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.LocalContentColor
@@ -70,3 +71,26 @@ fun ListRow(
}
}
}
/**
* The one per-item animation for the app's lazy lists (pipelines, runs, version
* and evidence rows). It is Compose's supported lazy-list item animation
* (`Modifier.animateItem`, not the deprecated placement-only one), so the list
* keeps its own scroll/measure state and is never re-measured or janked:
*
* - an item fades in as it appears and out as it leaves ([MotionQuick], a small
* in-place state change);
* - while it is on screen and the list is refreshed, filtered or re-sorted, it
* slides to its new position ([MotionStandard]) instead of jumping;
* - the item's resting appearance is untouched — the modifier only drives the
* transition, so the settled list is exactly the list without it.
*
* The specs are built here at composition time, not per frame, and every token
* maps the system animator duration scale, so with animations disabled Compose
* runs each spec for zero time and the item is at its final state at once.
*/
internal fun LazyItemScope.animateListItem(modifier: Modifier = Modifier): Modifier = modifier.animateItem(
fadeInSpec = MotionQuick.spec(),
placementSpec = MotionStandard.spec(),
fadeOutSpec = MotionQuick.spec(),
)
@@ -0,0 +1,61 @@
package net.awan.pipelines.ui.components
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.Easing
import androidx.compose.animation.core.TweenSpec
import androidx.compose.animation.core.tween
/**
* The named motion tokens: the one place every animation duration and easing in
* the app is defined, alongside the pane's dimension tokens in
* [SlidingPaneStack]. No call site writes a duration of its own.
*
* There are two, matching the size of the change:
* - [MotionQuick] — a small state change that stays where it is: a chevron
* turning, a list row appearing or leaving. Deliberately short (100-150ms).
* - [MotionStandard] — content that moves or swaps: a pane sliding, a section
* cross-fading, a row taking its new place in a refreshed, filtered or
* re-sorted list (200-250ms).
*
* Nothing animates for longer than [MAX_MOTION_MILLIS] (~300ms). Both easings
* are monotonic ease-in-out curves and [MotionStandard] is symmetric, so an
* animation run backwards is the same curve travelled backwards (see
* [paneSlideSpec], whose exact reversal is a unit-tested property).
*
* A token carries only timing; a call site asks it for the concrete spec it
* needs through [spec]. The spec is built during composition (or when the state
* changes), never per frame: the frame loop only advances an animator Compose
* already owns, so an animation allocates nothing as it runs.
*/
internal data class MotionToken(val durationMillis: Int, val easing: Easing) {
init {
require(durationMillis in 1..MAX_MOTION_MILLIS) {
"motion duration out of range: $durationMillis (1..$MAX_MOTION_MILLIS)"
}
}
}
/** The longest any single animation may run, in milliseconds. */
internal const val MAX_MOTION_MILLIS = 300
/** The stagger between the levels of a multi-level pane pop, in milliseconds. */
internal const val MOTION_STAGGER_MILLIS = 60
/** Small, in-place state changes (~100-150ms). */
internal val MotionQuick = MotionToken(
durationMillis = 120,
easing = CubicBezierEasing(0.4f, 0f, 0.6f, 1f),
)
/** Content moving or swapping (~200-250ms); symmetric, so it reverses exactly. */
internal val MotionStandard = MotionToken(
durationMillis = 220,
easing = CubicBezierEasing(0.42f, 0f, 0.58f, 1f),
)
/** The one tween for this token, optionally staggered by [delayMillis]. */
internal fun <T> MotionToken.spec(delayMillis: Int = 0): TweenSpec<T> = tween(
durationMillis = durationMillis,
delayMillis = delayMillis,
easing = easing,
)
@@ -17,11 +17,10 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
@@ -55,8 +54,9 @@ fun SectionHeader(
modifier: Modifier = Modifier,
containerColor: Color = MaterialTheme.colorScheme.background,
) {
val rotation by animateFloatAsState(
val rotation = animateFloatAsState(
targetValue = if (expanded) 0f else -90f,
animationSpec = MotionQuick.spec(),
label = "section-chevron",
)
Column(
@@ -91,7 +91,9 @@ fun SectionHeader(
Icon(
imageVector = Icons.Default.KeyboardArrowDown,
contentDescription = null,
modifier = Modifier.rotate(rotation),
// Read the animating angle inside the layer so the chevron turns
// without recomposing the header on every frame.
modifier = Modifier.graphicsLayer { rotationZ = rotation.value },
)
}
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
@@ -1,10 +1,7 @@
package net.awan.pipelines.ui.components
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.Easing
import androidx.compose.animation.core.TweenSpec
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
@@ -57,41 +54,37 @@ internal val MIN_ACTIVE_PANE_WIDTH_DP = 320.dp
internal val MIN_COVERED_PANE_WIDTH_DP = 112.dp
/**
* The one slide timing every pane shares. [PANE_SLIDE_EASING] is a symmetric
* ease (its control points mirror about the centre), so the same curve run from
* the open offset back to the closed one is exactly the open curve travelled
* backwards: closing a pane is the time-reverse of opening it, at the same
* [PANE_SLIDE_MILLIS] duration. When several levels close in one tap the levels
* below the topmost wait [PANE_POP_STEP_MILLIS] each, so they reverse in order.
* The one slide timing every pane shares: the [MotionStandard] token, whose
* easing is symmetric (its control points mirror about the centre). The same
* curve run from the open offset back to the closed one is therefore exactly the
* open curve travelled backwards — closing a pane is the time-reverse of opening
* it, at the same [MotionStandard.durationMillis]. When several levels close in
* one tap the levels below the topmost wait [MOTION_STAGGER_MILLIS] each, so they
* reverse in order.
*/
internal const val PANE_SLIDE_MILLIS = 300
internal const val PANE_POP_STEP_MILLIS = 60
internal val PANE_SLIDE_EASING: Easing = CubicBezierEasing(0.42f, 0f, 0.58f, 1f)
/**
* The extra delay, in milliseconds, before the pane at [level] starts reversing
* for a stack whose visible depth just moved from [previousDepth] to [depth]. A
* single closing level is the exact reverse of opening it and starts at once;
* when more than one level was open and several are leaving, the topmost leaves
* first and each lower level waits one more [PANE_POP_STEP_MILLIS] so the
* first and each lower level waits one more [MOTION_STAGGER_MILLIS] so the
* cascade reads in order. A level that is open or opening never waits. Pure, so
* the mirror/stagger rule needs no device.
*/
internal fun paneSlideDelayMillis(level: Int, depth: Int, previousDepth: Int): Int {
if (level <= depth) return 0
val closing = previousDepth - depth
return if (closing > 1) (previousDepth - level) * PANE_POP_STEP_MILLIS else 0
return if (closing > 1) (previousDepth - level) * MOTION_STAGGER_MILLIS else 0
}
/**
* The slide spec for the pane at [level]: one shared duration and easing in both
* directions, plus [paneSlideDelayMillis] when several levels pop together.
* The slide spec for the pane at [level]: the shared [MotionStandard] duration
* and easing in both directions, plus [paneSlideDelayMillis] when several levels
* pop together.
*/
internal fun paneSlideSpec(level: Int, depth: Int, previousDepth: Int): TweenSpec<Dp> = tween(
durationMillis = PANE_SLIDE_MILLIS,
delayMillis = paneSlideDelayMillis(level, depth, previousDepth),
easing = PANE_SLIDE_EASING,
)
internal fun paneSlideSpec(level: Int, depth: Int, previousDepth: Int): TweenSpec<Dp> =
MotionStandard.spec(delayMillis = paneSlideDelayMillis(level, depth, previousDepth))
/**
* The peek budget actually spent on a wide window: the fixed [PEEK_BUDGET_DP]
@@ -1,5 +1,6 @@
package net.awan.pipelines.ui.components
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
@@ -65,6 +66,88 @@ fun EmptyState(message: String, modifier: Modifier = Modifier) {
}
}
/**
* The mutually exclusive presentation states of a data-backed pane: a load with
* no data yet ([Loading]), a failed load with no data ([Error]), loaded-but-
* nothing-to-show ([Empty]) and loaded content ([Content]).
*
* Both message-carrying states and [Empty] capture the text they are rendered
* with when the state is classified and never read a live value, so the branch
* that is fading out cannot be recomposed against a since-cleared error or a
* since-changed filter. [StateCrossfade] animates between these and a pane is in
* exactly one at a time.
*/
sealed interface LoadPhase {
/** A load is in flight and there is nothing to show yet. */
data object Loading : LoadPhase
/** The load failed and there is no data to fall back to. */
data class Error(val message: String) : LoadPhase
/** The load succeeded but there is nothing to show; [message] explains it. */
data class Empty(val message: String) : LoadPhase
/** The loaded content. */
data object Content : LoadPhase
}
/**
* Classifies a list pane's [LoadPhase] from its load signals. A failed load with
* no data wins, then a load with no data, then an empty result; anything else is
* [LoadPhase.Content]. [emptyMessage] is non-null exactly when the pane is empty
* and is the text to show, captured so a fading-out empty branch never reads a
* changed query.
*
* When stale data is present neither loading nor an error replaces it: the
* screen keeps showing the data and surfaces the error inline, so [hasData]
* suppresses both.
*/
fun listLoadPhase(
loading: Boolean,
error: String?,
hasData: Boolean,
emptyMessage: String?,
): LoadPhase = when {
error != null && !hasData -> LoadPhase.Error(error)
loading && !hasData -> LoadPhase.Loading
emptyMessage != null -> LoadPhase.Empty(emptyMessage)
else -> LoadPhase.Content
}
/**
* Classifies a detail pane's [LoadPhase]. There is no empty state — a detail with
* no data is either an error or still loading — so data present means [Content],
* then a reported error, then [LoadPhase.Loading].
*/
fun detailLoadPhase(error: String?, hasData: Boolean): LoadPhase = when {
hasData -> LoadPhase.Content
error != null -> LoadPhase.Error(error)
else -> LoadPhase.Loading
}
/**
* Cross-fades a pane between its [LoadPhase] branches with the shared
* [MotionStandard] token. Both branches are laid out in the same box, so the
* resting layout is exactly the branch's own layout while the outgoing phase
* fades out under the incoming one: loading never flashes into content and an
* empty or error state fades in and out rather than popping. With system
* animations disabled Compose maps the platform animator duration scale onto the
* spec, so the swap is instant.
*/
@Composable
fun StateCrossfade(
phase: LoadPhase,
modifier: Modifier = Modifier,
content: @Composable (LoadPhase) -> Unit,
) {
Crossfade(
targetState = phase,
animationSpec = MotionStandard.spec(),
modifier = modifier,
label = "load-phase",
) { content(it) }
}
/** Renders a labelled key/value row used across detail screens. */
@Composable
fun KeyValueRow(
@@ -53,12 +53,17 @@ import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.DetailTabs
import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.KeyValueRow
import net.awan.pipelines.ui.components.LoadPhase
import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
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.collapsibleSection
import net.awan.pipelines.ui.components.copyText
import net.awan.pipelines.ui.components.detailLoadPhase
import net.awan.pipelines.ui.components.pipelineDetailTabs
import net.awan.pipelines.ui.components.rememberPaneContent
import net.awan.pipelines.ui.components.rememberSectionExpansion
import net.awan.pipelines.ui.graph.StageFieldRow
import net.awan.pipelines.ui.graph.WorkflowGraph
@@ -88,6 +93,11 @@ fun PipelineDetailScreen(
val detail = state.data?.takeIf { it.id == pipelineId }
// The cross-fading content branch renders the last non-null detail, so
// switching to another pipeline (which nulls the id-filtered detail) fades
// the old content out instead of blanking it.
val shownDetail = rememberPaneContent(detail)
// A covered pane shows its compact identity only; the tab rail and section
// body must never be drawn squeezed into the peek strip.
if (covered) {
@@ -122,29 +132,36 @@ fun PipelineDetailScreen(
)
},
) { padding ->
when {
detail == null && state.error != null -> ErrorState(
state.error!!,
onRetry = { vm.loadPipeline(pipelineId, version) },
modifier = Modifier.padding(padding),
)
detail == null -> LoadingState("Loading pipeline…", Modifier.padding(padding))
else -> DetailTabs(
tabs = pipelineDetailTabs,
selectedIndex = selectedSection,
onSelect = onSelectSection,
wide = wide,
modifier = Modifier.padding(padding).fillMaxSize(),
) { tab, contentModifier ->
// Only the selected section's content is composed at rest.
when (tab.key) {
"summary" -> PipelineSummaryTab(detail, wide, contentModifier)
"graph" -> PipelineGraphTab(
detail = detail,
modifier = contentModifier,
onStageTap = onOpenStage,
)
else -> PipelineSourceTab(detail, contentModifier)
StateCrossfade(
phase = detailLoadPhase(state.error, hasData = detail != null),
modifier = Modifier.fillMaxSize(),
) { phase ->
when (phase) {
is LoadPhase.Error -> ErrorState(
phase.message,
onRetry = { vm.loadPipeline(pipelineId, version) },
modifier = Modifier.padding(padding),
)
LoadPhase.Loading -> LoadingState("Loading pipeline…", Modifier.padding(padding))
else -> if (shownDetail != null) {
DetailTabs(
tabs = pipelineDetailTabs,
selectedIndex = selectedSection,
onSelect = onSelectSection,
wide = wide,
modifier = Modifier.padding(padding).fillMaxSize(),
) { tab, contentModifier ->
// Only the selected section's content is composed at rest.
when (tab.key) {
"summary" -> PipelineSummaryTab(shownDetail, wide, contentModifier)
"graph" -> PipelineGraphTab(
detail = shownDetail,
modifier = contentModifier,
onStageTap = onOpenStage,
)
else -> PipelineSourceTab(shownDetail, contentModifier)
}
}
}
}
}
@@ -214,7 +231,7 @@ private fun PipelineSummaryTab(detail: PipelineDetail, wide: Boolean, modifier:
}
} else {
items(detail.versions, key = { "version-${it.version}" }) { v ->
VersionRow(v, Modifier.padding(horizontal = 16.dp, vertical = 4.dp).animateItem())
VersionRow(v, animateListItem(Modifier.padding(horizontal = 16.dp, vertical = 4.dp)))
}
}
}
@@ -36,8 +36,12 @@ import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.components.EmptyState
import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.ListRow
import net.awan.pipelines.ui.components.LoadPhase
import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.StateCrossfade
import net.awan.pipelines.ui.components.animateListItem
import net.awan.pipelines.ui.components.listLoadPhase
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.theme.pipelinesText
@@ -91,29 +95,36 @@ fun PipelineListScreen(
singleLine = true,
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),
)
when {
state.loading && state.data == null -> LoadingState("Loading pipelines…")
state.error != null && state.data == null -> ErrorState(state.error!!, onRetry = vm::refreshPipelines)
else -> {
val items = (state.data ?: emptyList())
.filter { it.name.contains(query, ignoreCase = true) }
if (items.isEmpty()) {
EmptyState(
if (query.isBlank()) "No pipelines are defined on this server."
else "No pipelines match \"$query\".",
)
val pipelines = (state.data ?: emptyList())
.filter { it.name.contains(query, ignoreCase = true) }
StateCrossfade(
phase = listLoadPhase(
loading = state.loading,
error = state.error,
hasData = state.data != null,
emptyMessage = if (pipelines.isEmpty()) {
if (query.isBlank()) "No pipelines are defined on this server."
else "No pipelines match \"$query\"."
} else {
LazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(vertical = 8.dp),
) {
items(items, key = { it.id }) { pipeline ->
PipelineRow(
pipeline = pipeline,
selected = pipeline.id == selectedId,
onClick = { onOpen(pipeline.id, pipeline.version) },
)
}
null
},
),
) { phase ->
when (phase) {
LoadPhase.Loading -> LoadingState("Loading pipelines…")
is LoadPhase.Error -> ErrorState(phase.message, onRetry = vm::refreshPipelines)
is LoadPhase.Empty -> EmptyState(phase.message)
LoadPhase.Content -> LazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(vertical = 8.dp),
) {
items(pipelines, key = { it.id }) { pipeline ->
PipelineRow(
pipeline = pipeline,
selected = pipeline.id == selectedId,
onClick = { onOpen(pipeline.id, pipeline.version) },
modifier = animateListItem(),
)
}
}
}
@@ -135,11 +146,17 @@ fun PipelineListScreen(
* row is selected when its pipeline is the one open in the detail pane.
*/
@Composable
private fun PipelineRow(pipeline: PipelineSummary, selected: Boolean, onClick: () -> Unit) {
private fun PipelineRow(
pipeline: PipelineSummary,
selected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
val text = pipelinesText()
ListRow(
selected = selected,
onClick = onClick,
modifier = modifier,
leading = {
Icon(
imageVector = Icons.Default.AccountTree,
@@ -57,13 +57,18 @@ import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.DetailTabs
import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.KeyValueRow
import net.awan.pipelines.ui.components.LoadPhase
import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
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.RunStatusIcon
import net.awan.pipelines.ui.components.StatusChip
import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.clampTabIndex
import net.awan.pipelines.ui.components.detailLoadPhase
import net.awan.pipelines.ui.components.rememberPaneContent
import net.awan.pipelines.ui.components.rememberSectionExpansion
import net.awan.pipelines.ui.components.runDetailTabs
import net.awan.pipelines.ui.components.runStateOf
@@ -115,6 +120,13 @@ fun RunDetailScreen(
val run = state.data?.takeIf { it.id == runId }
val executing = run?.executing == true
// The cross-fading content branch renders the last non-null run, so
// switching to another run (which nulls the id-filtered run) fades the old
// content out instead of blanking it. The artifact groups are derived from
// the same snapshot, so the outgoing grid keeps its cells; the selection is
// reseeded per run id, so a stale candidate set is never selectable.
val shownRun = rememberPaneContent(run)
// Bounded polling: only while the run is executing, stopped on terminal status.
LaunchedEffect(runId, executing) {
if (executing) {
@@ -127,7 +139,7 @@ fun RunDetailScreen(
// Aggregated once per step-list change; it drives the grid and the
// selection's copy/share actions, never recomputed per recomposition.
val artifactGroups = remember(run?.steps) { runArtifactGroups(run?.steps.orEmpty()) }
val artifactGroups = remember(shownRun?.steps) { runArtifactGroups(shownRun?.steps.orEmpty()) }
val candidateArtifacts = remember(artifactGroups) {
artifactGroups.flatMap { it.artifacts }.distinctBy { it.url }
}
@@ -181,65 +193,70 @@ fun RunDetailScreen(
)
},
) { selection, onSelectionChange, padding ->
when {
run == null && state.error != null -> ErrorState(
state.error!!,
onRetry = { vm.loadRun(runId) },
modifier = Modifier.padding(padding),
)
run == null -> LoadingState("Loading run…", Modifier.padding(padding))
else -> {
DetailTabs(
tabs = runDetailTabs,
selectedIndex = selectedSection,
onSelect = onSelectSection,
wide = wide,
modifier = Modifier.padding(padding).fillMaxSize(),
) { tab, contentModifier ->
// Only the selected section's content is composed at rest.
when (tab.key) {
"summary" -> RunSummaryTab(
run = run,
wide = wide,
modifier = contentModifier,
configuredServerUrl = configuredServerUrl,
fetchArtifactBytes = vm::fetchArtifactBytes,
artifactGroups = artifactGroups,
selection = selection,
onSelectionChange = onSelectionChange,
)
"graph" -> RunGraphTab(
run = run,
modifier = contentModifier,
onStageTap = onOpenStage,
)
"input" -> RunFieldSectionsTab(
emptyMessage = "No input recorded.",
keyPrefix = "input",
entries = run.input.orEmpty().toList(),
wide = wide,
modifier = contentModifier,
)
"output" -> RunFieldSectionsTab(
emptyMessage = "No output recorded.",
keyPrefix = "output",
entries = run.output.orEmpty().toList(),
wide = wide,
modifier = contentModifier,
)
"evidence" -> RunEvidenceTab(
evidenceState = evidenceState,
steps = run.steps,
onLoadEvidence = { vm.loadEvidence(runId) },
wide = wide,
modifier = contentModifier,
)
else -> RunTimelineTab(
run = run,
wide = wide,
modifier = contentModifier,
onStageTap = onOpenStage,
)
StateCrossfade(
phase = detailLoadPhase(state.error, hasData = run != null),
modifier = Modifier.fillMaxSize(),
) { phase ->
when (phase) {
is LoadPhase.Error -> ErrorState(
phase.message,
onRetry = { vm.loadRun(runId) },
modifier = Modifier.padding(padding),
)
LoadPhase.Loading -> LoadingState("Loading run…", Modifier.padding(padding))
else -> if (shownRun != null) {
DetailTabs(
tabs = runDetailTabs,
selectedIndex = selectedSection,
onSelect = onSelectSection,
wide = wide,
modifier = Modifier.padding(padding).fillMaxSize(),
) { tab, contentModifier ->
// Only the selected section's content is composed at rest.
when (tab.key) {
"summary" -> RunSummaryTab(
run = shownRun,
wide = wide,
modifier = contentModifier,
configuredServerUrl = configuredServerUrl,
fetchArtifactBytes = vm::fetchArtifactBytes,
artifactGroups = artifactGroups,
selection = selection,
onSelectionChange = onSelectionChange,
)
"graph" -> RunGraphTab(
run = shownRun,
modifier = contentModifier,
onStageTap = onOpenStage,
)
"input" -> RunFieldSectionsTab(
emptyMessage = "No input recorded.",
keyPrefix = "input",
entries = shownRun.input.orEmpty().toList(),
wide = wide,
modifier = contentModifier,
)
"output" -> RunFieldSectionsTab(
emptyMessage = "No output recorded.",
keyPrefix = "output",
entries = shownRun.output.orEmpty().toList(),
wide = wide,
modifier = contentModifier,
)
"evidence" -> RunEvidenceTab(
evidenceState = evidenceState,
steps = shownRun.steps,
onLoadEvidence = { vm.loadEvidence(runId) },
wide = wide,
modifier = contentModifier,
)
else -> RunTimelineTab(
run = shownRun,
wide = wide,
modifier = contentModifier,
onStageTap = onOpenStage,
)
}
}
}
}
@@ -555,7 +572,7 @@ private fun RunEvidenceTab(
item(key = "$sectionKey-body") {
EvidenceDetails(
record,
Modifier.padding(horizontal = 16.dp, vertical = 4.dp).animateItem(),
animateListItem(Modifier.padding(horizontal = 16.dp, vertical = 4.dp)),
)
}
}
@@ -51,8 +51,12 @@ import net.awan.pipelines.ui.components.RunStatusChip
import net.awan.pipelines.ui.components.RunStatusIcon
import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.ListRow
import net.awan.pipelines.ui.components.LoadPhase
import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.StateCrossfade
import net.awan.pipelines.ui.components.animateListItem
import net.awan.pipelines.ui.components.listLoadPhase
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.runStateColor
import net.awan.pipelines.ui.components.runStateOf
@@ -101,22 +105,35 @@ fun RunHistoryScreen(
)
},
) { padding ->
when {
state.loading && state.data == null -> LoadingState("Loading runs…", Modifier.padding(padding))
state.error != null && state.data == null -> ErrorState(
state.error!!,
onRetry = vm::refreshRuns,
modifier = Modifier.padding(padding),
)
else -> RunHistoryContent(
usage = state.data?.usage,
runs = state.data?.runs.orEmpty(),
filterPipelineId = filterPipelineId,
selectedRunId = selectedRunId,
StateCrossfade(
phase = listLoadPhase(
loading = state.loading,
error = state.error,
onOpenRun = onOpenRun,
modifier = Modifier.padding(padding),
)
hasData = state.data != null,
// Runs has no pane-level empty state: an empty list keeps its
// usage block and shows the "no runs" line inside the list, where
// the item animation fades it in and out.
emptyMessage = null,
),
modifier = Modifier.fillMaxSize(),
) { phase ->
when (phase) {
LoadPhase.Loading -> LoadingState("Loading runs…", Modifier.padding(padding))
is LoadPhase.Error -> ErrorState(
phase.message,
onRetry = vm::refreshRuns,
modifier = Modifier.padding(padding),
)
else -> RunHistoryContent(
usage = state.data?.usage,
runs = state.data?.runs.orEmpty(),
filterPipelineId = filterPipelineId,
selectedRunId = selectedRunId,
error = state.error,
onOpenRun = onOpenRun,
modifier = Modifier.padding(padding),
)
}
}
}
}
@@ -159,7 +176,7 @@ private fun RunHistoryContent(
"No runs have been recorded yet.",
style = pipelinesText().body,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(24.dp),
modifier = animateListItem(Modifier.padding(24.dp)),
)
}
} else {
@@ -170,6 +187,7 @@ private fun RunHistoryContent(
run = run,
selected = run.id == selectedRunId,
onClick = { onOpenRun(run.id) },
modifier = animateListItem(),
)
}
}
@@ -180,7 +198,7 @@ private fun RunHistoryContent(
error,
color = MaterialTheme.colorScheme.error,
style = pipelinesText().body,
modifier = Modifier.padding(16.dp),
modifier = animateListItem(Modifier.padding(16.dp)),
)
}
}
@@ -249,12 +267,18 @@ private fun Metric(label: String, value: String, color: Color, text: PipelinesTe
* one open in the detail pane.
*/
@Composable
private fun RunRow(run: RunSummary, selected: Boolean, onClick: () -> Unit) {
private fun RunRow(
run: RunSummary,
selected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
val text = pipelinesText()
val state = runStateOf(run.status)
ListRow(
selected = selected,
onClick = onClick,
modifier = modifier,
leading = {
RunStatusIcon(
state = state,
@@ -0,0 +1,108 @@
package net.awan.pipelines.ui.components
import org.junit.Assert.assertEquals
import org.junit.Test
/**
* The load-phase classification is pure, so the rules the cross-fading screens
* rely on are checked here without a device: a failed load with no data wins over
* loading, a load with no data is loading, an empty result is empty, and stale
* data always keeps the pane on content (the screen shows the error inline
* instead). Detail panes have no empty state, so absent data is an error or a
* load. The message-carrying phases keep the text captured at classification.
*/
class LoadPhaseTest {
// ---- list panes ---------------------------------------------------------
@Test
fun listReportsAnErrorBeforeLoadingWhenThereIsNoData() {
assertEquals(
LoadPhase.Error("boom"),
listLoadPhase(loading = true, error = "boom", hasData = false, emptyMessage = null),
)
}
@Test
fun listReportsLoadingWhenEmptyAndFailedAreBothAbsent() {
assertEquals(
LoadPhase.Loading,
listLoadPhase(loading = true, error = null, hasData = false, emptyMessage = null),
)
}
@Test
fun listReportsEmptyWithItsCapturedMessage() {
assertEquals(
LoadPhase.Empty("No pipelines match \"x\"."),
listLoadPhase(loading = false, error = null, hasData = true, emptyMessage = "No pipelines match \"x\"."),
)
}
@Test
fun listReportsContentWhenThereAreRows() {
assertEquals(
LoadPhase.Content,
listLoadPhase(loading = false, error = null, hasData = true, emptyMessage = null),
)
}
@Test
fun listKeepsStaleDataOnContentDespiteLoadingOrError() {
// A refresh keeps the data on screen and surfaces the error inline.
assertEquals(
LoadPhase.Content,
listLoadPhase(loading = true, error = null, hasData = true, emptyMessage = null),
)
assertEquals(
LoadPhase.Content,
listLoadPhase(loading = false, error = "offline", hasData = true, emptyMessage = null),
)
}
@Test
fun listWithoutAnySignalStaysOnContent() {
// A runs pane deliberately has no pane-level empty state, so its initial
// no-data/no-error frame is content (the empty line lives in the list).
assertEquals(
LoadPhase.Content,
listLoadPhase(loading = false, error = null, hasData = false, emptyMessage = null),
)
}
// ---- detail panes -------------------------------------------------------
@Test
fun detailReportsContentWheneverDataIsPresent() {
assertEquals(
LoadPhase.Content,
detailLoadPhase(error = "offline", hasData = true),
)
}
@Test
fun detailReportsAnErrorWhenThereIsNoData() {
assertEquals(
LoadPhase.Error("boom"),
detailLoadPhase(error = "boom", hasData = false),
)
}
@Test
fun detailReportsLoadingWhenThereIsNoDataAndNoError() {
assertEquals(
LoadPhase.Loading,
detailLoadPhase(error = null, hasData = false),
)
}
// ---- the phases themselves ---------------------------------------------
@Test
fun messagePhasesCompareByTheirCapturedText() {
assertEquals(LoadPhase.Error("a"), LoadPhase.Error("a"))
assertEquals(LoadPhase.Empty("b"), LoadPhase.Empty("b"))
assertEquals(LoadPhase.Loading, LoadPhase.Loading)
assertEquals(LoadPhase.Content, LoadPhase.Content)
}
}
@@ -0,0 +1,90 @@
package net.awan.pipelines.ui.components
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
/**
* The motion tokens are pure data, so the rules the app relies on are checked
* here without a device: the tokens are ordered (quick is shorter than
* standard), each stays inside its intended band, nothing exceeds the cap, and
* every easing is a monotonic curve that starts at 0 and ends at 1 — so a token
* is always a real, reversible animation and never a no-op or an overshoot.
*/
class MotionTest {
private val tokens = listOf(MotionQuick, MotionStandard)
@Test
fun quickIsShorterThanStandard() {
assertTrue(
"quick (${MotionQuick.durationMillis}) must be shorter than standard (${MotionStandard.durationMillis})",
MotionQuick.durationMillis < MotionStandard.durationMillis,
)
}
@Test
fun eachTokenStaysInItsBand() {
// Small state changes (quick) and content changes (standard).
assertTrue(
"quick out of its 100-150ms band: ${MotionQuick.durationMillis}",
MotionQuick.durationMillis in 100..150,
)
assertTrue(
"standard out of its 200-250ms band: ${MotionStandard.durationMillis}",
MotionStandard.durationMillis in 200..250,
)
}
@Test
fun nothingRunsLongerThanTheCap() {
for (token in tokens) {
assertTrue(
"duration ${token.durationMillis} exceeds $MAX_MOTION_MILLIS",
token.durationMillis in 1..MAX_MOTION_MILLIS,
)
}
}
@Test
fun everyEasingIsMonotonicFromZeroToOne() {
for (token in tokens) {
assertEquals("easing does not start at 0", 0f, token.easing.transform(0f), 1e-4f)
assertEquals("easing does not end at 1", 1f, token.easing.transform(1f), 1e-4f)
var previous = 0f
for (i in 0..100) {
val value = token.easing.transform(i / 100f)
assertTrue("easing not monotonic at $i", value >= previous - 1e-4f)
assertTrue("easing out of [0,1] at $i: $value", value >= -1e-4f && value <= 1f + 1e-4f)
previous = value
}
}
}
@Test
fun theStandardEasingReversesItself() {
// A symmetric curve is what lets the pane slide reverse exactly (see
// SlidingPaneStackTest); it is a property of the token, so it is checked
// here too.
for (i in 0..100) {
val t = i / 100f
assertEquals(
"standard easing not symmetric at $t",
1f,
MotionStandard.easing.transform(t) + MotionStandard.easing.transform(1f - t),
1e-4f,
)
}
}
@Test
fun aSpecCarriesItsTokensTiming() {
val quick = MotionQuick.spec<Float>()
assertEquals(MotionQuick.durationMillis, quick.durationMillis)
assertEquals(MotionQuick.easing, quick.easing)
assertEquals(0, quick.delay)
val staggered = MotionStandard.spec<Float>(delayMillis = MOTION_STAGGER_MILLIS)
assertEquals(MotionStandard.durationMillis, staggered.durationMillis)
assertEquals(MOTION_STAGGER_MILLIS, staggered.delay)
}
}
@@ -142,7 +142,7 @@ class SlidingPaneStackTest {
assertEquals(
"easing is not symmetric at $t",
1f,
PANE_SLIDE_EASING.transform(t) + PANE_SLIDE_EASING.transform(1f - t),
MotionStandard.easing.transform(t) + MotionStandard.easing.transform(1f - t),
1e-4f,
)
}
@@ -165,9 +165,9 @@ class SlidingPaneStackTest {
// level beneath waits one step, so the cascade reads in order.
assertEquals(0, paneSlideDelayMillis(level = 2, depth = 0, previousDepth = 2))
assertEquals(
PANE_POP_STEP_MILLIS,
MOTION_STAGGER_MILLIS,
paneSlideDelayMillis(level = 1, depth = 0, previousDepth = 2),
)
assertTrue(PANE_SLIDE_MILLIS > 0)
assertTrue(MotionStandard.durationMillis > 0)
}
}