From a567257b924e8d0bea2faa4bf01b293d85864e2b Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sun, 18 Oct 2026 22:06:45 +0100 Subject: [PATCH] feat: move attention access to action bars --- .../awan/pipelines/ui/PipelineDestination.kt | 6 +++ .../net/awan/pipelines/ui/PipelinesApp.kt | 30 +++++-------- .../net/awan/pipelines/ui/RunsDestination.kt | 6 +++ .../ui/components/AttentionSurface.kt | 42 +++++-------------- .../ui/screens/PipelineDetailScreen.kt | 5 +++ .../ui/screens/PipelineListScreen.kt | 5 +++ .../pipelines/ui/screens/RunDetailScreen.kt | 5 +++ .../pipelines/ui/screens/RunHistoryScreen.kt | 5 +++ .../net/awan/pipelines/ui/theme/Dimens.kt | 10 ----- .../net/awan/pipelines/ui/PipelinesNavTest.kt | 9 ++-- docs/notes/actionbar-notification-access.md | 10 +++++ 11 files changed, 66 insertions(+), 67 deletions(-) create mode 100644 docs/notes/actionbar-notification-access.md diff --git a/android/app/src/main/java/net/awan/pipelines/ui/PipelineDestination.kt b/android/app/src/main/java/net/awan/pipelines/ui/PipelineDestination.kt index b31cc281..28305925 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/PipelineDestination.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/PipelineDestination.kt @@ -31,6 +31,8 @@ internal fun PipelineDestination( onSelectionChange: (PaneSelection) -> Unit, listState: LazyListState, onOpenRun: (Long) -> Unit, + attention: List, + onOpenAttention: () -> Unit, ) { val depth = selection.depth val onBack: () -> Unit = { onSelectionChange(backFrom(selection)) } @@ -70,6 +72,8 @@ internal fun PipelineDestination( covered = covered, wide = wide, listState = listState, + attention = attention, + onOpenAttention = onOpenAttention, ) 1 -> rememberPaneContent( selection.itemId.takeIf { it != 0L }?.let { @@ -92,6 +96,8 @@ internal fun PipelineDestination( ) }, covered = covered, + attention = attention, + onOpenAttention = onOpenAttention, ) } 2 -> rememberPaneContent( 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 d80f2ab1..83410154 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 @@ -58,7 +58,6 @@ import net.awan.pipelines.data.transport.ConnectionState import net.awan.pipelines.notify.NOTIFICATION_RATIONALE import net.awan.pipelines.notify.alertPermissionPrompt import net.awan.pipelines.ui.chat.ChatScreen -import net.awan.pipelines.ui.components.AttentionIndicator import net.awan.pipelines.ui.components.AttentionSheet import net.awan.pipelines.ui.components.BottomStripInset import net.awan.pipelines.ui.components.ConnectionBanner @@ -67,10 +66,8 @@ import net.awan.pipelines.ui.components.LocalPillBottomInset import net.awan.pipelines.ui.components.MotionStandard import net.awan.pipelines.ui.components.paneSafeArea import net.awan.pipelines.ui.components.spec -import net.awan.pipelines.ui.theme.ATTENTION_CHIP_RESERVE import net.awan.pipelines.ui.theme.DESTINATION_PILL_RESERVE import net.awan.pipelines.ui.theme.SPACING_L -import net.awan.pipelines.ui.theme.SPACING_S /** One destination the floating pill holds: its nav [route], the accessible [label] and its glyph. */ internal data class TopDestination(val route: String, val label: String, val icon: ImageVector) @@ -339,6 +336,8 @@ fun PipelinesApp( selection = pipelineSelection, onSelectionChange = { pipelineSelection = it }, listState = pipelineListState, + attention = attention, + onOpenAttention = { attentionOpen = true }, onOpenRun = { runId -> runSelection = PaneSelection( pane = MasterPane.Detail, @@ -359,6 +358,8 @@ fun PipelinesApp( listState = runListState, decisionRequest = decisionRequest, onDecisionRequestHandled = { decisionRequest = null }, + attention = attention, + onOpenAttention = { attentionOpen = true }, ) } composable("chat") { @@ -389,7 +390,7 @@ fun PipelinesApp( // Composed after the NavHost, so while the field is open Back (button // or gesture) dismisses the morph before any pane's own Back handler. BackHandler(enabled = searchState.open) { dismissSearch() } - // The results panel, the attention chip and the destination bar share + // The results panel and destination bar share // one bottom-anchored, inset-clearing column — the overlay layer, drawn // above the content and never part of its layout. `paneSafeArea` // (WindowInsets.safeDrawing) is applied once here, so the pill clears the @@ -403,8 +404,7 @@ fun PipelinesApp( // The overlay's resting place is the window width's in [destinationPillAlignment]: // horizontally centred on a narrow window, anchored to the bottom-right // corner on a wide one. Its margin comes from the named [SPACING_L], so the - // corner placement adds no new number. That rule positions the pill; the - // attention chip above it keeps its own bottom-right place at every width. + // corner placement adds no new number. // While a bottom selector strip is up, the whole overlay is lifted by that // strip's measured height ([pillBottomOffset]), so the pill never overlaps it. Column( @@ -432,15 +432,6 @@ fun PipelinesApp( .padding(bottom = SPACING_L), ) } - // The attention chip is not part of the pill's placement rule: it - // keeps its own bottom-right resting place at every width (as it - // had before the pill became width-dependent), so only the pill - // follows [destinationPillAlignment]. - AttentionIndicator( - entries = attention, - onClick = { attentionOpen = true }, - modifier = Modifier.align(Alignment.End).padding(bottom = SPACING_S), - ) // 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. @@ -528,8 +519,8 @@ internal fun destinationPillVisible( ): Boolean = !(currentRoute == CHAT_ROUTE && conversationOpen) && !runDetailOpen /** - * Where the bottom overlay — the destination pill and the attention chip above it - * — rests in the window: horizontally centred on a **narrow** window and anchored + * Where the bottom destination pill rests in the window: horizontally centred on a + * **narrow** window and anchored * to the bottom-right **corner** on a **wide** one. The overlay is drawn above the * content and never takes layout space either way, so this is purely where it * sits. A pure function of the window width, so the one arrangement rule is @@ -552,8 +543,7 @@ 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] + * of the floating destination pill, built from the named [DESTINATION_PILL_RESERVE] * while the pill is drawn, and none while it is hidden (an open conversation or a * run detail, see [destinationPillVisible]) so a hidden pill * leaves no empty band at the end of a list. Published to the content through @@ -565,7 +555,7 @@ internal fun contentPillPadding(pillVisible: Boolean): Dp = 0.dp * the pill appears and disappears. */ internal fun pillScrollInset(pillVisible: Boolean): Dp = - if (pillVisible) DESTINATION_PILL_RESERVE + ATTENTION_CHIP_RESERVE else 0.dp + if (pillVisible) DESTINATION_PILL_RESERVE else 0.dp /** * How far above the window's bottom the floating pill rests: its own [SPACING_L] diff --git a/android/app/src/main/java/net/awan/pipelines/ui/RunsDestination.kt b/android/app/src/main/java/net/awan/pipelines/ui/RunsDestination.kt index 0fa97a1b..b4be8365 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/RunsDestination.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/RunsDestination.kt @@ -34,6 +34,8 @@ internal fun RunsDestination( listState: LazyListState, decisionRequest: Long? = null, onDecisionRequestHandled: () -> Unit = {}, + attention: List, + onOpenAttention: () -> Unit, ) { val depth = selection.depth val onBack: () -> Unit = { onSelectionChange(backFrom(selection)) } @@ -83,6 +85,8 @@ internal fun RunsDestination( covered = covered, wide = wide, listState = listState, + attention = attention, + onOpenAttention = onOpenAttention, ) 1 -> rememberPaneContent( selection.itemId.takeIf { it != 0L }?.let { it to selection.sectionIndex }, @@ -103,6 +107,8 @@ internal fun RunsDestination( covered = covered, requestDecision = decisionRequest == itemId, onDecisionRequestHandled = onDecisionRequestHandled, + attention = attention, + onOpenAttention = onOpenAttention, ) } 2 -> rememberPaneContent( diff --git a/android/app/src/main/java/net/awan/pipelines/ui/components/AttentionSurface.kt b/android/app/src/main/java/net/awan/pipelines/ui/components/AttentionSurface.kt index 8ca63a3e..c686092f 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/components/AttentionSurface.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/components/AttentionSurface.kt @@ -6,10 +6,11 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.NotificationsActive +import androidx.compose.material3.Badge +import androidx.compose.material3.BadgedBox import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -23,10 +24,8 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.dp import net.awan.pipelines.ui.AttentionEntry import net.awan.pipelines.ui.AttentionKind -import net.awan.pipelines.ui.attentionHeadline import net.awan.pipelines.ui.theme.ICON_INLINE_DP import net.awan.pipelines.ui.theme.SPACING_L import net.awan.pipelines.ui.theme.SPACING_M @@ -49,43 +48,22 @@ internal fun attentionRunState(kind: AttentionKind): RunState = when (kind) { AttentionKind.Failed -> RunState.Failed } -/** - * The floating indicator: the count and the most important item, tappable to open - * the list. Hidden (draws nothing) when [entries] is empty, so it never becomes a - * permanent chrome element. - */ +/** The notifications action shared by the main and detail app bars. */ @Composable -fun AttentionIndicator( +fun AttentionAction( entries: List, onClick: () -> Unit, - modifier: Modifier = Modifier, ) { - if (entries.isEmpty()) return - val scheme = MaterialTheme.colorScheme - Surface( - onClick = onClick, - modifier = modifier, - shape = RoundedCornerShape(50), - color = scheme.errorContainer, - contentColor = scheme.onErrorContainer, - shadowElevation = 6.dp, - ) { - Row( - modifier = Modifier.padding(horizontal = SPACING_M, vertical = SPACING_S), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(SPACING_S), - ) { + IconButton(onClick = onClick) { + BadgedBox(badge = { + if (entries.isNotEmpty()) Badge { Text(entries.size.toString()) } + }) { Icon( imageVector = Icons.Default.NotificationsActive, - contentDescription = null, + contentDescription = if (entries.isEmpty()) "Notifications" else + "Notifications, ${entries.size} needing attention", modifier = Modifier.size(ICON_INLINE_DP), ) - Text( - text = attentionHeadline(entries), - style = MaterialTheme.typography.labelLarge, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) } } } diff --git a/android/app/src/main/java/net/awan/pipelines/ui/screens/PipelineDetailScreen.kt b/android/app/src/main/java/net/awan/pipelines/ui/screens/PipelineDetailScreen.kt index f90dab63..95478e15 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/screens/PipelineDetailScreen.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/screens/PipelineDetailScreen.kt @@ -63,6 +63,8 @@ import net.awan.pipelines.ui.theme.SPACING_L import net.awan.pipelines.ui.theme.SPACING_M import net.awan.pipelines.ui.theme.SPACING_S import net.awan.pipelines.ui.theme.SPACING_XS +import net.awan.pipelines.ui.AttentionEntry +import net.awan.pipelines.ui.components.AttentionAction import net.awan.pipelines.ui.theme.pipelinesText @OptIn(ExperimentalMaterial3Api::class) @@ -79,6 +81,8 @@ fun PipelineDetailScreen( modifier: Modifier = Modifier, wide: Boolean = false, covered: Boolean = false, + attention: List = emptyList(), + onOpenAttention: () -> Unit = {}, ) { val state by vm.pipelineDetail.collectAsStateWithLifecycle() val runsState by vm.runs.collectAsStateWithLifecycle() @@ -124,6 +128,7 @@ fun PipelineDetailScreen( }, windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal), actions = { + AttentionAction(attention, onOpenAttention) IconButton(onClick = { vm.loadPipeline(pipelineId, version) }) { Icon(Icons.Default.Refresh, contentDescription = "Refresh pipeline") } diff --git a/android/app/src/main/java/net/awan/pipelines/ui/screens/PipelineListScreen.kt b/android/app/src/main/java/net/awan/pipelines/ui/screens/PipelineListScreen.kt index eb25df10..ca7192d2 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/screens/PipelineListScreen.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/screens/PipelineListScreen.kt @@ -37,6 +37,8 @@ import java.time.OffsetDateTime import java.time.ZoneId import net.awan.pipelines.data.protocol.PipelineSummary import net.awan.pipelines.ui.AppViewModel +import net.awan.pipelines.ui.AttentionEntry +import net.awan.pipelines.ui.components.AttentionAction import net.awan.pipelines.ui.components.DetailTabBody import net.awan.pipelines.ui.components.EmptyState import net.awan.pipelines.ui.components.ErrorState @@ -74,6 +76,8 @@ fun PipelineListScreen( covered: Boolean = false, wide: Boolean = false, listState: LazyListState, + attention: List = emptyList(), + onOpenAttention: () -> Unit = {}, ) { val state by vm.pipelines.collectAsStateWithLifecycle() val runsState by vm.runs.collectAsStateWithLifecycle() @@ -151,6 +155,7 @@ fun PipelineListScreen( title = { Text("Pipelines") }, windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal), actions = { + AttentionAction(attention, onOpenAttention) PipelineFilterControl( filters = filters, onName = { vm.setPipelineFilterName(it) }, diff --git a/android/app/src/main/java/net/awan/pipelines/ui/screens/RunDetailScreen.kt b/android/app/src/main/java/net/awan/pipelines/ui/screens/RunDetailScreen.kt index d817c800..bf1574c4 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/screens/RunDetailScreen.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/screens/RunDetailScreen.kt @@ -53,6 +53,8 @@ import net.awan.pipelines.ui.runIdentity import net.awan.pipelines.ui.runLabel import net.awan.pipelines.ui.theme.SPACING_L import net.awan.pipelines.ui.theme.SPACING_S +import net.awan.pipelines.ui.AttentionEntry +import net.awan.pipelines.ui.components.AttentionAction import net.awan.pipelines.ui.theme.pipelinesText @OptIn(ExperimentalMaterial3Api::class) @@ -69,6 +71,8 @@ fun RunDetailScreen( covered: Boolean = false, requestDecision: Boolean = false, onDecisionRequestHandled: () -> Unit = {}, + attention: List = emptyList(), + onOpenAttention: () -> Unit = {}, ) { val state by vm.runDetail.collectAsStateWithLifecycle() val runsState by vm.runs.collectAsStateWithLifecycle() @@ -183,6 +187,7 @@ fun RunDetailScreen( }, windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal), actions = { + AttentionAction(attention, onOpenAttention) LiveBadge(runStream, Modifier.padding(end = SPACING_S)) IconButton(onClick = { vm.loadRun(runId) }) { Icon(Icons.Default.Refresh, contentDescription = "Refresh run") diff --git a/android/app/src/main/java/net/awan/pipelines/ui/screens/RunHistoryScreen.kt b/android/app/src/main/java/net/awan/pipelines/ui/screens/RunHistoryScreen.kt index eacf2ace..79f21ee1 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/screens/RunHistoryScreen.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/screens/RunHistoryScreen.kt @@ -48,6 +48,8 @@ import java.time.format.DateTimeFormatter import net.awan.pipelines.data.protocol.RunSummary import net.awan.pipelines.data.protocol.UsageStats import net.awan.pipelines.ui.AppViewModel +import net.awan.pipelines.ui.AttentionEntry +import net.awan.pipelines.ui.components.AttentionAction import net.awan.pipelines.ui.components.DetailTabBody import net.awan.pipelines.ui.components.EmptyState import net.awan.pipelines.ui.components.ErrorState @@ -98,6 +100,8 @@ fun RunHistoryScreen( covered: Boolean = false, wide: Boolean = false, listState: LazyListState, + attention: List = emptyList(), + onOpenAttention: () -> Unit = {}, ) { val state by vm.runs.collectAsStateWithLifecycle() val runStream by vm.runStream.collectAsStateWithLifecycle() @@ -153,6 +157,7 @@ fun RunHistoryScreen( title = { Text(if (filterPipelineId == null) "Runs" else "Runs for this pipeline") }, windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal), actions = { + AttentionAction(attention, onOpenAttention) RunFilterControl( filters = filters, pipelines = pipelineOptions, diff --git a/android/app/src/main/java/net/awan/pipelines/ui/theme/Dimens.kt b/android/app/src/main/java/net/awan/pipelines/ui/theme/Dimens.kt index b5798a36..92472bd0 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/theme/Dimens.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/theme/Dimens.kt @@ -84,16 +84,6 @@ internal val MIN_COVERED_PANE_WIDTH_DP = 112.dp */ internal val DESTINATION_PILL_RESERVE = 88.dp -/** - * Bottom space the floating attention chip occupies above the destination pill: - * the chip's own height (its single label line plus its vertical padding) plus the - * gap below it. Added to a scrollable's trailing space alongside - * [DESTINATION_PILL_RESERVE] while the pill is drawn, so the chip can never be laid - * out over a row, a field or a button and the content does not jump as it appears - * and clears. - */ -internal val ATTENTION_CHIP_RESERVE = SPACING_XXL + SPACING_M - // ---- Detail rail and max content width (ui/components/DetailTabs.kt) ------- /** The always-visible wide section rail's width (icons with labels). */ 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 1347a1c5..6c0800a7 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 @@ -3,7 +3,6 @@ package net.awan.pipelines.ui import androidx.compose.ui.Alignment import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import net.awan.pipelines.ui.theme.ATTENTION_CHIP_RESERVE import net.awan.pipelines.ui.theme.DESTINATION_PILL_RESERVE import net.awan.pipelines.ui.theme.SPACING_L import org.junit.Assert.assertEquals @@ -133,11 +132,11 @@ class PipelinesNavTest { @Test fun theScrollInsetTracksTheDrawnPillSoAListNeitherJumpsNorHidesItsLastRow() { - // Drawn: a scrollable keeps the named pill + attention-chip space at the - // end of its own scroll content and its last row scrolls clear of the whole - // floating bottom stack. Hidden: no clearance, so there is no empty band + // Drawn: a scrollable keeps the named pill space at the end of its own + // scroll content and its last row scrolls clear of the floating pill. Hidden: no clearance, + // so there is no empty band // where the pill used to be. - val drawnInset = DESTINATION_PILL_RESERVE + ATTENTION_CHIP_RESERVE + val drawnInset = DESTINATION_PILL_RESERVE assertDp(drawnInset.value, pillScrollInset(pillVisible = true)) assertDp(0f, pillScrollInset(pillVisible = false)) // One predicate drives both the drawing and the clearance, so the space can diff --git a/docs/notes/actionbar-notification-access.md b/docs/notes/actionbar-notification-access.md new file mode 100644 index 00000000..3a84d7dc --- /dev/null +++ b/docs/notes/actionbar-notification-access.md @@ -0,0 +1,10 @@ +# Action-bar notification access + +The in-app attention entry point moved from the floating bottom indicator into the +existing main/detail app bars. The action remains present when the destination pill +is hidden, and its badge uses the existing attention list count; the attention sheet +and permission behavior are unchanged. + +The packaged OpenCode skill references that describe the old floating attention +indicator may be stale. The manual `docs-fold` pipeline should fold this note into +the shared documentation and references; this item does not edit those shared files.