android: preserve Runs home navigation stack

This commit is contained in:
2026-10-18 22:02:20 +01:00
parent 6faa32f8e3
commit 72f976b636
2 changed files with 19 additions and 5 deletions
@@ -92,6 +92,10 @@ internal val destinations = listOf(
/** The home route remains beneath top-level navigation, so Back returns to Runs. */
internal const val HOME_ROUTE = "runs"
/** Returning to home clears the accumulated top-level stack; other destinations keep it. */
internal fun topLevelPopUpToHomeInclusive(destination: String): Boolean =
destination == HOME_ROUTE
/**
* Whether [route] is the current destination. Detail panes are no longer
* separate routes (they are saved state inside a destination), so this is a
@@ -220,7 +224,7 @@ fun PipelinesApp(
is SearchTarget.Run -> {
runSelection = PaneSelection(MasterPane.Detail, target.runId)
runSearchNav = target.takeIf { it.sequence > 0 }
navController.navigate("runs") { launchSingleTop = true }
navController.navigate(HOME_ROUTE) { launchSingleTop = true }
}
null -> Unit
}
@@ -234,7 +238,7 @@ fun PipelinesApp(
val openRunFromAttention: (Long) -> Unit = { runId ->
vm.arrivedAtRun(runId)
runSelection = PaneSelection(pane = MasterPane.Detail, itemId = runId)
navController.navigate("runs") { launchSingleTop = true }
navController.navigate(HOME_ROUTE) { launchSingleTop = true }
}
// A deep link (or the notification's click action) opens its run once. The
@@ -277,7 +281,9 @@ fun PipelinesApp(
val onNavigate: (TopDestination) -> Unit = { destination ->
if (currentRoute != destination.route) {
navController.navigate(destination.route) {
popUpTo(HOME_ROUTE) { inclusive = destination.route == HOME_ROUTE }
popUpTo(HOME_ROUTE) {
inclusive = topLevelPopUpToHomeInclusive(destination.route)
}
launchSingleTop = true
}
}
@@ -347,11 +353,11 @@ fun PipelinesApp(
pane = MasterPane.Detail,
itemId = runId,
)
navController.navigate("runs") { launchSingleTop = true }
navController.navigate(HOME_ROUTE) { launchSingleTop = true }
},
)
}
composable("runs") {
composable(HOME_ROUTE) {
RunsDestination(
vm = vm,
wide = wide,
@@ -18,6 +18,14 @@ class PipelinesNavTest {
assertEquals("runs", HOME_ROUTE)
}
@Test
fun returningToHomeIsTheOnlyTopLevelNavigationThatClearsHome() {
assertTrue(topLevelPopUpToHomeInclusive(HOME_ROUTE))
assertFalse(topLevelPopUpToHomeInclusive("pipelines"))
assertFalse(topLevelPopUpToHomeInclusive("chat"))
assertFalse(topLevelPopUpToHomeInclusive("settings"))
}
@Test
fun thePillDoesNotHoldTemplates() {
// Templates is configuration and moved to the Settings page; the pill keeps