android: preserve run detail pill correction
This commit is contained in:
@@ -189,13 +189,11 @@ fun PipelinesApp(
|
||||
// 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()
|
||||
// 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)
|
||||
// A run detail owns the lower part of the screen, including its graph, stage,
|
||||
// artifact and decision surfaces. Hide the pill for the entire detail stack,
|
||||
// not just one sheet inside it; returning to the run list restores it.
|
||||
val runDetailOpen = runDetailOpen(currentRoute, runSelection)
|
||||
val pillVisible = destinationPillVisible(currentRoute, conversationOpen, runDetailOpen)
|
||||
val searchKind by vm.searchKind.collectAsStateWithLifecycle()
|
||||
val searchSort by vm.searchSort.collectAsStateWithLifecycle()
|
||||
|
||||
@@ -361,7 +359,6 @@ fun PipelinesApp(
|
||||
listState = runListState,
|
||||
decisionRequest = decisionRequest,
|
||||
onDecisionRequestHandled = { decisionRequest = null },
|
||||
onDecisionSurfaceChange = { decisionSurfaceOpen = it },
|
||||
)
|
||||
}
|
||||
composable("chat") {
|
||||
@@ -444,10 +441,9 @@ fun PipelinesApp(
|
||||
onClick = { attentionOpen = true },
|
||||
modifier = Modifier.align(Alignment.End).padding(bottom = SPACING_S),
|
||||
)
|
||||
// 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.
|
||||
// The pill stands down while a conversation or run detail 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,
|
||||
@@ -503,28 +499,33 @@ private const val SEARCH_SCRIM_ALPHA = 0.5f
|
||||
|
||||
/** The Chat destination's navigation route. */
|
||||
private const val CHAT_ROUTE = "chat"
|
||||
private const val RUNS_ROUTE = "runs"
|
||||
|
||||
/** A run detail is any non-list level of the Runs pane stack. */
|
||||
internal fun runDetailOpen(currentRoute: String?, selection: PaneSelection): Boolean =
|
||||
currentRoute == RUNS_ROUTE && selection.depth >= 1
|
||||
|
||||
/**
|
||||
* Whether the floating destination pill is drawn for [currentRoute]. The pill
|
||||
* stands down in the two places a deliberate bottom surface owns the foot of the
|
||||
* stands down in the two places a deliberate detail 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.
|
||||
* - while a run detail is open ([runDetailOpen]), including its summary, graph,
|
||||
* stage, artifact and decision surfaces, where it would cover their controls.
|
||||
*
|
||||
* 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
|
||||
* Everything else keeps it: the chat list and run list both draw it, 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,
|
||||
decisionOpen: Boolean,
|
||||
): Boolean = !(currentRoute == CHAT_ROUTE && conversationOpen) && !decisionOpen
|
||||
runDetailOpen: Boolean,
|
||||
): Boolean = !(currentRoute == CHAT_ROUTE && conversationOpen) && !runDetailOpen
|
||||
|
||||
/**
|
||||
* Where the bottom overlay — the destination pill and the attention chip above it
|
||||
@@ -554,7 +555,7 @@ internal fun contentPillPadding(pillVisible: Boolean): Dp = 0.dp
|
||||
* 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 or a
|
||||
* run's open decision surface, see [destinationPillVisible]) so a hidden pill
|
||||
* run detail, 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
|
||||
|
||||
@@ -34,7 +34,6 @@ internal fun RunsDestination(
|
||||
listState: LazyListState,
|
||||
decisionRequest: Long? = null,
|
||||
onDecisionRequestHandled: () -> Unit = {},
|
||||
onDecisionSurfaceChange: (Boolean) -> Unit = {},
|
||||
) {
|
||||
val depth = selection.depth
|
||||
val onBack: () -> Unit = { onSelectionChange(backFrom(selection)) }
|
||||
@@ -104,7 +103,6 @@ internal fun RunsDestination(
|
||||
covered = covered,
|
||||
requestDecision = decisionRequest == itemId,
|
||||
onDecisionRequestHandled = onDecisionRequestHandled,
|
||||
onDecisionSurfaceChange = onDecisionSurfaceChange,
|
||||
)
|
||||
}
|
||||
2 -> rememberPaneContent(
|
||||
@@ -128,7 +126,6 @@ internal fun RunsDestination(
|
||||
wide = wide,
|
||||
modifier = paneModifier,
|
||||
covered = covered,
|
||||
onDecisionSurfaceChange = onDecisionSurfaceChange,
|
||||
)
|
||||
}
|
||||
3 -> rememberPaneContent(
|
||||
@@ -150,7 +147,6 @@ internal fun RunsDestination(
|
||||
wide = wide,
|
||||
modifier = paneModifier,
|
||||
covered = covered,
|
||||
onDecisionSurfaceChange = onDecisionSurfaceChange,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ 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
|
||||
@@ -61,12 +60,6 @@ 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(
|
||||
@@ -75,7 +68,6 @@ fun DecisionPrompt(
|
||||
modifier: Modifier = Modifier,
|
||||
openRequest: Boolean = false,
|
||||
onOpenRequestHandled: () -> Unit = {},
|
||||
onSurfaceOpenChange: (Boolean) -> Unit = {},
|
||||
) {
|
||||
val shown = rememberPaneContent(decision)
|
||||
var open by remember { mutableStateOf(false) }
|
||||
@@ -83,13 +75,6 @@ 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,7 +420,6 @@ 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.
|
||||
@@ -486,7 +485,6 @@ fun StageDetailPane(
|
||||
runContext = runContext,
|
||||
decision = decision,
|
||||
onDecide = onDecide,
|
||||
onDecisionSurfaceChange = onDecisionSurfaceChange,
|
||||
modifier = Modifier.padding(padding),
|
||||
)
|
||||
}
|
||||
@@ -507,7 +505,6 @@ private fun StageDetailBody(
|
||||
runContext: Boolean,
|
||||
decision: PendingDecision?,
|
||||
onDecide: (PendingDecision, String, String, (Result<RunDetail>) -> Unit) -> Unit,
|
||||
onDecisionSurfaceChange: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
@@ -542,7 +539,6 @@ private fun StageDetailBody(
|
||||
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
|
||||
@@ -856,7 +852,6 @@ 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()
|
||||
@@ -892,7 +887,6 @@ fun RunStagePane(
|
||||
onDecide = { pending, option, feedback, onResult ->
|
||||
vm.decideRun(pending.runId, pending.stageKey, option, feedback, onResult)
|
||||
},
|
||||
onDecisionSurfaceChange = onDecisionSurfaceChange,
|
||||
)
|
||||
} else {
|
||||
StageSectionPane(
|
||||
|
||||
@@ -69,7 +69,6 @@ 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()
|
||||
@@ -218,7 +217,6 @@ 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,31 +83,44 @@ class PipelinesNavTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun thePillStandsDownWhileAConversationOrARunDecisionSurfaceIsOpen() {
|
||||
fun thePillStandsDownWhileAConversationOrRunDetailIsOpen() {
|
||||
// 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, decisionOpen = false))
|
||||
assertTrue(destinationPillVisible("chat", conversationOpen = false, decisionOpen = false))
|
||||
assertFalse(destinationPillVisible("chat", conversationOpen = true, runDetailOpen = false))
|
||||
assertTrue(destinationPillVisible("chat", conversationOpen = false, runDetailOpen = false))
|
||||
for (route in listOf("pipelines", "runs", "settings", null)) {
|
||||
assertTrue(destinationPillVisible(route, conversationOpen = false, decisionOpen = false))
|
||||
assertTrue(destinationPillVisible(route, conversationOpen = false, runDetailOpen = 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, 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.
|
||||
assertTrue(destinationPillVisible("runs", conversationOpen = true, runDetailOpen = false))
|
||||
// Every run detail surface owns the bottom of the Runs destination: summary,
|
||||
// graph, stage, artifact and decision states all hide the pill. Back to the
|
||||
// list clears the one detail flag and restores it on narrow and wide panes.
|
||||
assertFalse(destinationPillVisible("runs", conversationOpen = false, runDetailOpen = true))
|
||||
assertTrue(destinationPillVisible("runs", conversationOpen = false, runDetailOpen = false))
|
||||
for (route in listOf("pipelines", "runs", "chat", "settings", null)) {
|
||||
assertFalse(destinationPillVisible(route, conversationOpen = false, decisionOpen = true))
|
||||
assertFalse(destinationPillVisible(route, conversationOpen = false, runDetailOpen = true))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aRunDetailCoversEveryNonListLevelAndBackRestoresTheListPill() {
|
||||
val list = PaneSelection()
|
||||
val detail = PaneSelection(pane = MasterPane.Detail, itemId = 12)
|
||||
val stage = detail.copy(pane = MasterPane.Stage, stageKey = "implementer")
|
||||
val section = stage.copy(pane = MasterPane.Section, sectionKey = "output")
|
||||
|
||||
assertFalse(runDetailOpen("runs", list))
|
||||
assertTrue(destinationPillVisible("runs", conversationOpen = false, runDetailOpen = runDetailOpen("runs", list)))
|
||||
for (selection in listOf(detail, stage, section)) {
|
||||
assertTrue(runDetailOpen("runs", selection))
|
||||
assertFalse(destinationPillVisible("runs", conversationOpen = false, runDetailOpen = runDetailOpen("runs", selection)))
|
||||
}
|
||||
assertFalse(runDetailOpen("pipelines", detail))
|
||||
assertFalse(runDetailOpen("runs", backFrom(detail)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theContentKeepsItsOwnHeightBecauseThePillIsAnOverlay() {
|
||||
// The pill floats above the content and never takes layout space, so the
|
||||
@@ -132,15 +145,15 @@ class PipelinesNavTest {
|
||||
// when hidden.
|
||||
for (route in listOf("pipelines", "chat", "runs", "settings", null)) {
|
||||
for (open in listOf(false, true)) {
|
||||
for (deciding in listOf(false, true)) {
|
||||
val drawn = destinationPillVisible(route, open, deciding)
|
||||
for (detailOpen in listOf(false, true)) {
|
||||
val drawn = destinationPillVisible(route, open, detailOpen)
|
||||
val inset = pillScrollInset(drawn)
|
||||
assertTrue(
|
||||
"scroll clearance held behind a hidden pill on $route (open=$open, deciding=$deciding)",
|
||||
"scroll clearance held behind a hidden pill on $route (open=$open, detail=$detailOpen)",
|
||||
drawn || inset.value == 0f,
|
||||
)
|
||||
assertTrue(
|
||||
"list not cleared of a drawn pill on $route (open=$open, deciding=$deciding)",
|
||||
"list not cleared of a drawn pill on $route (open=$open, detail=$detailOpen)",
|
||||
!drawn || inset.value == drawnInset.value,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user