android: stand the destination pill down in an open chat conversation

The floating destinations pill was drawn over the bottom of every screen,
including an open chat, where it sat on the composer and the newest message
and competed with the send/stop controls. It now stands down while the Chat
destination shows an open conversation and stays everywhere else, unchanged.

- One rule: `destinationPillVisible(currentRoute, conversationOpen)` is false
  only for `chat` with an open conversation. `conversationOpen` is the new
  `AppViewModel.conversationOpen`, a distinctUntilChanged boolean derived from
  the same ChatStore the chat surface renders, so a background chat never hides
  the pill elsewhere and a streamed delta never recomposes the app shell.
- The space, not just the pill: `destinationPillReserve(pillVisible)` returns
  the named DESTINATION_PILL_RESERVE while drawn and 0.dp while hidden, so the
  content Column clears a drawn pill and leaves no empty band when it is gone,
  and no frame reserves a gap behind a hidden pill or draws one over content it
  does not clear. Keyboard-open and the IME padding are unchanged.
- Escapability untouched: the top-bar "Back to chats" arrow, ChatScreen's
  PredictiveBackHandler and SlidingPaneStack.onPopTo remain the way out.
- No other pill behaviour changed: destinations, selection indicator,
  morph-into-search and every other screen are as before.

Checked for staleness: none of the packaged templates or the packaged authoring
skill references (internal/author/skill/references) mention the destination pill,
so no template or reference needed updating for this Android-only change.

