Merge branch 'main' into background-tasks-viewer

This commit is contained in:
2026-10-18 23:45:42 +01:00
20 changed files with 616 additions and 70 deletions
@@ -179,6 +179,12 @@ internal fun attentionHeadline(entries: List<AttentionEntry>): String = when {
else -> "${entries.size} runs need you"
}
/**
* Captures the entries shown when the attention sheet opens. Bulk dismissal uses
* this snapshot so entries that arrive while the sheet is open are not removed.
*/
internal fun attentionDismissalSnapshot(entries: List<AttentionEntry>): List<AttentionEntry> = entries.toList()
/**
* Parses the run id from a `pipelines://run/<id>` deep link, or null for
* anything else. Pure and total, so a malformed link simply opens nothing rather
@@ -17,8 +17,10 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -27,6 +29,7 @@ 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.attentionDismissalSnapshot
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
@@ -105,6 +108,7 @@ fun AttentionSheet(
onDismiss: () -> Unit,
) {
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
val dismissalSnapshot = remember { attentionDismissalSnapshot(entries) }
ModalBottomSheet(onDismissRequest = onDismiss, sheetState = sheetState) {
Column(
modifier = Modifier.fillMaxWidth().padding(bottom = SPACING_L),
@@ -124,6 +128,13 @@ fun AttentionSheet(
)
return@Column
}
TextButton(
onClick = { dismissalSnapshot.forEach(onDismissEntry) },
enabled = dismissalSnapshot.isNotEmpty(),
modifier = Modifier.padding(horizontal = SPACING_L),
) {
Text("Clear all")
}
entries.forEach { entry ->
AttentionRow(
entry = entry,
@@ -194,6 +194,16 @@ class AttentionTest {
assertEquals("A run failed", attentionHeadline(singleFailed))
}
@Test
fun dismissalSnapshotDoesNotIncludeEntriesThatArriveLater() {
val original = attentionEntries(listOf(run(1, "waiting")), AttentionState())
val snapshot = attentionDismissalSnapshot(original)
val current = original + attentionEntries(listOf(run(2, "failed")), AttentionState())
assertEquals(listOf(1L), snapshot.map { it.runId })
assertEquals(listOf(1L, 2L), current.map { it.runId })
}
// --- persistence -----------------------------------------------------------
@Test