diff --git a/android/app/src/main/java/net/awan/pipelines/ui/PipelinesApp.kt b/android/app/src/main/java/net/awan/pipelines/ui/PipelinesApp.kt index f6b84ad4..261a331c 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/PipelinesApp.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/PipelinesApp.kt @@ -80,7 +80,7 @@ internal data class TopDestination(val route: String, val label: String, val ico * narrows it. */ internal val destinations = listOf( - TopDestination("pipelines", "Pipelines", Icons.Default.AccountTree), + TopDestination(PIPELINES_ROUTE, "Pipelines", Icons.Default.AccountTree), TopDestination("runs", "Runs", Icons.Default.History), TopDestination("chat", "Chat", Icons.AutoMirrored.Filled.Chat), TopDestination("settings", "Settings", Icons.Default.Settings), @@ -193,11 +193,12 @@ 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() - // 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. + // A run or pipeline 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 list restores it. val runDetailOpen = runDetailOpen(currentRoute, runSelection) - val pillVisible = destinationPillVisible(currentRoute, conversationOpen, runDetailOpen) + val pipelineDetailOpen = pipelineDetailOpen(currentRoute, pipelineSelection) + val pillVisible = destinationPillVisible(currentRoute, conversationOpen, runDetailOpen, pipelineDetailOpen) val searchKind by vm.searchKind.collectAsStateWithLifecycle() val searchSort by vm.searchSort.collectAsStateWithLifecycle() @@ -213,7 +214,7 @@ fun PipelinesApp( when (val target = searchTarget(hit)) { is SearchTarget.Pipeline -> { pipelineSelection = PaneSelection(MasterPane.Detail, target.pipelineId, target.version) - navController.navigate("pipelines") { + navController.navigate(PIPELINES_ROUTE) { popUpTo(HOME_ROUTE) { inclusive = false } launchSingleTop = true } @@ -338,7 +339,7 @@ fun PipelinesApp( }, ), ) { - composable("pipelines") { + composable(PIPELINES_ROUTE) { PipelineDestination( vm = vm, wide = wide, @@ -500,24 +501,31 @@ 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" +private const val PIPELINES_ROUTE = "pipelines" /** 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 +/** A pipeline detail is any non-list level of the Pipelines pane stack. */ +internal fun pipelineDetailOpen(currentRoute: String?, selection: PaneSelection): Boolean = + currentRoute == PIPELINES_ROUTE && selection.depth >= 1 + /** * Whether the floating destination pill is drawn for [currentRoute]. The pill - * stands down in the two places a deliberate detail surface owns the foot of the - * screen and the pill would sit over it: + * stands down in the three 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 detail is open ([runDetailOpen]), including its summary, graph, - * stage, artifact and decision surfaces, where it would cover their controls. + * stage, artifact and decision surfaces, where it would cover their controls; + * - while a pipeline detail is open ([pipelineDetailOpen]), including its + * description, graph and run history, where it would cover their controls. * - * 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 + * Everything else keeps it: the chat list, run list and pipeline list all draw + * it, and the covered peek strip and Back still leave every hiding state, 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. */ @@ -525,7 +533,9 @@ internal fun destinationPillVisible( currentRoute: String?, conversationOpen: Boolean, runDetailOpen: Boolean, -): Boolean = !(currentRoute == CHAT_ROUTE && conversationOpen) && !runDetailOpen + pipelineDetailOpen: Boolean, +): Boolean = + !(currentRoute == CHAT_ROUTE && conversationOpen) && !runDetailOpen && !pipelineDetailOpen /** * Where the bottom destination pill rests in the window: horizontally centred on a diff --git a/android/app/src/test/java/net/awan/pipelines/ui/PipelinesNavTest.kt b/android/app/src/test/java/net/awan/pipelines/ui/PipelinesNavTest.kt index b736e89c..528fcc91 100644 --- a/android/app/src/test/java/net/awan/pipelines/ui/PipelinesNavTest.kt +++ b/android/app/src/test/java/net/awan/pipelines/ui/PipelinesNavTest.kt @@ -95,24 +95,53 @@ class PipelinesNavTest { } @Test - fun thePillStandsDownWhileAConversationOrRunDetailIsOpen() { + fun thePillStandsDownWhileAConversationOrADetailIsOpen() { // 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, runDetailOpen = false)) - assertTrue(destinationPillVisible("chat", conversationOpen = false, runDetailOpen = false)) + assertFalse(destinationPillVisible("chat", conversationOpen = true, runDetailOpen = false, pipelineDetailOpen = false)) + assertTrue(destinationPillVisible("chat", conversationOpen = false, runDetailOpen = false, pipelineDetailOpen = false)) for (route in listOf("pipelines", "runs", "settings", null)) { - assertTrue(destinationPillVisible(route, conversationOpen = false, runDetailOpen = false)) + assertTrue(destinationPillVisible(route, conversationOpen = false, runDetailOpen = false, pipelineDetailOpen = 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, runDetailOpen = false)) + assertTrue(destinationPillVisible("runs", conversationOpen = true, runDetailOpen = false, pipelineDetailOpen = 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)) + assertFalse(destinationPillVisible("runs", conversationOpen = false, runDetailOpen = true, pipelineDetailOpen = false)) + assertTrue(destinationPillVisible("runs", conversationOpen = false, runDetailOpen = false, pipelineDetailOpen = false)) for (route in listOf("pipelines", "runs", "chat", "settings", null)) { - assertFalse(destinationPillVisible(route, conversationOpen = false, runDetailOpen = true)) + assertFalse(destinationPillVisible(route, conversationOpen = false, runDetailOpen = true, pipelineDetailOpen = false)) + } + } + + @Test + fun aPipelineDetailHidesThePillLikeARunDetail() { + // Opening a pipeline is a detail surface: it owns the foot of the Pipelines + // destination, so the pill stands down exactly as it does for a run detail, + // and returning to the pipeline list restores it. + val list = PaneSelection() + val detail = PaneSelection(pane = MasterPane.Detail, itemId = 7) + val stage = detail.copy(pane = MasterPane.Stage, stageKey = "implementer") + + assertFalse(pipelineDetailOpen("pipelines", list)) + assertTrue(pipelineDetailOpen("pipelines", detail)) + assertTrue(pipelineDetailOpen("pipelines", stage)) + assertFalse(pipelineDetailOpen("runs", detail)) + assertTrue( + destinationPillVisible( + "pipelines", conversationOpen = false, runDetailOpen = false, + pipelineDetailOpen = pipelineDetailOpen("pipelines", list), + ), + ) + for (selection in listOf(detail, stage)) { + assertFalse( + destinationPillVisible( + "pipelines", conversationOpen = false, runDetailOpen = false, + pipelineDetailOpen = pipelineDetailOpen("pipelines", selection), + ), + ) } } @@ -124,10 +153,10 @@ class PipelinesNavTest { val section = stage.copy(pane = MasterPane.Section, sectionKey = "output") assertFalse(runDetailOpen("runs", list)) - assertTrue(destinationPillVisible("runs", conversationOpen = false, runDetailOpen = runDetailOpen("runs", list))) + assertTrue(destinationPillVisible("runs", conversationOpen = false, runDetailOpen = runDetailOpen("runs", list), pipelineDetailOpen = false)) for (selection in listOf(detail, stage, section)) { assertTrue(runDetailOpen("runs", selection)) - assertFalse(destinationPillVisible("runs", conversationOpen = false, runDetailOpen = runDetailOpen("runs", selection))) + assertFalse(destinationPillVisible("runs", conversationOpen = false, runDetailOpen = runDetailOpen("runs", selection), pipelineDetailOpen = false)) } assertFalse(runDetailOpen("pipelines", detail)) assertFalse(runDetailOpen("runs", backFrom(detail))) @@ -158,7 +187,7 @@ class PipelinesNavTest { for (route in listOf("pipelines", "chat", "runs", "settings", null)) { for (open in listOf(false, true)) { for (detailOpen in listOf(false, true)) { - val drawn = destinationPillVisible(route, open, detailOpen) + val drawn = destinationPillVisible(route, open, detailOpen, false) val inset = pillScrollInset(drawn) assertTrue( "scroll clearance held behind a hidden pill on $route (open=$open, detail=$detailOpen)",