diff --git a/android/README.md b/android/README.md index 0119fda0..7935b161 100644 --- a/android/README.md +++ b/android/README.md @@ -3776,3 +3776,53 @@ verdict layout is exercised by the unit tests and the compile only. No server th actually sends `verdict` was available to the implementer, so the block's live rendering against real data is deferred to visual review. +## One search: the pipelines list drops its inline field (16 Oct 2026) + +The pipelines list carried its own "Search pipelines" text field while the app +also has the omni search (the destination pill's Search entry point), so the list +offered a second, narrower way to do the same job. The inline field is gone and +name narrowing moved into the list's filter control, keeping "filters narrow one +list" separate from "search finds things across the system". + +- **One field removed.** `PipelineListScreen` no longer owns a `query` state or + draws the `OutlinedTextField`; the list is now the first thing under the app + bar, so no spacer stands in for the field that used to sit there. +- **Name is a filter.** `PipelineFilters` gained a free-text `name` facet beside + `presence`/`lastRunStatuses`, applied by `filterPipelines` through the new + `pipelineMatchesName` (case-insensitive `contains`, blank means any). Unlike the + run facets it needs no run history, so it narrows as soon as the pipelines load + while the run facets still wait for `runsKnown`. +- **In the menu.** `PipelineFilterControl` opens with a `Name` section holding a + single-line `PipelineNameFilter` (label "Pipeline name contains") that keeps the + menu open while typing; the shared Clear filters resets it with the run facets + and the active-count badge counts it. +- **Persisted.** `SettingsRepository`/`AppViewModel` store the name under + `pipeline_filter_name` like the other facets, so a restart remembers it. +- **Runs list unchanged.** The runs list never had an inline search field, so + nothing was removed there. +- **Geometry.** No new `dp`/`sp` literal and no percentage: the field reuses + `SPACING_M`/`SPACING_S` and fills the filter menu's own width, and the reclaimed + vertical space comes from the removed field's layout, not a replacement + constant. + +Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 8.11.1 from the wrapper +cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--no-daemon --offline`): + +- `:app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the 35 result XMLs aggregate to + **312 tests, 0 failures, 0 errors, 0 skipped**. `ListFilterTest` now has 20 cases + (+4: name substring/blank, name before the run history, name AND the run facets, + active count/`hasRunFacets`; `pipelineFiltersFromStorageParsesAndFallsBack` now + covers the name). +- `:app:assembleDebug` → `app-debug.apk` **18,164,618 bytes**, sha256 + `375be755d03d17c7721fe5b4ea23f637c928fd48acc300b4aec9f3d3cf2d4e50`. +- **APK publish.** `app-debug.apk` copied to + `~/.local/share/pipelines/data/artifacts/171/1/pipelines-debug-wip-e7c4b8f.apk` + (`e7c4b8f` = short `HEAD`); `shasum -a 256` matched. The LAN URL + `http://10.0.0.249:8080/artifacts/171/1/pipelines-debug-wip-e7c4b8f.apk` returned + `HTTP 200`, `Content-Type: application/vnd.android.package-archive`, + `Content-Length: 18164618`. + +Not verified in this pass: device captures (the visual review owns the device, per +the brief's device policy), so the filter-menu name field's on-screen layout is +exercised by the compile and the pure filter tests only. + diff --git a/android/app/src/main/java/net/awan/pipelines/data/SettingsRepository.kt b/android/app/src/main/java/net/awan/pipelines/data/SettingsRepository.kt index 230761d9..8f4a8c7b 100644 --- a/android/app/src/main/java/net/awan/pipelines/data/SettingsRepository.kt +++ b/android/app/src/main/java/net/awan/pipelines/data/SettingsRepository.kt @@ -49,6 +49,9 @@ class SettingsRepository(context: Context) { MutableStateFlow(prefs.getString(KEY_PIPELINE_FILTER_RUN_STATUSES, "").orEmpty()) val pipelineFilterRunStatuses: StateFlow = _pipelineFilterRunStatuses.asStateFlow() + private val _pipelineFilterName = MutableStateFlow(prefs.getString(KEY_PIPELINE_FILTER_NAME, "").orEmpty()) + val pipelineFilterName: StateFlow = _pipelineFilterName.asStateFlow() + fun setServerUrl(value: String) { val trimmed = value.trim() _serverUrl.value = trimmed @@ -96,6 +99,11 @@ class SettingsRepository(context: Context) { prefs.edit().putString(KEY_PIPELINE_FILTER_RUN_STATUSES, value).apply() } + fun setPipelineFilterName(value: String) { + _pipelineFilterName.value = value + prefs.edit().putString(KEY_PIPELINE_FILTER_NAME, value).apply() + } + /** True only when the user has explicitly supplied both required values. */ fun isConfigured(): Boolean = _serverUrl.value.isNotBlank() && _workspace.value.isNotBlank() @@ -109,5 +117,6 @@ class SettingsRepository(context: Context) { const val KEY_RUN_FILTER_TIME_RANGE = "run_filter_time_range" const val KEY_PIPELINE_FILTER_PRESENCE = "pipeline_filter_presence" const val KEY_PIPELINE_FILTER_RUN_STATUSES = "pipeline_filter_run_statuses" + const val KEY_PIPELINE_FILTER_NAME = "pipeline_filter_name" } } diff --git a/android/app/src/main/java/net/awan/pipelines/ui/AppViewModel.kt b/android/app/src/main/java/net/awan/pipelines/ui/AppViewModel.kt index 0bd11535..f5079e44 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/AppViewModel.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/AppViewModel.kt @@ -62,6 +62,7 @@ class AppViewModel( val runFilterTimeRange: StateFlow = settings.runFilterTimeRange val pipelineFilterPresence: StateFlow = settings.pipelineFilterPresence val pipelineFilterRunStatuses: StateFlow = settings.pipelineFilterRunStatuses + val pipelineFilterName: StateFlow = settings.pipelineFilterName private val _serverUrlDraft = MutableStateFlow(settings.serverUrl.value) val serverUrlDraft: StateFlow = _serverUrlDraft.asStateFlow() @@ -192,6 +193,8 @@ class AppViewModel( fun setPipelineFilterRunStatuses(value: String) = settings.setPipelineFilterRunStatuses(value) + fun setPipelineFilterName(value: String) = settings.setPipelineFilterName(value) + private fun awaitConnected() { viewModelScope.launch { val connected = withTimeoutOrNull(CONNECT_TIMEOUT_MILLIS) { diff --git a/android/app/src/main/java/net/awan/pipelines/ui/screens/ListFilter.kt b/android/app/src/main/java/net/awan/pipelines/ui/screens/ListFilter.kt index 29924d7b..8b3d6ddc 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/screens/ListFilter.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/screens/ListFilter.kt @@ -108,27 +108,37 @@ data class RunFilters( } /** - * The pipelines-list run filters: whether a pipeline has any recorded run and - * the status of its most recent one. The name search stays a separate control - * (it narrows by text, not by run facts); these two are persisted per list. + * The pipelines-list filters: a case-insensitive name narrowing plus whether a + * pipeline has any recorded run and the status of its most recent one. Name is + * free text (any stored value is a legitimate filter), so it is the one facet not + * resolved against a closed vocabulary; like the run facets it is persisted per + * list. Unlike them, the name narrowing needs no run history, so it applies as + * soon as the pipelines load (see [filterPipelines]). */ data class PipelineFilters( val presence: RunPresence = RunPresence.Default, val lastRunStatuses: Set = emptySet(), + val name: String = "", ) { val activeCount: Int get() = (if (presence != RunPresence.Default) 1 else 0) + - (if (lastRunStatuses.isNotEmpty()) 1 else 0) + (if (lastRunStatuses.isNotEmpty()) 1 else 0) + + (if (name.isNotBlank()) 1 else 0) val isActive: Boolean get() = activeCount > 0 + /** Whether a run-history facet is set; only those depend on the run history. */ + val hasRunFacets: Boolean + get() = presence != RunPresence.Default || lastRunStatuses.isNotEmpty() + companion object { val Default = PipelineFilters() - fun fromStorage(presence: String?, lastRunStatuses: String?): PipelineFilters = + fun fromStorage(presence: String?, lastRunStatuses: String?, name: String?): PipelineFilters = PipelineFilters( presence = RunPresence.fromStorage(presence), lastRunStatuses = decodeRunStates(lastRunStatuses), + name = name.orEmpty(), ) } } @@ -208,10 +218,16 @@ internal fun pipelineMatchesFilters(filters: PipelineFilters, latestRun: RunSumm pipelineMatchesPresence(filters.presence, latestRun != null) && pipelineMatchesLastRunStatus(latestRun, filters.lastRunStatuses) +/** True when [name] is blank, or when [pipelineName] contains it, ignoring case. */ +internal fun pipelineMatchesName(name: String, pipelineName: String): Boolean = + name.isBlank() || pipelineName.contains(name, ignoreCase = true) + /** - * Narrows [pipelines] by [filters]. Both facets depend on the run history, so - * while that history is still unknown (`runsKnown == false`) the list is left - * unfiltered rather than briefly hiding every pipeline. + * Narrows [pipelines] by [filters]: the name narrowing and both run facets combined + * with AND. The name facet never depends on the run history, so it applies + * immediately; the run facets do, so while that history is still unknown + * (`runsKnown == false`) they are skipped rather than briefly hiding every + * pipeline. */ internal fun filterPipelines( pipelines: List, @@ -219,8 +235,11 @@ internal fun filterPipelines( latestRuns: Map, runsKnown: Boolean = true, ): List { - if (!filters.isActive || !runsKnown) return pipelines - return pipelines.filter { pipelineMatchesFilters(filters, latestRuns[it.id]) } + if (!filters.isActive) return pipelines + return pipelines.filter { pipeline -> + pipelineMatchesName(filters.name, pipeline.name) && + (!filters.hasRunFacets || !runsKnown || pipelineMatchesFilters(filters, latestRuns[pipeline.id])) + } } /** One selectable pipeline in the run filter, named from its runs. */ 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 287204aa..5fa107c6 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 @@ -14,7 +14,6 @@ import androidx.compose.foundation.lazy.items import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AccountTree import androidx.compose.material.icons.filled.Refresh -import androidx.compose.material.icons.filled.Search import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon @@ -27,9 +26,7 @@ import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextOverflow @@ -54,6 +51,7 @@ import net.awan.pipelines.ui.components.animateListItem import net.awan.pipelines.ui.components.listLoadPhase import net.awan.pipelines.ui.components.paneSafeArea 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.pipelinesText @@ -72,8 +70,8 @@ fun PipelineListScreen( val sort = PipelineSort.fromStorage(sortKey) val presenceKey by vm.pipelineFilterPresence.collectAsStateWithLifecycle() val runStatusKey by vm.pipelineFilterRunStatuses.collectAsStateWithLifecycle() - val filters = PipelineFilters.fromStorage(presenceKey, runStatusKey) - var query by remember { mutableStateOf("") } + val nameKey by vm.pipelineFilterName.collectAsStateWithLifecycle() + val filters = PipelineFilters.fromStorage(presenceKey, runStatusKey, nameKey) // The last-run line joins list_runs onto the pipelines client-side; runs are // fetched here too so a pipeline list opened first still shows its history. @@ -99,11 +97,11 @@ fun PipelineListScreen( val onClearFilters: () -> Unit = { vm.setPipelineFilterPresence("") vm.setPipelineFilterRunStatuses("") - query = "" + vm.setPipelineFilterName("") } - // A covered pane shows its compact identity only; the search field and list - // must never be drawn squeezed into the peek strip. + // A covered pane shows its compact identity only; the list must never be + // drawn squeezed into the peek strip. if (covered) { val count = state.data?.size ?: 0 PaneIdentity( @@ -124,6 +122,7 @@ fun PipelineListScreen( actions = { PipelineFilterControl( filters = filters, + onName = { vm.setPipelineFilterName(it) }, onPresence = { vm.setPipelineFilterPresence(it.storageKey) }, onRunStatuses = { vm.setPipelineFilterRunStatuses(encodeRunStates(it)) }, onClear = onClearFilters, @@ -149,25 +148,10 @@ fun PipelineListScreen( }, ) { padding -> Column(Modifier.fillMaxSize().padding(padding)) { - OutlinedTextField( - value = query, - onValueChange = { query = it }, - label = { Text("Search pipelines") }, - leadingIcon = { Icon(Icons.Default.Search, contentDescription = null) }, - singleLine = true, - modifier = Modifier.fillMaxWidth().padding(horizontal = SPACING_L, vertical = SPACING_S), - ) val all = state.data ?: emptyList() - val items = remember(all, query, sort, latestRuns, filters, runsKnown) { - filterPipelines( - sortPipelines(all, sort, latestRuns), - filters, - latestRuns, - runsKnown, - ).filter { it.name.contains(query, ignoreCase = true) } + val items = remember(all, sort, latestRuns, filters, runsKnown) { + filterPipelines(sortPipelines(all, sort, latestRuns), filters, latestRuns, runsKnown) } - val queryActive = query.isNotBlank() - val filtersActive = filters.isActive && runsKnown StateCrossfade( phase = listLoadPhase( loading = state.loading, @@ -175,13 +159,11 @@ fun PipelineListScreen( hasData = state.data != null, emptyMessage = if (items.isEmpty()) { if (all.isEmpty()) { - // Nothing exists: neither the search nor the filters can - // reveal a pipeline, so there is no clear action. + // Nothing exists: no filter can reveal a pipeline, so + // there is no clear action. "No pipelines are defined on this server." - } else if (queryActive && filtersActive) { - "No pipelines match the current search and filters." - } else if (queryActive) { - "No pipelines match \"$query\"." + } else if (filters.name.isNotBlank() && !filters.hasRunFacets) { + "No pipelines match \"${filters.name}\"." } else { "No pipelines match the current filters." } @@ -228,13 +210,16 @@ fun PipelineListScreen( } /** - * The pipelines-list run filter control: presence (has/no runs) and the - * most-recent run's status (multi-select), with the shared active-count badge - * and one Clear filters action. The name search stays a separate field. + * The pipelines-list filter control: a case-insensitive name narrowing plus the + * run facets (has/no runs) and the most-recent run's status (multi-select), with + * the shared active-count badge and one Clear filters action. The name is a + * filter, not a search: it narrows only this list, while the omni search is the + * one affordance that finds pipelines, runs and artifacts across the system. */ @Composable private fun PipelineFilterControl( filters: PipelineFilters, + onName: (String) -> Unit, onPresence: (RunPresence) -> Unit, onRunStatuses: (Set) -> Unit, onClear: () -> Unit, @@ -245,6 +230,9 @@ private fun PipelineFilterControl( resetLabel = "Clear filters", onReset = onClear, ) { dismiss -> + FilterSectionHeader("Name") + PipelineNameFilter(filters.name, onName) + HorizontalDivider() FilterSectionHeader("Runs") RunPresence.entries.forEach { presence -> FilterCheckItem(presence.label, filters.presence == presence) { @@ -262,6 +250,24 @@ private fun PipelineFilterControl( } } +/** + * The name narrowing inside the pipelines filter menu: free text that keeps the + * menu open while typing so the list can be watched narrowing behind it. It fills + * the menu's own width, so it needs no width of its own. + */ +@Composable +private fun PipelineNameFilter(name: String, onName: (String) -> Unit) { + OutlinedTextField( + value = name, + onValueChange = onName, + label = { Text("Pipeline name contains") }, + singleLine = true, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = SPACING_M, vertical = SPACING_S), + ) +} + /** * One pipeline as a row of the shared real list: a leading workflow glyph, the * name as the title, the id/version/stage-count as the secondary line and the diff --git a/android/app/src/test/java/net/awan/pipelines/ui/screens/ListFilterTest.kt b/android/app/src/test/java/net/awan/pipelines/ui/screens/ListFilterTest.kt index d07e6d80..559fd685 100644 --- a/android/app/src/test/java/net/awan/pipelines/ui/screens/ListFilterTest.kt +++ b/android/app/src/test/java/net/awan/pipelines/ui/screens/ListFilterTest.kt @@ -56,11 +56,18 @@ class ListFilterTest { @Test fun pipelineFiltersFromStorageParsesAndFallsBack() { assertEquals( - PipelineFilters(RunPresence.NoRuns, setOf(RunState.Failed)), - PipelineFilters.fromStorage("no_runs", "failed"), + PipelineFilters(RunPresence.NoRuns, setOf(RunState.Failed), "deploy"), + PipelineFilters.fromStorage("no_runs", "failed", "deploy"), + ) + // A blank or absent name is no narrowing. + assertEquals(PipelineFilters.Default, PipelineFilters.fromStorage(null, null, null)) + assertEquals(PipelineFilters.Default, PipelineFilters.fromStorage("", "", "")) + // The name is free text, so any stored value is a legitimate filter and is + // kept as-is; only the closed-vocabulary run facets fall back to a default. + assertEquals( + PipelineFilters(name = "garbage"), + PipelineFilters.fromStorage("garbage", "garbage", "garbage"), ) - assertEquals(PipelineFilters.Default, PipelineFilters.fromStorage(null, null)) - assertEquals(PipelineFilters.Default, PipelineFilters.fromStorage("garbage", "garbage")) } @Test @@ -203,6 +210,69 @@ class ListFilterTest { assertEquals(listOf(2L), filterPipelines(pipelines, filters, latest).map { it.id }) } + @Test + fun nameNarrowsByCaseInsensitiveSubstringAndBlankNarrowsNothing() { + val pipelines = listOf( + pipeline(1, "Deploy API"), + pipeline(2, "redeploy web"), + pipeline(3, "release"), + ) + assertEquals( + listOf(1L, 2L), + filterPipelines(pipelines, PipelineFilters(name = "deploy"), emptyMap()).map { it.id }, + ) + assertEquals( + listOf(1L), + filterPipelines(pipelines, PipelineFilters(name = "Deploy API"), emptyMap()).map { it.id }, + ) + // A blank name is no narrowing. + assertEquals(pipelines, filterPipelines(pipelines, PipelineFilters(name = " "), emptyMap())) + } + + @Test + fun nameAppliesBeforeTheRunHistoryIsKnownWhileRunFacetsStillWait() { + val pipelines = listOf(pipeline(1, "alpha"), pipeline(2, "beta")) + // The name facet needs no run history, so it narrows at once. + assertEquals( + listOf(2L), + filterPipelines(pipelines, PipelineFilters(name = "bet"), emptyMap(), runsKnown = false).map { it.id }, + ) + // A run facet still waits for the history, combined with the name. + assertEquals( + listOf(1L), + filterPipelines( + pipelines, + PipelineFilters(presence = RunPresence.NoRuns, name = "al"), + emptyMap(), + runsKnown = false, + ).map { it.id }, + ) + } + + @Test + fun nameAndRunFacetsCombineWithAnd() { + val filters = PipelineFilters(RunPresence.HasRuns, setOf(RunState.Failed), "web") + val latest = mapOf( + 1L to run(1, pipelineId = 1, status = "failed"), + 2L to run(2, pipelineId = 2, status = "failed"), + 3L to run(3, pipelineId = 3, status = "succeeded"), + ) + val pipelines = listOf(pipeline(1, "web"), pipeline(2, "api"), pipeline(3, "web")) + // 2 fails the name; 3 fails the last-run status. + assertEquals(listOf(1L), filterPipelines(pipelines, filters, latest).map { it.id }) + } + + @Test + fun activeCountCountsTheNameAndRunFacetsButNotABlankName() { + assertEquals(0, PipelineFilters().activeCount) + assertEquals(1, PipelineFilters(name = "x").activeCount) + assertEquals(2, PipelineFilters(RunPresence.NoRuns, name = "x").activeCount) + assertEquals(0, PipelineFilters(name = " ").activeCount) + // Only the run-history facets need the history loaded. + assertFalse(PipelineFilters(name = "x").hasRunFacets) + assertTrue(PipelineFilters(RunPresence.NoRuns).hasRunFacets) + } + @Test fun pipelineFiltersLeaveTheListUnfilteredUntilRunsAreKnown() { val filters = PipelineFilters(presence = RunPresence.NoRuns)