Render a compact identity for covered Android panes

On a wide window, a covered pane in the stack used to render a squeezed
copy of a full pane, so a covered entry showed a truncated title and a
crushed tab rail. A covered pane now renders only a compact identity: a
centred title plus at most one status/subtitle line, with no tab rail,
list, gallery or scroll body drawn into the sliver.

- SlidingPaneStack's pane lambda receives a covered flag; on a wide window
  a covered level composes only the new PaneIdentity, while the list, both
  detail screens and the stage pane early-return from their covered branch
  after their data-loading effects.
- Adds MIN_COVERED_PANE_WIDTH_DP (112.dp); peekStripsDp shows at most
  budget / MIN_COVERED_PANE_WIDTH_DP covered peeks and folds the oldest
  levels into a single "<n> more" edge indicator rather than squeezing
  them below the minimum.
- The fixed PEEK_BUDGET_DP (224.dp) and the constant active-pane width
  are unchanged; the peek tap, Back and the narrow layout keep the same
  behaviour.
- Rewrites SlidingPaneStackTest (10 cases) for the fold rule, minimum
  width, constant active width and inset/geometry invariants, and records
  the evidence and the unreachable-fold gap in android/README.md.
This commit is contained in:
2026-10-16 01:16:24 +01:00
parent 206953e067
commit 3deff18572
10 changed files with 461 additions and 133 deletions
+86
View File
@@ -1159,3 +1159,89 @@ covered by the existing unit tests (`StageDetailSheetTest`, `FormatTest`) rather
driven on the device; the narrow/wide gallery thumbnail failure for run 60's corrupt
artifacts is a data issue in that run, not re-tested against a repaired copy.
## Covered panes show a compact identity, with a minimum peek width (16 Oct 2026)
A wide-window stack no longer squeezes a full pane into each covered peek: a
covered pane now renders only its compact identity (a title and at most one
status/subtitle, centred in its strip) and its full body — tab rail, list,
gallery, scroll body — is never drawn into a sliver. `android/` only; nothing in
the Pipelines server, its Go source, the Docker/compose files or the installer was
touched, no dependency was added, no run was started from the app, and the
attached Pixel 10 Pro Fold was never installed on or driven (the debug APK was
installed with `adb -s emulator-5554 install -r`).
- **Compact covered panes.** `SlidingPaneStack`'s `pane` lambda now receives a
`covered: Boolean`; on a wide window a covered level is composed inside a box
constrained to its visible strip, and the caller renders only
`ui/components/PaneIdentity.kt` — a centred title plus at most one
status/subtitle line. The list (`PipelineListScreen`/`RunHistoryScreen`), both
detail screens and the stage pane each gained a `covered` branch that
early-returns after their data-loading effects, so nothing heavy is composed
into a sliver. The strip itself stays a separate, higher tappable sibling and
the compact identity rides with the pane's own slide.
- **A named minimum covered width, and a fold.** `MIN_COVERED_PANE_WIDTH_DP`
(`112.dp`) is the least width a covered pane's compact identity needs.
`peekStripsDp` shows at most `budget / MIN_COVERED_PANE_WIDTH_DP` covered peeks;
when a stack has more covered levels than that, the oldest levels fold into a
single edge indicator (`"<n> more"`) rather than being squeezed below the
minimum, and the number of peeks shown shrinks instead of their width. The fixed
budget (`PEEK_BUDGET_DP`, `224.dp`) and the constant active-pane width are
unchanged.
- **Unchanged behaviour.** Tapping a covered pane's peek calls the same
`onPopTo(level)`, closing everything to its right; Back/gesture/back arrow and
the narrow (no-peek) layout are untouched.
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 8.11.1,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--offline`):
- `gradle :app:testDebugUnitTest` reported **134 tests, 0 failures, 0 errors**;
`gradle :app:assembleDebug` succeeded (17,992,288-byte debug APK, sha256
`3923224136be7ef9bdd8eb87111fae1f6af0211a7ba070af0e5270e324a0fc93`). The
rewritten `SlidingPaneStackTest` has 10 cases (narrow spends no peek, the wide
active pane is constant width at every depth, two covered levels each keep the
minimum, a fourth level folds the oldest into one indicator carrying its count,
the newest level still peeks, the first strip clears the gesture inset, the
budget clamps, a tiny host never goes negative, strips are monotonic and
deterministic, and widths are host-less-offset).
- On `emulator-5554` (2076x2152, density 390 ≈ 852dp wide; **never** the attached
Pixel) against the live server `ws://10.0.2.2:8080/connect`, driven with
`adb shell input` and `uiautomator dump`:
- Wide, `uiautomator dump` of the peek strips: at two levels the single strip
was `[73,165]–[546,1859]` (`[30dp, 224dp]` after the ~30dp left gesture
inset); at three levels the two strips were `[73,165]–[273,1859]` and
`[273,165]–[546,1859]` (`[30dp,112dp]` and `[112dp,224dp]`), so the active
pane still starts at `224dp` (constant width) and each covered pane now keeps
at least `112dp` for its identity.
- Narrowest wide size (`wm size 1463x2152`, density 390 = 600dp): the same
`224dp` budget, strips `[73,127]–[273,1859]` and `[273,127]–[546,1859]`; both
compact identities stayed readable and the active pane was full.
- Tapping the detail peek (`409 1000`) at three levels popped to the detail
(only `Back to pipelines` left); tapping the list peek (`173 1000`) popped to
the list (no strips). `input keyevent 4` at depth 2 returned to depth 1 (one
`Back to pipelines` strip).
- Narrow (`wm size 1080x1920`, `wm density 480`, ≈360dp): opening a pipeline
showed **0** `Back to …` strips and the detail tabs as before.
- `adb -s emulator-5554 logcat -d` contained 0 `FATAL EXCEPTION`; no run was
started from the app.
- Screenshots were written to the run's artifacts directory:
`wide-2-levels.png` (the list covered as `Pipelines · 11 on this server`),
`wide-3-levels.png` (list and detail covered, stage active) and
`wide-narrowest.png` (600dp); `wide-2-levels-after-peek.png` is the state
after the peek tap.
- **APK publish.** `app/build/outputs/apk/debug/app-debug.apk` was copied to
`…/artifacts/65/1/pipelines-debug-wip-206953e.apk` (`206953e` =
`git rev-parse --short HEAD`); `shasum -a 256` matched. `curl -I
http://10.0.0.249:8080/artifacts/65/1/pipelines-debug-wip-206953e.apk` (LAN
address from `ipconfig getifaddr en0`) returned `HTTP/1.1 200 OK`,
`Content-Type: application/vnd.android.package-archive`, `Content-Length:
17992288`; a streamed `GET | shasum -a 256` equalled the local file. At 17.2 MiB
it exceeds the server's 8 MiB per-file inventory cap, so it is served by direct
URL only.
Not verified in this pass: the four-level / folded layout on a device — the app
has exactly three pane levels (`MasterPane.List/Detail/Stage`, `MAX_PANE_DEPTH =
2`), so the fold is unreachable and its rule is covered by the pure
`SlidingPaneStackTest` cases instead; a long covered detail title wraps to three
centred lines and ellipsizes (e.g. `Pipelines maintenance - plan implem…`) rather
than being rotated.
@@ -211,7 +211,7 @@ private fun PipelineDestination(vm: AppViewModel, wide: Boolean, onOpenRun: (Lon
wide = wide,
onPopTo = { level -> selection = popTo(selection, level) },
backContentDescription = { level -> if (level == 0) "Back to pipelines" else "Back to pipeline" },
pane = { level, paneModifier ->
pane = { level, covered, paneModifier ->
when (level) {
0 -> PipelineListScreen(
vm = vm,
@@ -220,6 +220,7 @@ private fun PipelineDestination(vm: AppViewModel, wide: Boolean, onOpenRun: (Lon
},
modifier = paneModifier,
selectedId = selection.itemId.takeIf { depth >= 1 },
covered = covered,
)
1 -> if (selection.itemId != 0L) {
PipelineDetailScreen(
@@ -235,6 +236,7 @@ private fun PipelineDestination(vm: AppViewModel, wide: Boolean, onOpenRun: (Lon
onOpenStage = { key ->
selection = selection.copy(pane = MasterPane.Stage, stageKey = key, stageVisit = 0)
},
covered = covered,
)
}
2 -> selection.stageKey?.let { key ->
@@ -246,6 +248,7 @@ private fun PipelineDestination(vm: AppViewModel, wide: Boolean, onOpenRun: (Lon
onBack = onBack,
wide = wide,
modifier = paneModifier,
covered = covered,
)
}
}
@@ -278,13 +281,14 @@ private fun RunsDestination(
wide = wide,
onPopTo = { level -> onSelectionChange(popTo(selection, level)) },
backContentDescription = { level -> if (level == 0) "Back to runs" else "Back to run" },
pane = { level, paneModifier ->
pane = { level, covered, paneModifier ->
when (level) {
0 -> RunHistoryScreen(
vm = vm,
onOpenRun = { runId -> onSelectionChange(PaneSelection(MasterPane.Detail, runId)) },
modifier = paneModifier,
selectedRunId = selection.itemId.takeIf { depth >= 1 },
covered = covered,
)
1 -> if (selection.itemId != 0L) {
RunDetailScreen(
@@ -300,6 +304,7 @@ private fun RunsDestination(
selection.copy(pane = MasterPane.Stage, stageKey = key, stageVisit = visit),
)
},
covered = covered,
)
}
2 -> selection.stageKey?.let { key ->
@@ -311,6 +316,7 @@ private fun RunsDestination(
onBack = onBack,
wide = wide,
modifier = paneModifier,
covered = covered,
)
}
}
@@ -0,0 +1,54 @@
package net.awan.pipelines.ui.components
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import net.awan.pipelines.ui.theme.pipelinesText
/**
* A covered pane's compact identity: its title and, when there is one, a single
* status/subtitle line, both centred in the peek strip. A covered pane renders
* this instead of its full body, so its tab rail, list, gallery and scrollable
* body are never drawn squeezed into a sliver.
*
* The strip is narrow but the identity is the whole point of it, so the title
* wraps onto a few centered lines rather than becoming an unreadable ellipsis;
* it is the one place a title may legitimately run over more than one line.
*/
@Composable
fun PaneIdentity(title: String, subtitle: String? = null, modifier: Modifier = Modifier) {
val text = pipelinesText()
Box(modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Column(
modifier = Modifier.padding(horizontal = 8.dp, vertical = 12.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
Text(
text = title,
style = text.cardTitle,
textAlign = TextAlign.Center,
maxLines = 3,
overflow = TextOverflow.Ellipsis,
)
if (!subtitle.isNullOrBlank()) {
Text(
text = subtitle,
style = text.meta,
textAlign = TextAlign.Center,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
}
}
}
}
@@ -42,10 +42,15 @@ import net.awan.pipelines.ui.MAX_PANE_DEPTH
* all covered panes together, however deep the stack gets.
* [MIN_ACTIVE_PANE_WIDTH_DP] is the least width worth leaving to the active
* (topmost) pane before the budget has to be reduced.
* [MIN_COVERED_PANE_WIDTH_DP] is the least width a covered pane's compact
* identity needs to stay readable and tappable; when the budget cannot give
* every covered pane this much, the oldest levels are folded into one edge
* indicator instead of being squeezed below it.
*/
internal val PEEK_WIDTH_DP = 56.dp
internal val PEEK_BUDGET_DP = 224.dp
internal val MIN_ACTIVE_PANE_WIDTH_DP = 320.dp
internal val MIN_COVERED_PANE_WIDTH_DP = 112.dp
/**
* The peek budget actually spent on a wide window: the fixed [PEEK_BUDGET_DP]
@@ -57,37 +62,6 @@ internal val MIN_ACTIVE_PANE_WIDTH_DP = 320.dp
internal fun peekBudgetDp(hostWidth: Dp, requested: Dp = PEEK_BUDGET_DP): Dp =
requested.coerceAtMost((hostWidth - MIN_ACTIVE_PANE_WIDTH_DP).coerceAtLeast(0.dp))
/**
* The open left offset of every pane `0..covered` on a wide window. `[0]` is the
* list at 0 and `[covered]` is the active pane at exactly [budget]; the covered
* panes therefore share that one fixed budget between them and the active pane
* keeps the constant width `hostWidth - budget` no matter how deep the stack is.
* The leftmost strip is widened first so that after [startInset] it still leaves
* [minPeek] tappable; the remaining budget is then split evenly between the other
* covered panes. A degenerate host clamps to whatever fits rather than
* overflowing. Pure, so the shared-budget geometry needs no device.
*/
internal fun paneOpenOffsetsDp(
covered: Int,
budget: Dp,
startInset: Dp,
minPeek: Dp,
): List<Dp> {
if (covered <= 0) return listOf(0.dp)
if (budget <= 0.dp) return List(covered + 1) { 0.dp }
if (covered == 1) return listOf(0.dp, budget)
val offsets = ArrayList<Dp>(covered + 1)
offsets += 0.dp
val first = minOf(budget, maxOf(budget / covered, startInset + minPeek))
offsets += first
val rest = budget - first
val steps = covered - 1
for (i in 2..covered) {
offsets += first + rest * (i - 1) / steps
}
return offsets
}
/**
* The width of the pane whose open left edge is [offset] on a wide window: from
* that offset to the host's right edge. The active pane therefore measures
@@ -96,6 +70,71 @@ internal fun paneOpenOffsetsDp(
internal fun paneWidthDp(hostWidth: Dp, offset: Dp): Dp =
maxOf(0.dp, hostWidth - offset)
/**
* One covered strip of a wide-window stack, in left-to-right order. [level] is
* the pane whose compact identity it shows; a [folded] count greater than one
* marks a strip that stands in for that many older levels (one edge indicator
* with a count) instead of a single pane, so no covered pane is squeezed below
* the named minimum width.
*/
internal data class PeekStrip(
val level: Int,
val start: Dp,
val width: Dp,
val folded: Int = 1,
)
/**
* The covered strips of a wide stack for [covered] covered levels and the fixed
* [budget]. Every shown pane keeps at least `minCovered`; the leftmost strip is
* widened first so that after [startInset] it still leaves [minPeek] tappable,
* and the rest of the budget is then split evenly between the other strips.
*
* When [covered] levels cannot each get `minCovered` out of [budget], one strip
* (the leftmost) is reserved as an edge indicator folding the oldest levels into
* a single count, and only the newest levels keep their own peek: the number of
* peeks shown shrinks rather than the width of each. The active pane's left edge
* is therefore still exactly the budget. Pure, so the shared-budget geometry and
* the fold rule need no device; an empty list means nothing is covered.
*/
internal fun peekStripsDp(
covered: Int,
budget: Dp,
startInset: Dp,
minPeek: Dp,
minCovered: Dp = MIN_COVERED_PANE_WIDTH_DP,
): List<PeekStrip> {
if (covered <= 0 || budget <= 0.dp) return emptyList()
// How many covered panes the budget can show at the minimum width. When some
// levels have to fold, one of those slots is spent on the edge indicator.
val capacity = if (minCovered > 0.dp) (budget.value / minCovered.value).toInt() else covered
val fold = covered > capacity
val shown = if (fold) (capacity - 1).coerceAtLeast(0) else covered
val folded = covered - shown
val slots = shown + if (fold) 1 else 0
val first = minOf(budget, maxOf(budget / slots, startInset + minPeek))
val rest = budget - first
val steps = slots - 1
val starts = ArrayList<Dp>(slots + 1)
starts += 0.dp
starts += first
for (i in 1 until slots) {
starts += first + rest * i / steps
}
val strips = ArrayList<PeekStrip>(slots)
var slot = 0
if (fold) {
strips += PeekStrip(folded - 1, starts[0], starts[1] - starts[0], folded = folded)
slot = 1
}
for (i in 0 until shown) {
val level = folded + i
val s = slot + i
strips += PeekStrip(level, starts[s], starts[s + 1] - starts[s])
}
return strips
}
/**
* The one shared sliding pane stack, adaptive to the window width. Both the
* Pipelines and Runs destinations use it, so the motion and geometry live in
@@ -109,13 +148,20 @@ internal fun paneWidthDp(hostWidth: Dp, offset: Dp): Dp =
* keeps a constant width and the stack never consumes more than the budget
* however deep it gets.
*
* A covered pane shows a compact identity only (its pane composable is told
* [covered] and is expected to render just a title/status), constrained to the
* visible strip, so its full body is never drawn into a sliver. When the budget
* cannot give every covered pane the named minimum width, the oldest levels
* fold into a single edge indicator carrying their count rather than being
* squeezed.
*
* [depth] is the number of visible panes minus one (0..[MAX_PANE_DEPTH]);
* [pane] composes the level's content and is expected to render nothing for a
* level whose selection is empty (so a closing pane simply slides back out).
* On a wide window, tapping a covered pane's peek calls [onPopTo] with that
* pane's level, closing every pane to its right; [backContentDescription] names
* each strip. On a narrow window there is no strip and Back/gesture/the pane's
* own back control pop the level.
* level whose selection is empty (so a closing pane simply slides back out). On
* a wide window, tapping a covered pane's peek calls [onPopTo] with that pane's
* level, closing every pane to its right; [backContentDescription] names each
* strip. On a narrow window there is no strip and Back/gesture/the pane's own
* back control pop the level.
*
* Every pane is always composed and each level has its own long-lived
* [animateDpAsState], so opening slides in and closing slides back out with no
@@ -133,7 +179,7 @@ fun SlidingPaneStack(
onPopTo: (Int) -> Unit,
modifier: Modifier = Modifier,
backContentDescription: (Int) -> String = { "Back" },
pane: @Composable (level: Int, modifier: Modifier) -> Unit,
pane: @Composable (level: Int, covered: Boolean, modifier: Modifier) -> Unit,
) {
BoxWithConstraints(modifier.fillMaxSize()) {
// Measured once per layout. The insets are read once here and applied to
@@ -146,64 +192,64 @@ fun SlidingPaneStack(
val startInset = insetPadding.calculateLeftPadding(direction)
val topInset = insetPadding.calculateTopPadding()
val bottomInset = insetPadding.calculateBottomPadding()
// The strip/compact identity area: the host clear of the top/bottom insets.
val stripHeight = maxOf(0.dp, maxHeight - topInset - bottomInset)
// Narrow: no peek at all (budget 0, every pane fills the host). Wide: one
// fixed budget shared between the covered panes. The platform's minimum
// interactive size is the floor for a tappable strip, never a literal.
// fixed budget shared between the covered panes, folded when it cannot
// give each the named minimum. The platform's minimum interactive size is
// the floor for a tappable strip, never a literal.
val minPeek = maxOf(PEEK_WIDTH_DP, LocalMinimumInteractiveComponentSize.current)
val budget = if (wide) peekBudgetDp(hostWidth) else 0.dp
val offsets = paneOpenOffsetsDp(
covered = depth,
budget = budget,
startInset = startInset,
minPeek = minPeek,
)
val strips = peekStripsDp(depth, budget, startInset, minPeek)
val stripByLevel = strips.associateBy { it.level }
val folded = strips.firstOrNull()?.takeIf { it.folded > 1 }?.folded ?: 0
// The active pane always opens at the whole budget (or 0 when narrow).
val activeStart = strips.fold(0.dp) { acc, strip -> acc + strip.width }
// Pane 0 fills the host; it is blocked as soon as anything covers it.
pane(
0,
Modifier
.fillMaxSize()
.then(if (depth >= 1) Modifier.blockPointerInput() else Modifier),
)
// Panes 1..MAX are always composed (the animator stays warm); a level
// beyond the depth sits off-screen and the caller renders nothing.
for (level in 1..MAX_PANE_DEPTH) {
val covered = level - 1
// The covered pane's tappable peek (wide windows only): the strip
// between this pane's offset and the next pane's, clear of the
// status/nav bars and of the left gesture area. Tapping it closes
// every pane to its right.
if (budget > 0.dp && covered < depth) {
val stripStart = offsets[covered]
val stripEnd = offsets[covered + 1]
val stripOffset = if (covered == 0) startInset else stripStart
val stripWidth = if (covered == 0) stripEnd - startInset else stripEnd - stripStart
Box(
Modifier
.align(Alignment.TopStart)
.offset(x = stripOffset, y = topInset)
.width(maxOf(0.dp, stripWidth))
.height(maxOf(0.dp, maxHeight - topInset - bottomInset))
.clickable(
role = Role.Button,
onClickLabel = backContentDescription(covered),
onClick = { onPopTo(covered) },
)
.semantics {
contentDescription = backContentDescription(covered)
role = Role.Button
},
)
// The folded older levels as one edge indicator with a count, clear of the
// status/nav bars and of the left gesture area; tapping it jumps back to
// the newest folded level.
if (folded > 0) {
val strip = strips.first()
Box(
Modifier
.align(Alignment.TopStart)
.offset(x = startInset, y = topInset)
.width(maxOf(0.dp, strip.width - startInset))
.height(stripHeight)
.clickable(
role = Role.Button,
onClickLabel = backContentDescription(folded - 1),
onClick = { onPopTo(folded - 1) },
)
.semantics {
contentDescription = backContentDescription(folded - 1)
role = Role.Button
},
) {
PaneIdentity("$folded more", null, Modifier.fillMaxSize())
}
}
// Panes 0..MAX are always composed in order (the animator stays warm); a
// level beyond the depth sits off-screen and the caller renders nothing.
for (level in 0..MAX_PANE_DEPTH) {
val covered = level < depth
// A level folded into the edge indicator is not drawn on its own.
if (covered && level < folded) continue
val strip = if (covered) stripByLevel[level] else null
// An open pane sits at its shared-budget offset; a closed one waits
// exactly off the right edge. Its width is already the width it will
// have when open, so it slides rather than grows.
val openOffset = if (level <= depth) offsets[level] else hostWidth
val openWidth = paneWidthDp(hostWidth, if (level <= depth) offsets[level] else budget)
val openOffset = when {
level > depth -> hostWidth
level == depth -> activeStart
strip != null -> strip.start
else -> 0.dp
}
val openWidth = paneWidthDp(hostWidth, if (level <= depth) openOffset else budget)
val offset by animateDpAsState(
targetValue = openOffset,
animationSpec = spring(),
@@ -216,7 +262,48 @@ fun SlidingPaneStack(
.fillMaxHeight()
.then(if (level < depth) Modifier.blockPointerInput() else Modifier),
) {
pane(level, Modifier.fillMaxSize())
if (strip != null) {
// Constrain the compact identity to the visible strip so it is
// centred in the space the covered pane actually has. It rides
// with the pane's own offset and so slides in and out with it.
val stripInset = if (level == 0) startInset else 0.dp
Box(
Modifier
.align(Alignment.TopStart)
.offset(x = stripInset, y = topInset)
.width(maxOf(0.dp, strip.width - stripInset))
.height(stripHeight),
) {
pane(level, true, Modifier.fillMaxSize())
}
} else {
pane(level, false, Modifier.fillMaxSize())
}
}
// The covered pane's tappable peek (wide windows only): the strip
// between this pane's offset and the next pane's, clear of the
// status/nav bars and of the left gesture area. It sits above the
// pane's compact identity so tapping it closes every pane to its
// right; it never overlaps the next pane.
if (strip != null) {
val stripInset = if (level == 0) startInset else 0.dp
Box(
Modifier
.align(Alignment.TopStart)
.offset(x = strip.start + stripInset, y = topInset)
.width(maxOf(0.dp, strip.width - stripInset))
.height(stripHeight)
.clickable(
role = Role.Button,
onClickLabel = backContentDescription(level),
onClick = { onPopTo(level) },
)
.semantics {
contentDescription = backContentDescription(level)
role = Role.Button
},
)
}
}
}
@@ -2,6 +2,7 @@ package net.awan.pipelines.ui.graph
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
@@ -41,6 +42,7 @@ import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.components.CodeBlock
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.KeyValueRow
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.SectionHeader
import net.awan.pipelines.ui.components.rememberSectionExpansion
import net.awan.pipelines.ui.displayMap
@@ -289,7 +291,19 @@ fun StageDetailPane(
onBack: () -> Unit,
wide: Boolean = false,
modifier: Modifier = Modifier,
covered: Boolean = false,
) {
// A covered pane shows its compact identity only; the visit tab row and the
// stage body must never be drawn squeezed into the peek strip.
if (covered) {
val stage = graph.stages.firstOrNull { it.key == stageKey }
PaneIdentity(
title = GraphSemantics.nodeLabel(stageKey),
subtitle = if (stage != null) effectiveStageType(stage.type) else "terminal",
modifier = modifier.fillMaxSize(),
)
return
}
Scaffold(
modifier = modifier,
topBar = {
@@ -449,6 +463,7 @@ fun RunStagePane(
onBack: () -> Unit,
wide: Boolean,
modifier: Modifier = Modifier,
covered: Boolean = false,
) {
val state by vm.runDetail.collectAsStateWithLifecycle()
val configuredServerUrl by vm.configuredServerUrl.collectAsStateWithLifecycle()
@@ -466,6 +481,7 @@ fun RunStagePane(
onBack = onBack,
wide = wide,
modifier = modifier,
covered = covered,
)
}
@@ -479,6 +495,7 @@ fun PipelineStagePane(
onBack: () -> Unit,
wide: Boolean,
modifier: Modifier = Modifier,
covered: Boolean = false,
) {
val state by vm.pipelineDetail.collectAsStateWithLifecycle()
val detail = state.data?.takeIf { it.id == pipelineId && it.version == version }
@@ -488,6 +505,7 @@ fun PipelineStagePane(
onBack = onBack,
wide = wide,
modifier = modifier,
covered = covered,
)
}
@@ -53,6 +53,7 @@ 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.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.pipelineDetailTabs
import net.awan.pipelines.ui.components.rememberSectionExpansion
@@ -75,6 +76,7 @@ fun PipelineDetailScreen(
onOpenStage: (String) -> Unit,
modifier: Modifier = Modifier,
wide: Boolean = false,
covered: Boolean = false,
) {
val state by vm.pipelineDetail.collectAsStateWithLifecycle()
var showStart by remember { mutableStateOf(false) }
@@ -83,6 +85,17 @@ fun PipelineDetailScreen(
val detail = state.data?.takeIf { it.id == pipelineId }
// 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) {
PaneIdentity(
title = detail?.name ?: "Pipeline",
subtitle = detail?.let { "v$version · ${it.graph.stages.size} stages" },
modifier = modifier.fillMaxSize(),
)
return
}
Scaffold(
modifier = modifier,
topBar = {
@@ -35,6 +35,7 @@ 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.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.theme.pipelinesText
@OptIn(ExperimentalMaterial3Api::class)
@@ -44,12 +45,25 @@ fun PipelineListScreen(
onOpen: (id: Long, version: Int) -> Unit,
modifier: Modifier = Modifier,
selectedId: Long? = null,
covered: Boolean = false,
) {
val state by vm.pipelines.collectAsStateWithLifecycle()
var query by remember { mutableStateOf("") }
LaunchedEffect(Unit) { vm.refreshPipelines() }
// A covered pane shows its compact identity only; the search field and list
// must never be drawn squeezed into the peek strip.
if (covered) {
val count = state.data?.size ?: 0
PaneIdentity(
title = "Pipelines",
subtitle = if (count > 0) "$count on this server" else null,
modifier = modifier.fillMaxSize(),
)
return
}
Scaffold(
modifier = modifier,
topBar = {
@@ -56,6 +56,7 @@ 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.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.RunStatusIcon
import net.awan.pipelines.ui.components.StatusChip
import net.awan.pipelines.ui.components.collapsibleSection
@@ -82,6 +83,7 @@ fun RunDetailScreen(
onOpenStage: (String, Int) -> Unit,
modifier: Modifier = Modifier,
wide: Boolean = false,
covered: Boolean = false,
) {
val state by vm.runDetail.collectAsStateWithLifecycle()
val evidenceState by vm.evidence.collectAsStateWithLifecycle()
@@ -111,6 +113,17 @@ fun RunDetailScreen(
}
}
// A covered pane shows its compact identity only; the tab rail, timeline and
// graphs must never be drawn squeezed into the peek strip.
if (covered) {
PaneIdentity(
title = run?.name ?: "Run",
subtitle = run?.status?.takeIf { it.isNotBlank() },
modifier = modifier.fillMaxSize(),
)
return
}
Scaffold(
modifier = modifier,
topBar = {
@@ -50,6 +50,7 @@ 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.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.runStateColor
import net.awan.pipelines.ui.components.runStateOf
import net.awan.pipelines.ui.formatDuration
@@ -65,10 +66,23 @@ fun RunHistoryScreen(
modifier: Modifier = Modifier,
filterPipelineId: Long? = null,
selectedRunId: Long? = null,
covered: Boolean = false,
) {
val state by vm.runs.collectAsStateWithLifecycle()
LaunchedEffect(Unit) { vm.refreshRuns() }
// A covered pane shows its compact identity only; the usage block, sticky day
// headers and run rows must never be drawn squeezed into the peek strip.
if (covered) {
val count = state.data?.runs?.size ?: 0
PaneIdentity(
title = if (filterPipelineId == null) "Runs" else "Runs for this pipeline",
subtitle = if (count > 0) "$count recorded" else null,
modifier = modifier.fillMaxSize(),
)
return
}
Scaffold(
modifier = modifier,
topBar = {
@@ -7,28 +7,27 @@ import org.junit.Assert.assertTrue
import org.junit.Test
/**
* The pane geometry is pure, so the adaptive width rules are checked here without
* a device: a narrow window spends no peek at all, and a wide window spends one
* fixed budget shared between the covered panes however deep the stack gets.
* The pane geometry is pure, so the adaptive width and fold rules are checked
* here without a device: a narrow window spends no peek at all, a wide window
* spends one fixed budget shared between the covered panes however deep the
* stack gets, every shown peek keeps the named minimum covered width, and when
* the budget cannot give the whole stack that much the oldest levels fold into a
* single edge indicator rather than being squeezed.
*/
class SlidingPaneStackTest {
private fun assertDp(expected: Dp, actual: Dp, delta: Float = 0.01f) =
assertEquals(expected.value, actual.value, delta)
private fun totalWidth(strips: List<PeekStrip>): Dp =
strips.fold(0.dp) { acc, strip -> acc + strip.width }
@Test
fun narrowWindowSpendsNoPeekAtAnyDepth() {
// Budget 0 is the narrow model: no stack and no leftover strip, so every
// pane's open offset is 0 (the host's left edge).
// Budget 0 is the narrow model: no stack and no leftover strip, so there
// are no covered strips and every pane opens at the host's left edge.
for (covered in 0..4) {
val offsets = paneOpenOffsetsDp(
covered = covered,
budget = 0.dp,
startInset = 30.dp,
minPeek = PEEK_WIDTH_DP,
)
assertEquals(covered + 1, offsets.size)
offsets.forEach { assertDp(0.dp, it) }
assertTrue(peekStripsDp(covered, 0.dp, 30.dp, PEEK_WIDTH_DP).isEmpty())
}
}
@@ -37,41 +36,59 @@ class SlidingPaneStackTest {
val host = 800.dp
val budget = peekBudgetDp(host)
assertDp(PEEK_BUDGET_DP, budget)
// The active (topmost) pane's left edge is exactly the budget, so its
// width is host - budget no matter how many levels are open.
// The covered strips always sum to exactly the budget, so the active
// (topmost) pane's left edge — and its width — never depend on depth.
for (covered in 1..4) {
val offsets = paneOpenOffsetsDp(covered, budget, startInset = 0.dp, minPeek = PEEK_WIDTH_DP)
assertDp(budget, offsets.last())
assertDp(host - budget, paneWidthDp(host, offsets.last()))
val strips = peekStripsDp(covered, budget, startInset = 0.dp, minPeek = PEEK_WIDTH_DP)
assertDp(budget, totalWidth(strips))
assertDp(host - budget, paneWidthDp(host, totalWidth(strips)))
}
}
@Test
fun fourLevelsShareTheOneFixedBudget() {
val offsets = paneOpenOffsetsDp(
covered = 3,
budget = PEEK_BUDGET_DP,
startInset = 0.dp,
minPeek = PEEK_WIDTH_DP,
)
// Four levels: the list plus three covered panes plus the active one.
assertEquals(4, offsets.size)
assertDp(PEEK_BUDGET_DP, offsets.last())
val strips = offsets.zipWithNext { a, b -> b - a }
assertEquals(3, strips.size)
// The three covered panes share the budget between them, not three peeks.
assertDp(PEEK_BUDGET_DP, strips.fold(0.dp) { acc, strip -> acc + strip })
strips.forEach { assertTrue("peek too thin to tap: $it", it >= PEEK_WIDTH_DP) }
fun twoCoveredLevelsEachKeepTheMinimumCoveredWidth() {
val strips = peekStripsDp(2, PEEK_BUDGET_DP, startInset = 0.dp, minPeek = PEEK_WIDTH_DP)
// Three levels (list + detail + stage): two covered panes, no fold, and
// each has at least the named minimum so its compact identity reads.
assertEquals(2, strips.size)
assertEquals(listOf(0, 1), strips.map { it.level })
strips.forEach { assertTrue("peek below the minimum: $it", it.width >= MIN_COVERED_PANE_WIDTH_DP) }
assertTrue(strips.all { it.folded == 1 })
}
@Test
fun aFourthLevelFoldsTheOldestIntoOneIndicator() {
// Four levels (three covered) with a budget of two minimums: the oldest
// levels collapse into one edge indicator carrying their count instead of
// squeezing all three, and one peek still shows the newest covered pane.
val strips = peekStripsDp(3, PEEK_BUDGET_DP, startInset = 0.dp, minPeek = PEEK_WIDTH_DP)
assertEquals(2, strips.size)
assertEquals(2, strips.first().folded)
assertEquals(1, strips.last().folded)
assertEquals(2, strips.last().level)
assertTrue(strips.all { it.width >= MIN_COVERED_PANE_WIDTH_DP })
assertDp(PEEK_BUDGET_DP, totalWidth(strips))
}
@Test
fun foldedLevelsAreTheOldestAndTheNewestStillPeeks() {
val covered = 4
val strips = peekStripsDp(covered, PEEK_BUDGET_DP, startInset = 0.dp, minPeek = PEEK_WIDTH_DP)
// The newest covered level keeps its own peek; all older ones fold.
assertEquals(covered - 1, strips.last().level)
assertEquals(3, strips.first().folded)
}
@Test
fun firstStripStaysTappableAfterTheGestureInset() {
val startInset = 30.dp
val offsets = paneOpenOffsetsDp(3, PEEK_BUDGET_DP, startInset, PEEK_WIDTH_DP)
val strips = peekStripsDp(2, PEEK_BUDGET_DP, startInset, PEEK_WIDTH_DP)
// The leftmost strip is widened so the tappable part (after the inset)
// still measures at least the named minimum.
val firstStrip = offsets[1] - offsets[0]
assertTrue(firstStrip - startInset >= PEEK_WIDTH_DP)
assertTrue(strips.first().width - startInset >= PEEK_WIDTH_DP)
// Even when the fold forces the smallest split, the widening holds.
val folded = peekStripsDp(4, PEEK_BUDGET_DP, 80.dp, PEEK_WIDTH_DP)
assertTrue(folded.first().width - 80.dp >= PEEK_WIDTH_DP)
}
@Test
@@ -87,19 +104,25 @@ class SlidingPaneStackTest {
@Test
fun tinyHostNeverProducesNegativeGeometry() {
assertDp(0.dp, peekBudgetDp(100.dp))
val offsets = paneOpenOffsetsDp(3, peekBudgetDp(100.dp), 0.dp, PEEK_WIDTH_DP)
offsets.zipWithNext { a, b -> assertTrue(b >= a) }
offsets.forEach { assertTrue(paneWidthDp(100.dp, it) >= 0.dp) }
val empty = peekStripsDp(3, peekBudgetDp(100.dp), 0.dp, PEEK_WIDTH_DP)
assertTrue(empty.isEmpty())
assertTrue(paneWidthDp(100.dp, 0.dp) >= 0.dp)
// A tiny non-zero budget still yields one usable strip, never negative.
val tiny = peekStripsDp(3, 40.dp, 0.dp, PEEK_WIDTH_DP)
assertEquals(1, tiny.size)
assertTrue(tiny.first().width >= 0.dp)
assertTrue(paneWidthDp(100.dp, totalWidth(tiny)) >= 0.dp)
}
@Test
fun offsetsAreMonotonicAndDeterministic() {
// Same inputs give the same offsets (opening and closing are mirrors),
// and the panes never overlap in the wrong order.
val a = paneOpenOffsetsDp(3, PEEK_BUDGET_DP, 30.dp, PEEK_WIDTH_DP)
val b = paneOpenOffsetsDp(3, PEEK_BUDGET_DP, 30.dp, PEEK_WIDTH_DP)
fun stripsAreMonotonicAndDeterministic() {
// Same inputs give the same strips (opening and closing are mirrors),
// the strips never overlap, and they never run past the budget.
val a = peekStripsDp(3, PEEK_BUDGET_DP, 30.dp, PEEK_WIDTH_DP)
val b = peekStripsDp(3, PEEK_BUDGET_DP, 30.dp, PEEK_WIDTH_DP)
assertEquals(a, b)
a.zipWithNext { x, y -> assertTrue(y >= x) }
a.zipWithNext { x, y -> assertTrue(y.start >= x.start + x.width) }
assertTrue(a.all { it.width >= 0.dp })
}
@Test