From 73759d468545beb24b5a4fd7386bee66278cfcf0 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Tue, 22 Sep 2026 19:21:08 +0000 Subject: [PATCH] chore(settings): derive the search enum-prefix exclusions from the schema (#7308) --- .../settings/search/SettingsSearchCatalog.kt | 33 ++++--------------- .../search/SettingsSearchCatalogTest.kt | 8 +++-- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/search/SettingsSearchCatalog.kt b/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/search/SettingsSearchCatalog.kt index c2555074bc..3852a31740 100644 --- a/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/search/SettingsSearchCatalog.kt +++ b/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/search/SettingsSearchCatalog.kt @@ -17,6 +17,7 @@ package org.meshtastic.feature.settings.search import org.jetbrains.compose.resources.StringResource +import org.meshtastic.core.model.schemaEnumValuePrefixes import org.meshtastic.core.navigation.Route import org.meshtastic.core.navigation.SettingsRoute import org.meshtastic.core.navigation.WifiProvisionRoute @@ -114,34 +115,12 @@ object SettingsSearchCatalog { * Keys that name an enum *value* rather than a field, so search does not offer "Long Fast" as though it were a * setting. Meshtastic-Apple's settings search excludes them the same way (spec 019, FR-004). * - * Hand-listed because nothing in the key's spelling separates `schema_bluetooth_fixed_pin` (a field) from - * `schema_bluetooth_pairingmode_fixed_pin` (a value of one). `SettingsSearchCatalogTest` pins the list against the - * registry. Once the generated enum-label lookup lands this set can be derived from it instead. + * Generated alongside the enum labels, because nothing in a key's spelling separates `schema_bluetooth_fixed_pin` + * (a field) from `schema_bluetooth_pairingmode_fixed_pin` (a value of one). An enum the schema starts or stops + * labelling moves this set on the next sync rather than leaving search filtering on a stale copy. */ - private val enumValuePrefixes: Set = - setOf( - "schema_audio_audio_baud_", - "schema_bluetooth_pairingmode_", - "schema_cannedmessage_inputeventchar_", - "schema_detectionsensor_triggertype_", - "schema_device_rebroadcastmode_", - "schema_device_role_", - "schema_display_compassorientation_", - "schema_display_displaymode_", - "schema_display_displayunits_", - "schema_display_oledtype_", - "schema_lora_modempreset_", - "schema_lora_regioncode_", - "schema_memberrole_", - "schema_network_addressmode_", - "schema_network_protocolflags_", - "schema_position_gpsmode_", - "schema_position_positionflags_", - "schema_security_packetsignaturepolicy_", - "schema_serial_serial_baud_", - "schema_serial_serial_mode_", - "schema_team_", - ) + private val enumValuePrefixes: Set + get() = schemaEnumValuePrefixes /** The settings destinations themselves, so a query for a screen's own name finds it. */ private fun screenEntries(): List = ( diff --git a/feature/settings/src/commonTest/kotlin/org/meshtastic/feature/settings/search/SettingsSearchCatalogTest.kt b/feature/settings/src/commonTest/kotlin/org/meshtastic/feature/settings/search/SettingsSearchCatalogTest.kt index 5790c9083e..0b64028062 100644 --- a/feature/settings/src/commonTest/kotlin/org/meshtastic/feature/settings/search/SettingsSearchCatalogTest.kt +++ b/feature/settings/src/commonTest/kotlin/org/meshtastic/feature/settings/search/SettingsSearchCatalogTest.kt @@ -51,6 +51,10 @@ class SettingsSearchCatalogTest { ) } + /** + * The generated set is pinned against the registry upstream; this checks the other half, that every prefix in it + * reaches a resource this module can actually see, which is what the index filters on. + */ @Test fun everyDeclaredEnumStillHasValuesInTheSchema() { val stale = @@ -61,8 +65,8 @@ class SettingsSearchCatalogTest { assertEquals( emptyList(), stale.sorted(), - "these enums no longer carry labelled values, so excluding them from search does nothing. " + - "Drop them from enumValuePrefixes.", + "these enum prefixes match no string resource, so the index is filtering on something that is not there. " + + "The generated set and schema_strings.xml have diverged; re-run :schema-strings:sync.", ) }