From 11dcf3bef765d8ab8d18dfdacd0bd0b50d87b0ba Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Tue, 2 Sep 2025 16:23:03 +0200 Subject: [PATCH] search-suggestions: Use narrowed_by_topic for empty search query. Use narrow_state.narrowed_by_topic when getting suggestions for an empty search query to check if the current filter corresponds to a specific channel/topic conversation. This is functionally equivalent to what we have been doing since these suggestions are only added when the search query is empty. For narrows that have a term with a near operator or additional filter terms (is:starred, has:link, etc.), the search query would not be empty when constructing the attacher for the search box suggestions. --- web/src/search_suggestion.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/src/search_suggestion.ts b/web/src/search_suggestion.ts index 3b006fbe4b..f406ec9101 100644 --- a/web/src/search_suggestion.ts +++ b/web/src/search_suggestion.ts @@ -862,7 +862,11 @@ function suggestion_search_string(suggestion_line: SuggestionLine): string { } function suggestions_for_empty_search_query(): SuggestionLine[] { - if (narrow_state.stream_id() && narrow_state.topic() !== undefined) { + // Since the context here is an **empty** search query, we assume + // that there is no `near:` operator. So it's safe to use + // functions like narrowed_by_topic_reply that return false on + // conversation views with `near` or `with` operators. + if (narrow_state.narrowed_by_topic_reply()) { return [ get_default_suggestion_line([ {