android: make the destinations pill a true overlay, centred narrow and right when wide

The floating destination pill no longer takes layout space: it is drawn in the
bottom overlay layer above the content, horizontally centred on a narrow window
and anchored to the bottom-right corner on a wide one. Templates leaves the pill
for a Templates row on the Settings page.

- PipelinesApp: the content Column's pill reservation is gone; contentPillPadding
  (pillVisible) is the named zero and a unit test pins both states. The pill and
  the attention chip stay in their own bottom-anchored overlay Column, a sibling
  of the content in the Box, so nothing positions the content. The one placement
  rule is destinationPillAlignment(wide) (CenterHorizontally narrow, End wide);
  the corner margin is the named SPACING_L, so no new number. The attention chip
  keeps its own bottom-right place at every width via Modifier.align(End).
- Trailing clearance moves into each scrollable's own content: pillScrollInset
  (DESTINATION_PILL_RESERVE + ATTENTION_CHIP_RESERVE while drawn, zero while
  hidden) is published through the new LocalPillBottomInset
  (components/PillInset.kt) and applied with pillContentPadding /
  Modifier.pillBottomPadding in every list, grid and scrolling detail, stage and
  settings body. The container keeps its full height, a hidden pill leaves no
  empty band, and the last row still scrolls clear of the pill.
- Templates is no longer a pill destination: TemplatesDestination.kt is deleted
  and destinations is pipelines/runs/chat/settings. The new SettingsDestination
  sliding stack (pane 0 SettingsScreen, 1 TemplateGalleryScreen, 2
  TemplateDetailScreen) with the pure, Bundle-able SettingsSelection model gives
  the gallery the shared covered-pane strip and one-level Back; SettingsScreen
  gains the Templates row that opens it. This re-lands the intent of a2043f9,
  which never reached main.
- Dimens: the two reserve tokens' docs now describe the scroll-content clearance
  and the chip's share of it; no new token and no hardcoded geometry.

