Swap Android detail sections in place instead of sliding them

Selecting a section in a run or pipeline detail now cross-fades the body in
place rather than sliding it sideways, so a tap on the rail or tab row is an
ordinary tab change with no lateral motion and nothing to swipe.

- DetailTabs.kt drops the HorizontalPager for section bodies and renders only
  the selected section behind a short Crossfade (SECTION_SWAP_MILLIS = 180).
  Level navigation (list -> detail -> stage pane) still slides via the
  unchanged SlidingPaneStack.
- Each section's saved state (its LazyColumn scroll) is kept under its stable
  tab key with rememberSaveableStateHolder().SaveableStateProvider, so
  returning to a section restores where the operator left off instead of
  resetting it.
- The rail/tab-row selected state and tab semantics are unchanged.
- Update the two call sites' stale "pager" comments and refresh the README
  section describing the section selector.
This commit is contained in:
2026-10-15 23:57:57 +01:00
parent 0b373d0c65
commit 791d3dd3ff
4 changed files with 136 additions and 62 deletions
+97 -14
View File
@@ -112,22 +112,26 @@ stops it.
- Consistent Material 3 top app bars on Pipelines, Runs and Settings (and the
existing back/refresh/start/cancel/retry bars on the detail screens).
- Both detail screens are tabbed via one shared `ui/components/DetailTabs.kt`:
run detail exposes Summary, Graph, Input, Output, Evidence and Steps, pipeline
run detail exposes Summary, Graph, Input, Output, Evidence and Timeline, pipeline
detail Summary, Graph and Source, with Summary first and the default. Every tab
carries a meaningful icon alongside its label. The section index stays fixed and
visible while the sections themselves live in a `HorizontalPager`: tapping a tab
(or swiping) slides that section's panel in, a later section entering from the
right and an earlier one from the left, following the index order. The pager
composes only the visible page at rest, each section is a single `LazyColumn`,
and the Graph tab keeps the full-height `WorkflowGraph` panel with its Fit and
expand controls. Narrow windows show a horizontally scrolling
visible while the selected section's panel swaps in place behind a short
`Crossfade`: selecting a section is an ordinary tab change with no lateral
motion, so there is nothing to swipe — the sections are not a left-to-right
pager. Only navigation between levels (list → detail → stage pane) slides, via
`SlidingPaneStack`. Only the selected section is composed at rest, each section
is a single `LazyColumn`, and each section's own saved state (its list scroll
position) is kept under its stable tab key through a
`rememberSaveableStateHolder`, so returning to a section never resets its
scroll. The Graph tab keeps the full-height `WorkflowGraph` panel with its Fit
and expand controls. Narrow windows show a horizontally scrolling
`PrimaryScrollableTabRow`; wide windows show an always-visible selectable rail
(icon + label, no collapse control). `selectedIndex` is the single source of
truth: an external change (Back) scrolls the pager and a settled pager reports
the new index, guarded against feedback loops. The tabs carry real tab semantics
(`Role.Tab` + selected state), so selection is never conveyed by colour alone,
and the selected index is `rememberSaveable` (survives recomposition,
configuration change and process death) and clamped by `clampTabIndex`.
truth and a tap reports the new index through `onSelect`. The tabs carry real tab
semantics (`Role.Tab` + selected state), so selection is never conveyed by
colour alone, and the selected index is `rememberSaveable` (survives
recomposition, configuration change and process death) and clamped by
`clampTabIndex`.
- The Source tab fills the whole tab area and renders the parsed definition
instead of dumping the raw markdown: one collapsible section per stage (name ·
type) holding labelled blocks for prompt, output, tools, configs, edges
@@ -927,8 +931,8 @@ on or driven (the debug APK was installed with `adb -s emulator-5554 install -r`
- Both models keep the other pane rules: opening and closing are exact mirrors
(the same offsets and `spring()` retarget in reverse), panes are opaque, the
peek strips are inset inside the status/nav bars and the gesture area, and a
section inside a detail is a selection on its own tab row/pager, never a
navigation level.
section inside a detail is a selection on its own tab row, never a navigation
level.
Evidence obtained in this pass (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle
8.11.1 from the wrapper cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`,
@@ -983,3 +987,82 @@ a two-finger pinch and the frame-by-frame preview is not captured); the wide
recording's final close-detail frame lands at the end of the clip. The narrow
layout was produced with `wm size`/`wm density` (a real hardware fold was not
exercised).
## Sections change in place, not sideways (15 Oct 2026)
Selecting a section in a run or pipeline detail now swaps the section body in
place instead of sliding it in from the side. `android/` only; nothing in the
Pipelines server, its Go source, the Docker/compose files or the installer was
touched, no run was started from the app, no dependency was added, and the
attached Pixel 10 Pro Fold was not installed on or driven (every device command
targeted `emulator-5554`).
- **In-place swap instead of a pager.** `ui/components/DetailTabs.kt` no longer
uses a `HorizontalPager` for the section bodies. The selected section
cross-fades in place behind a `Crossfade` (`SECTION_SWAP_MILLIS = 180`), so a tap
on the rail/tab row is an ordinary tab change with no lateral motion and nothing
to swipe. `Crossfade` comes from `androidx.compose.animation:animation`, already
on the compile classpath transitively via `androidx.compose.foundation` (no new
dependency was declared; `gradle/libs.versions.toml` and the dependency blocks
are unchanged). Only the selected section is composed at rest.
- **Level navigation still slides.** The `SlidingPaneStack` (list → detail → stage
pane) is untouched, so navigation between levels keeps its `spring()` slide; only
the section selector inside a detail changed.
- **The rail's selected state is kept.** The narrow `PrimaryScrollableTabRow` and
the wide selectable rail are unchanged; selection is still `Role.Tab` + selected
semantics plus the tonal container, never colour alone.
- **A section's scroll position is not reset on return.** Each section's saved
state (its `LazyColumn` scroll) is kept under its stable tab key with
`rememberSaveableStateHolder().SaveableStateProvider(tab.key)`, so leaving and
returning to a section restores where the operator left off (this matches the
previous pager's per-page saved state).
- The two call sites' stale "pager composes only the visible section" comments were
updated; no other behaviour changed.
Evidence obtained in this pass (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle
8.11.1 from the wrapper cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`,
`--offline`):
- `gradle :app:testDebugUnitTest :app:assembleDebug` → `BUILD SUCCESSFUL in 2s`;
the test-result XMLs aggregate to **130 tests, 0 failures, 0 errors, 0 skipped**
(the existing `DetailTabsTest` still covers the tab lists and `clampTabIndex`).
- `app/build/outputs/apk/debug/app-debug.apk` is 17,990,397 bytes, sha256
`ef467eaafd9cd7662167c17229a39281683aed6c890c48c9fabf0a1e3ed04172`.
- On `emulator-5554` (2076x2152, density 390 ≈ 852dp wide; **never** the attached
Pixel) against the live server `ws://10.0.0.75:8080/connect` (run 58, seven
completed visits), driven with `adb shell input`:
- A 13s `screenrecord` of tapping Summary → Graph → Input → Output → Evidence →
Timeline (`after-section-swap.mp4`), with stills of each section
(`after-run-summary/graph/evidence/timeline.png`): the rail's selected state
moves and the body changes, and an extracted mid-transition frame
(`frame-3.65.png`) shows the outgoing and incoming panels overlapping **at the
same x** — a cross-fade, not a slide.
- The same sequence on the pre-change build (built from `HEAD` in a throwaway
`git worktree`, installed as a baseline) recorded as `before-section-slide.mp4`
and frame `before-frame-2.05.png`: the outgoing panel is visibly shifted left
with the incoming panel entering from the right — the old lateral slide, by
contrast.
- Scroll preservation: Summary was scrolled down, Graph selected, then Summary
re-selected; `scroll-summary-returned.png` matches `scroll-summary-scrolled.png`
(Finished/Duration/Artifacts still on screen), not the top.
- `adb -s emulator-5554 logcat -d` contained 0 `FATAL EXCEPTION` and 0
`E AndroidRuntime` lines; no run was started from the app.
- **APK publish.** `app-debug.apk` was copied to
`~/.local/share/pipelines/data/artifacts/62/1/pipelines-debug-wip-0b373d0.apk`
(`0b373d0` = `git rev-parse --short HEAD`); `shasum -a 256` matched. `curl -I
http://10.0.0.249:8080/artifacts/62/1/pipelines-debug-wip-0b373d0.apk` (LAN
address from `ipconfig getifaddr en0`, never `localhost`/`10.0.2.2`) returned
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 17990397`; a streamed `GET | shasum -a 256` returned
`ef467eaafd9cd7662167c17229a39281683aed6c890c48c9fabf0a1e3ed04172`, equal to the
local file. At 17.3 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 cross-fade's exact duration/frames beyond the single
extracted frame and the 180 ms spec; a real hardware fold (the wide layout is the
emulator's default 852dp); the narrow top-tab-row presentation (the emulator was
driven wide only) — the narrow selector code is unchanged and shared, so this is a
presentation difference the existing `WindowSizeTest`/`DetailTabsTest` still cover
where they can. The `after-section-swap.mp4` frame is the only mid-transition
sample taken; `before-frame-2.05.png` is the only baseline mid-slide sample.
@@ -1,5 +1,7 @@
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
@@ -12,8 +14,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.material.icons.Icons
@@ -32,15 +32,12 @@ import androidx.compose.material3.Tab
import androidx.compose.material3.Text
import androidx.compose.material3.VerticalDivider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.snapshotFlow
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -49,7 +46,6 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.flow.distinctUntilChanged
import net.awan.pipelines.ui.theme.pipelinesText
/**
@@ -83,19 +79,19 @@ fun clampTabIndex(index: Int, tabCount: Int): Int =
if (tabCount <= 0) 0 else index.coerceIn(0, tabCount - 1)
/**
* The section index + its panel, open to the right. On narrow windows the index
* is a horizontally scrolling Material 3 [PrimaryScrollableTabRow]; on wide
* windows it is an always-visible selectable rail. Both stay fixed and visible
* while the sections themselves live in a [HorizontalPager], so tapping a
* section slides its panel in from the right (and a later section enters from the
* right, an earlier one from the left as the pager follows the index order);
* swiping switches sections too.
* The section index + its panel. On narrow windows the index is a horizontally
* scrolling Material 3 [PrimaryScrollableTabRow]; on wide windows it is an
* always-visible selectable rail. Both stay fixed and visible while the selected
* section's panel swaps in place behind a short [Crossfade]: selecting a section
* is an ordinary tab change with no lateral motion and no swipe, because the
* sections are not a left-to-right pager. Only navigation between levels
* (list → detail → stage pane) slides, via
* [net.awan.pipelines.ui.components.SlidingPaneStack].
*
* The pager composes only the visible page at rest (the default
* `beyondViewportPageCount`), preserving the previous laziness. `selectedIndex`
* is the single source of truth: a change from outside (e.g. Back) scrolls the
* pager, and a settled pager (a tap or a swipe) reports the new index through
* [onSelect]. The two are guarded against feedback loops.
* [selectedIndex] is the single source of truth; a tap reports the new index
* through [onSelect]. Each section's own saved state (e.g. its list scroll
* position) is keyed by its stable tab key, so returning to a section restores
* where the operator left off instead of resetting it.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -109,27 +105,26 @@ fun DetailTabs(
) {
if (tabs.isEmpty()) return
val selected = clampTabIndex(selectedIndex, tabs.size)
val pagerState = rememberPagerState(initialPage = selected, pageCount = { tabs.size })
// One entry per stable tab key holds a section's state while that section is
// off-screen, so swapping sections never resets a section's scroll position
// (or any other saved state).
val stateHolder = rememberSaveableStateHolder()
// External selection (Back, or a restored index) moves the pager; skip while
// a finger is down so a swipe is never fought mid-gesture.
LaunchedEffect(selected, tabs.size) {
if (!pagerState.isScrollInProgress && pagerState.settledPage != selected) {
pagerState.animateScrollToPage(selected)
// A short cross-fade replaces the section in place: the incoming panel fades
// in as the outgoing one fades out, with no horizontal travel.
val swap: @Composable (Modifier) -> Unit = { contentModifier ->
Crossfade(
targetState = selected,
animationSpec = tween(durationMillis = SECTION_SWAP_MILLIS),
modifier = contentModifier,
label = "section-swap",
) { index ->
val tab = tabs[clampTabIndex(index, tabs.size)]
stateHolder.SaveableStateProvider(tab.key) {
content(tab, Modifier.fillMaxSize())
}
}
}
// A settled pager (tab tap or swipe) reports the section up. Keyed only on the
// pager so it is never restarted; the callback is read through a fresh state.
val report by rememberUpdatedState(onSelect)
LaunchedEffect(pagerState) {
snapshotFlow { pagerState.settledPage }
.distinctUntilChanged()
.collect { report(it) }
}
val page: @Composable (Int) -> Unit = { index ->
content(tabs[clampTabIndex(index, tabs.size)], Modifier.fillMaxSize())
}
if (wide) {
Row(modifier.fillMaxSize()) {
@@ -158,9 +153,7 @@ fun DetailTabs(
}
VerticalDivider()
Box(Modifier.weight(1f).fillMaxHeight()) {
HorizontalPager(state = pagerState, modifier = Modifier.fillMaxSize()) { index ->
page(index)
}
swap(Modifier.fillMaxSize())
}
}
} else {
@@ -174,12 +167,7 @@ fun DetailTabs(
)
}
}
HorizontalPager(
state = pagerState,
modifier = Modifier.weight(1f).fillMaxWidth(),
) { index ->
page(index)
}
swap(Modifier.weight(1f).fillMaxWidth())
}
}
}
@@ -282,5 +270,8 @@ fun rememberSectionExpansion(vararg inputs: Any?): SectionExpansionState {
/** 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
@@ -118,7 +118,7 @@ fun PipelineDetailScreen(
wide = wide,
modifier = Modifier.padding(padding).fillMaxSize(),
) { tab, contentModifier ->
// The pager composes only the visible section's content.
// Only the selected section's content is composed at rest.
when (tab.key) {
"summary" -> PipelineSummaryTab(detail, wide, contentModifier)
"graph" -> PipelineGraphTab(
@@ -154,7 +154,7 @@ fun RunDetailScreen(
wide = wide,
modifier = Modifier.padding(padding).fillMaxSize(),
) { tab, contentModifier ->
// The pager composes only the visible section's content.
// Only the selected section's content is composed at rest.
when (tab.key) {
"summary" -> RunSummaryTab(
run = run,