android: preserve run decision pill work
This commit is contained in:
@@ -185,11 +185,17 @@ fun PipelinesApp(
|
||||
}
|
||||
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
|
||||
// floating pill stands down 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)
|
||||
// Whether a run's pending-decision surface — the decision sheet the operator
|
||||
// opens from the run summary's Decide action — is currently open. It is a state
|
||||
// of the run view (reported up by the run detail and its stage pane), not a
|
||||
// destination, so the pill stands down for exactly as long as it is up and
|
||||
// returns the moment the decision is answered or dismissed, with no navigation.
|
||||
var decisionSurfaceOpen by remember { mutableStateOf(false) }
|
||||
val pillVisible = destinationPillVisible(currentRoute, conversationOpen, decisionSurfaceOpen)
|
||||
val searchKind by vm.searchKind.collectAsStateWithLifecycle()
|
||||
val searchSort by vm.searchSort.collectAsStateWithLifecycle()
|
||||
|
||||
@@ -291,7 +297,8 @@ fun PipelinesApp(
|
||||
// ([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
|
||||
// (an open conversation or a run's open decision surface, see
|
||||
// [destinationPillVisible]) that clearance is zero
|
||||
// so a hidden pill leaves no empty band. See [contentPillPadding].
|
||||
val bannerVisible = connectionState !is ConnectionState.Connected
|
||||
// The live height of any bottom selector strip the current pane is showing. The
|
||||
@@ -354,6 +361,7 @@ fun PipelinesApp(
|
||||
listState = runListState,
|
||||
decisionRequest = decisionRequest,
|
||||
onDecisionRequestHandled = { decisionRequest = null },
|
||||
onDecisionSurfaceChange = { decisionSurfaceOpen = it },
|
||||
)
|
||||
}
|
||||
composable("chat") {
|
||||
@@ -436,9 +444,10 @@ fun PipelinesApp(
|
||||
onClick = { attentionOpen = true },
|
||||
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
|
||||
// from the pill), so nothing is stranded by not drawing it.
|
||||
// The pill stands down while a conversation is open, or while a
|
||||
// run's pending-decision surface is up; 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,
|
||||
@@ -497,15 +506,25 @@ 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
|
||||
* stands down in the two places a deliberate bottom surface owns the foot of the
|
||||
* screen and the pill would sit over it:
|
||||
*
|
||||
* - while the Chat destination is showing an open conversation — a session's
|
||||
* transcript and composer — where it would compete with send/stop;
|
||||
* - while a run's pending-decision surface is open ([decisionOpen], the sheet the
|
||||
* operator answers from the run summary), where it would cover the options.
|
||||
*
|
||||
* Everything else keeps it: the chat list, a run being read, its stage pane, an
|
||||
* artifact and the graph all draw it exactly as before, and the covered peek strip
|
||||
* and Back still leave both hiding states, so hiding the pill strands nothing. The
|
||||
* clearance and the drawn pill both key off this one predicate. Pure, so the one
|
||||
* rule is unit-testable without a device.
|
||||
*/
|
||||
internal fun destinationPillVisible(currentRoute: String?, conversationOpen: Boolean): Boolean =
|
||||
!(currentRoute == CHAT_ROUTE && conversationOpen)
|
||||
internal fun destinationPillVisible(
|
||||
currentRoute: String?,
|
||||
conversationOpen: Boolean,
|
||||
decisionOpen: Boolean,
|
||||
): Boolean = !(currentRoute == CHAT_ROUTE && conversationOpen) && !decisionOpen
|
||||
|
||||
/**
|
||||
* Where the bottom overlay — the destination pill and the attention chip above it
|
||||
@@ -534,9 +553,10 @@ 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
|
||||
* while the pill is drawn, and none while it is hidden (an open conversation or a
|
||||
* run's open decision surface, 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
|
||||
|
||||
@@ -34,6 +34,7 @@ internal fun RunsDestination(
|
||||
listState: LazyListState,
|
||||
decisionRequest: Long? = null,
|
||||
onDecisionRequestHandled: () -> Unit = {},
|
||||
onDecisionSurfaceChange: (Boolean) -> Unit = {},
|
||||
) {
|
||||
val depth = selection.depth
|
||||
val onBack: () -> Unit = { onSelectionChange(backFrom(selection)) }
|
||||
@@ -103,6 +104,7 @@ internal fun RunsDestination(
|
||||
covered = covered,
|
||||
requestDecision = decisionRequest == itemId,
|
||||
onDecisionRequestHandled = onDecisionRequestHandled,
|
||||
onDecisionSurfaceChange = onDecisionSurfaceChange,
|
||||
)
|
||||
}
|
||||
2 -> rememberPaneContent(
|
||||
@@ -126,6 +128,7 @@ internal fun RunsDestination(
|
||||
wide = wide,
|
||||
modifier = paneModifier,
|
||||
covered = covered,
|
||||
onDecisionSurfaceChange = onDecisionSurfaceChange,
|
||||
)
|
||||
}
|
||||
3 -> rememberPaneContent(
|
||||
@@ -147,6 +150,7 @@ internal fun RunsDestination(
|
||||
wide = wide,
|
||||
modifier = paneModifier,
|
||||
covered = covered,
|
||||
onDecisionSurfaceChange = onDecisionSurfaceChange,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -60,6 +61,12 @@ import net.awan.pipelines.ui.theme.pipelinesText
|
||||
* [onSend] performs the request; it reports the outcome through its callback so
|
||||
* this component owns no networking and is unit-testable through the pure
|
||||
* [DecisionDraft]/[decisionRefusalMessage] model.
|
||||
*
|
||||
* [onSurfaceOpenChange] reports whether the decision sheet — the run's pending
|
||||
* decision surface — is currently open, so the host can tell the app shell to
|
||||
* stand the floating destination pill down for exactly as long as the operator is
|
||||
* answering. It is the host's job to route that to the pill (see
|
||||
* `destinationPillVisible`); this component only says when its own surface is up.
|
||||
*/
|
||||
@Composable
|
||||
fun DecisionPrompt(
|
||||
@@ -68,6 +75,7 @@ fun DecisionPrompt(
|
||||
modifier: Modifier = Modifier,
|
||||
openRequest: Boolean = false,
|
||||
onOpenRequestHandled: () -> Unit = {},
|
||||
onSurfaceOpenChange: (Boolean) -> Unit = {},
|
||||
) {
|
||||
val shown = rememberPaneContent(decision)
|
||||
var open by remember { mutableStateOf(false) }
|
||||
@@ -75,6 +83,13 @@ fun DecisionPrompt(
|
||||
var sending by remember { mutableStateOf(false) }
|
||||
var error by remember { mutableStateOf<String?>(null) }
|
||||
|
||||
// The decision surface is up exactly while the sheet is open (it can outlive
|
||||
// the decision, kept open to report a refusal), so the host is told on every
|
||||
// change. It is cleared when the prompt leaves the composition, so a surface
|
||||
// that closes with its pane can never leave the pill hidden behind it.
|
||||
LaunchedEffect(open) { onSurfaceOpenChange(open) }
|
||||
DisposableEffect(Unit) { onDispose { onSurfaceOpenChange(false) } }
|
||||
|
||||
// A notification's tap asks for the decision itself, not just the run:
|
||||
// open the sheet once the waiting run's detail has loaded. The request is
|
||||
// consumed here so a recomposition or a dismissal does not reopen it.
|
||||
|
||||
@@ -420,6 +420,7 @@ fun StageDetailPane(
|
||||
runLabel: String? = null,
|
||||
decision: PendingDecision? = null,
|
||||
onDecide: (PendingDecision, String, String, (Result<RunDetail>) -> Unit) -> Unit = { _, _, _, _ -> },
|
||||
onDecisionSurfaceChange: (Boolean) -> Unit = {},
|
||||
) {
|
||||
// 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.
|
||||
@@ -485,6 +486,7 @@ fun StageDetailPane(
|
||||
runContext = runContext,
|
||||
decision = decision,
|
||||
onDecide = onDecide,
|
||||
onDecisionSurfaceChange = onDecisionSurfaceChange,
|
||||
modifier = Modifier.padding(padding),
|
||||
)
|
||||
}
|
||||
@@ -505,6 +507,7 @@ private fun StageDetailBody(
|
||||
runContext: Boolean,
|
||||
decision: PendingDecision?,
|
||||
onDecide: (PendingDecision, String, String, (Result<RunDetail>) -> Unit) -> Unit,
|
||||
onDecisionSurfaceChange: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
@@ -536,7 +539,11 @@ private fun StageDetailBody(
|
||||
// the stage screen: reaching the stage is enough. Rendered
|
||||
// unconditionally so the open sheet survives a refusal (which clears the
|
||||
// decision) and can report the server's reason.
|
||||
DecisionPrompt(decision = decision, onSend = onDecide)
|
||||
DecisionPrompt(
|
||||
decision = decision,
|
||||
onSend = onDecide,
|
||||
onSurfaceOpenChange = onDecisionSurfaceChange,
|
||||
)
|
||||
// The stage's own name is the app bar's title, so the body does not
|
||||
// repeat it: the pane leads with the stage's type and facts instead of
|
||||
// a duplicated heading.
|
||||
@@ -849,6 +856,7 @@ fun RunStagePane(
|
||||
wide: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
covered: Boolean = false,
|
||||
onDecisionSurfaceChange: (Boolean) -> Unit = {},
|
||||
) {
|
||||
val state by vm.runDetail.collectAsStateWithLifecycle()
|
||||
val configuredServerUrl by vm.configuredServerUrl.collectAsStateWithLifecycle()
|
||||
@@ -884,6 +892,7 @@ fun RunStagePane(
|
||||
onDecide = { pending, option, feedback, onResult ->
|
||||
vm.decideRun(pending.runId, pending.stageKey, option, feedback, onResult)
|
||||
},
|
||||
onDecisionSurfaceChange = onDecisionSurfaceChange,
|
||||
)
|
||||
} else {
|
||||
StageSectionPane(
|
||||
|
||||
@@ -69,6 +69,7 @@ fun RunDetailScreen(
|
||||
covered: Boolean = false,
|
||||
requestDecision: Boolean = false,
|
||||
onDecisionRequestHandled: () -> Unit = {},
|
||||
onDecisionSurfaceChange: (Boolean) -> Unit = {},
|
||||
) {
|
||||
val state by vm.runDetail.collectAsStateWithLifecycle()
|
||||
val runsState by vm.runs.collectAsStateWithLifecycle()
|
||||
@@ -217,6 +218,7 @@ fun RunDetailScreen(
|
||||
modifier = Modifier.padding(horizontal = SPACING_L, vertical = SPACING_S),
|
||||
openRequest = requestDecision,
|
||||
onOpenRequestHandled = onDecisionRequestHandled,
|
||||
onSurfaceOpenChange = onDecisionSurfaceChange,
|
||||
)
|
||||
StateCrossfade(
|
||||
phase = detailLoadPhase(state.error, hasData = run != null),
|
||||
|
||||
@@ -83,17 +83,29 @@ class PipelinesNavTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun thePillStandsDownOnlyWhileAConversationIsOpen() {
|
||||
fun thePillStandsDownWhileAConversationOrARunDecisionSurfaceIsOpen() {
|
||||
// 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))
|
||||
assertFalse(destinationPillVisible("chat", conversationOpen = true, decisionOpen = false))
|
||||
assertTrue(destinationPillVisible("chat", conversationOpen = false, decisionOpen = false))
|
||||
for (route in listOf("pipelines", "runs", "settings", null)) {
|
||||
assertTrue(destinationPillVisible(route, conversationOpen = false))
|
||||
assertTrue(destinationPillVisible(route, conversationOpen = false, decisionOpen = 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))
|
||||
assertTrue(destinationPillVisible("runs", conversationOpen = true, decisionOpen = false))
|
||||
// A run's pending-decision surface (the decision sheet the operator opens
|
||||
// from the run summary) hides the pill on the Runs destination, and only
|
||||
// while it is open: the run being read, its stage pane, an artifact or a
|
||||
// graph all keep it.
|
||||
assertFalse(destinationPillVisible("runs", conversationOpen = false, decisionOpen = true))
|
||||
assertTrue(destinationPillVisible("runs", conversationOpen = false, decisionOpen = false))
|
||||
// The decision surface is a state of the run view, not a route, so the
|
||||
// predicate hides it everywhere it were reported, exactly as for a
|
||||
// conversation — and never for the chat list's own conversation flag.
|
||||
for (route in listOf("pipelines", "runs", "chat", "settings", null)) {
|
||||
assertFalse(destinationPillVisible(route, conversationOpen = false, decisionOpen = true))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,16 +132,18 @@ class PipelinesNavTest {
|
||||
// when hidden.
|
||||
for (route in listOf("pipelines", "chat", "runs", "settings", null)) {
|
||||
for (open in listOf(false, true)) {
|
||||
val drawn = destinationPillVisible(route, open)
|
||||
val inset = pillScrollInset(drawn)
|
||||
assertTrue(
|
||||
"scroll clearance held behind a hidden pill on $route (open=$open)",
|
||||
drawn || inset.value == 0f,
|
||||
)
|
||||
assertTrue(
|
||||
"list not cleared of a drawn pill on $route (open=$open)",
|
||||
!drawn || inset.value == drawnInset.value,
|
||||
)
|
||||
for (deciding in listOf(false, true)) {
|
||||
val drawn = destinationPillVisible(route, open, deciding)
|
||||
val inset = pillScrollInset(drawn)
|
||||
assertTrue(
|
||||
"scroll clearance held behind a hidden pill on $route (open=$open, deciding=$deciding)",
|
||||
drawn || inset.value == 0f,
|
||||
)
|
||||
assertTrue(
|
||||
"list not cleared of a drawn pill on $route (open=$open, deciding=$deciding)",
|
||||
!drawn || inset.value == drawnInset.value,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# The destinations pill stands down over a run's pending decision
|
||||
|
||||
## What this item changed
|
||||
|
||||
`android/` only, the app shell's floating destination pill and the run view's decision surface.
|
||||
|
||||
- `ui/PipelinesApp.kt` — the pill's one rule gains a second hiding state.
|
||||
`destinationPillVisible(currentRoute, conversationOpen, decisionOpen)` is now
|
||||
`!(currentRoute == CHAT_ROUTE && conversationOpen) && !decisionOpen`: the chat conversation
|
||||
hides it exactly as before (the chat clause is unchanged), and a run's open pending-decision
|
||||
surface hides it too. Everything downstream is unchanged and still keys off that one
|
||||
predicate — `contentPillPadding(pillVisible)` (the named zero) and
|
||||
`pillScrollInset(pillVisible)` (the named `DESTINATION_PILL_RESERVE` +
|
||||
`ATTENTION_CHIP_RESERVE`, or `0.dp` while hidden) — so hiding the pill over a decision
|
||||
leaves no empty band, exactly as hiding it in a conversation already does. The shell holds
|
||||
the new input as `decisionSurfaceOpen` (`remember { mutableStateOf(false) }`: a transient
|
||||
state of the run view, not a destination and not saved — the sheet is not saveable either,
|
||||
so a configuration change closes both together) and passes its setter down the same path
|
||||
`decisionRequest` already travels.
|
||||
- `ui/components/DecisionPrompt.kt` — gains `onSurfaceOpenChange: (Boolean) -> Unit = {}`,
|
||||
reporting `open` on every change (`LaunchedEffect(open)`) and clearing it when the prompt
|
||||
leaves the composition (`DisposableEffect`) so a surface closed with its pane can never
|
||||
leave the pill hidden behind it. The component still owns no networking and no pill
|
||||
knowledge: it only says when its own surface is up.
|
||||
- `ui/screens/RunDetailScreen.kt`, `ui/RunsDestination.kt`, `ui/graph/StageDetailPane.kt` —
|
||||
the run detail, the runs destination and the run's stage pane (its section level included)
|
||||
pass that callback through, so the decision sheet hides the pill wherever it is opened
|
||||
from. The pipeline-side stage pane gets the default no-op.
|
||||
- Tests — `PipelinesNavTest`: the existing `destinationPillVisible` test is extended in place
|
||||
(renamed `thePillStandsDownWhileAConversationOrARunDecisionSurfaceIsOpen`) to pin that the
|
||||
decision surface hides the pill on the runs route, that a run being read keeps it, and that
|
||||
the chat clause is untouched; and the scroll-inset test's loop gains the decision
|
||||
dimension, so `pillScrollInset` is proved zero while the decision surface hides the pill
|
||||
(no empty band) and the drawn reserve while it is drawn.
|
||||
|
||||
No new dimension, so no `ui/theme/Dimens.kt` token was needed (a raw literal would fail
|
||||
`DimensTest`). No dependency added, no server/Go/installer/Docker file touched, and no run
|
||||
started from the app.
|
||||
|
||||
## Shared documents this change makes stale
|
||||
|
||||
`android/README.md` documents the pill's hiding rule and is written here rather than edited in
|
||||
place; the `docs-fold` writer should update it.
|
||||
|
||||
- `android/README.md:6219` — the section headline
|
||||
"## Destination pill stands down in an open conversation (17 Oct 2026)" and its opening
|
||||
paragraph ("It now stands down while the Chat destination is showing an open conversation
|
||||
and stays everywhere else, unchanged") now describe only half the rule. The section should
|
||||
also record the new item, e.g. append a dated section:
|
||||
|
||||
```markdown
|
||||
## The destinations pill stands down over a run's pending decision (18 Oct 2026)
|
||||
|
||||
The floating destinations pill also stood over a run's pending-decision surface — the
|
||||
decision sheet ("Choose things that need to happen") the operator opens from the run
|
||||
summary's Decide action — where it covered the options. It now stands down there too,
|
||||
exactly as it already does inside an open chat conversation, and returns the moment the
|
||||
decision is answered or dismissed. `android/` only; no new dependency, no run started from
|
||||
the app, no server/installer/Docker file touched.
|
||||
|
||||
- **The one rule gains a second hiding state.** `destinationPillVisible(currentRoute,
|
||||
conversationOpen, decisionOpen)` is `!(currentRoute == CHAT_ROUTE && conversationOpen) &&
|
||||
!decisionOpen`. The chat clause is unchanged; the new `decisionOpen` is reported up by the
|
||||
run view (`DecisionPrompt.onSurfaceOpenChange`), so the surface is a state of the run view,
|
||||
not a destination: answering or dismissing it returns the pill with no navigation.
|
||||
- **Still one predicate, still no band.** `contentPillPadding` and `pillScrollInset` are
|
||||
unchanged and still derive from `pillVisible` alone, so a hidden pill over the decision
|
||||
leaves no empty band; the scroll-inset test now loops the decision dimension and pins that.
|
||||
- **Scoped to the decision surface.** A run being read, its stage pane, an artifact and the
|
||||
graph all keep the pill; only the open decision sheet hides it. The chat behaviour and the
|
||||
narrow/wide placement rules are untouched.
|
||||
```
|
||||
|
||||
## Not stale
|
||||
|
||||
- No packaged OpenCode skill reference (`internal/author/skill/references/`) documents the
|
||||
app's destination pill or its hiding states; they describe the server, the CLI and the
|
||||
pipeline authoring model. No packaged template (`examples/*.md`) and no `internal/author/`
|
||||
managed file names them either, so `internal/author/install.go`'s inventory needs no change.
|
||||
- `android/AGENTS.md` describes `ui/PipelinesApp.kt` generically ("the app shell:
|
||||
destinations, the floating pill, the omni-search morph") and needs no change.
|
||||
Reference in New Issue
Block a user