Checked where the change belongs: no packaged template (examples/*.md) and no
packaged authoring skill reference (internal/author/skill/references/*) describes
the Android pill, its destinations or the Templates gallery, so none needs
updating and internal/author/install.go's inventory is unchanged. android/README.md
does document the surfaces this item changed, so it is now stale: this item does
not edit that shared document - docs/notes/pill-overlay-and-position.md records
the two places that need it (the Templates bullet and the dated section to append)
for the single docs-fold writer.

Tests: at a297fb6 with these working changes the build and unit suite were green
(593 tests, 0 failures); no device command was run and the geometry stays
token-derived. Visual rendering of the centred/right pill needs the device and
was not verified here.
This commit is contained in:
2026-10-18 00:18:40 +01:00
parent a297fb6fb3
commit 5a44ff1568
24 changed files with 777 additions and 198 deletions
@@ -32,6 +32,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -60,19 +61,27 @@ import net.awan.pipelines.ui.chat.ChatScreen
import net.awan.pipelines.ui.components.AttentionIndicator
import net.awan.pipelines.ui.components.AttentionSheet
import net.awan.pipelines.ui.components.ConnectionBanner
import net.awan.pipelines.ui.components.LocalPillBottomInset
import net.awan.pipelines.ui.components.MotionStandard
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.spec
import net.awan.pipelines.ui.screens.SettingsScreen
import net.awan.pipelines.ui.theme.ATTENTION_CHIP_RESERVE
import net.awan.pipelines.ui.theme.DESTINATION_PILL_RESERVE
import net.awan.pipelines.ui.theme.SPACING_L
import net.awan.pipelines.ui.theme.SPACING_S
/** One destination the floating pill holds: its nav [route], the accessible [label] and its glyph. */
internal data class TopDestination(val route: String, val label: String, val icon: ImageVector)
private val destinations = listOf(
/**
* The pill's destinations, in display order. Templates is deliberately absent: it
* is configuration, reached from the Settings page instead, so the pill holds only
* the surfaces a person moves between constantly. The pill's width derives from
* this list (its icon row), never a fixed value, so removing a destination only
* narrows it.
*/
internal val destinations = listOf(
TopDestination("pipelines", "Pipelines", Icons.Default.AccountTree),
TopDestination("templates", "Templates", TemplatesIcon),
TopDestination("runs", "Runs", Icons.Default.History),
TopDestination("chat", "Chat", Icons.AutoMirrored.Filled.Chat),
TopDestination("settings", "Settings", Icons.Default.Settings),
@@ -270,74 +279,78 @@ fun PipelinesApp(
// screens' app bars (a Material 3 TopAppBar applies the top safe-area inset),
// which removed the duplicate top band. The bottom is owned by each screen's
// Scaffold, and the floating pill explicitly clears the safe area (system
// bars, cutout, gesture area and IME) via windowInsetsPadding. The Column
// reserves DESTINATION_PILL_RESERVE at the bottom so no scrollable content is
// permanently hidden behind the pill; while the pill is hidden (an open
// conversation, see [destinationPillVisible]) that reservation is dropped too,
// so the composer sits at the true bottom instead of over an empty band.
// bars, cutout, gesture area and IME) via windowInsetsPadding.
//
// The pill is a true overlay: it is drawn in its own bottom-anchored layer over
// the content and never takes layout space, so the content keeps its full
// height. Nothing is positioned by the pill; its bottom clearance
// ([pillScrollInset], published through [LocalPillBottomInset]) is applied
// inside each scrollable screen's own scroll content, so scrolling to the end
// still reveals the last row clear of the pill, and while the pill is hidden
// (an open conversation, see [destinationPillVisible]) that clearance is zero
// so a hidden pill leaves no empty band. See [contentPillPadding].
val bannerVisible = connectionState !is ConnectionState.Connected
Scaffold(contentWindowInsets = WindowInsets(0, 0, 0, 0)) { padding ->
Box(Modifier.fillMaxSize().padding(padding)) {
Column(Modifier.fillMaxSize().padding(bottom = destinationPillReserve(pillVisible) + ATTENTION_CHIP_RESERVE)) {
ConnectionBanner(
state = connectionState,
configuredUrl = configuredUrl,
onReconnect = vm::reconnect,
)
NavHost(
navController = navController,
startDestination = "pipelines",
// While the banner is visible it owns the status-bar inset, so
// the inner app bars below must not apply it a second time.
modifier = Modifier
.weight(1f)
.then(
if (bannerVisible) {
Modifier.consumeWindowInsets(
paneSafeArea().only(WindowInsetsSides.Top),
)
} else {
Modifier
},
),
) {
composable("pipelines") {
PipelineDestination(
vm = vm,
wide = wide,
selection = pipelineSelection,
onSelectionChange = { pipelineSelection = it },
listState = pipelineListState,
onOpenRun = { runId ->
runSelection = PaneSelection(
pane = MasterPane.Detail,
itemId = runId,
)
navController.navigate("runs") { launchSingleTop = true }
},
)
}
composable("runs") {
RunsDestination(
vm = vm,
wide = wide,
selection = runSelection,
onSelectionChange = { runSelection = it },
pendingNav = runSearchNav,
onPendingNavResolved = { runSearchNav = null },
listState = runListState,
decisionRequest = decisionRequest,
onDecisionRequestHandled = { decisionRequest = null },
)
}
composable("chat") {
ChatScreen(vm = vm, wide = wide)
}
composable("templates") {
TemplatesDestination(vm = vm, wide = wide, listState = templateListState)
}
composable("settings") {
SettingsScreen(vm, wide = wide)
CompositionLocalProvider(LocalPillBottomInset provides pillScrollInset(pillVisible)) {
Column(Modifier.fillMaxSize().padding(bottom = contentPillPadding(pillVisible))) {
ConnectionBanner(
state = connectionState,
configuredUrl = configuredUrl,
onReconnect = vm::reconnect,
)
NavHost(
navController = navController,
startDestination = "pipelines",
// While the banner is visible it owns the status-bar inset, so
// the inner app bars below must not apply it a second time.
modifier = Modifier
.weight(1f)
.then(
if (bannerVisible) {
Modifier.consumeWindowInsets(
paneSafeArea().only(WindowInsetsSides.Top),
)
} else {
Modifier
},
),
) {
composable("pipelines") {
PipelineDestination(
vm = vm,
wide = wide,
selection = pipelineSelection,
onSelectionChange = { pipelineSelection = it },
listState = pipelineListState,
onOpenRun = { runId ->
runSelection = PaneSelection(
pane = MasterPane.Detail,
itemId = runId,
)
navController.navigate("runs") { launchSingleTop = true }
},
)
}
composable("runs") {
RunsDestination(
vm = vm,
wide = wide,
selection = runSelection,
onSelectionChange = { runSelection = it },
pendingNav = runSearchNav,
onPendingNavResolved = { runSearchNav = null },
listState = runListState,
decisionRequest = decisionRequest,
onDecisionRequestHandled = { decisionRequest = null },
)
}
composable("chat") {
ChatScreen(vm = vm, wide = wide)
}
composable("settings") {
SettingsDestination(vm = vm, wide = wide, listState = templateListState)
}
}
}
}
@@ -360,21 +373,29 @@ fun PipelinesApp(
// Composed after the NavHost, so while the field is open Back (button
// or gesture) dismisses the morph before any pane's own Back handler.
BackHandler(enabled = searchState.open) { dismissSearch() }
// The results panel and the destination bar share one bottom-anchored,
// inset-clearing column. `paneSafeArea` (WindowInsets.safeDrawing) is
// applied once here: the panel then takes exactly the height the IME and
// navigation bar leave (weight, `fill = false` so a short panel wraps)
// and scrolls inside it, and the input always sits directly below the
// panel and above the keyboard. The activity declares `adjustResize`
// and the app is edge-to-edge, so the Compose window inset is the only
// source of the IME geometry and it is applied once, here.
// The results panel, the attention chip and the destination bar share
// one bottom-anchored, inset-clearing column — the overlay layer, drawn
// above the content and never part of its layout. `paneSafeArea`
// (WindowInsets.safeDrawing) is applied once here, so the pill clears the
// system bars, cutout, gesture area and IME: the panel then takes exactly
// the height the IME and navigation bar leave (weight, `fill = false` so
// a short panel wraps) and scrolls inside it, and the input always sits
// directly below the panel and above the keyboard. The activity declares
// `adjustResize` and the app is edge-to-edge, so the Compose window inset
// is the only source of the IME geometry and it is applied once, here.
//
// The overlay's resting place is the window width's in [destinationPillAlignment]:
// horizontally centred on a narrow window, anchored to the bottom-right
// corner on a wide one. Its margin comes from the named [SPACING_L], so the
// corner placement adds no new number. That rule positions the pill; the
// attention chip above it keeps its own bottom-right place at every width.
Column(
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(paneSafeArea())
.padding(end = 16.dp, bottom = 16.dp),
.padding(end = if (wide) SPACING_L else 0.dp, bottom = SPACING_L),
verticalArrangement = Arrangement.Bottom,
horizontalAlignment = Alignment.End,
horizontalAlignment = destinationPillAlignment(wide),
) {
if (searchState.open && searchState.query.isNotBlank()) {
SearchResultsPanel(
@@ -383,13 +404,17 @@ fun PipelinesApp(
modifier = Modifier
.fillMaxWidth()
.weight(1f, fill = false)
.padding(bottom = 16.dp),
.padding(bottom = SPACING_L),
)
}
// The attention chip is not part of the pill's placement rule: it
// keeps its own bottom-right resting place at every width (as it
// had before the pill became width-dependent), so only the pill
// follows [destinationPillAlignment].
AttentionIndicator(
entries = attention,
onClick = { attentionOpen = true },
modifier = Modifier.padding(bottom = SPACING_S),
modifier = Modifier.align(Alignment.End).padding(bottom = SPACING_S),
)
// The pill stands down while a conversation is open; the search
// field it morphs into is unreachable there anyway (the field opens
@@ -463,14 +488,40 @@ internal fun destinationPillVisible(currentRoute: String?, conversationOpen: Boo
!(currentRoute == CHAT_ROUTE && conversationOpen)
/**
* The bottom space the content reserves for the pill: the named
* [DESTINATION_PILL_RESERVE] while the pill is drawn, and none while it is
* hidden, so a hidden pill leaves no empty band at the end of scrollable content
* and the composer sits at the true bottom. Derived from [pillVisible] alone, so
* the reservation and the drawn pill can never disagree into a frame with a
* drawn pill over content it does not clear, or a reserved gap behind a hidden
* one — which is what keeps the content from jumping as the pill appears and
* disappears.
* Where the bottom overlay — the destination pill and the attention chip above it
* — rests in the window: horizontally centred on a **narrow** window and anchored
* to the bottom-right **corner** on a **wide** one. The overlay is drawn above the
* content and never takes layout space either way, so this is purely where it
* sits. A pure function of the window width, so the one arrangement rule is
* unit-testable and no screen hardcodes a width.
*/
internal fun destinationPillReserve(pillVisible: Boolean): Dp =
if (pillVisible) DESTINATION_PILL_RESERVE else 0.dp
internal fun destinationPillAlignment(wide: Boolean): Alignment.Horizontal =
if (wide) Alignment.End else Alignment.CenterHorizontally
/**
* The bottom padding the app's content column applies for the pill: none, whether
* the pill is [pillVisible] or not. The pill is an overlay drawn above the
* content, so it must never size or offset it — the content keeps its own full
* height and the pill's clearance lives in each scrollable's own scroll content
* (see [pillScrollInset]). The value is a function of the drawn state (both of
* which the unit test pins at zero) rather than left implicit in an absent
* modifier, so a later change that reintroduces a reserved band here fails the
* test.
*/
internal fun contentPillPadding(pillVisible: Boolean): Dp = 0.dp
/**
* The trailing bottom space a scrollable screen keeps so its last row scrolls clear
* of the floating bottom stack — the destination pill and the attention chip above
* it — built from the named [DESTINATION_PILL_RESERVE] and [ATTENTION_CHIP_RESERVE]
* while the pill is drawn, and none while it is hidden (an open conversation, see
* [destinationPillVisible]) so a hidden pill leaves no empty band at the end of a
* list. Published to the content through `LocalPillBottomInset` and applied inside
* each scrollable's own scroll content, never as layout padding on the content. It
* is derived from [pillVisible] alone, so the clearance and the drawn pill can
* never disagree into a frame with a drawn pill over content it does not clear, or
* a reserved gap behind a hidden one — which is what keeps a list from jumping as
* the pill appears and disappears.
*/
internal fun pillScrollInset(pillVisible: Boolean): Dp =
if (pillVisible) DESTINATION_PILL_RESERVE + ATTENTION_CHIP_RESERVE else 0.dp
@@ -0,0 +1,89 @@
package net.awan.pipelines.ui
import androidx.activity.compose.PredictiveBackHandler
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Settings
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import kotlinx.coroutines.flow.collect
import net.awan.pipelines.ui.components.SlidingPaneStack
import net.awan.pipelines.ui.components.rememberPaneContent
import net.awan.pipelines.ui.screens.SettingsScreen
import net.awan.pipelines.ui.screens.TemplateDetailScreen
import net.awan.pipelines.ui.screens.TemplateGalleryScreen
/**
* The Settings destination: the same shared pane stack the other destinations
* use, with the settings page as pane 0 and the templates gallery it opens from
* its Templates row as pane 1 and the selected template's detail as pane 2.
* Templates is configuration, so it is one of the settings destinations rather
* than a floating-pill entry; the gallery is the existing [TemplateGalleryScreen]
* (and its detail the existing [TemplateDetailScreen]), so no second templates
* surface is built. Its selection is saved state, so it survives rotation,
* configuration change and process death; the covered-pane strip, the back gesture
* and the pane's own back control all step exactly one level via [settingsBack].
* Nothing here starts a run.
*/
@Composable
internal fun SettingsDestination(
vm: AppViewModel,
wide: Boolean,
listState: LazyListState,
) {
var selection by rememberSaveable(stateSaver = SettingsSelectionSaver) {
mutableStateOf(SettingsSelection())
}
val depth = selection.depth
val onBack: () -> Unit = { selection = settingsBack(selection) }
PredictiveBackHandler(enabled = depth >= 1) { progress ->
// Consume the gesture; on completion perform exactly one Back step.
progress.collect { }
onBack()
}
SlidingPaneStack(
depth = depth,
wide = wide,
onPopTo = { level -> selection = settingsPopTo(selection, level) },
compactLabel = "Settings",
compactIcon = Icons.Filled.Settings,
backContentDescription = { level ->
if (level == 0) "Back to settings" else "Back to templates"
},
pane = { level, covered, paneModifier ->
when (level) {
0 -> SettingsScreen(
vm = vm,
onOpenTemplates = { selection = openTemplatesGallery(selection) },
wide = wide,
modifier = paneModifier,
covered = covered,
)
1 -> TemplateGalleryScreen(
vm = vm,
wide = wide,
onOpen = { key -> selection = openTemplateDetail(selection, key) },
listState = listState,
modifier = paneModifier,
covered = covered,
)
2 -> rememberPaneContent(selection.templateKey)?.let { key ->
TemplateDetailScreen(
vm = vm,
templateKey = key,
onBack = onBack,
wide = wide,
modifier = paneModifier,
covered = covered,
)
}
}
},
)
}
@@ -0,0 +1,86 @@
package net.awan.pipelines.ui
import androidx.compose.runtime.saveable.Saver
/**
* Which pane of the Settings destination's sliding stack is rightmost: the
* settings page itself (level 0), the templates gallery opened from its Templates
* row (level 1) or the selected template's detail (level 2). Templates is
* configuration, so it is one of the settings destinations reached from the
* Settings page rather than an entry in the floating destination pill; modelling
* the stack here is what gives the gallery the same covered-pane strip and
* one-level Back step the other destinations use.
*/
internal enum class SettingsPane(val level: Int) {
Settings(0),
Gallery(1),
Template(2),
}
/**
* The Settings destination's saved pane selection. The only state beyond the
* rightmost pane is the open template's key, so the whole selection is
* Bundle-able primitives and survives rotation, configuration change and process
* death. Geometry (peek widths, insets) is deliberately not part of the model; it
* is derived from layout by the shared stack.
*/
internal data class SettingsSelection(
val pane: SettingsPane = SettingsPane.Settings,
val templateKey: String? = null,
) {
/** How many panes are stacked: 0 settings, 1 gallery, 2 template detail. */
val depth: Int
get() = pane.level
}
/** The Settings page's Templates row opens the gallery as its own pane. */
internal fun openTemplatesGallery(selection: SettingsSelection): SettingsSelection =
selection.copy(pane = SettingsPane.Gallery, templateKey = null)
/** A gallery card opens the selected template's detail as the next pane. */
internal fun openTemplateDetail(selection: SettingsSelection, key: String): SettingsSelection =
selection.copy(pane = SettingsPane.Template, templateKey = key)
/**
* Exactly one pane level of Back, so the back gesture, the covered strip's tap and
* the detail's own back control all step the same single level: detail → gallery →
* settings. At settings there is nothing to close and the selection is unchanged,
* so the caller lets Back leave the destination.
*/
internal fun settingsBack(selection: SettingsSelection): SettingsSelection = when (selection.pane) {
SettingsPane.Settings -> selection
SettingsPane.Gallery -> selection.copy(pane = SettingsPane.Settings, templateKey = null)
SettingsPane.Template -> selection.copy(pane = SettingsPane.Gallery, templateKey = null)
}
/**
* The selection after tapping a covered pane's strip at [level]: every pane to its
* right is closed. Level 0 closes back to the settings page, level 1 closes the
* template detail back to the gallery, and a [level] at or beyond the current
* depth is a no-op. Peeks exist only on a wide window; narrow windows use
* Back/gesture for the same one-level step.
*/
internal fun settingsPopTo(selection: SettingsSelection, level: Int): SettingsSelection = when {
level <= 0 -> SettingsSelection()
level == 1 -> selection.copy(pane = SettingsPane.Gallery, templateKey = null)
else -> selection
}
/**
* Encodes a [SettingsSelection] as Bundle-able primitives. Paired with
* [decodeSettingsSelection].
*/
internal fun encodeSettingsSelection(selection: SettingsSelection): List<Any> =
listOf(selection.pane.name, selection.templateKey ?: "")
/** Restores a [SettingsSelection] encoded by [encodeSettingsSelection]. */
internal fun decodeSettingsSelection(encoded: List<Any>): SettingsSelection = SettingsSelection(
pane = SettingsPane.valueOf(encoded[0] as String),
templateKey = (encoded[1] as String).takeIf { it.isNotEmpty() },
)
/** Saves/restores a [SettingsSelection] across configuration change and process death. */
internal val SettingsSelectionSaver: Saver<SettingsSelection, List<Any>> = Saver(
save = { encodeSettingsSelection(it) },
restore = { decodeSettingsSelection(it) },
)
@@ -1,70 +0,0 @@
package net.awan.pipelines.ui
import androidx.activity.compose.PredictiveBackHandler
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import kotlinx.coroutines.flow.collect
import net.awan.pipelines.ui.components.SlidingPaneStack
import net.awan.pipelines.ui.components.rememberPaneContent
import net.awan.pipelines.ui.screens.TemplateDetailScreen
import net.awan.pipelines.ui.screens.TemplateGalleryScreen
/**
* The Templates destination: the same shared pane stack, with the template
* gallery as pane 0 and the selected template's detail as pane 1. The selected
* template key is the saved state, so it survives rotation, configuration change
* and process death; Back/the peek pop one level. Nothing here starts a run.
*/
@Composable
internal fun TemplatesDestination(
vm: AppViewModel,
wide: Boolean,
listState: LazyListState,
) {
var selectedKey by rememberSaveable { mutableStateOf<String?>(null) }
val depth = if (selectedKey == null) 0 else 1
val onBack: () -> Unit = { selectedKey = null }
PredictiveBackHandler(enabled = depth >= 1) { progress ->
progress.collect { }
onBack()
}
SlidingPaneStack(
depth = depth,
wide = wide,
onPopTo = { level -> if (level <= 0) selectedKey = null },
compactLabel = "Templates",
compactIcon = TemplatesIcon,
backContentDescription = { level ->
if (level == 0) "Back to templates" else "Back to template"
},
pane = { level, covered, paneModifier ->
when (level) {
0 -> TemplateGalleryScreen(
vm = vm,
wide = wide,
onOpen = { key -> selectedKey = key },
listState = listState,
modifier = paneModifier,
covered = covered,
)
1 -> rememberPaneContent(selectedKey)?.let { key ->
TemplateDetailScreen(
vm = vm,
templateKey = key,
onBack = onBack,
wide = wide,
modifier = paneModifier,
covered = covered,
)
}
}
},
)
}
@@ -3,6 +3,7 @@ package net.awan.pipelines.ui.chat
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
@@ -33,6 +34,7 @@ import net.awan.pipelines.ui.AppViewModel
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.pillContentPadding
import net.awan.pipelines.ui.theme.ICON_INLINE_DP
import net.awan.pipelines.ui.theme.pipelinesText
@@ -85,7 +87,10 @@ internal fun NewChatPane(
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(horizontal = CHAT_GUTTER, vertical = CHAT_ITEM_GAP),
)
LazyColumn(Modifier.weight(1f).fillMaxWidth()) {
LazyColumn(
modifier = Modifier.weight(1f).fillMaxWidth(),
contentPadding = pillContentPadding(PaddingValues()),
) {
items(choices, key = { it.createDirectory }) { choice ->
DirectoryRow(
choice = choice,
@@ -4,6 +4,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
@@ -55,6 +56,7 @@ import net.awan.pipelines.ui.components.LabelChip
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.pillContentPadding
import net.awan.pipelines.ui.theme.ICON_BUTTON_SMALL_DP
import net.awan.pipelines.ui.theme.ICON_INLINE_DP
import net.awan.pipelines.ui.theme.SPACING_M
@@ -169,7 +171,10 @@ internal fun ChatListPane(
// drift hundreds of pixels from its title, the same constraint the
// other lists and detail bodies use; narrow windows fill as before.
else -> DetailTabBody(wide, Modifier.fillMaxSize()) { listModifier ->
LazyColumn(listModifier) {
LazyColumn(
modifier = listModifier,
contentPadding = pillContentPadding(PaddingValues()),
) {
if (groups.size > 1) {
// More than one directory: one section per repository so
// same-directory chats sit together, each keeping the
@@ -0,0 +1,53 @@
package net.awan.pipelines.ui.components
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
/**
* The floating destination pill's clearance at the bottom of the content, as the
* app shell computes it for the current window and route (see
* `pillScrollInset`). It is published around the content so a scrollable screen
* can add it to its own scroll content's bottom padding and let its last row
* scroll clear of the pill, without the pill ever taking or positioning layout
* space. Defaults to zero, so a screen composed outside the app shell (a preview,
* a test) keeps exactly its own padding.
*/
internal val LocalPillBottomInset = compositionLocalOf { 0.dp }
/**
* [base] with the floating pill's clearance added at the bottom, for a scroll
* container's `contentPadding`. It adds the clearance **inside** the scroll
* content, so the container keeps its full height and its last row can still be
* scrolled into view above the pill; it is deliberately not a layout padding on
* the container, which would shrink the viewport and hide the row behind the pill
* instead. Returns [base] unchanged when no pill is drawn.
*/
@Composable
internal fun pillContentPadding(base: PaddingValues): PaddingValues {
val inset = LocalPillBottomInset.current
if (inset == 0.dp) return base
val direction = LocalLayoutDirection.current
return PaddingValues(
start = base.calculateLeftPadding(direction),
top = base.calculateTopPadding(),
end = base.calculateRightPadding(direction),
bottom = base.calculateBottomPadding() + inset,
)
}
/**
* Adds the floating pill's clearance as bottom padding on a scrollable's **own
* content** (a `Column` inside `verticalScroll`, or any content whose end must
* clear the pill), for the cases a `LazyColumn`'s `contentPadding` cannot reach.
* Like [pillContentPadding] it is content padding, not a layout inset, so the
* container keeps its full height and only its last content scrolls clear of the
* pill. A no-op when no pill is drawn.
*/
@Composable
internal fun Modifier.pillBottomPadding(): Modifier = padding(bottom = LocalPillBottomInset.current)
@@ -32,6 +32,7 @@ import net.awan.pipelines.data.protocol.Graph
import net.awan.pipelines.ui.components.CodeBlock
import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.copyText
import net.awan.pipelines.ui.components.pillContentPadding
import net.awan.pipelines.ui.components.rememberSectionExpansion
import net.awan.pipelines.ui.theme.ICON_INLINE_DP
import net.awan.pipelines.ui.theme.SPACING_L
@@ -71,7 +72,7 @@ internal fun PipelineSourceView(
LazyColumn(
modifier = modifier.fillMaxSize(),
contentPadding = PaddingValues(vertical = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_L)),
) {
item(key = "source-actions") {
Row(
@@ -48,6 +48,7 @@ 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.paneSafeArea
import net.awan.pipelines.ui.components.pillBottomPadding
import net.awan.pipelines.ui.STAGE_RUN_LABEL_LINES
import net.awan.pipelines.ui.displayMap
import net.awan.pipelines.ui.fileChangeLine
@@ -520,7 +521,8 @@ private fun StageDetailBody(
Column(
modifier = columnModifier
.verticalScroll(rememberScrollState())
.padding(horizontal = SPACING_L, vertical = SPACING_S),
.padding(horizontal = SPACING_L, vertical = SPACING_S)
.pillBottomPadding(),
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
) {
// A run parked on this stage surfaces its decision here, at the top of
@@ -755,7 +757,8 @@ private fun StageSectionBody(
Column(
modifier = columnModifier
.verticalScroll(rememberScrollState())
.padding(horizontal = SPACING_L, vertical = SPACING_L),
.padding(horizontal = SPACING_L, vertical = SPACING_L)
.pillBottomPadding(),
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
) {
KeyValueRow("Stage", GraphSemantics.nodeLabel(stageKey))
@@ -52,6 +52,7 @@ import net.awan.pipelines.ui.components.StateCrossfade
import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.detailLoadPhase
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.pillContentPadding
import net.awan.pipelines.ui.components.pipelineDetailTabs
import net.awan.pipelines.ui.components.rememberPaneContent
import net.awan.pipelines.ui.formatLocalTimestamp
@@ -200,7 +201,7 @@ private fun PipelineSummaryTab(detail: PipelineDetail, wide: Boolean, modifier:
DetailTabBody(wide, modifier) { columnModifier ->
LazyColumn(
modifier = columnModifier,
contentPadding = PaddingValues(vertical = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_L)),
) {
item(key = "pipeline-summary") {
Column(
@@ -256,7 +257,7 @@ private fun PipelineGraphTab(
val text = pipelinesText()
LazyColumn(
modifier = modifier,
contentPadding = PaddingValues(vertical = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_L)),
) {
item(key = "pipeline-graph") {
Column(
@@ -55,6 +55,7 @@ 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.pillContentPadding
import net.awan.pipelines.ui.components.rememberLiveNowMillis
import net.awan.pipelines.ui.formatLocalTimestamp
import net.awan.pipelines.ui.stageCountText
@@ -227,7 +228,7 @@ fun PipelineListScreen(
LazyColumn(
state = listState,
modifier = listModifier,
contentPadding = PaddingValues(vertical = SPACING_S),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_S)),
) {
items(items, key = { it.id }) { pipeline ->
PipelineRow(
@@ -20,6 +20,7 @@ import net.awan.pipelines.ui.LoadState
import net.awan.pipelines.ui.components.CodeBlock
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.pillContentPadding
import net.awan.pipelines.ui.components.rememberSectionExpansion
import net.awan.pipelines.ui.theme.SPACING_L
import net.awan.pipelines.ui.theme.SPACING_S
@@ -45,7 +46,7 @@ internal fun RunEvidenceTab(
DetailTabBody(wide, modifier) { columnModifier ->
LazyColumn(
modifier = columnModifier,
contentPadding = PaddingValues(vertical = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_L)),
) {
item(key = "evidence-reload") {
Row(
@@ -10,6 +10,7 @@ import kotlinx.serialization.json.JsonElement
import net.awan.pipelines.ui.components.CodeBlock
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.pillContentPadding
import net.awan.pipelines.ui.components.rememberSectionExpansion
import net.awan.pipelines.ui.displayText
import net.awan.pipelines.ui.theme.SPACING_L
@@ -35,7 +36,7 @@ internal fun RunFieldSectionsTab(
DetailTabBody(wide, modifier) { columnModifier ->
LazyColumn(
modifier = columnModifier,
contentPadding = PaddingValues(vertical = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_L)),
) {
if (entries.isEmpty()) {
item(key = "$keyPrefix-empty") {
@@ -12,6 +12,7 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import net.awan.pipelines.data.protocol.RunDetail
import net.awan.pipelines.data.protocol.RunGraphState
import net.awan.pipelines.ui.components.pillContentPadding
import net.awan.pipelines.ui.graph.WorkflowGraph
import net.awan.pipelines.ui.theme.SPACING_L
import net.awan.pipelines.ui.theme.SPACING_S
@@ -39,7 +40,7 @@ internal fun RunGraphTab(
val timeline = remember(run.steps) { runTimeline(run.steps) }
LazyColumn(
modifier = modifier,
contentPadding = PaddingValues(vertical = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_L)),
) {
item(key = "run-graph") {
Column(
@@ -68,6 +68,7 @@ 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.pillContentPadding
import net.awan.pipelines.ui.components.rememberLiveNowMillis
import net.awan.pipelines.ui.components.runStateColor
import net.awan.pipelines.ui.components.runStateOf
@@ -330,7 +331,7 @@ private fun RunHistoryContent(
LazyColumn(
state = listState,
modifier = listModifier,
contentPadding = PaddingValues(bottom = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(bottom = SPACING_L)),
) {
entries.forEach { entry ->
when (entry) {
@@ -20,6 +20,7 @@ import net.awan.pipelines.ui.RUN_VIEW_TITLE_LINES
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.pillContentPadding
import net.awan.pipelines.ui.components.StatusChip
import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.rememberLiveNowMillis
@@ -68,7 +69,7 @@ internal fun RunSummaryTab(
DetailTabBody(wide, modifier) { columnModifier ->
LazyColumn(
modifier = columnModifier,
contentPadding = PaddingValues(vertical = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_L)),
) {
// The artifacts gallery still leads the summary, but inside one
// collapsed section: its header alone carries the run's capture
@@ -27,6 +27,7 @@ import net.awan.pipelines.data.protocol.RunDetail
import net.awan.pipelines.ui.components.ColoredChip
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.RunStatusIcon
import net.awan.pipelines.ui.components.pillContentPadding
import net.awan.pipelines.ui.components.runStateIcon
import net.awan.pipelines.ui.components.runStateOf
import net.awan.pipelines.ui.graph.graphColors
@@ -60,7 +61,7 @@ internal fun RunTimelineTab(
DetailTabBody(wide, modifier) { columnModifier ->
LazyColumn(
modifier = columnModifier,
contentPadding = PaddingValues(vertical = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_L)),
) {
if (timeline.entries.isEmpty()) {
item(key = "timeline-empty") {
@@ -1,9 +1,11 @@
package net.awan.pipelines.ui.screens
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
@@ -11,6 +13,8 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.WarningAmber
import androidx.compose.material3.Button
import androidx.compose.material3.Card
@@ -26,18 +30,32 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import net.awan.pipelines.data.transport.ConnectionState
import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.TemplatesIcon
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.pillBottomPadding
import net.awan.pipelines.ui.theme.SPACING_L
import net.awan.pipelines.ui.theme.SPACING_M
import net.awan.pipelines.ui.theme.SPACING_XS
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsScreen(vm: AppViewModel, modifier: Modifier = Modifier, wide: Boolean = false) {
fun SettingsScreen(
vm: AppViewModel,
onOpenTemplates: () -> Unit,
modifier: Modifier = Modifier,
wide: Boolean = false,
covered: Boolean = false,
) {
val serverUrl by vm.serverUrlDraft.collectAsStateWithLifecycle()
val workspace by vm.workspaceDraft.collectAsStateWithLifecycle()
val urlError by vm.urlError.collectAsStateWithLifecycle()
@@ -47,6 +65,17 @@ fun SettingsScreen(vm: AppViewModel, modifier: Modifier = Modifier, wide: Boolea
val configuredWorkspace by vm.configuredWorkspace.collectAsStateWithLifecycle()
val workspaceError by vm.workspaceError.collectAsStateWithLifecycle()
if (covered) {
// A covered pane shows only its compact identity, never its fields
// squeezed into the peek strip (the same rule as the other destinations).
PaneIdentity(
title = "Settings",
icon = Icons.Filled.Settings,
modifier = modifier.fillMaxSize(),
)
return
}
Scaffold(
modifier = modifier,
contentWindowInsets = paneSafeArea(),
@@ -75,6 +104,7 @@ fun SettingsScreen(vm: AppViewModel, modifier: Modifier = Modifier, wide: Boolea
onDisconnect = vm::disconnect,
onReconnect = vm::reconnect,
onSaveWorkspace = vm::saveWorkspace,
onOpenTemplates = onOpenTemplates,
)
}
}
@@ -98,15 +128,19 @@ private fun SettingsContent(
onDisconnect: () -> Unit,
onReconnect: () -> Unit,
onSaveWorkspace: () -> Unit,
onOpenTemplates: () -> Unit,
) {
// The settings body keeps the app's comfortable reading width on a wide
// window (centred) instead of letting a helper line run the whole 2000px.
// The floating pill is an overlay, so the scrolled body adds its clearance to
// its own scroll content and its last control scrolls clear of the pill.
DetailTabBody(wide, padding) { columnModifier ->
Column(
modifier = columnModifier
.verticalScroll(rememberScrollState())
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
.padding(SPACING_L)
.pillBottomPadding(),
verticalArrangement = Arrangement.spacedBy(SPACING_M),
) {
Text("Connection", style = MaterialTheme.typography.titleMedium)
@@ -163,6 +197,51 @@ private fun SettingsContent(
)
Button(onClick = onSaveWorkspace, enabled = workspaceError == null) { Text("Save workspace") }
Text("Saved workspace: ${configuredWorkspace.ifBlank { "(none)" }}")
Text("Templates", style = MaterialTheme.typography.titleMedium)
// The templates gallery is configuration, so it lives here rather than in
// the floating pill. The row is the settings page's idiom: a section
// label followed by a card, with a leading glyph and a forward chevron.
Card(
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
),
modifier = Modifier
.fillMaxWidth()
.clickable(
role = Role.Button,
onClickLabel = "Open templates",
onClick = onOpenTemplates,
),
) {
Row(
modifier = Modifier.fillMaxWidth().padding(SPACING_L),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(SPACING_M),
) {
Icon(
imageVector = TemplatesIcon,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
) {
Text("Browse templates", style = MaterialTheme.typography.bodyLarge)
Text(
text = "Reusable pipeline definitions offered by the server.",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Icon(
imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight,
contentDescription = null,
)
}
}
}
}
}
@@ -50,6 +50,7 @@ import net.awan.pipelines.ui.components.StateCrossfade
import net.awan.pipelines.ui.components.clampTabIndex
import net.awan.pipelines.ui.components.detailLoadPhase
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.pillContentPadding
import net.awan.pipelines.ui.components.pipelineDetailTabs
import net.awan.pipelines.ui.graph.PipelineSourceView
import net.awan.pipelines.ui.graph.WorkflowGraph
@@ -161,7 +162,7 @@ private fun TemplateSummaryTab(entry: TemplateEntry, wide: Boolean, modifier: Mo
DetailTabBody(wide, modifier) { columnModifier ->
LazyColumn(
modifier = columnModifier,
contentPadding = PaddingValues(vertical = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_L)),
) {
item(key = "template-summary") {
Column(
@@ -232,7 +233,7 @@ private fun TemplateGraphTab(entry: TemplateEntry, modifier: Modifier) {
}
LazyColumn(
modifier = modifier,
contentPadding = PaddingValues(vertical = SPACING_L),
contentPadding = pillContentPadding(PaddingValues(vertical = SPACING_L)),
) {
item(key = "template-graph") {
Column(
@@ -49,6 +49,7 @@ 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.pillContentPadding
import net.awan.pipelines.ui.templateCard
import net.awan.pipelines.ui.templateGridColumns
import net.awan.pipelines.ui.templateStageCountLabel
@@ -151,7 +152,7 @@ private fun TemplateGrid(
LazyColumn(
state = listState,
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(SPACING_L),
contentPadding = pillContentPadding(PaddingValues(SPACING_L)),
verticalArrangement = Arrangement.spacedBy(SPACING_S),
) {
items(rows, key = { it.first().key }) { row ->
@@ -76,17 +76,21 @@ internal val MIN_COVERED_PANE_WIDTH_DP = 112.dp
// ---- Destination pill (ui/PipelinesApp.kt) ---------------------------------
/**
* Bottom space reserved by the floating destination pill, so content is never
* permanently hidden behind it (pill height + its margins + a small gap).
* The trailing bottom space a scrollable screen keeps at the end of its own scroll
* content so its last row is never permanently hidden behind the floating
* destination pill (pill height + its margins + a small gap). The pill itself is
* an overlay and takes no layout space; this is clearance inside the scroll
* content, applied through `LocalPillBottomInset`.
*/
internal val DESTINATION_PILL_RESERVE = 88.dp
/**
* Bottom space the floating attention chip occupies above the destination pill:
* the chip's own height (its single label line plus its vertical padding) plus the
* gap below it. Reserved at the bottom of the content whether or not a chip is
* present, so the chip can never be laid out over a row, a field or a button and
* the content does not jump as it appears and clears.
* gap below it. Added to a scrollable's trailing space alongside
* [DESTINATION_PILL_RESERVE] while the pill is drawn, so the chip can never be laid
* out over a row, a field or a button and the content does not jump as it appears
* and clears.
*/
internal val ATTENTION_CHIP_RESERVE = SPACING_XXL + SPACING_M
@@ -1,6 +1,8 @@
package net.awan.pipelines.ui
import androidx.compose.ui.Alignment
import androidx.compose.ui.unit.Dp
import net.awan.pipelines.ui.theme.ATTENTION_CHIP_RESERVE
import net.awan.pipelines.ui.theme.DESTINATION_PILL_RESERVE
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@@ -9,6 +11,31 @@ import org.junit.Test
class PipelinesNavTest {
@Test
fun thePillDoesNotHoldTemplates() {
// Templates is configuration and moved to the Settings page; the pill keeps
// only the surfaces a person moves between constantly.
assertFalse(destinations.any { it.route == "templates" })
}
@Test
fun thePillKeepsItsRemainingDestinationsInOrder() {
// The pill's width derives from exactly this list, so removing a
// destination only narrows it.
assertEquals(
listOf("pipelines", "runs", "chat", "settings"),
destinations.map { it.route },
)
}
@Test
fun thePillIsCentredOnANarrowWindowAndOnTheRightCornerOnAWideOne() {
// The overlay is bottom-anchored; only its horizontal arrangement follows
// the window width: centred when narrow, the right corner when wide.
assertEquals(Alignment.CenterHorizontally, destinationPillAlignment(wide = false))
assertEquals(Alignment.End, destinationPillAlignment(wide = true))
}
@Test
fun listRoutesSelectTheirOwnDestination() {
assertTrue(destinationSelected("pipelines", "pipelines"))
@@ -59,7 +86,7 @@ class PipelinesNavTest {
// the chat list keeps it, and so does every other destination.
assertFalse(destinationPillVisible("chat", conversationOpen = true))
assertTrue(destinationPillVisible("chat", conversationOpen = false))
for (route in listOf("pipelines", "templates", "runs", "settings", null)) {
for (route in listOf("pipelines", "runs", "settings", null)) {
assertTrue(destinationPillVisible(route, conversationOpen = false))
}
// A conversation only exists on the chat route; even if the flag were set
@@ -68,24 +95,38 @@ class PipelinesNavTest {
}
@Test
fun theReserveTracksTheDrawnPillSoContentNeitherJumpsNorLeavesAGap() {
// Drawn: content reserves the named pill space and clears it. Hidden: no
// reservation, so there is no empty band where the pill used to be.
assertDp(DESTINATION_PILL_RESERVE.value, destinationPillReserve(pillVisible = true))
assertDp(0f, destinationPillReserve(pillVisible = false))
// One predicate drives both, so the space can never disagree with the
// pill: reserved exactly when drawn, gone exactly when hidden.
fun theContentKeepsItsOwnHeightBecauseThePillIsAnOverlay() {
// The pill floats above the content and never takes layout space, so the
// content column's own bottom padding for it is zero — whether the pill is
// drawn or hidden — and a scrollable list's last row scrolls under the pill
// rather than the whole content being shortened by it.
assertDp(0f, contentPillPadding(pillVisible = true))
assertDp(0f, contentPillPadding(pillVisible = false))
}
@Test
fun theScrollInsetTracksTheDrawnPillSoAListNeitherJumpsNorHidesItsLastRow() {
// Drawn: a scrollable keeps the named pill + attention-chip space at the
// end of its own scroll content and its last row scrolls clear of the whole
// floating bottom stack. Hidden: no clearance, so there is no empty band
// where the pill used to be.
val drawnInset = DESTINATION_PILL_RESERVE + ATTENTION_CHIP_RESERVE
assertDp(drawnInset.value, pillScrollInset(pillVisible = true))
assertDp(0f, pillScrollInset(pillVisible = false))
// One predicate drives both the drawing and the clearance, so the space can
// never disagree with the pill: cleared exactly when drawn, gone exactly
// when hidden.
for (route in listOf("pipelines", "chat", "runs", "settings", null)) {
for (open in listOf(false, true)) {
val drawn = destinationPillVisible(route, open)
val reserve = destinationPillReserve(drawn)
val inset = pillScrollInset(drawn)
assertTrue(
"reserve held behind a hidden pill on $route (open=$open)",
drawn || reserve.value == 0f,
"scroll clearance held behind a hidden pill on $route (open=$open)",
drawn || inset.value == 0f,
)
assertTrue(
"content not cleared of a drawn pill on $route (open=$open)",
!drawn || reserve.value == DESTINATION_PILL_RESERVE.value,
"list not cleared of a drawn pill on $route (open=$open)",
!drawn || inset.value == drawnInset.value,
)
}
}
@@ -0,0 +1,74 @@
package net.awan.pipelines.ui
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
/**
* The Settings destination's one-level navigation: its Templates row opens the
* gallery as its own pane, a gallery card opens the template detail as the next
* pane, and Back (the gesture, the covered strip's tap and the detail's own back
* control) steps exactly one pane at a time — detail → gallery → settings. Pure,
* so none of this needs a device.
*/
class SettingsSelectionTest {
@Test
fun theTemplatesRowOpensTheGalleryAsItsOwnPane() {
val opened = openTemplatesGallery(SettingsSelection())
assertEquals(SettingsPane.Gallery, opened.pane)
assertEquals(1, opened.depth)
assertNull(opened.templateKey)
}
@Test
fun aGalleryCardOpensTheSelectedTemplatesDetailPane() {
val opened = openTemplateDetail(openTemplatesGallery(SettingsSelection()), "three-stage")
assertEquals(SettingsPane.Template, opened.pane)
assertEquals(2, opened.depth)
assertEquals("three-stage", opened.templateKey)
}
@Test
fun backStepsExactlyOnePaneAndClearsTheTemplateKey() {
val detail = openTemplateDetail(openTemplatesGallery(SettingsSelection()), "three-stage")
val gallery = settingsBack(detail)
assertEquals(SettingsPane.Gallery, gallery.pane)
assertEquals(1, gallery.depth)
assertNull(gallery.templateKey)
val settings = settingsBack(gallery)
assertEquals(SettingsPane.Settings, settings.pane)
assertEquals(0, settings.depth)
}
@Test
fun backAtSettingsLeavesTheSelectionSoBackCanLeaveTheDestination() {
assertEquals(SettingsSelection(), settingsBack(SettingsSelection()))
}
@Test
fun tappingACoveredStripPopsEveryPaneToItsRight() {
val detail = openTemplateDetail(openTemplatesGallery(SettingsSelection()), "three-stage")
// The settings strip closes everything back to the settings page.
assertEquals(SettingsSelection(), settingsPopTo(detail, level = 0))
// The gallery strip closes only the template detail above it.
assertEquals(
SettingsSelection(pane = SettingsPane.Gallery),
settingsPopTo(detail, level = 1),
)
// A strip at or beyond the current depth has nothing to its right.
assertEquals(detail, settingsPopTo(detail, level = 2))
}
@Test
fun theSelectionSurvivesThroughItsSaverPayload() {
val detail = openTemplateDetail(openTemplatesGallery(SettingsSelection()), "three-stage")
assertEquals(detail, decodeSettingsSelection(encodeSettingsSelection(detail)))
assertEquals(
SettingsSelection(),
decodeSettingsSelection(encodeSettingsSelection(SettingsSelection())),
)
}
}