Modern Apps git

← Modern-Apps.git

ui+news: scaffold-owned search; news categories replace sources row

Commit
dd901b65c0df97c9aac615fedc6784a2e432525d
Author
Vayun Mathur <[email protected]>
When
2026-11-23 18:43 UTC (12 days ago)
Parents
5d117bd
AppScaffold gains a search parameter rendering the
search bar in the top bar's title slot (title replaced),
forwarded to Detail/LazyList scaffolds; a fatal
ScaffoldSearch lint flags standalone search bars in app
UI (SCAFFOLD SEARCH EXCEPTION marker for overlays and
dialogs). Screen-level searches migrated repo-wide
(news, appstore, shop, contacts, notes, email, health,
translate, vpn, globalesim, games hub, flashcards,
todo, calendar).

News: the feed's source chip row is replaced by a
category row - World (42), Local (36), Technology (7),
Science, US - tags as catalog data, applied client-side
to server and fallback articles alike; search composes
within the selected category.

Verified: library:ui + lint-rules tests, todo suite,
news 35 tests, compile + lintVitalRelease across
migrated modules.

Diff

AGENTS.md
diff --git a/AGENTS.md b/AGENTS.mdindex 132b28fd70..6707fe8b8e 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -65,6 +65,7 @@ The backend (relay server for findfamily/everysync/office/voxels) lives outside - `Toast` banned (fatal lint). Use `rememberMessenger().show()` in composable, `AppMessages.show()` elsewhere. - Never `Icon()`/`painterResource()`/`androidx.compose.material.icons.*` in app. Add `IconXxx()` to `library/ui/.../Icons.kt`. - Never raw `Scaffold`. Use `AppScaffold` family. Refresh/loading indication goes through the scaffold's pull-to-refresh box (`isRefreshing`/`onRefresh`/`refreshEnabled` on `AppScaffold` family; TV: `TvAppFrame.isRefreshing`/`TvLoading` top indicator), never a standalone `LoadingState`/`LoadingIndicator`/`CircularProgressIndicator`/`ContainedLoadingIndicator` or hand-rolled pull-to-refresh in app UI (fatal `ScaffoldLoading` lint). Truly local progress is a non-icon affordance (disabled state, progress text); real determinate progress is a `LinearProgressIndicator(progress=...)` bar. Exception marker only for library-internal helpers and genuinely non-screen contexts. Never raw `androidx.compose.animation` at call site — use `library.ui` helpers. Never `imePadding()/navigationBarsPadding()/systemBarsPadding()` in `library.ui`.+- Screen-level search goes through the scaffold's `search` parameter (`search = ScaffoldSearch(query, onQueryChange, placeholder)` on `AppScaffold`/`DetailScaffold`/`DetailLazyColumn`/`LazyListScaffold`; the field renders AS the top app bar in its title slot, title replaced, above the refresh box), never a standalone `CommonSearchBar`/`SearchBar`/`SearchBarInputField` or search-identified `TextField`/`OutlinedTextField` in app UI (fatal `ScaffoldSearch` lint). The `AppScaffold(topBar=...)` overload, `SetupScaffold`, and `TabbedPagerScaffold` (pages own their scaffolds) have no search slot by design; TV uses its own text field. Dialog/sheet/drawer-local filters and expandable overlay search with no scaffold host use the exception marker only. - Room 3 only. Literal `androidx.room.` flagged even in comments. Never `buildDatabase()` at call site — subclass `library.room.RoomRepository`. - Network only via `library.network.NetworkClient` + `TrustBundle` narrowest (`FIRST_PARTY/STANDARD/EXTENDED/SYSTEM/ESIM`). - Package roots closed set: `ui data domain platform network intents service provider widget notifications auth sync telephony`. No `util/`. One public `@Composable` per file, named as file. `domain/` pure (no Android/Compose).@@ -73,7 +74,7 @@ The backend (relay server for findfamily/everysync/office/voxels) lives outside - Every native library has exactly one guarded wrapper in `platform/` named `<Feature>Native`; it is the only `System.loadLibrary` caller for that library and exposes availability instead of letting initialization fail. JNI-frozen FQNs are the only package exceptions and must carry the verbatim JNI marker. - Every app has exactly one preferences owner in `data/` named `<App>Prefs`; only it opens the app’s DataStore/SharedPreferences, and it recovers from corruption with documented defaults. Persisted/external decoding goes through non-throwing helpers in `data/` or `domain/`; Room converters never throw. - Every exported entry point has one validated contract in `intents/`; entry points consume validated values only. Regexes must be Android-ICU-valid (escape literal braces outside quantifiers/character classes). Widgets render from one immutable snapshot and use fallbacks for missing keys/items. One widget, one file: every file in `widget/` declares a `MaWidget` subclass at top level together with its receiver; no helper-only files in `widget/` (helpers nest inside the widget; non-Glance app helpers belong to their own root).-- Escape hatches verbatim: `// PACKAGE STRUCTURE EXCEPTION (JNI)`, `// RAW SCAFFOLD EXCEPTION: <reason>`, `// TOAST EXCEPTION: <reason>`, `// RAW ANIMATION EXCEPTION: <reason>`.+- Escape hatches verbatim: `// PACKAGE STRUCTURE EXCEPTION (JNI)`, `// RAW SCAFFOLD EXCEPTION: <reason>`, `// TOAST EXCEPTION: <reason>`, `// RAW ANIMATION EXCEPTION: <reason>`, `// SCAFFOLD LOADING EXCEPTION: <reason>`, `// SCAFFOLD SEARCH EXCEPTION: <reason>`. - detekt rules live in `detekt.yml` (ui/domain/odf/service scoping rationale inline). Fix code, not config, to green a module.  ## 3. Verify (slice touched, never whole repo)
appstore/src/main/java/com/vayunmathur/appstore/ui/SearchScreen.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/SearchScreen.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/SearchScreen.ktindex 2f8a893dbf..356170ab2f 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/SearchScreen.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/SearchScreen.kt@@ -25,7 +25,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.platform.AppStoreViewModel-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.ErrorState import com.vayunmathur.library.ui.FilterChip@@ -54,15 +54,17 @@ fun SearchScreen(         if (autoFocus) runCatching { focusRequester.requestFocus() }     } -    AppScaffold(topBar = {}, isRefreshing = state.isSearching) { padding ->+    AppScaffold(+        title = "",+        isRefreshing = state.isSearching,+        search = ScaffoldSearch(+            query = state.query,+            onQueryChange = actions::setSearch,+            placeholder = stringResource(R.string.search_placeholder),+            modifier = Modifier.focusRequester(focusRequester),+        ),+    ) { padding ->         Column(Modifier.fillMaxSize().padding(padding)) {-            CommonSearchBar(-                value = state.query,-                onValueChange = actions::setSearch,-                placeholder = stringResource(R.string.search_placeholder),-                padding = PaddingValues(horizontal = 16.dp, vertical = 8.dp),-                modifier = Modifier.focusRequester(focusRequester),-            )              LazyRow(                 Modifier.fillMaxWidth(),
astronomy/src/main/java/com/vayunmathur/astronomy/ui/SearchScreen.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SearchScreen.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SearchScreen.ktindex 7c687b374d..0b83c8991c 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SearchScreen.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SearchScreen.kt@@ -1,4 +1,6 @@ package com.vayunmathur.astronomy.ui++// SCAFFOLD SEARCH EXCEPTION: full-bleed sky-map screen with TopAppBarOverlay chrome; no scaffold host for the catalog search field import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column
calendar/src/main/java/com/vayunmathur/calendar/ui/HolidayCalendarsScreen.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/HolidayCalendarsScreen.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/HolidayCalendarsScreen.ktindex f64381c045..3bdc952eb5 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/HolidayCalendarsScreen.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/HolidayCalendarsScreen.kt@@ -1,5 +1,7 @@ package com.vayunmathur.calendar.ui +// SCAFFOLD SEARCH EXCEPTION: language-picker dialog-local search filter in this file; the screen's country search uses the scaffold search parameter+ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row@@ -13,6 +15,7 @@ import androidx.compose.foundation.lazy.items import com.vayunmathur.calendar.R import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.AlertDialog import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.ExperimentalMaterial3Api@@ -108,15 +111,13 @@ fun HolidayCalendarsScreen(viewModel: CalendarViewModel, backStack: NavBackStack     AppScaffold(         title = stringResource(R.string.holiday_calendars),         backStack = backStack,+        search = ScaffoldSearch(+            query = query,+            onQueryChange = { query = it },+            placeholder = stringResource(R.string.search_countries),+        ),     ) { paddingValues ->         Column(Modifier.padding(paddingValues).fillMaxSize()) {-            OutlinedTextField(-                value = query,-                onValueChange = { query = it },-                modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 8.dp),-                placeholder = { Text(stringResource(R.string.search_countries)) },-                singleLine = true,-            )             LazyColumn(Modifier.fillMaxSize()) {                 items(filtered, key = { it.code }) { country ->                     val langCode = added[country.code]
calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/TimezonePickerDialog.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/TimezonePickerDialog.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/TimezonePickerDialog.ktindex 5124d70a5c..b6c85084c4 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/TimezonePickerDialog.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/TimezonePickerDialog.kt@@ -1,4 +1,6 @@ package com.vayunmathur.calendar.ui.dialogs++// SCAFFOLD SEARCH EXCEPTION: dialog-local timezone filter inside a picker dialog; no scaffold host import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row
contacts/src/main/java/com/vayunmathur/contacts/ui/ContactListPick.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactListPick.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactListPick.ktindex 6cbb039673..7752bedef7 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactListPick.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactListPick.kt@@ -14,7 +14,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.vayunmathur.contacts.R import com.vayunmathur.contacts.data.Contact-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.ExtendedFloatingActionButton@@ -59,6 +59,11 @@ fun ContactListPick(      LazyListScaffold(         isRefreshing = isLoading,+        search = ScaffoldSearch(+            query = query,+            onQueryChange = { query = it },+            placeholder = stringResource(R.string.search_contacts),+        ),         topBar = { TopAppBar(title = { Text(stringResource(R.string.app_name)) }) },         floatingActionButton = {             if (allowMultiple) {@@ -72,15 +77,6 @@ fun ContactListPick(         horizontalPadding = 16.dp,         verticalArrangement = Arrangement.spacedBy(8.dp),     ) {-        item(key = "pick-search") {-            CommonSearchBar(-                value = query,-                onValueChange = { query = it },-                placeholder = stringResource(R.string.search_contacts),-                padding = PaddingValues(vertical = 8.dp),-                modifier = Modifier.fillMaxWidth()-            )-        }         when {             filtered.isEmpty() && isLoading -> {                 item(key = "pick-loading") {
contacts/src/main/java/com/vayunmathur/contacts/ui/ContactListScreen.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactListScreen.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactListScreen.ktindex 0412a8a878..ef3b4c8245 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactListScreen.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactListScreen.kt@@ -29,7 +29,7 @@ import com.vayunmathur.contacts.domain.ContactSorting.sectionKey import com.vayunmathur.contacts.domain.ContactSorting.sortedByMode import com.vayunmathur.contacts.platform.ContactsActions import com.vayunmathur.library.ui.AlertDialog-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.FloatingActionButton@@ -45,7 +45,6 @@ import com.vayunmathur.library.ui.IconShare import com.vayunmathur.library.ui.LazyListScaffold import com.vayunmathur.library.ui.OverflowMenu import com.vayunmathur.library.ui.PopVisibility-import com.vayunmathur.library.ui.SwappedTopBar import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.ui.TopAppBar@@ -134,10 +133,50 @@ fun ContactListScreen(      LazyListScaffold(         isRefreshing = state.isLoading,+        search = if (isSelectionMode) null else ScaffoldSearch(+            query = state.searchQuery,+            onQueryChange = { actions.setSearchQuery(it) },+            placeholder = stringResource(R.string.search_contacts),+            modifier = Modifier+                .focusProperties { canFocus = isFocusableBySystem }+                .pointerInput(Unit) {+                    awaitPointerEventScope {+                        while (true) {+                            awaitPointerEvent(PointerEventPass.Initial)+                            if (!isFocusableBySystem) isFocusableBySystem = true+                        }+                    }+                }+                .onFocusChanged { focusState ->+                    if (!focusState.isFocused) {+                        isFocusableBySystem = false+                    }+                },+        ),         state = listState,+        actions = {+            IconButton(onClick = { actions.shareContacts(contacts, "all_contacts.vcf") }) {+                IconShare()+            }+            OverflowMenu {+                Item(+                    text = stringResource(R.string.first_name),+                    trailingIcon = if (sortMode == ContactSortMode.FirstName) {+                        { IconCheck() }+                    } else null,+                    onClick = { onSortModeChange(ContactSortMode.FirstName) },+                )+                Item(+                    text = stringResource(R.string.last_name),+                    trailingIcon = if (sortMode == ContactSortMode.LastName) {+                        { IconCheck() }+                    } else null,+                    onClick = { onSortModeChange(ContactSortMode.LastName) },+                )+            }+        },         topBar = {-            SwappedTopBar(showingOverlay = isSelectionMode) { selecting ->-                if (selecting) {+            if (isSelectionMode) {                 TopAppBar(                     title = { Text(pluralStringResource(R.plurals.selected_count, selectedIds.size, selectedIds.size)) },                     navigationIcon = {@@ -166,54 +205,6 @@ fun ContactListScreen(                         }                     }                 )-            } else {-                TopAppBar(-                    title = {-                        CommonSearchBar(-                            value = state.searchQuery,-                            onValueChange = { actions.setSearchQuery(it) },-                            placeholder = stringResource(R.string.search_contacts),-                            padding = PaddingValues(bottom = 8.dp),-                            modifier = Modifier-                                .focusProperties { canFocus = isFocusableBySystem }-                                .pointerInput(Unit) {-                                    awaitPointerEventScope {-                                        while (true) {-                                            awaitPointerEvent(PointerEventPass.Initial)-                                            if (!isFocusableBySystem) isFocusableBySystem = true-                                        }-                                    }-                                }-                                .onFocusChanged { focusState ->-                                    if (!focusState.isFocused) {-                                        isFocusableBySystem = false-                                    }-                                }-                        )-                    },-                    actions = {-                        IconButton(onClick = { actions.shareContacts(contacts, "all_contacts.vcf") }) {-                            IconShare()-                        }-                        OverflowMenu {-                            Item(-                                text = stringResource(R.string.first_name),-                                trailingIcon = if (sortMode == ContactSortMode.FirstName) {-                                    { IconCheck() }-                                } else null,-                                onClick = { onSortModeChange(ContactSortMode.FirstName) },-                            )-                            Item(-                                text = stringResource(R.string.last_name),-                                trailingIcon = if (sortMode == ContactSortMode.LastName) {-                                    { IconCheck() }-                                } else null,-                                onClick = { onSortModeChange(ContactSortMode.LastName) },-                            )-                        }-                    }-                )-                }             }         },         floatingActionButton = {
contacts/src/main/java/com/vayunmathur/contacts/ui/InsertOrEditContactScreen.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/InsertOrEditContactScreen.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/InsertOrEditContactScreen.ktindex 898ada9f01..5839228611 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/ui/InsertOrEditContactScreen.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/InsertOrEditContactScreen.kt@@ -38,7 +38,7 @@ import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch  /**  * Shown for ACTION_INSERT_OR_EDIT / SHOW_OR_CREATE_CONTACT (Fossify dialer "Add number to contact").@@ -79,6 +79,11 @@ fun InsertOrEditContactScreen(             }         },         onClose = onExit,+        search = ScaffoldSearch(+            query = searchQuery,+            onQueryChange = { viewModel.setSearchQuery(it) },+            placeholder = stringResource(R.string.search_contacts),+        ),         bottomBar = {             Row(                 Modifier.fillMaxWidth().padding(16.dp),@@ -100,13 +105,6 @@ fun InsertOrEditContactScreen(         },     ) { padding ->         Column(Modifier.fillMaxSize().padding(padding)) {-            CommonSearchBar(-                value = searchQuery,-                onValueChange = { viewModel.setSearchQuery(it) },-                placeholder = stringResource(R.string.search_contacts),-                padding = PaddingValues(horizontal = 16.dp, vertical = 8.dp),-                modifier = Modifier.fillMaxWidth()-            )              when {                 contacts.isEmpty() && searchQuery.isEmpty() && !hasLoadedContacts -> {
email/src/main/java/com/vayunmathur/email/ui/MessageListScreen.kt
diff --git a/email/src/main/java/com/vayunmathur/email/ui/MessageListScreen.kt b/email/src/main/java/com/vayunmathur/email/ui/MessageListScreen.ktindex bdeaeacb9a..071c0ae992 100644--- a/email/src/main/java/com/vayunmathur/email/ui/MessageListScreen.kt+++ b/email/src/main/java/com/vayunmathur/email/ui/MessageListScreen.kt@@ -48,7 +48,7 @@ import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.CardDefaults import com.vayunmathur.library.ui.EmptyState-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.FloatingActionButton import com.vayunmathur.library.ui.HorizontalDivider@@ -113,7 +113,8 @@ fun MessageListScreen(         title = {             when {                 selectionActive -> Text(pluralStringResource(R.plurals.selected_count, state.selectedUids.size, state.selectedUids.size))-                isSearching -> CommonSearchBar(value = state.searchQuery, onValueChange = { actions.setSearchQuery(it) }, padding = PaddingValues(0.dp))+                // Unseen while searching: the scaffold replaces the title slot with the field.+                isSearching -> Text("")                 else -> Text(if (state.selectedAccountEmail == null) stringResource(R.string.unified_inbox_label) else state.selectedFolderName)             }         },@@ -148,6 +149,10 @@ fun MessageListScreen(         snackbarHost = { SnackbarHost(snackbarHostState) },         isRefreshing = state.isSyncing,         onRefresh = { actions.refresh(context) },+        search = if (isSearching && !selectionActive) ScaffoldSearch(+            query = state.searchQuery,+            onQueryChange = { actions.setSearchQuery(it) },+        ) else null,     ) { padding ->         Column(modifier = Modifier.padding(padding).fillMaxSize()) {             Box(modifier = Modifier.fillMaxWidth().height(2.dp)) {
flashcards/src/main/java/com/vayunmathur/flashcards/ui/NoteListScreen.kt
diff --git a/flashcards/src/main/java/com/vayunmathur/flashcards/ui/NoteListScreen.kt b/flashcards/src/main/java/com/vayunmathur/flashcards/ui/NoteListScreen.ktindex db57fa42d2..e401bb2d7b 100644--- a/flashcards/src/main/java/com/vayunmathur/flashcards/ui/NoteListScreen.kt+++ b/flashcards/src/main/java/com/vayunmathur/flashcards/ui/NoteListScreen.kt@@ -23,7 +23,7 @@ import com.vayunmathur.flashcards.ui.NoteListActions import com.vayunmathur.flashcards.ui.NoteListUiState import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.DropdownMenu import com.vayunmathur.library.ui.DropdownMenuItem@@ -82,6 +82,11 @@ fun NoteListScreen(      AppScaffold(         isRefreshing = !state.hasLoaded,+        search = if (!selection.isActive && state.notes.isNotEmpty()) ScaffoldSearch(+            query = query,+            onQueryChange = { query = it },+            placeholder = stringResource(R.string.search_cards),+        ) else null,         title = {             if (selection.isActive) {                 Text(pluralStringResource(R.plurals.selected_count, selection.count, selection.count))@@ -164,14 +169,6 @@ fun NoteListScreen(                     },                 )             }-            if (state.notes.isNotEmpty()) {-                CommonSearchBar(-                    value = query,-                    onValueChange = { query = it },-                    placeholder = stringResource(R.string.search_cards),-                    padding = PaddingValues(horizontal = 16.dp, vertical = 4.dp),-                )-            }             when {                 !state.hasLoaded && state.notes.isEmpty() -> androidx.compose.foundation.layout.Box(                     modifier = Modifier.fillMaxSize(),
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/AchievementsScreen.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/AchievementsScreen.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/AchievementsScreen.ktindex 598428f813..3d2799cdfb 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/AchievementsScreen.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/AchievementsScreen.kt@@ -21,7 +21,7 @@ import com.vayunmathur.games.hub.domain.KnownGames import com.vayunmathur.games.hub.ui.components.AchievementRow import com.vayunmathur.games.hub.viewmodel.GameHubViewModel import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.FilterChip import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.R as UiR@@ -72,7 +72,10 @@ fun AchievementsScreen(         list.sortedWith(compareBy<AchievementWithProgress> { !it.isUnlocked }.thenBy { it.gameId }.thenBy { it.name })     } -    AppScaffold(title = { CommonSearchBar(value = search, onValueChange = { search = it }, padding = PaddingValues(0.dp)) }) { padding ->+    AppScaffold(+        title = "",+        search = ScaffoldSearch(query = search, onQueryChange = { search = it }),+    ) { padding ->         LazyColumn(modifier = modifier.fillMaxSize().padding(padding), contentPadding = PaddingValues(bottom = 16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {             item {                 LazyRow(contentPadding = PaddingValues(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/GamesListScreen.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/GamesListScreen.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/GamesListScreen.ktindex 792d369723..f4a8cac960 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/GamesListScreen.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/GamesListScreen.kt@@ -24,7 +24,7 @@ import com.vayunmathur.games.hub.ui.components.GameCard import com.vayunmathur.games.hub.util.GamesListActions import com.vayunmathur.games.hub.util.GamesListUiState import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconMoreVert import com.vayunmathur.library.ui.MaterialTheme@@ -73,14 +73,12 @@ fun GamesListScreen(     }      AppScaffold(-        title = {-            CommonSearchBar(-                value = search,-                onValueChange = { search = it },-                placeholder = stringResource(com.vayunmathur.games.hub.R.string.search_games),-                padding = PaddingValues(0.dp),-            )-        },+        title = "",+        search = ScaffoldSearch(+            query = search,+            onQueryChange = { search = it },+            placeholder = stringResource(com.vayunmathur.games.hub.R.string.search_games),+        ),         actions = {             IconButton(onClick = { showSortMenu = true }) { IconMoreVert() }             DropdownMenu(expanded = showSortMenu, onDismissRequest = { showSortMenu = false }) {
globalesim/src/main/java/com/vayunmathur/globalesim/ui/PricingScreen.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/PricingScreen.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/PricingScreen.ktindex 625e823fa8..786a7a523e 100644--- a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/PricingScreen.kt+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/PricingScreen.kt@@ -23,7 +23,7 @@ import androidx.compose.ui.unit.dp import com.vayunmathur.globalesim.R import com.vayunmathur.globalesim.domain.QuoteMath import com.vayunmathur.globalesim.platform.EsimUiState-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.ExpandVisibility import com.vayunmathur.library.ui.IconSim@@ -34,7 +34,6 @@ import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.OutlinedButton import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.ui.animatedColor import com.vayunmathur.library.ui.animatedDp@@ -62,18 +61,11 @@ fun PricingScreen(     }      LazyListScaffold(-        topBar = {-            TopAppBar(-                title = {-                    CommonSearchBar(-                        value = query,-                        onValueChange = { query = it },-                        placeholder = stringResource(R.string.search_countries),-                        padding = PaddingValues(bottom = 8.dp),-                    )-                },-            )-        },+        search = ScaffoldSearch(+            query = query,+            onQueryChange = { query = it },+            placeholder = stringResource(R.string.search_countries),+        ),         horizontalPadding = 8.dp,         verticalArrangement = Arrangement.spacedBy(4.dp),     ) {
health/src/main/java/com/vayunmathur/health/ui/CatalogPickerPage.kt
diff --git a/health/src/main/java/com/vayunmathur/health/ui/CatalogPickerPage.kt b/health/src/main/java/com/vayunmathur/health/ui/CatalogPickerPage.ktindex 47076ccdba..5c79096331 100644--- a/health/src/main/java/com/vayunmathur/health/ui/CatalogPickerPage.kt+++ b/health/src/main/java/com/vayunmathur/health/ui/CatalogPickerPage.kt@@ -26,7 +26,7 @@ import com.vayunmathur.health.data.ReferenceCatalog import com.vayunmathur.health.data.VaccineCatalog import com.vayunmathur.health.platform.MedicalViewModel import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.MaterialTheme@@ -180,31 +180,29 @@ fun CatalogPickerPage(         backStack.pop()     } -    // Back clears the search before leaving, matching ListPage. With the field in the app bar-    // there is nowhere else for a back press to sensibly go first.+    // Back clears the search before leaving, matching ListPage. With the field in the+    // scaffold's search slot there is nowhere else for a back press to sensibly go first.     BackHandler(enabled = query.isNotEmpty()) { query = "" }      AppScaffold(-        // The search field *is* the title. These lists are the whole point of the screen, and a-        // separate title bar above the field costs a row of height to say what the placeholder-        // already says.-        title = {-            CommonSearchBar(-                value = query,-                onValueChange = { query = it },-                placeholder = stringResource(-                    when (route.kind) {-                        CatalogKind.Vaccine -> R.string.search_vaccines-                        CatalogKind.MedicationIngredient -> R.string.search_medications-                        CatalogKind.MedicationProduct -> R.string.search_strengths-                        CatalogKind.Allergen -> R.string.search_allergens-                        CatalogKind.Condition -> R.string.search_conditions-                        CatalogKind.LabTest -> R.string.search_lab_tests-                    }-                ),-                padding = PaddingValues(0.dp),-            )-        },+        // The search field lives in the scaffold's search slot under the bar;+        // these lists are the whole point of the screen, so the bar itself+        // carries no separate title text.+        title = "",+        search = ScaffoldSearch(+            query = query,+            onQueryChange = { query = it },+            placeholder = stringResource(+                when (route.kind) {+                    CatalogKind.Vaccine -> R.string.search_vaccines+                    CatalogKind.MedicationIngredient -> R.string.search_medications+                    CatalogKind.MedicationProduct -> R.string.search_strengths+                    CatalogKind.Allergen -> R.string.search_allergens+                    CatalogKind.Condition -> R.string.search_conditions+                    CatalogKind.LabTest -> R.string.search_lab_tests+                }+            ),+        ),         onNavigateBack = { backStack.pop() },     ) { padding ->         Column(modifier = Modifier.padding(padding)) {
health/src/main/java/com/vayunmathur/health/ui/IngredientSearchDialog.kt
diff --git a/health/src/main/java/com/vayunmathur/health/ui/IngredientSearchDialog.kt b/health/src/main/java/com/vayunmathur/health/ui/IngredientSearchDialog.ktindex 62ae856968..332665f27a 100644--- a/health/src/main/java/com/vayunmathur/health/ui/IngredientSearchDialog.kt+++ b/health/src/main/java/com/vayunmathur/health/ui/IngredientSearchDialog.kt@@ -1,5 +1,7 @@ package com.vayunmathur.health.ui +// SCAFFOLD SEARCH EXCEPTION: dialog-local ingredient search inside an AlertDialog; no scaffold host+ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row
launcher/src/main/java/com/vayunmathur/launcher/ui/DrawerContent.kt
diff --git a/launcher/src/main/java/com/vayunmathur/launcher/ui/DrawerContent.kt b/launcher/src/main/java/com/vayunmathur/launcher/ui/DrawerContent.ktindex 55400b6ae3..8398bbbcf4 100644--- a/launcher/src/main/java/com/vayunmathur/launcher/ui/DrawerContent.kt+++ b/launcher/src/main/java/com/vayunmathur/launcher/ui/DrawerContent.kt@@ -1,5 +1,7 @@ package com.vayunmathur.launcher.ui +// SCAFFOLD SEARCH EXCEPTION: app-drawer overlay over the home screen (not a scaffold screen); apps must stay draggable into the home gesture root+ import androidx.activity.compose.BackHandler import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box
launcher/src/main/java/com/vayunmathur/launcher/ui/WidgetPickerContent.kt
diff --git a/launcher/src/main/java/com/vayunmathur/launcher/ui/WidgetPickerContent.kt b/launcher/src/main/java/com/vayunmathur/launcher/ui/WidgetPickerContent.ktindex a7c2f0b5d7..fe15a82d8c 100644--- a/launcher/src/main/java/com/vayunmathur/launcher/ui/WidgetPickerContent.kt+++ b/launcher/src/main/java/com/vayunmathur/launcher/ui/WidgetPickerContent.kt@@ -1,5 +1,7 @@ package com.vayunmathur.launcher.ui +// SCAFFOLD SEARCH EXCEPTION: bottom-sheet-local widget picker content hosted by a ModalBottomSheet, not a scaffold screen+ import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box
library/ui/AGENTS.md
diff --git a/library/ui/AGENTS.md b/library/ui/AGENTS.mdindex 883b29fa80..94bee70f5f 100644--- a/library/ui/AGENTS.md+++ b/library/ui/AGENTS.md@@ -69,6 +69,7 @@ - com/vayunmathur/library/ui/SelectionMode.kt - com/vayunmathur/library/ui/SwipeActionsBox.kt - com/vayunmathur/library/ui/CommonSearchBar.kt+- com/vayunmathur/library/ui/ScaffoldSearch.kt — scaffold `search` parameter value (screen-level search is declared here, never by placing CommonSearchBar in app content; fatal `ScaffoldSearch` lint) - com/vayunmathur/library/ui/OverflowMenu.kt - com/vayunmathur/library/ui/ConfirmDialog.kt - com/vayunmathur/library/ui/AddToListDialog.kt
library/ui/src/main/java/com/vayunmathur/library/ui/AppScaffold.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/AppScaffold.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/AppScaffold.ktindex 23cc6cb114..e16526d742 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/AppScaffold.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/AppScaffold.kt@@ -11,6 +11,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.semantics.heading import androidx.compose.ui.semantics.semantics+import androidx.compose.ui.unit.dp import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.util.NavKey @@ -66,6 +67,14 @@ enum class AppBarSize { Small, MediumFlexible, LargeFlexible }  * flag. Set [refreshEnabled] = false to disable the pull gesture while still  * reflecting a programmatic refresh. No other loading icon belongs in a  * screen; the `ScaffoldLoading` lint rule flags standalone ones.+ *+ * Search belongs here too: pass [search] and the scaffold renders the+ * shared inline filter field AS the top app bar, replacing the title in+ * its title slot (the ListPage / notes / contacts placement), while+ * navigation/actions keep rendering around it. The field sits above (and+ * outside) the refresh box, so a refresh indicator drops in over the+ * content under the bar as before. No standalone search bar belongs in a+ * screen; the `ScaffoldSearch` lint rule flags them.  */ @Composable fun AppScaffold(@@ -86,6 +95,7 @@ fun AppScaffold(     isRefreshing: Boolean = false,     onRefresh: (() -> Unit)? = null,     refreshEnabled: Boolean = true,+    search: ScaffoldSearch? = null,     content: @Composable (PaddingValues) -> Unit, ) = AppScaffold(     title = { Text(title, modifier = Modifier.semantics { heading() }) },@@ -105,6 +115,7 @@ fun AppScaffold(     isRefreshing = isRefreshing,     onRefresh = onRefresh,     refreshEnabled = refreshEnabled,+    search = search,     content = content, ) @@ -133,6 +144,7 @@ fun AppScaffold(     isRefreshing: Boolean = false,     onRefresh: (() -> Unit)? = null,     refreshEnabled: Boolean = true,+    search: ScaffoldSearch? = null,     content: @Composable (PaddingValues) -> Unit, ) {     val resolvedNavigationIcon = resolveNavigationIcon(navigationIcon, onClose, onNavigateBack)@@ -141,7 +153,23 @@ fun AppScaffold(         modifier = modifier.nestedScroll(behavior.nestedScrollConnection),         topBar = {             AppTopBar(-                title = title,+                // Search replaces the title in the bar's title slot (the+                // ListPage / notes / contacts placement): while a screen+                // searches, its name gives way to the field, whose+                // placeholder carries the context. The title composable is+                // not rendered at all in that state.+                title = if (search != null) {+                    {+                        CommonSearchBar(+                            value = search.query,+                            onValueChange = search.onQueryChange,+                            placeholder = search.placeholder,+                            modifier = search.modifier,+                            onSearch = search.onSearch,+                            padding = PaddingValues(0.dp),+                        )+                    }+                } else title,                 subtitle = subtitle,                 navigationIcon = resolvedNavigationIcon,                 actions = actions,@@ -166,9 +194,15 @@ fun AppScaffold( }  /**- * [AppScaffold] whose top bar is supplied by the screen (e.g. a search field), or+ * [AppScaffold] whose top bar is supplied by the screen, or  * omitted entirely with `topBar = {}`. Without a bar the content padding still  * covers the status bar.+ *+ * This overload deliberately has no `search` parameter: a screen that supplies+ * its whole bar owns that bar. Screen-level search goes through a titled+ * overload's `search` parameter instead; a custom bar that is itself an+ * expandable search surface (photos, youpipe) is the sanctioned exception and+ * carries a `// SCAFFOLD SEARCH EXCEPTION: <reason>` marker.  */ @Composable fun AppScaffold(@@ -219,6 +253,7 @@ fun <T : NavKey> AppScaffold(     isRefreshing: Boolean = false,     onRefresh: (() -> Unit)? = null,     refreshEnabled: Boolean = true,+    search: ScaffoldSearch? = null,     content: @Composable (PaddingValues) -> Unit, ) = AppScaffold(     title = title,@@ -238,6 +273,7 @@ fun <T : NavKey> AppScaffold(     isRefreshing = isRefreshing,     onRefresh = onRefresh,     refreshEnabled = refreshEnabled,+    search = search,     content = content, ) 
library/ui/src/main/java/com/vayunmathur/library/ui/CommonSearchBar.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/CommonSearchBar.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/CommonSearchBar.ktindex 2bb4a605be..d2ddeddb20 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/CommonSearchBar.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/CommonSearchBar.kt@@ -13,9 +13,16 @@ import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.unit.dp  /**- * The app-facing inline search field: an always-visible local filter, not an+ * The scaffold-owned inline search field: an always-visible local filter, not an  * expandable global-search bar.  *+ * App screens do NOT call this directly (the fatal `ScaffoldSearch` lint flags+ * it in app code): declare search through a scaffold's `search` parameter+ * ([ScaffoldSearch]) and the scaffold renders this field in its top-bar area.+ * This composable remains the rendering primitive the scaffolds share, plus+ * the sanctioned field for genuinely non-screen contexts that carry a+ * `// SCAFFOLD SEARCH EXCEPTION: <reason>` marker (sheet/drawer-local pickers).+ *  * This is deliberately built on [SearchBarInputField] (M3  * `SearchBarDefaults.InputField`) rather than the full [SearchBar] (or the newer  * `SearchBarState` family): every call-site filters an in-memory list live and has@@ -24,6 +31,10 @@ import androidx.compose.ui.unit.dp  * title slot it usually sits in — pure regression for zero benefit. The input field  * alone gives real search semantics (IME search action, search text style/colors,  * a11y role) with the same inline layout footprint as before.+ *+ * [onSearch] overrides the IME search action; by default live filtering has+ * already applied the query, so the action just dismisses the keyboard.+ * Explicit-submit screens (shop, via [ScaffoldSearch.onSearch]) pass one.  */ @Composable fun CommonSearchBar(@@ -31,14 +42,16 @@ fun CommonSearchBar(     onValueChange: (String) -> Unit,     modifier: Modifier = Modifier,     placeholder: String = "Search",-    padding: PaddingValues = PaddingValues(16.dp)+    padding: PaddingValues = PaddingValues(16.dp),+    onSearch: ((String) -> Unit)? = null, ) {     val focusManager = LocalFocusManager.current     SearchBarInputField(         query = value,         onQueryChange = onValueChange,-        // Live filtering already applied the query; the IME action just dismisses.-        onSearch = { focusManager.clearFocus() },+        onSearch = { submitted ->+            if (onSearch != null) onSearch(submitted) else focusManager.clearFocus()+        },         expanded = false,         onExpandedChange = {},         modifier = modifier
library/ui/src/main/java/com/vayunmathur/library/ui/DetailScaffold.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/DetailScaffold.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/DetailScaffold.ktindex ebe3abd85f..7bf6c75003 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/DetailScaffold.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/DetailScaffold.kt@@ -45,7 +45,8 @@ import com.vayunmathur.library.util.NavKey  *  * [isRefreshing]/[onRefresh] are forwarded to [AppScaffold]: while a refresh  * runs the scaffold's pull-to-refresh indicator shows over the detail column- * (see AppScaffold).+ * (see AppScaffold). [search] is forwarded likewise and renders the shared+ * search field under the bar (see [ScaffoldSearch]).  *  * On wide windows the scrolling column is centred and capped at  * [DesktopContentMaxWidth] so forms and detail blocks keep a readable@@ -69,6 +70,7 @@ fun DetailScaffold(     isRefreshing: Boolean = false,     onRefresh: (() -> Unit)? = null,     refreshEnabled: Boolean = true,+    search: ScaffoldSearch? = null,     content: @Composable ColumnScope.() -> Unit, ) = AppScaffold(     title = title,@@ -84,6 +86,7 @@ fun DetailScaffold(     isRefreshing = isRefreshing,     onRefresh = onRefresh,     refreshEnabled = refreshEnabled,+    search = search, ) { pad ->     DetailColumn(pad, fillHeight = false, fullBleed = fullBleed, content) }@@ -106,6 +109,7 @@ fun DetailScaffold(     isRefreshing: Boolean = false,     onRefresh: (() -> Unit)? = null,     refreshEnabled: Boolean = true,+    search: ScaffoldSearch? = null,     content: @Composable ColumnScope.() -> Unit, ) = AppScaffold(     title = title,@@ -121,6 +125,7 @@ fun DetailScaffold(     isRefreshing = isRefreshing,     onRefresh = onRefresh,     refreshEnabled = refreshEnabled,+    search = search, ) { pad ->     DetailColumn(pad, fillHeight, fullBleed, content) }@@ -142,6 +147,7 @@ fun <T : NavKey> DetailScaffold(     isRefreshing: Boolean = false,     onRefresh: (() -> Unit)? = null,     refreshEnabled: Boolean = true,+    search: ScaffoldSearch? = null,     content: @Composable ColumnScope.() -> Unit, ) = DetailScaffold(     title = title,@@ -158,6 +164,7 @@ fun <T : NavKey> DetailScaffold(     isRefreshing = isRefreshing,     onRefresh = onRefresh,     refreshEnabled = refreshEnabled,+    search = search,     content = content, ) @@ -180,6 +187,7 @@ fun DetailLazyColumn(     isRefreshing: Boolean = false,     onRefresh: (() -> Unit)? = null,     refreshEnabled: Boolean = true,+    search: ScaffoldSearch? = null,     content: LazyListScope.() -> Unit, ) = AppScaffold(     title = title,@@ -193,6 +201,7 @@ fun DetailLazyColumn(     isRefreshing = isRefreshing,     onRefresh = onRefresh,     refreshEnabled = refreshEnabled,+    search = search, ) { pad ->     DetailList(pad, content) }@@ -211,6 +220,7 @@ fun DetailLazyColumn(     isRefreshing: Boolean = false,     onRefresh: (() -> Unit)? = null,     refreshEnabled: Boolean = true,+    search: ScaffoldSearch? = null,     content: LazyListScope.() -> Unit, ) = AppScaffold(     title = title,@@ -224,6 +234,7 @@ fun DetailLazyColumn(     isRefreshing = isRefreshing,     onRefresh = onRefresh,     refreshEnabled = refreshEnabled,+    search = search, ) { pad ->     DetailList(pad, content) }@@ -242,6 +253,7 @@ fun <T : NavKey> DetailLazyColumn(     isRefreshing: Boolean = false,     onRefresh: (() -> Unit)? = null,     refreshEnabled: Boolean = true,+    search: ScaffoldSearch? = null,     content: LazyListScope.() -> Unit, ) = DetailLazyColumn(     title = title,@@ -255,6 +267,7 @@ fun <T : NavKey> DetailLazyColumn(     isRefreshing = isRefreshing,     onRefresh = onRefresh,     refreshEnabled = refreshEnabled,+    search = search,     content = content, ) 
library/ui/src/main/java/com/vayunmathur/library/ui/LazyListScaffold.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/LazyListScaffold.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/LazyListScaffold.ktindex 3b08a1477d..441173c475 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/LazyListScaffold.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/LazyListScaffold.kt@@ -56,12 +56,19 @@ import androidx.compose.ui.unit.dp  * [overlay] is drawn on top of the list in a [Box] exactly the list's size,  * for chrome that must track the viewport itself - e.g. a fast-scroller whose  * travel should run along the list, not the whole screen.+ *+ * [search] renders the shared search field AS the top bar's title slot+ * (see [ScaffoldSearch]), with [navigationIcon]/[actions] around it; while+ * it is supplied the [title] text and any custom [topBar] are not used.+ * Screens whose bar swaps for a selection bar pass `search = null` while+ * selecting and supply that bar through [topBar].  */ @Composable fun LazyListScaffold(     modifier: Modifier = Modifier,-    topBar: @Composable () -> Unit = {},+    topBar: (@Composable () -> Unit)? = null,     title: String = "",+    navigationIcon: (@Composable () -> Unit)? = null,     actions: (@Composable RowScope.() -> Unit)? = null,     scrollBehavior: TopAppBarScrollBehavior? = null,     bottomBar: @Composable () -> Unit = {},@@ -77,17 +84,50 @@ fun LazyListScaffold(     isRefreshing: Boolean = false,     onRefresh: (() -> Unit)? = null,     refreshEnabled: Boolean = true,+    search: ScaffoldSearch? = null,     content: LazyListScope.() -> Unit, ) {     val behavior = scrollBehavior ?: appBarScrollBehavior()+    // Search owns the bar: while [search] is supplied the scaffold builds the+    // bar itself with the field in its title slot. Otherwise a custom+    // [topBar] (when supplied) wins over the plain bar the scaffold builds+    // from [title]/[actions]. When none of those are given, no bar is drawn+    // (the historical default).+    val searchBar: (@Composable () -> Unit)? = if (search == null) null else {+        @Composable {+            TopAppBar(+                title = {+                    CommonSearchBar(+                        value = search.query,+                        onValueChange = search.onQueryChange,+                        placeholder = search.placeholder,+                        modifier = search.modifier,+                        onSearch = search.onSearch,+                        padding = PaddingValues(0.dp),+                    )+                },+                navigationIcon = navigationIcon ?: {},+                actions = actions ?: {},+                scrollBehavior = behavior,+            )+        }+    }+    val plainBar: (@Composable () -> Unit)? =+        if (actions == null && title.isEmpty() && navigationIcon == null) null else {+            @Composable {+                TopAppBar(+                    title = { Text(title) },+                    navigationIcon = navigationIcon ?: {},+                    actions = actions ?: {},+                    scrollBehavior = behavior,+                )+            }+        }+    val resolvedTopBar: @Composable () -> Unit =+        searchBar ?: topBar ?: plainBar ?: @Composable {}     Scaffold(     modifier.nestedScroll(behavior.nestedScrollConnection),-    // A caller can either pass a fully custom [topBar], or - the common case --    // let the scaffold build a plain top bar from [title]/[actions]. When neither-    // a title nor actions are given, no bar is drawn (the historical default).-    if (actions != null || title.isNotEmpty()) {-        { TopAppBar(title = { Text(title) }, actions = actions ?: {}, scrollBehavior = behavior) }-    } else topBar,+    resolvedTopBar,     bottomBar,     snackbarHost,     floatingActionButton,
library/ui/src/main/java/com/vayunmathur/library/ui/ScaffoldSearch.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/ScaffoldSearch.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/ScaffoldSearch.ktnew file mode 100644index 0000000000..9f38816ee7--- /dev/null+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/ScaffoldSearch.kt@@ -0,0 +1,43 @@+package com.vayunmathur.library.ui++import androidx.compose.ui.Modifier++/**+ * Screen-level search declared through the `AppScaffold` family.+ *+ * Pass a non-null [ScaffoldSearch] as a scaffold's `search` parameter and the+ * scaffold renders the shared inline filter field (see [CommonSearchBar]) AS+ * the top app bar: the field replaces the title in the bar's title slot (the+ * ListPage / notes / contacts placement), with the bar's navigation icon and+ * actions still rendering around it. Pass null (the default) for no search —+ * the title renders normally. The field is always visible while+ * [ScaffoldSearch] is supplied: screens that reveal search from a toolbar+ * icon keep that toggle as their own state and pass `search` only while it+ * is on (the email list does this), so their title returns when search ends.+ *+ * Search is deliberately NOT offered by every scaffold variant:+ *  - the `AppScaffold(topBar = ...)` overload owns no bar of its own, so it+ *    has nowhere sanctioned to put the field — use a titled overload;+ *  - [SetupScaffold]'s heading is its content and a setup step has nothing+ *    to filter;+ *  - [TabbedPagerScaffold] hosts pages that own their own scaffolds, so+ *    search belongs to the page's scaffold, not the tab host;+ *  - TV screens use the TV family's own text field, not this one.+ *+ * [ListPage] predates this type and keeps its own internal `searchEnabled`+ * state in the same title area; it is already scaffold-hosted and unchanged.+ *+ * [onSearch] is the IME search action. Live filtering has normally already+ * applied the query by then, so the default just dismisses the keyboard;+ * explicit-submit screens (shop) pass one to run their search.+ *+ * [modifier] is forwarded to the field, e.g. for a `focusRequester` on a+ * dedicated search screen (appstore, shop).+ */+data class ScaffoldSearch(+    val query: String,+    val onQueryChange: (String) -> Unit,+    val placeholder: String = "Search",+    val modifier: Modifier = Modifier,+    val onSearch: ((String) -> Unit)? = null,+)
library/ui/src/test/java/com/vayunmathur/library/ui/ScaffoldSearchSliceTest.kt
diff --git a/library/ui/src/test/java/com/vayunmathur/library/ui/ScaffoldSearchSliceTest.kt b/library/ui/src/test/java/com/vayunmathur/library/ui/ScaffoldSearchSliceTest.ktnew file mode 100644index 0000000000..1f2ad3a239--- /dev/null+++ b/library/ui/src/test/java/com/vayunmathur/library/ui/ScaffoldSearchSliceTest.kt@@ -0,0 +1,118 @@+package com.vayunmathur.library.ui++import androidx.compose.foundation.lazy.items+import androidx.compose.material3.Text+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.test.assertIsDisplayed+import androidx.compose.ui.test.junit4.createComposeRule+import androidx.compose.ui.test.onNodeWithContentDescription+import androidx.compose.ui.test.onNodeWithText+import androidx.compose.ui.test.performClick+import androidx.compose.ui.test.performTextInput+import kotlin.test.Test+import kotlin.test.assertEquals+import org.junit.Rule+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner++/**+ * Scaffold-owned search: the `search` parameter renders the shared field AS+ * the top app bar (title slot, title replaced), query edits flow to the+ * caller, the clear affordance empties the query, and the default (no+ * search) renders the title with no field.+ */+@RunWith(RobolectricTestRunner::class)+class ScaffoldSearchSliceTest {++    @get:Rule+    val rule = createComposeRule()++    @Test fun appScaffoldSearchRendersAndQueryFlows() {+        rule.setContent {+            var query by remember { mutableStateOf("") }+            AppScaffold(+                title = "Inbox",+                search = ScaffoldSearch(+                    query = query,+                    onQueryChange = { query = it },+                    placeholder = "Search mail",+                ),+                scrollBehavior = appBarScrollBehavior(),+            ) { Text("Body text") }+        }+        // Search replaces the title in the bar's title slot.+        rule.onNodeWithText("Inbox").assertDoesNotExist()+        rule.onNodeWithText("Search mail").assertIsDisplayed()+        rule.onNodeWithText("Search mail").performTextInput("hello")+        // The typed text replaces the placeholder once the query flows back in.+        rule.onNodeWithText("hello").assertIsDisplayed()+    }++    @Test fun appScaffoldWithoutSearchHasNoField() {+        rule.setContent {+            AppScaffold(+                title = "Inbox",+                scrollBehavior = appBarScrollBehavior(),+            ) { Text("Body text") }+        }+        rule.onNodeWithText("Inbox").assertIsDisplayed()+        rule.onNodeWithText("Search").assertDoesNotExist()+    }++    @Test fun scaffoldSearchClearEmptiesQuery() {+        var last = "seed"+        rule.setContent {+            var query by remember { mutableStateOf("seed") }+            AppScaffold(+                title = "Notes",+                search = ScaffoldSearch(+                    query = query,+                    onQueryChange = { query = it; last = it },+                    placeholder = "Search notes",+                ),+                scrollBehavior = appBarScrollBehavior(),+            ) { Text("B") }+        }+        rule.onNodeWithContentDescription("Close").performClick()+        assertEquals("", last)+    }++    @Test fun lazyListScaffoldSearchRendersAboveList() {+        rule.setContent {+            var query by remember { mutableStateOf("") }+            LazyListScaffold(+                title = "Countries",+                search = ScaffoldSearch(+                    query = query,+                    onQueryChange = { query = it },+                    placeholder = "Search countries",+                ),+            ) {+                items(listOf("France", "Spain")) { Text(it) }+            }+        }+        rule.onNodeWithText("Countries").assertDoesNotExist()+        rule.onNodeWithText("Search countries").assertIsDisplayed()+        rule.onNodeWithText("France").assertIsDisplayed()+    }++    @Test fun detailScaffoldSearchRenders() {+        rule.setContent {+            var query by remember { mutableStateOf("") }+            DetailScaffold(+                title = "Picker",+                search = ScaffoldSearch(+                    query = query,+                    onQueryChange = { query = it },+                    placeholder = "Search items",+                ),+                scrollBehavior = appBarScrollBehavior(),+            ) { Text("Row") }+        }+        rule.onNodeWithText("Search items").assertIsDisplayed()+        rule.onNodeWithText("Row").assertIsDisplayed()+    }+}
lint-rules/AGENTS.md
diff --git a/lint-rules/AGENTS.md b/lint-rules/AGENTS.mdindex 0d1fdef441..107e3a650a 100644--- a/lint-rules/AGENTS.md+++ b/lint-rules/AGENTS.md@@ -12,7 +12,7 @@  ## Overview **Purpose:** Custom Android-lint detectors enforcing repo conventions at build time — the executable form of root `AGENTS.md` §2. Fatal detectors break the build; advisory ones warn.-**Blocking:** every Modern-Apps detector is fatal in the app and library conventions. That includes `ToastUsage` (no `Toast` — use messenger), `DirectComposeAnimation` (no raw animation at call sites), `FileLength`, `DirectAndroidLog` (no direct `android.util.Log`), `DirectBuildDatabase` (subclass `RoomRepository`), `OneComposablePerFile`, `PackageStructure` (closed roots and flat `widget`), `RawScaffoldInApp` (use `AppScaffold`), `ScaffoldLoading` (scaffold owns refresh indication; standalone loading icons in app UI flagged), `Room2Usage` (Room 3 only), `WindowInsetsInReusableComponent` (no padding in `library.ui`), and the comment-hygiene detectors (`CommentedOutCode`, `ExceptionMarkerFormat`, `TodoEvasion` with `CommentOnlyMatcher`).+**Blocking:** every Modern-Apps detector is fatal in the app and library conventions. That includes `ToastUsage` (no `Toast` — use messenger), `DirectComposeAnimation` (no raw animation at call sites), `FileLength`, `DirectAndroidLog` (no direct `android.util.Log`), `DirectBuildDatabase` (subclass `RoomRepository`), `OneComposablePerFile`, `PackageStructure` (closed roots and flat `widget`), `RawScaffoldInApp` (use `AppScaffold`), `ScaffoldLoading` (scaffold owns refresh indication; standalone loading icons in app UI flagged), `ScaffoldSearch` (scaffold owns screen-level search via its `search` parameter; standalone `CommonSearchBar`/`SearchBar`/`SearchBarInputField` and reliably search-identified text fields in app UI flagged, exception marker `// SCAFFOLD SEARCH EXCEPTION: <reason>` for dialog/sheet/drawer-local and expandable-overlay search), `Room2Usage` (Room 3 only), `WindowInsetsInReusableComponent` (no padding in `library.ui`), and the comment-hygiene detectors (`CommentedOutCode`, `ExceptionMarkerFormat`, `TodoEvasion` with `CommentOnlyMatcher`). **Entry points:** `ModernAppsIssueRegistry.kt` → the detector for your rule → `LintPackageExclusions.kt` for scope. **Gotchas:** New detectors need registry entries + severity decisions (fatal vs advisory is a deliberate call). Fix code to green modules, never relax config (`detekt.yml` rationale is inline per the root card). @@ -25,6 +25,7 @@ - com/vayunmathur/lint/Room2UsageDetector.kt — Room 3 rule - com/vayunmathur/lint/RawScaffoldInAppDetector.kt — AppScaffold rule - com/vayunmathur/lint/ScaffoldLoadingDetector.kt — scaffold-owned loading rule+- com/vayunmathur/lint/ScaffoldSearchDetector.kt — scaffold-owned search rule - com/vayunmathur/lint/PackageStructureDetector.kt — closed-roots rule - com/vayunmathur/lint/OneComposablePerFileDetector.kt - com/vayunmathur/lint/WindowInsetsInReusableComponentDetector.kt
lint-rules/src/main/java/com/vayunmathur/lint/ExceptionMarkerFormatDetector.kt
diff --git a/lint-rules/src/main/java/com/vayunmathur/lint/ExceptionMarkerFormatDetector.kt b/lint-rules/src/main/java/com/vayunmathur/lint/ExceptionMarkerFormatDetector.ktindex 70a95d6075..1c5bc4ba4b 100644--- a/lint-rules/src/main/java/com/vayunmathur/lint/ExceptionMarkerFormatDetector.kt+++ b/lint-rules/src/main/java/com/vayunmathur/lint/ExceptionMarkerFormatDetector.kt@@ -33,6 +33,10 @@ import java.io.File  *  - `// TOAST EXCEPTION: <reason>` with colon and non-empty reason  *    (see [ToastDetector])  *  - `// RAW ANIMATION EXCEPTION: <reason>` with colon and non-empty reason+ *  - `// SCAFFOLD LOADING EXCEPTION: <reason>` with colon and non-empty reason+ *    (see [ScaffoldLoadingDetector])+ *  - `// SCAFFOLD SEARCH EXCEPTION: <reason>` with colon and non-empty reason+ *    (see [ScaffoldSearchDetector])  *  * A reason may continue on immediately following `//` lines, which the shared  * scaffold/animation markers use for multi-line justifications.@@ -125,6 +129,22 @@ class ExceptionMarkerFormatDetector : Detector(), SourceCodeScanner {             return         } +        if (text.contains(SEARCH_KEYWORD)) {+            if (!text.contains(SEARCH_PREFIX)) {+                report(context, node, file, source, base + text.indexOf(SEARCH_KEYWORD), SEARCH_KEYWORD.length,+                    "Malformed Scaffold Search exception marker: the colon is required and a marker without " ++                        "it does NOT opt the file out. Use `// SCAFFOLD SEARCH EXCEPTION: <reason>`.")+                return+            }+            val reason = reasonAfter(text, SEARCH_PREFIX)+            if (!hasReason(source, comments, index, reason)) {+                report(context, node, file, source, base + text.indexOf(SEARCH_PREFIX), SEARCH_PREFIX.length,+                    "Exception marker without a reason. Append `: <reason>` to " ++                        "`// SCAFFOLD SEARCH EXCEPTION:` so the opt-out stays reviewable.")+            }+            return+        }+         if (text.contains(TOAST_KEYWORD)) {             if (!text.contains(TOAST_PREFIX)) {                 report(context, node, file, source, base + text.indexOf(TOAST_KEYWORD), TOAST_KEYWORD.length,@@ -219,6 +239,8 @@ class ExceptionMarkerFormatDetector : Detector(), SourceCodeScanner {         private const val SCAFFOLD_PREFIX = "// RAW SCAFFOLD EXCEPTION"         private const val LOADING_KEYWORD = "SCAFFOLD LOADING EXCEPTION"         private const val LOADING_PREFIX = "// SCAFFOLD LOADING EXCEPTION:"+        private const val SEARCH_KEYWORD = "SCAFFOLD SEARCH EXCEPTION"+        private const val SEARCH_PREFIX = "// SCAFFOLD SEARCH EXCEPTION:"         private const val TOAST_KEYWORD = "TOAST EXCEPTION"         private const val TOAST_PREFIX = "// TOAST EXCEPTION:"         private const val ANIMATION_KEYWORD = "RAW ANIMATION EXCEPTION"@@ -237,7 +259,9 @@ class ExceptionMarkerFormatDetector : Detector(), SourceCodeScanner {                 (JNI)` verbatim, `// RAW SCAFFOLD EXCEPTION: <reason>`, `// TOAST EXCEPTION: \                 <reason>`, `// RAW ANIMATION EXCEPTION: <reason>`, `// SCAFFOLD LOADING EXCEPTION: <reason>` — each with a non-empty \                 reason (which may continue on following `//` lines), so every opt-out stays \-                reviewable.+                reviewable. Scaffold-owned affordances use \+                `// SCAFFOLD LOADING EXCEPTION: <reason>` and \+                `// SCAFFOLD SEARCH EXCEPTION: <reason>` in the same shape.                 """.trimIndent(),             category = Category.CORRECTNESS,             priority = 6,
lint-rules/src/main/java/com/vayunmathur/lint/ModernAppsIssueRegistry.kt
diff --git a/lint-rules/src/main/java/com/vayunmathur/lint/ModernAppsIssueRegistry.kt b/lint-rules/src/main/java/com/vayunmathur/lint/ModernAppsIssueRegistry.ktindex 979169070f..21e4f38fd8 100644--- a/lint-rules/src/main/java/com/vayunmathur/lint/ModernAppsIssueRegistry.kt+++ b/lint-rules/src/main/java/com/vayunmathur/lint/ModernAppsIssueRegistry.kt@@ -18,6 +18,7 @@ class ModernAppsIssueRegistry : IssueRegistry() {         PackageStructureDetector.ISSUE,         RawScaffoldInAppDetector.ISSUE,         ScaffoldLoadingDetector.ISSUE,+        ScaffoldSearchDetector.ISSUE,         Room2UsageDetector.ISSUE,         WindowInsetsInReusableComponentDetector.ISSUE,         ExceptionMarkerFormatDetector.ISSUE,
lint-rules/src/main/java/com/vayunmathur/lint/ScaffoldSearchDetector.kt
diff --git a/lint-rules/src/main/java/com/vayunmathur/lint/ScaffoldSearchDetector.kt b/lint-rules/src/main/java/com/vayunmathur/lint/ScaffoldSearchDetector.ktnew file mode 100644index 0000000000..cb71c4cd05--- /dev/null+++ b/lint-rules/src/main/java/com/vayunmathur/lint/ScaffoldSearchDetector.kt@@ -0,0 +1,159 @@+package com.vayunmathur.lint++import com.android.tools.lint.detector.api.Category+import com.android.tools.lint.detector.api.Detector+import com.android.tools.lint.detector.api.Implementation+import com.android.tools.lint.detector.api.Issue+import com.android.tools.lint.detector.api.JavaContext+import com.android.tools.lint.detector.api.Scope+import com.android.tools.lint.detector.api.Severity+import com.android.tools.lint.detector.api.SourceCodeScanner+import com.intellij.psi.PsiMethod+import org.jetbrains.kotlin.psi.KtFile+import org.jetbrains.uast.UCallExpression++/**+ * Flags standalone search bars in app UI.+ *+ * Screen-level search is owned by the scaffold: `AppScaffold` (and the+ * wrappers built on it — `DetailScaffold`, `DetailLazyColumn`,+ * `LazyListScaffold`) take a `search: ScaffoldSearch?` parameter and render+ * the shared inline filter field AS the top app bar, in its title slot.+ * Rendering `CommonSearchBar`, `SearchBar`, or `SearchBarInputField`+ * anywhere in app UI — as a content row, a first lazy item, or hand-built+ * into a custom top bar's title slot — is flagged here, as is a raw+ * Material 3 `SearchBar` behind those wrappers.+ *+ * TextField-as-search: a `TextField` / `OutlinedTextField` call is flagged+ * only when it is reliably identifiable as search from its own source —+ * a string literal containing "search", a `R.string.*search*` /+ * `UiR.string.*search*` resource reference, or an `IconSearch` leading+ * icon in the call. Ordinary form fields never match, which is deliberate:+ * an unreliable guess must not break form screens.+ *+ * Scope: app packages only (`com.vayunmathur.*` outside+ * `com.vayunmathur.library.*`). The shared library is exempt: the scaffolds+ * and their field are built there (`ListPage`'s internal search included).+ * TV text fields (`TvTextField`) are a different chrome family and are not+ * flagged.+ *+ * Legitimate non-screen search — a bottom-sheet/drawer-local picker+ * (launcher), a dialog-local filter (a timezone/ingredient picker), an+ * expandable SearchBar whose overlay IS the screen's results surface+ * (photos, youpipe), a map/document/browser overlay with no scaffold —+ * opts out per file with:+ * `// SCAFFOLD SEARCH EXCEPTION: <reason>`.+ */+class ScaffoldSearchDetector : Detector(), SourceCodeScanner {++    override fun getApplicableMethodNames(): List<String> = SEARCH_CALLS.toList()++    override fun visitMethodCall(context: JavaContext, node: UCallExpression, method: PsiMethod) {+        if (!isSearchCall(context, node, method)) return++        val packageName = context.uastFile?.packageName ?: return+        if (!packageName.startsWith(APP_PACKAGE_PREFIX)) return+        if (isLibraryPackage(packageName)) return++        val ktFile = context.uastFile?.sourcePsi as? KtFile+        if (ktFile != null && CommentOnlyMatcher.containsMarkerInComments(ktFile, EXCEPTION_MARKER)) return++        context.report(+            ISSUE,+            node,+            context.getLocation(node),+            "Screen-level search is owned by the scaffold: pass " ++                "`search = ScaffoldSearch(query, onQueryChange, placeholder)` to " ++                "AppScaffold / DetailScaffold / DetailLazyColumn / LazyListScaffold " ++                "instead of rendering `${node.methodName}` in app UI. " ++                "Dialog/sheet/drawer-local filters and expandable overlay search " ++                "that genuinely have no scaffold host use the exception marker " ++                "`$EXCEPTION_MARKER <reason>`.",+        )+    }++    private fun isSearchCall(context: JavaContext, node: UCallExpression, method: PsiMethod): Boolean {+        val name = method.name+        val containing = method.containingClass?.qualifiedName ?: return false+        val inScope = containing.startsWith(LIBRARY_PREFIX) || containing.startsWith(MATERIAL3_PREFIX)+        if (!inScope) return false+        if (name in DIRECT_SEARCH_CALLS) return true+        if (name in TEXT_FIELD_CALLS) return looksLikeSearch(node)+        return false+    }++    /**+     * Reliable search identification for a raw text field, from the call's+     * own source only: a "search" string literal, a `*.string.*search*`+     * resource reference, or a search leading icon.+     */+    private fun looksLikeSearch(node: UCallExpression): Boolean {+        val source = node.asSourceString()+        if (source.contains(ICON_SEARCH)) return true+        if (SEARCH_RESOURCE.containsMatchIn(source)) return true+        return STRING_LITERAL.findAll(source).any { it.groupValues[1].lowercase().contains(SEARCH_WORD) }+    }++    companion object {+        private const val APP_PACKAGE_PREFIX = "com.vayunmathur."+        private const val LIBRARY_PREFIX = "com.vayunmathur.library"+        private const val MATERIAL3_PREFIX = "androidx.compose.material3"+        private const val ICON_SEARCH = "IconSearch"+        private const val SEARCH_WORD = "search"++        const val EXCEPTION_MARKER = "// SCAFFOLD SEARCH EXCEPTION:"++        private val DIRECT_SEARCH_CALLS = setOf(+            "CommonSearchBar",+            "SearchBar",+            "SearchBarInputField",+        )++        private val TEXT_FIELD_CALLS = setOf(+            "TextField",+            "OutlinedTextField",+        )++        private val SEARCH_CALLS = DIRECT_SEARCH_CALLS + TEXT_FIELD_CALLS++        private val SEARCH_RESOURCE = Regex("""\.\s*string\s*\.\s*\w*[Ss]earch\w*""")+        private val STRING_LITERAL = Regex("\"([^\"]*)\"")++        private fun isLibraryPackage(packageName: String): Boolean =+            packageName == LIBRARY_PREFIX || packageName.startsWith("$LIBRARY_PREFIX.")++        val ISSUE: Issue = Issue.create(+            id = "ScaffoldSearch",+            briefDescription = "Standalone search bar in app UI; scaffold owns screen-level search",+            explanation = """+                Screen-level search belongs to the scaffold object. AppScaffold and \+                the shared wrappers built on it (DetailScaffold, DetailLazyColumn, \+                LazyListScaffold) accept a `search: ScaffoldSearch?` parameter and \+                render the shared inline filter field AS the top app bar, in \+                its title slot (title replaced), above the refresh box. Rendering a CommonSearchBar, \+                SearchBar, or SearchBarInputField in app UI is flagged here, \+                wherever it sits — content row, first lazy item, or a custom top \+                bar's title slot. A raw TextField/OutlinedTextField is flagged only \+                when its own source reliably identifies it as search (a "search" \+                string literal, a `*.string.*search*` resource, or an IconSearch \+                leading icon); ordinary form fields are never flagged.++                The shared library modules (com.vayunmathur.library.*) are exempt \+                because the scaffolds and their field are built there. TV text \+                fields are a different chrome family and are not flagged.++                Dialog/sheet/drawer-local filters, expandable overlay search whose \+                overlay is the results surface, and other genuinely non-screen \+                search opt out per file with the marker comment \+                `// SCAFFOLD SEARCH EXCEPTION: <reason>`.+                """.trimIndent(),+            category = Category.CORRECTNESS,+            priority = 6,+            severity = Severity.ERROR,+            implementation = Implementation(+                ScaffoldSearchDetector::class.java,+                Scope.JAVA_FILE_SCOPE,+            ),+        )+    }+}
lint-rules/src/test/java/com/vayunmathur/lint/ScaffoldSearchDetectorTest.kt
diff --git a/lint-rules/src/test/java/com/vayunmathur/lint/ScaffoldSearchDetectorTest.kt b/lint-rules/src/test/java/com/vayunmathur/lint/ScaffoldSearchDetectorTest.ktnew file mode 100644index 0000000000..33e86c44dd--- /dev/null+++ b/lint-rules/src/test/java/com/vayunmathur/lint/ScaffoldSearchDetectorTest.kt@@ -0,0 +1,216 @@+package com.vayunmathur.lint++import com.android.tools.lint.checks.infrastructure.LintDetectorTest+import com.android.tools.lint.checks.infrastructure.TestFile+import com.android.tools.lint.checks.infrastructure.TestFiles.kotlin+import com.android.tools.lint.detector.api.Detector+import com.android.tools.lint.detector.api.Issue+import org.junit.Test+import org.junit.runner.RunWith+import org.junit.runners.JUnit4++@RunWith(JUnit4::class)+class ScaffoldSearchDetectorTest : LintDetectorTest() {++    override fun getDetector(): Detector = ScaffoldSearchDetector()++    override fun getIssues(): List<Issue> = listOf(ScaffoldSearchDetector.ISSUE)++    @Test+    fun commonSearchBarInContentIsFlagged() {+        lint().files(UI_STUBS, COMPOSABLE_STUB, LAYOUT_STUB, kotlin(+            """+            package com.vayunmathur.example.ui+            import androidx.compose.runtime.Composable+            import com.vayunmathur.library.ui.AppScaffold+            import com.vayunmathur.library.ui.CommonSearchBar+            @Composable fun Screen(q: String) {+                AppScaffold(title = "T") {+                    CommonSearchBar(value = q, onValueChange = {})+                }+            }+            """.trimIndent(),+        )).run().expectErrorCount(1)+    }++    @Test+    fun commonSearchBarInCustomTopBarTitleIsFlagged() {+        lint().files(UI_STUBS, COMPOSABLE_STUB, LAYOUT_STUB, kotlin(+            """+            package com.vayunmathur.example.ui+            import androidx.compose.runtime.Composable+            import com.vayunmathur.library.ui.CommonSearchBar+            import com.vayunmathur.library.ui.LazyListScaffold+            import com.vayunmathur.library.ui.TopAppBar+            @Composable fun Screen(q: String) {+                LazyListScaffold(topBar = {+                    TopAppBar(title = { CommonSearchBar(value = q, onValueChange = {}) })+                }) { }+            }+            """.trimIndent(),+        )).run().expectErrorCount(1)+    }++    @Test+    fun scaffoldSearchParameterIsClean() {+        lint().files(UI_STUBS, COMPOSABLE_STUB, LAYOUT_STUB, kotlin(+            """+            package com.vayunmathur.example.ui+            import androidx.compose.runtime.Composable+            import com.vayunmathur.library.ui.AppScaffold+            import com.vayunmathur.library.ui.ScaffoldSearch+            @Composable fun Screen(q: String) {+                AppScaffold(+                    title = "T",+                    search = ScaffoldSearch(query = q, onQueryChange = {}),+                ) { }+            }+            """.trimIndent(),+        )).run().expectClean()+    }++    @Test+    fun rawSearchBarAndInputFieldAreFlagged() {+        lint().files(UI_STUBS, COMPOSABLE_STUB, LAYOUT_STUB, kotlin(+            """+            package com.vayunmathur.example.ui+            import androidx.compose.runtime.Composable+            import com.vayunmathur.library.ui.SearchBar+            import com.vayunmathur.library.ui.SearchBarInputField+            @Composable fun Screen(q: String) {+                SearchBar(inputField = {}, expanded = false, onExpandedChange = {}) { }+                SearchBarInputField(query = q, onQueryChange = {}, onSearch = {}, expanded = false, onExpandedChange = {})+            }+            """.trimIndent(),+        )).run().expectErrorCount(2)+    }++    @Test+    fun searchTextFieldByLiteralIsFlagged() {+        lint().files(UI_STUBS, COMPOSABLE_STUB, LAYOUT_STUB, kotlin(+            """+            package com.vayunmathur.example.ui+            import androidx.compose.runtime.Composable+            import com.vayunmathur.library.ui.OutlinedTextField+            import com.vayunmathur.library.ui.Text+            @Composable fun Screen(q: String) {+                OutlinedTextField(value = q, onValueChange = {}, label = { Text("Search stars") })+            }+            """.trimIndent(),+        )).run().expectErrorCount(1)+    }++    @Test+    fun searchTextFieldByResourceIsFlagged() {+        lint().files(UI_STUBS, COMPOSABLE_STUB, LAYOUT_STUB, kotlin(+            """+            package com.vayunmathur.example.ui+            import androidx.compose.runtime.Composable+            import com.vayunmathur.library.ui.OutlinedTextField+            import com.vayunmathur.library.ui.Text+            @Composable fun Screen(q: String) {+                OutlinedTextField(+                    value = q,+                    onValueChange = {},+                    label = { Text(com.vayunmathur.example.R.string.search_stars) },+                )+            }+            """.trimIndent(),+        )).run().expectErrorCount(1)+    }++    @Test+    fun ordinaryFormFieldIsClean() {+        lint().files(UI_STUBS, COMPOSABLE_STUB, LAYOUT_STUB, kotlin(+            """+            package com.vayunmathur.example.ui+            import androidx.compose.runtime.Composable+            import com.vayunmathur.library.ui.OutlinedTextField+            import com.vayunmathur.library.ui.Text+            @Composable fun Screen(q: String) {+                OutlinedTextField(value = q, onValueChange = {}, label = { Text("Email address") })+            }+            """.trimIndent(),+        )).run().expectClean()+    }++    @Test+    fun exceptionMarkerOptsOut() {+        lint().files(UI_STUBS, COMPOSABLE_STUB, LAYOUT_STUB, kotlin(+            """+            package com.vayunmathur.example.ui+            // SCAFFOLD SEARCH EXCEPTION: dialog-local filter, no scaffold host+            import androidx.compose.runtime.Composable+            import com.vayunmathur.library.ui.CommonSearchBar+            @Composable fun Picker(q: String) {+                CommonSearchBar(value = q, onValueChange = {})+            }+            """.trimIndent(),+        )).run().expectClean()+    }++    @Test+    fun libraryPackageIsExempt() {+        lint().files(UI_STUBS, COMPOSABLE_STUB, LAYOUT_STUB, kotlin(+            """+            package com.vayunmathur.library.ui+            import androidx.compose.runtime.Composable+            @Composable fun Internal(q: String) {+                CommonSearchBar(value = q, onValueChange = {})+            }+            """.trimIndent(),+        )).run().expectClean()+    }++    companion object {+        private val COMPOSABLE_STUB: TestFile = kotlin(+            "src/androidx/compose/runtime/Composable.kt",+            """+            package androidx.compose.runtime+            annotation class Composable+            """.trimIndent(),+        )++        private val LAYOUT_STUB: TestFile = kotlin(+            "src/androidx/compose/foundation/layout/Layout.kt",+            """+            package androidx.compose.foundation.layout+            class PaddingValues+            """.trimIndent(),+        )++        private val R_STUB: TestFile = kotlin(+            "src/com/vayunmathur/example/R.kt",+            """+            package com.vayunmathur.example+            object R { object string { const val search_stars: Int = 1 } }+            """.trimIndent(),+        )++        private val UI_STUBS: TestFile = kotlin(+            "src/com/vayunmathur/library/ui/UiStubs.kt",+            """+            package com.vayunmathur.library.ui+            import androidx.compose.foundation.layout.PaddingValues+            import androidx.compose.runtime.Composable+            class ScaffoldSearch(val query: String, val onQueryChange: (String) -> Unit, val placeholder: String = "Search")+            @Composable fun AppScaffold(+                title: String,+                search: ScaffoldSearch? = null,+                content: @Composable (PaddingValues) -> Unit,+            ) {}+            @Composable fun LazyListScaffold(+                topBar: @Composable () -> Unit = {},+                content: () -> Unit,+            ) {}+            @Composable fun TopAppBar(title: @Composable () -> Unit) {}+            @Composable fun CommonSearchBar(value: String, onValueChange: (String) -> Unit) {}+            @Composable fun SearchBar(inputField: @Composable () -> Unit, expanded: Boolean, onExpandedChange: (Boolean) -> Unit, content: @Composable () -> Unit) {}+            @Composable fun SearchBarInputField(query: String, onQueryChange: (String) -> Unit, onSearch: (String) -> Unit, expanded: Boolean, onExpandedChange: (Boolean) -> Unit) {}+            @Composable fun OutlinedTextField(value: String, onValueChange: (String) -> Unit, label: @Composable () -> Unit) {}+            @Composable fun Text(text: String) {}+            @Composable fun Text(resId: Int) {}+            """.trimIndent(),+        )+    }+}
news/src/main/java/com/vayunmathur/news/domain/NewsCategory.kt
diff --git a/news/src/main/java/com/vayunmathur/news/domain/NewsCategory.kt b/news/src/main/java/com/vayunmathur/news/domain/NewsCategory.ktnew file mode 100644index 0000000000..850f412c71--- /dev/null+++ b/news/src/main/java/com/vayunmathur/news/domain/NewsCategory.kt@@ -0,0 +1,44 @@+package com.vayunmathur.news.domain++/**+ * Feed category taxonomy for the built-in catalog.+ *+ * Decided from the actual 88-source catalog (see [SourceCatalog]), not+ * from a generic news template:+ * - Geographic scope for general-news outlets: [WORLD] (international and+ *   non-US national generalists), [US] (US national generalists), and+ *   [LOCAL] (city/metro/state/regional outlets in any country).+ * - Editorial topic for single-topic verticals: [TECHNOLOGY] and+ *   [SCIENCE] (science includes health/medicine, e.g. STAT).+ *+ * There are deliberately no Business, Politics, Culture, Sport, or+ * Language categories: the catalog has no dedicated outlet for the first+ * four (generalists merely *cover* those sections, so tagging them by+ * section would put almost every source in almost every category and+ * make filtering meaningless), and language is already a separate field+ * ([NewsSource.language]) — it is not conflated with category.+ *+ * Assignment rule (data in [SourceCatalog], no code branches): a+ * single-topic vertical gets its topic; every other outlet gets exactly+ * one geographic category by its scope. A vertical may add one secondary+ * topic tag where that beat is definitional (e.g. Ars Technica also gets+ * [SCIENCE]). The first entry of [NewsSource.categories] is the primary+ * category; any further entries are secondary tags, and an article+ * matches a selected category when the category is among its source's+ * tags.+ *+ * Server `news.json` carries no category field. Articles inherit their+ * category client-side: the server's `source` value is resolved to a+ * catalog id by [ServerFeedParser] (id or exact display name), and the+ * category is then looked up from [SourceCatalog] by that id. The same+ * lookup applies to fallback on-device crawl articles, which are created+ * with a catalog source id directly. An unresolved source id has no+ * categories: it matches "All" only, never a specific category.+ */+enum class NewsCategory(val label: String) {+    WORLD("World"),+    US("US"),+    TECHNOLOGY("Technology"),+    SCIENCE("Science"),+    LOCAL("Local"),+}
news/src/main/java/com/vayunmathur/news/domain/ServerFeedParser.kt
diff --git a/news/src/main/java/com/vayunmathur/news/domain/ServerFeedParser.kt b/news/src/main/java/com/vayunmathur/news/domain/ServerFeedParser.ktindex ebf423db1f..1e01406cbc 100644--- a/news/src/main/java/com/vayunmathur/news/domain/ServerFeedParser.kt+++ b/news/src/main/java/com/vayunmathur/news/domain/ServerFeedParser.kt@@ -31,6 +31,11 @@ import kotlinx.serialization.json.jsonObject  * - `language` is a BCP-47 tag stated per article by the server (its  *   per-article refinement of the source default); when absent it  *   defaults from [SourceCatalog] for the resolved source.+ * - There is no category field. Category is derived client-side only:+ *   the resolved catalog id maps to [NewsSource.categories] in+ *   [SourceCatalog] (see [NewsCategory]), and the feed/search filters+ *   apply that mapping to the article's `sourceId`. Unresolved ids have+ *   no category and match the feed's "All" filter only.  *  * Pure and non-throwing: malformed documents/articles yield an empty or  * partial list, which the repository treats as server-feed failure and
news/src/main/java/com/vayunmathur/news/domain/SourceCatalog.kt
diff --git a/news/src/main/java/com/vayunmathur/news/domain/SourceCatalog.kt b/news/src/main/java/com/vayunmathur/news/domain/SourceCatalog.ktindex b9a80f29aa..761e225e7a 100644--- a/news/src/main/java/com/vayunmathur/news/domain/SourceCatalog.kt+++ b/news/src/main/java/com/vayunmathur/news/domain/SourceCatalog.kt@@ -18,7 +18,16 @@ data class NewsSource(     val badge: String? = null,     /** BCP-47 language of this source's feed (e.g. "en", "de"); default for its articles. */     val language: String = "en",-)+    /**+     * Category tags for feed filtering; the first entry is the primary+     * category. See [NewsCategory] for the taxonomy and assignment rule.+     * Articles inherit these from their source (no server field).+     */+    val categories: List<NewsCategory>,+) {+    /** Primary category (first tag); every source has at least one. */+    val primaryCategory: NewsCategory get() = categories.first()+}  /** Built-in catalog; every URL here was fetched and parsed during development. */ object SourceCatalog {@@ -26,94 +35,155 @@ object SourceCatalog {         NewsSource(             "bbc", "BBC News",             "https://www.bbc.com/sitemaps/https-sitemap-com-news-1.xml", FeedKind.SITEMAP,+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "guardian", "The Guardian",             "https://www.theguardian.com/sitemaps/news.xml", FeedKind.SITEMAP,             badge = "No paywall; article pages refused our datacentre verification IP, " +                 "so full text is verified on-device only.",+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("aljazeera", "Al Jazeera", "https://www.aljazeera.com/news-sitemap.xml", FeedKind.SITEMAP,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("techcrunch", "TechCrunch", "https://techcrunch.com/news-sitemap.xml", FeedKind.SITEMAP,+            categories = listOf(NewsCategory.TECHNOLOGY),+        ),+        NewsSource("propublica", "ProPublica", "https://www.propublica.org/news-sitemap.xml", FeedKind.SITEMAP,+            categories = listOf(NewsCategory.US),         ),-        NewsSource("aljazeera", "Al Jazeera", "https://www.aljazeera.com/news-sitemap.xml", FeedKind.SITEMAP),-        NewsSource("techcrunch", "TechCrunch", "https://techcrunch.com/news-sitemap.xml", FeedKind.SITEMAP),-        NewsSource("propublica", "ProPublica", "https://www.propublica.org/news-sitemap.xml", FeedKind.SITEMAP),         NewsSource(             "elpais", "El País", "https://elpais.com/sitemaps/news.xml", FeedKind.SITEMAP, language = "es",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("npr", "NPR", "https://feeds.npr.org/1001/rss.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.US),+        ),+        NewsSource("dw", "DW", "https://rss.dw.com/xml/rss-en-all", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("ars", "Ars Technica", "https://feeds.arstechnica.com/arstechnica/index", FeedKind.RSS,+            categories = listOf(NewsCategory.TECHNOLOGY, NewsCategory.SCIENCE),+        ),+        NewsSource("verge", "The Verge", "https://www.theverge.com/rss/index.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.TECHNOLOGY),         ),-        NewsSource("npr", "NPR", "https://feeds.npr.org/1001/rss.xml", FeedKind.RSS),-        NewsSource("dw", "DW", "https://rss.dw.com/xml/rss-en-all", FeedKind.RSS),-        NewsSource("ars", "Ars Technica", "https://feeds.arstechnica.com/arstechnica/index", FeedKind.RSS),-        NewsSource("verge", "The Verge", "https://www.theverge.com/rss/index.xml", FeedKind.RSS),         NewsSource(             "hn", "Hacker News", "https://news.ycombinator.com/rss", FeedKind.RSS,             badge = "Links point at third-party sites; reader quality depends on the linked site.",+            categories = listOf(NewsCategory.TECHNOLOGY),         ),         // Second verification round (2026-11-23, same bar as above: feed fetched         // with 200 and parsed; sampled article HTML held the full body).-        NewsSource("tagesschau", "Tagesschau", "https://www.tagesschau.de/newsticker.rdf", FeedKind.RSS, language = "de"),-        NewsSource("nos", "NOS", "https://feeds.nos.nl/nosnieuwsalgemeen", FeedKind.RSS, language = "nl"),-        NewsSource("svt", "SVT Nyheter", "https://www.svt.se/nyheter/rss.xml", FeedKind.RSS, language = "sv"),-        NewsSource("nrk", "NRK", "https://www.nrk.no/toppsaker.rss", FeedKind.RSS, language = "nb"),-        NewsSource("yle", "Yle News", "https://yle.fi/rss/news", FeedKind.RSS),-        NewsSource("rte", "RTÉ News", "https://www.rte.ie/news/rss/news-headlines.xml", FeedKind.RSS),-        NewsSource("cbc", "CBC News", "https://www.cbc.ca/webfeed/rss/rss-topstories", FeedKind.RSS),-        NewsSource("euronews", "Euronews", "https://www.euronews.com/rss", FeedKind.RSS),-        NewsSource("abc-au", "ABC Australia", "https://www.abc.net.au/news/feed/51120/rss.xml", FeedKind.RSS),-        NewsSource("rnz", "RNZ", "https://www.rnz.co.nz/rss/national.xml", FeedKind.RSS),-        NewsSource("cna", "CNA", "https://www.channelnewsasia.com/rssfeeds/8395986", FeedKind.RSS),-        NewsSource("ansa", "ANSA", "https://www.ansa.it/sito/ansait_rss.xml", FeedKind.RSS, language = "it"),-        NewsSource("mee", "Middle East Eye", "https://www.middleeasteye.net/rss.xml", FeedKind.RSS),-        NewsSource("semafor", "Semafor", "https://www.semafor.com/rss.xml", FeedKind.RSS),-        NewsSource("restofworld", "Rest of World", "https://restofworld.org/feed/", FeedKind.RSS),-        NewsSource("africanarguments", "African Arguments", "https://africanarguments.org/feed/", FeedKind.RSS),-        NewsSource("dailymaverick", "Daily Maverick", "https://www.dailymaverick.co.za/dmrss/", FeedKind.RSS),+        NewsSource("tagesschau", "Tagesschau", "https://www.tagesschau.de/newsticker.rdf", FeedKind.RSS, language = "de",+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("nos", "NOS", "https://feeds.nos.nl/nosnieuwsalgemeen", FeedKind.RSS, language = "nl",+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("svt", "SVT Nyheter", "https://www.svt.se/nyheter/rss.xml", FeedKind.RSS, language = "sv",+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("nrk", "NRK", "https://www.nrk.no/toppsaker.rss", FeedKind.RSS, language = "nb",+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("yle", "Yle News", "https://yle.fi/rss/news", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("rte", "RTÉ News", "https://www.rte.ie/news/rss/news-headlines.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("cbc", "CBC News", "https://www.cbc.ca/webfeed/rss/rss-topstories", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("euronews", "Euronews", "https://www.euronews.com/rss", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("abc-au", "ABC Australia", "https://www.abc.net.au/news/feed/51120/rss.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("rnz", "RNZ", "https://www.rnz.co.nz/rss/national.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("cna", "CNA", "https://www.channelnewsasia.com/rssfeeds/8395986", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("ansa", "ANSA", "https://www.ansa.it/sito/ansait_rss.xml", FeedKind.RSS, language = "it",+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("mee", "Middle East Eye", "https://www.middleeasteye.net/rss.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("semafor", "Semafor", "https://www.semafor.com/rss.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD, NewsCategory.US),+        ),+        NewsSource("restofworld", "Rest of World", "https://restofworld.org/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD, NewsCategory.TECHNOLOGY),+        ),+        NewsSource("africanarguments", "African Arguments", "https://africanarguments.org/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("dailymaverick", "Daily Maverick", "https://www.dailymaverick.co.za/dmrss/", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),+        ),         NewsSource(             "buenosairesherald", "Buenos Aires Herald", "https://buenosairesherald.com/feed", FeedKind.RSS,+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "straitstimes", "The Straits Times",             "https://www.straitstimes.com/news/singapore/rss.xml", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "thehindu", "The Hindu",             "https://www.thehindu.com/news/national/feeder/default.rss", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "hindustantimes", "Hindustan Times",             "https://www.hindustantimes.com/feeds/rss/india-news/rssfeed.xml", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "japantimes", "The Japan Times", "https://www.japantimes.co.jp/feed/", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "stat", "STAT", "https://www.statnews.com/feed/", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.SCIENCE),         ),         NewsSource(             "wired", "WIRED", "https://www.wired.com/feed/rss", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.TECHNOLOGY, NewsCategory.SCIENCE),         ),         NewsSource(             "mittech", "MIT Technology Review", "https://www.technologyreview.com/feed/", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.TECHNOLOGY, NewsCategory.SCIENCE),         ),         NewsSource(             "latimes", "Los Angeles Times",             "https://www.latimes.com/california/rss2.0.xml", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         // Third verification round (2026-11-23, same bar: feed fetched 200 and         // parsed; 2-3 sampled article HTML pages held the full body). Emphasis:@@ -126,182 +196,273 @@ object SourceCatalog {             "seattle-times", "Seattle Times", "https://www.seattletimes.com/feed/", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "dallas-morning", "Dallas Morning News",             "https://www.dallasnews.com/sitemap/news/local.xml", FeedKind.SITEMAP,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "houston-chronicle", "Houston Chronicle",             "https://www.houstonchronicle.com/news-sitemap.xml", FeedKind.SITEMAP,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "sf-chronicle", "San Francisco Chronicle",             "https://www.sfchronicle.com/news-sitemap.xml", FeedKind.SITEMAP,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "inquirer", "Philadelphia Inquirer",             "https://www.inquirer.com/arc/outboundfeeds/rss/?outputType=xml", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("gothamist", "Gothamist", "https://gothamist.com/feed", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("laist", "LAist", "https://laist.com/index.atom", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("block-club", "Block Club Chicago", "https://blockclubchicago.org/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("wbez", "WBEZ Chicago", "https://www.wbez.org/rss/index.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("minnpost", "MinnPost", "https://www.minnpost.com/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("mprnews", "MPR News", "https://www.mprnews.org/feed/homepage", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("texas-tribune", "Texas Tribune", "https://www.texastribune.org/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("calmatters", "CalMatters", "https://calmatters.org/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("austin-monitor", "Austin Monitor", "https://www.austinmonitor.com/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),         ),-        NewsSource("gothamist", "Gothamist", "https://gothamist.com/feed", FeedKind.RSS),-        NewsSource("laist", "LAist", "https://laist.com/index.atom", FeedKind.RSS),-        NewsSource("block-club", "Block Club Chicago", "https://blockclubchicago.org/feed/", FeedKind.RSS),-        NewsSource("wbez", "WBEZ Chicago", "https://www.wbez.org/rss/index.xml", FeedKind.RSS),-        NewsSource("minnpost", "MinnPost", "https://www.minnpost.com/feed/", FeedKind.RSS),-        NewsSource("mprnews", "MPR News", "https://www.mprnews.org/feed/homepage", FeedKind.RSS),-        NewsSource("texas-tribune", "Texas Tribune", "https://www.texastribune.org/feed/", FeedKind.RSS),-        NewsSource("calmatters", "CalMatters", "https://calmatters.org/feed/", FeedKind.RSS),-        NewsSource("austin-monitor", "Austin Monitor", "https://www.austinmonitor.com/feed/", FeedKind.RSS),         NewsSource(             "houston-public", "Houston Public Media", "https://www.houstonpublicmedia.org/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("wbur", "WBUR Boston", "https://www.wbur.org/feed", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("kqed", "KQED News", "https://ww2.kqed.org/news/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),         ),-        NewsSource("wbur", "WBUR Boston", "https://www.wbur.org/feed", FeedKind.RSS),-        NewsSource("kqed", "KQED News", "https://ww2.kqed.org/news/feed/", FeedKind.RSS),         NewsSource(             "sltrib", "Salt Lake Tribune",             "https://www.sltrib.com/arc/outboundfeeds/rss/?outputType=xml", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "adn", "Anchorage Daily News",             "https://www.adn.com/arc/outboundfeeds/rss/?outputType=xml", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("civil-beat", "Honolulu Civil Beat", "https://www.civilbeat.org/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("vtdigger", "VTDigger", "https://vtdigger.org/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("the-city", "THE CITY (New York)", "https://www.thecity.nyc/feed/", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),         ),-        NewsSource("civil-beat", "Honolulu Civil Beat", "https://www.civilbeat.org/feed/", FeedKind.RSS),-        NewsSource("vtdigger", "VTDigger", "https://vtdigger.org/feed/", FeedKind.RSS),-        NewsSource("the-city", "THE CITY (New York)", "https://www.thecity.nyc/feed/", FeedKind.RSS),         NewsSource(             "bangor", "Bangor Daily News", "https://www.bangordailynews.com/feed/", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         // International local / regional (English).         NewsSource(             "manchester-evening", "Manchester Evening News",             "https://www.manchestereveningnews.co.uk/rss.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "liverpool-echo", "Liverpool Echo", "https://www.liverpoolecho.co.uk/rss.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("walesonline", "WalesOnline", "https://www.walesonline.co.uk/rss.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),         ),-        NewsSource("walesonline", "WalesOnline", "https://www.walesonline.co.uk/rss.xml", FeedKind.RSS),         NewsSource(             "chroniclelive", "ChronicleLive (Newcastle)", "https://www.chroniclelive.co.uk/rss.xml", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),+        ),+        NewsSource("standard", "Evening Standard (London)", "https://www.standard.co.uk/rss", FeedKind.RSS,+            categories = listOf(NewsCategory.LOCAL),         ),-        NewsSource("standard", "Evening Standard (London)", "https://www.standard.co.uk/rss", FeedKind.RSS),         NewsSource(             "belfast-telegraph", "Belfast Telegraph", "https://www.belfasttelegraph.co.uk/rss", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "thejournal", "The Journal (Ireland)", "https://www.thejournal.ie/feed/", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "vancouver-sun", "Vancouver Sun", "https://vancouversun.com/feed/", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "ottawa-citizen", "Ottawa Citizen", "https://ottawacitizen.com/feed/", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "smh", "Sydney Morning Herald", "https://www.smh.com.au/rss/feed.xml", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "the-age", "The Age (Melbourne)", "https://www.theage.com.au/rss/feed.xml", FeedKind.RSS,             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         // Non-English (language = BCP-47 feed language; articles inherit it).-        NewsSource("eldiario", "elDiario.es", "https://www.eldiario.es/rss", FeedKind.RSS, language = "es"),-        NewsSource("20minutos-es", "20minutos", "https://www.20minutos.es/rss/", FeedKind.RSS, language = "es"),+        NewsSource("eldiario", "elDiario.es", "https://www.eldiario.es/rss", FeedKind.RSS, language = "es",+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("20minutos-es", "20minutos", "https://www.20minutos.es/rss/", FeedKind.RSS, language = "es",+            categories = listOf(NewsCategory.WORLD),+        ),         NewsSource(             "heise", "Heise online", "https://www.heise.de/rss/heise-atom.xml", FeedKind.RSS, language = "de",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.TECHNOLOGY),         ),         NewsSource(             "spiegel", "DER SPIEGEL",             "https://www.spiegel.de/schlagzeilen/rss/0,5291,,00.xml", FeedKind.RSS, language = "de",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "mopo", "Hamburger Morgenpost", "https://www.mopo.de/feed/", FeedKind.RSS, language = "de",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "20minutes-fr", "20 Minutes", "https://www.20minutes.fr/feeds/rss-une.xml", FeedKind.RSS,             language = "fr",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "lefigaro", "Le Figaro", "https://www.lefigaro.fr/rss/figaro_actualites.xml", FeedKind.RSS,             language = "fr",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "ladepeche", "La Dépêche (Toulouse)", "https://www.ladepeche.fr/rss.xml", FeedKind.RSS,             language = "fr",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.LOCAL),         ),         NewsSource(             "observador", "Observador", "https://observador.pt/feed/", FeedKind.RSS, language = "pt",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("g1", "G1 (Globo)", "https://g1.globo.com/rss/g1/", FeedKind.RSS, language = "pt",+            categories = listOf(NewsCategory.WORLD),         ),-        NewsSource("g1", "G1 (Globo)", "https://g1.globo.com/rss/g1/", FeedKind.RSS, language = "pt"),         NewsSource(             "folha", "Folha de S.Paulo",             "https://feeds.folha.uol.com.br/mundo/rss091.xml", FeedKind.RSS, language = "pt",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "corriere", "Corriere della Sera", "https://www.corriere.it/rss/homepage.xml", FeedKind.RSS,             language = "it",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),+        ),+        NewsSource("open-it", "Open (Italy)", "https://www.open.online/feed/", FeedKind.RSS, language = "it",+            categories = listOf(NewsCategory.WORLD),         ),-        NewsSource("open-it", "Open (Italy)", "https://www.open.online/feed/", FeedKind.RSS, language = "it"),         NewsSource(             "vg", "VG", "https://www.vg.no/rss/feed/", FeedKind.RSS, language = "nb",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "aftenposten", "Aftenposten (Oslo)", "https://www.aftenposten.no/rss", FeedKind.RSS, language = "nb",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "aftonbladet", "Aftonbladet",             "https://rss.aftonbladet.se/rss2/small/pages/sections/senastenytt/", FeedKind.RSS, language = "sv",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),         NewsSource(             "iltalehti", "Iltalehti", "https://www.iltalehti.fi/rss/uutiset.xml", FeedKind.RSS, language = "fi",             badge = "Metered: full article text was present in the raw HTML during " +                 "verification; some articles may still truncate.",+            categories = listOf(NewsCategory.WORLD),         ),     )      fun byId(id: String): NewsSource? = sources.firstOrNull { it.id == id }++    /** Category tags for [sourceId]; empty for an id not in the catalog. */+    fun categoriesOf(sourceId: String): List<NewsCategory> = byId(sourceId)?.categories.orEmpty()++    /**+     * Whether an article from [sourceId] belongs to [category]. A null+     * [category] is the feed's "All" filter and matches every source,+     * including unresolved ids; a specific category matches only when it+     * is among the source's catalog tags.+     */+    fun matchesCategory(sourceId: String, category: NewsCategory?): Boolean =+        category == null || category in categoriesOf(sourceId)++    /** Categories present among [sources], in taxonomy order. */+    fun categoriesAmong(sources: List<NewsSource>): List<NewsCategory> =+        NewsCategory.entries.filter { category -> sources.any { category in it.categories } } }++/** [articles] kept to [category] via their sources' catalog tags; null keeps all. */+fun List<FeedArticle>.inCategory(category: NewsCategory?): List<FeedArticle> =+    filter { SourceCatalog.matchesCategory(it.sourceId, category) }
news/src/main/java/com/vayunmathur/news/platform/NewsViewModel.kt
diff --git a/news/src/main/java/com/vayunmathur/news/platform/NewsViewModel.kt b/news/src/main/java/com/vayunmathur/news/platform/NewsViewModel.ktindex 03d29e7b85..0c96db918c 100644--- a/news/src/main/java/com/vayunmathur/news/platform/NewsViewModel.kt+++ b/news/src/main/java/com/vayunmathur/news/platform/NewsViewModel.kt@@ -9,6 +9,7 @@ import com.vayunmathur.news.data.CachedArticle import com.vayunmathur.news.data.NewsPrefs import com.vayunmathur.news.data.NewsRepository import com.vayunmathur.news.domain.ExtractedArticle+import com.vayunmathur.news.domain.NewsCategory import com.vayunmathur.news.domain.SourceCatalog import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted@@ -18,8 +19,14 @@ import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch -/** Feed filtering: "all", a source id, or nothing matches (empty feed). */-const val FILTER_ALL = "all"+/**+ * Feed category filtering: a null category filter is "All" (every+ * enabled source); a non-null [NewsCategory] keeps only articles whose+ * source carries that catalog tag (see [SourceCatalog.matchesCategory]).+ * Categories never enable/disable sources — that stays per-source in+ * [NewsPrefs] via the Sources screen; the category filter only narrows+ * the already-enabled corpus.+ */  /** UI state and actions for feed, reader, sources and saved screens. */ class NewsViewModel(@@ -34,13 +41,31 @@ class NewsViewModel(     private val _refreshFailed = MutableStateFlow(false)     val refreshFailed: StateFlow<Boolean> = _refreshFailed.asStateFlow() -    private val _sourceFilter = MutableStateFlow(FILTER_ALL)-    val sourceFilter: StateFlow<String> = _sourceFilter.asStateFlow()+    private val _categoryFilter = MutableStateFlow<NewsCategory?>(null)+    val categoryFilter: StateFlow<NewsCategory?> = _categoryFilter.asStateFlow()++    val disabledSourceIds: StateFlow<Set<String>> = prefs.disabledSourceIds+        .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptySet())      private val _searchQuery = MutableStateFlow("")     val searchQuery: StateFlow<String> = _searchQuery.asStateFlow()     private val _searchResults = MutableStateFlow<List<CachedArticle>>(emptyList())-    val searchResults: StateFlow<List<CachedArticle>> = _searchResults.asStateFlow()++    /**+     * Search composes with the category filter: the repository search+     * runs over the whole local corpus, and its results are then kept to+     * the selected category (and enabled sources) exactly like the feed.+     * So searching searches *within* the selected category, and changing+     * the category while a query is active re-filters the visible+     * results without a new search.+     */+    val searchResults: StateFlow<List<CachedArticle>> = combine(+        _searchResults, _categoryFilter, disabledSourceIds,+    ) { results, category, disabled ->+        results.filter {+            it.sourceId !in disabled && SourceCatalog.matchesCategory(it.sourceId, category)+        }+    }.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptyList())     private var searchJob: kotlinx.coroutines.Job? = null      /** Debounced on-device search (local corpus only); blank query clears results. */@@ -55,18 +80,15 @@ class NewsViewModel(             kotlinx.coroutines.delay(SEARCH_DEBOUNCE_MS)             val results = runCatching { repository.search(query) }.getOrDefault(emptyList())             if (_searchQuery.value == query) {-                _searchResults.value = results.filter { it.sourceId !in disabledSourceIds.value }+                _searchResults.value = results             }         }     } -    val disabledSourceIds: StateFlow<Set<String>> = prefs.disabledSourceIds-        .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptySet())-     val articles: StateFlow<List<CachedArticle>> = combine(-        repository.articles, _sourceFilter, disabledSourceIds,-    ) { all, filter, disabled ->-        all.filter { it.sourceId !in disabled && (filter == FILTER_ALL || it.sourceId == filter) }+        repository.articles, _categoryFilter, disabledSourceIds,+    ) { all, category, disabled ->+        all.filter { it.sourceId !in disabled && SourceCatalog.matchesCategory(it.sourceId, category) }     }.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptyList())      val bookmarked: StateFlow<List<CachedArticle>> = repository.bookmarked@@ -89,8 +111,9 @@ class NewsViewModel(         refresh()     } -    fun setSourceFilter(filter: String) {-        _sourceFilter.value = filter+    /** Single-select category filter; null is "All". Never enables/disables sources. */+    fun setCategoryFilter(category: NewsCategory?) {+        _categoryFilter.value = category     }      fun refresh() {
news/src/main/java/com/vayunmathur/news/ui/FeedScreen.kt
diff --git a/news/src/main/java/com/vayunmathur/news/ui/FeedScreen.kt b/news/src/main/java/com/vayunmathur/news/ui/FeedScreen.ktindex d5fa6d4dca..73ab9f39d5 100644--- a/news/src/main/java/com/vayunmathur/news/ui/FeedScreen.kt+++ b/news/src/main/java/com/vayunmathur/news/ui/FeedScreen.kt@@ -1,6 +1,7 @@ package com.vayunmathur.news.ui  import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn@@ -13,7 +14,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.CommonSearchBar+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.FilterChip import com.vayunmathur.library.ui.IconBookmark import com.vayunmathur.library.ui.IconButton@@ -21,10 +22,15 @@ import com.vayunmathur.library.ui.IconSettings import com.vayunmathur.library.ui.Text import com.vayunmathur.news.R import com.vayunmathur.news.domain.SourceCatalog-import com.vayunmathur.news.platform.FILTER_ALL import com.vayunmathur.news.platform.NewsViewModel -/** Merged newest-first feed with per-source filter chips and pull-to-refresh. */+/**+ * Merged newest-first feed with category filter chips and pull-to-refresh.+ * The chip row is categories, not sources: chips are the categories of the+ * enabled sources (plus the current selection, so it stays tappable), and+ * per-source enable/disable lives only on the Sources screen. Selecting a+ * category also narrows search results (see NewsViewModel.searchResults).+ */ @Composable fun FeedScreen(     viewModel: NewsViewModel,@@ -35,14 +41,22 @@ fun FeedScreen(     val articles by viewModel.articles.collectAsState()     val isRefreshing by viewModel.isRefreshing.collectAsState()     val refreshFailed by viewModel.refreshFailed.collectAsState()-    val filter by viewModel.sourceFilter.collectAsState()+    val categoryFilter by viewModel.categoryFilter.collectAsState()     val disabled by viewModel.disabledSourceIds.collectAsState()     val searchQuery by viewModel.searchQuery.collectAsState()     val searchResults by viewModel.searchResults.collectAsState()     val searching = searchQuery.isNotBlank()     val shownArticles = if (searching) searchResults else articles     AppScaffold(-        title = stringResource(R.string.feed_title),+        // The search field IS the top app bar (no "News" title): declared+        // through the scaffold's search parameter, which renders the field+        // in the bar's title slot — the ListPage / notes / contacts placement.+        title = "",+        search = ScaffoldSearch(+            query = searchQuery,+            onQueryChange = viewModel::setSearchQuery,+            placeholder = stringResource(R.string.feed_search_placeholder),+        ),         isRefreshing = isRefreshing,         onRefresh = viewModel::refresh,         actions = {@@ -51,25 +65,28 @@ fun FeedScreen(         },     ) { padding ->         Column(modifier = Modifier.fillMaxSize().padding(padding)) {-            CommonSearchBar(-                value = searchQuery,-                onValueChange = viewModel::setSearchQuery,-                placeholder = stringResource(R.string.feed_search_placeholder),-            )             if (!searching) {+            // Category chips (single-select, "All" = no category filter).+            // Categories come from the enabled sources only; the current+            // selection is kept in the row even if its sources were since+            // disabled, so the filter can always be changed back.+            val enabledSources = SourceCatalog.sources.filter { it.id !in disabled }+            val categories = (SourceCatalog.categoriesAmong(enabledSources) ++                listOfNotNull(categoryFilter)).distinct()+                .sortedBy { it.ordinal }             LazyRow(modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp)) {                 item {                     FilterChip(-                        selected = filter == FILTER_ALL,-                        onClick = { viewModel.setSourceFilter(FILTER_ALL) },-                        label = { Text(stringResource(R.string.feed_all_sources)) },+                        selected = categoryFilter == null,+                        onClick = { viewModel.setCategoryFilter(null) },+                        label = { Text(stringResource(R.string.feed_all_categories)) },                     )                 }-                items(SourceCatalog.sources.filter { it.id !in disabled }) { source ->+                items(categories) { category ->                     FilterChip(-                        selected = filter == source.id,-                        onClick = { viewModel.setSourceFilter(source.id) },-                        label = { Text(source.name) },+                        selected = categoryFilter == category,+                        onClick = { viewModel.setCategoryFilter(category) },+                        label = { Text(category.label) },                         modifier = Modifier.padding(start = 8.dp),                     )                 }
news/src/main/res/values/strings.xml
diff --git a/news/src/main/res/values/strings.xml b/news/src/main/res/values/strings.xmlindex 5a52769f57..83fee2302c 100644--- a/news/src/main/res/values/strings.xml+++ b/news/src/main/res/values/strings.xml@@ -4,7 +4,7 @@     <!-- FeedScreen -->     <string name="feed_title">News</string>     <string name="feed_empty">No articles yet. Pull to refresh.</string>-    <string name="feed_all_sources">All</string>+    <string name="feed_all_categories">All</string>     <string name="feed_refresh_failed">Could not refresh all sources; showing the cached feed.</string>     <string name="feed_search_placeholder">Search downloaded news</string>     <string name="feed_search_empty">No downloaded articles match. Search covers titles and articles you have opened.</string>
news/src/test/java/com/vayunmathur/news/domain/SourceCatalogCategoryTest.kt
diff --git a/news/src/test/java/com/vayunmathur/news/domain/SourceCatalogCategoryTest.kt b/news/src/test/java/com/vayunmathur/news/domain/SourceCatalogCategoryTest.ktnew file mode 100644index 0000000000..05780ee064--- /dev/null+++ b/news/src/test/java/com/vayunmathur/news/domain/SourceCatalogCategoryTest.kt@@ -0,0 +1,153 @@+package com.vayunmathur.news.domain++import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertFalse+import kotlin.test.assertTrue++/**+ * Category taxonomy: every catalog source is tagged, articles inherit+ * their source's category, and "All" (null) passes everything through.+ * Server and fallback articles are both [FeedArticle]s keyed by catalog+ * source id (the server parser resolves `source` to that id), so the+ * same [inCategory] mapping covers both paths.+ */+class SourceCatalogCategoryTest {++    @Test fun everyCatalogSourceHasSensibleCategories() {+        assertEquals(88, SourceCatalog.sources.size)+        for (source in SourceCatalog.sources) {+            assertTrue(source.categories.isNotEmpty(), "${source.id} has no category")+            assertEquals(source.categories.distinct(), source.categories, "${source.id} duplicate tags")+            assertEquals(source.categories.first(), source.primaryCategory)+        }+        // Each taxonomy category is the primary category of at least one source.+        for (category in NewsCategory.entries) {+            assertTrue(+                SourceCatalog.sources.any { it.primaryCategory == category },+                "no source primarily in $category",+            )+        }+    }++    @Test fun knownAssignmentsFollowTheScopeAndTopicRule() {+        fun primary(id: String) = SourceCatalog.byId(id)!!.primaryCategory+        // Non-US / US national generalists by scope.+        assertEquals(NewsCategory.WORLD, primary("bbc"))+        assertEquals(NewsCategory.WORLD, primary("elpais"))+        assertEquals(NewsCategory.WORLD, primary("lefigaro"))+        assertEquals(NewsCategory.US, primary("npr"))+        assertEquals(NewsCategory.US, primary("propublica"))+        // Single-topic verticals by topic, whatever their scope/language.+        assertEquals(NewsCategory.TECHNOLOGY, primary("techcrunch"))+        assertEquals(NewsCategory.TECHNOLOGY, primary("heise"))+        assertEquals(NewsCategory.SCIENCE, primary("stat"))+        // City/regional outlets are Local in any country.+        assertEquals(NewsCategory.LOCAL, primary("gothamist"))+        assertEquals(NewsCategory.LOCAL, primary("texas-tribune"))+        assertEquals(NewsCategory.LOCAL, primary("manchester-evening"))+        assertEquals(NewsCategory.LOCAL, primary("the-age"))+        // Secondary tags: definitional second beats only.+        assertTrue(NewsCategory.SCIENCE in SourceCatalog.categoriesOf("ars"))+        assertTrue(NewsCategory.US in SourceCatalog.categoriesOf("semafor"))+    }++    private fun article(sourceId: String, url: String = "https://e/$sourceId") =+        FeedArticle(url = url, sourceId = sourceId, title = "Story $sourceId", publishedAtMillis = 1L)++    @Test fun categoryFilterAppliesSourceMappingToArticles() {+        val articles = listOf(+            article("bbc"), article("techcrunch"), article("ars"),+            article("stat"), article("gothamist"), article("npr"),+        )+        assertEquals(+            listOf("bbc"),+            articles.inCategory(NewsCategory.WORLD).map { it.sourceId },+        )+        assertEquals(+            listOf("techcrunch", "ars"),+            articles.inCategory(NewsCategory.TECHNOLOGY).map { it.sourceId },+        )+        // Secondary tag counts: Ars is Technology-primary but also Science.+        assertEquals(+            listOf("ars", "stat"),+            articles.inCategory(NewsCategory.SCIENCE).map { it.sourceId },+        )+        assertEquals(+            listOf("gothamist"),+            articles.inCategory(NewsCategory.LOCAL).map { it.sourceId },+        )+        assertEquals(+            listOf("npr"),+            articles.inCategory(NewsCategory.US).map { it.sourceId },+        )+    }++    @Test fun serverResolvedAndFallbackArticlesFilterTheSame() {+        // Server path: "BBC News" (display name) resolves to catalog id bbc.+        val server = ServerFeedParser.parse(+            """{"articles":[+                {"title":"Srv World","url":"https://srv/w","source":"BBC News","published_at":1},+                {"title":"Srv Tech","url":"https://srv/t","source":"techcrunch","published_at":2},+                {"title":"Srv Unknown","url":"https://srv/u","source":"not-a-source","published_at":3}+            ]}""",+        )+        // Fallback path: crawl articles are built with the catalog id directly.+        val fallback = listOf(article("bbc", "https://e/fallback-bbc"), article("stat", "https://e/fallback-stat"))+        val combined = server + fallback+       

Diff truncated.