fix(desktop): revert relay debounce to 300ms, separate 1s history save

- Relay query debounce stays at 300ms (AdvancedSearchBarState default)
- Separate 1s debounce on searchText: when user stops typing for 1s,
  save the query to SearchHistoryStore (assumes intent confirmed)
- LaunchedEffect(searchText.text) auto-cancels on each keystroke,
  so only fires after 1s of inactivity
- No duplicates: addToHistory() deduplicates by serialized query

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
nrobi144
2026-05-29 07:02:51 +03:00
co-authored by Claude Opus 4.6
parent 956eee67d7
commit 971d20be77
@@ -828,7 +828,7 @@ private fun FeedTabsHeader(
val pinnedFeeds by feedRepo.pinnedFeeds.collectAsState()
val sidePadding = LocalReadingSidePadding.current
val scope = rememberCoroutineScope()
val searchState = remember { AdvancedSearchBarState(scope, debounceMs = 1000L) }
val searchState = remember { AdvancedSearchBarState(scope) }
var searchText by remember { mutableStateOf(TextFieldValue("")) }
val focusRequester = remember { FocusRequester() }
val focusManager = LocalFocusManager.current
@@ -841,13 +841,20 @@ private fun FeedTabsHeader(
searchState.updateFromText(searchText.text)
}
// Save to history + clear on collapse
LaunchedEffect(searchExpanded) {
if (!searchExpanded) {
// Auto-save to history after 1s of no typing (separate from relay debounce)
LaunchedEffect(searchText.text) {
if (searchText.text.isNotBlank()) {
kotlinx.coroutines.delay(1000L)
val query = searchState.query.value
if (!query.isEmpty) {
SearchHistoryStore.addToHistory(query)
}
}
}
// Clear on collapse
LaunchedEffect(searchExpanded) {
if (!searchExpanded) {
searchText = TextFieldValue("")
searchState.clearSearch()
}