Tests: PipelinesNavTest gains thePillStandsDownOnlyWhileAConversationIsOpen and
theReserveTracksTheDrawnPillSoContentNeitherJumpsNorLeavesAGap.
This commit is contained in:
2026-10-17 16:25:22 +01:00
parent 890d267c71
commit 3e14baebd7
4 changed files with 168 additions and 16 deletions
@@ -153,6 +153,19 @@ class AppViewModel(
)
val chat: StateFlow<ChatState> = chatStore.state
/**
* Whether the Chat destination is showing an open conversation — a session's
* transcript and composer — rather than the session list or the create flow.
* The app hides the floating destination pill in exactly this state. A derived
* boolean, distinct until changed, so the whole chat state (streamed deltas,
* drafts, scroll) never recomposes the app shell; it is read from the same
* store the chat surface renders, so the pill and the pane can never disagree.
*/
val conversationOpen: StateFlow<Boolean> = chatStore.state
.map { it.active != null }
.distinctUntilChanged()
.stateIn(viewModelScope, SharingStarted.Eagerly, chatStore.value.active != null)
// The live run subscription: the workspace currently watched, the job that
// established it, and the coalescing jobs that re-sync on a push. One
// subscription per connection; a reconnect (which clears this watch, not the
@@ -175,6 +175,12 @@ fun PipelinesApp(
mutableStateOf(OmniSearchState())
}
val search by vm.search.collectAsStateWithLifecycle()
// Whether the Chat destination currently shows an open conversation. The
// floating pill stands down only there (see [destinationPillVisible]); it is
// read from the chat store, so it flips in the same recomposition that swaps
// the chat list for the conversation.
val conversationOpen by vm.conversationOpen.collectAsStateWithLifecycle()
val pillVisible = destinationPillVisible(currentRoute, conversationOpen)
/** Back/scrim/close and a selection all dismiss the morph and clear the panel. */
val dismissSearch: () -> Unit = {
@@ -264,11 +270,13 @@ fun PipelinesApp(
// 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.
// 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.
val bannerVisible = connectionState !is ConnectionState.Connected
Scaffold(contentWindowInsets = WindowInsets(0, 0, 0, 0)) { padding ->
Box(Modifier.fillMaxSize().padding(padding)) {
Column(Modifier.fillMaxSize().padding(bottom = DESTINATION_PILL_RESERVE)) {
Column(Modifier.fillMaxSize().padding(bottom = destinationPillReserve(pillVisible))) {
ConnectionBanner(
state = connectionState,
configuredUrl = configuredUrl,
@@ -379,20 +387,25 @@ fun PipelinesApp(
onClick = { attentionOpen = true },
modifier = Modifier.padding(bottom = SPACING_S),
)
DestinationBar(
destinations = destinations,
currentRoute = currentRoute,
state = searchState,
onSelect = onNavigate,
onOpenSearch = { searchState = openOmniSearch(searchState) },
onDismissSearch = dismissSearch,
onQueryChange = {
searchState = setOmniSearchQuery(searchState, it)
vm.onSearchQueryChanged(it)
},
onFocusChange = { searchState = setOmniSearchFocus(searchState, it) },
onSubmitSearch = { vm.searchNow() },
)
// The pill stands down while a conversation is open; the search
// field it morphs into is unreachable there anyway (the field opens
// from the pill), so nothing is stranded by not drawing it.
if (pillVisible) {
DestinationBar(
destinations = destinations,
currentRoute = currentRoute,
state = searchState,
onSelect = onNavigate,
onOpenSearch = { searchState = openOmniSearch(searchState) },
onDismissSearch = dismissSearch,
onQueryChange = {
searchState = setOmniSearchQuery(searchState, it)
vm.onSearchQueryChanged(it)
},
onFocusChange = { searchState = setOmniSearchFocus(searchState, it) },
onSubmitSearch = { vm.searchNow() },
)
}
}
if (attentionOpen) {
AttentionSheet(
@@ -730,6 +743,34 @@ private fun TemplatesDestination(
internal fun destinationIndicatorOffsetDp(index: Int, itemSize: Dp, gap: Dp): Dp =
gap + (itemSize + gap) * index.coerceAtLeast(0)
/** The Chat destination's navigation route. */
private const val CHAT_ROUTE = "chat"
/**
* Whether the floating destination pill is drawn for [currentRoute]. The pill
* stands down only while the Chat destination is showing an open conversation —
* a session's transcript and composer — where it would sit over the composer and
* the newest message and compete with send/stop. The chat list and every other
* destination keep it exactly as before; the covered peek strip and Back still
* leave a conversation, so hiding the pill strands nothing. Pure, so the one
* rule is unit-testable without a device.
*/
internal fun destinationPillVisible(currentRoute: String?, conversationOpen: Boolean): Boolean =
!(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.
*/
internal fun destinationPillReserve(pillVisible: Boolean): Dp =
if (pillVisible) DESTINATION_PILL_RESERVE else 0.dp
/**
* The bottom container: the destination pill that morphs into the omni-search
* field. It is one [Surface] so the morph reads as the same container changing
@@ -1,6 +1,7 @@
package net.awan.pipelines.ui
import androidx.compose.ui.unit.Dp
import net.awan.pipelines.ui.theme.DESTINATION_PILL_RESERVE
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
@@ -52,6 +53,44 @@ class PipelinesNavTest {
)
}
@Test
fun thePillStandsDownOnlyWhileAConversationIsOpen() {
// An open conversation (the chat transcript and composer) hides the pill;
// 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)) {
assertTrue(destinationPillVisible(route, conversationOpen = false))
}
// A conversation only exists on the chat route; even if the flag were set
// elsewhere the pill stays, so a background chat never hides it.
assertTrue(destinationPillVisible("runs", conversationOpen = true))
}
@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.
for (route in listOf("pipelines", "chat", "runs", "settings", null)) {
for (open in listOf(false, true)) {
val drawn = destinationPillVisible(route, open)
val reserve = destinationPillReserve(drawn)
assertTrue(
"reserve held behind a hidden pill on $route (open=$open)",
drawn || reserve.value == 0f,
)
assertTrue(
"content not cleared of a drawn pill on $route (open=$open)",
!drawn || reserve.value == DESTINATION_PILL_RESERVE.value,
)
}
}
}
private fun assertDp(expected: Float, actual: Dp) =
assertEquals(expected, actual.value, 0.01f)
}