Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 327adbd

Browse files
authored
UX: Full page search -- always show tooltip & add msg (#1051)
1 parent 749af40 commit 327adbd

File tree

4 files changed

+34
-26
lines changed

4 files changed

+34
-26
lines changed

assets/javascripts/discourse/components/ai-full-page-search.gjs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { SEARCH_TYPE_DEFAULT } from "discourse/controllers/full-page-search";
99
import { ajax } from "discourse/lib/ajax";
1010
import { isValidSearchTerm, translateResults } from "discourse/lib/search";
1111
import icon from "discourse-common/helpers/d-icon";
12-
import I18n, { i18n } from "discourse-i18n";
12+
import { i18n } from "discourse-i18n";
1313
import DTooltip from "float-kit/components/d-tooltip";
1414
import AiIndicatorWave from "./ai-indicator-wave";
1515

@@ -64,26 +64,26 @@ export default class AiFullPageSearch extends Component {
6464

6565
get searchStateText() {
6666
if (!this.validSearchOrder) {
67-
return I18n.t(
67+
return i18n(
6868
"discourse_ai.embeddings.semantic_search_results.unavailable"
6969
);
7070
}
7171

7272
// Search loading:
7373
if (this.searching) {
74-
return I18n.t("discourse_ai.embeddings.semantic_search_loading");
74+
return i18n("discourse_ai.embeddings.semantic_search_loading");
7575
}
7676

7777
// We have results and we are showing them
7878
if (this.AiResults.length && this.showingAiResults) {
79-
return I18n.t("discourse_ai.embeddings.semantic_search_results.toggle", {
79+
return i18n("discourse_ai.embeddings.semantic_search_results.toggle", {
8080
count: this.AiResults.length,
8181
});
8282
}
8383

8484
// We have results but are hiding them
8585
if (this.AiResults.length && !this.showingAiResults) {
86-
return I18n.t(
86+
return i18n(
8787
"discourse_ai.embeddings.semantic_search_results.toggle_hidden",
8888
{
8989
count: this.AiResults.length,
@@ -96,12 +96,12 @@ export default class AiFullPageSearch extends Component {
9696
this.AiResults.length === 0 &&
9797
this.searchTerm !== this.initialSearchTerm
9898
) {
99-
return I18n.t("discourse_ai.embeddings.semantic_search_results.new");
99+
return i18n("discourse_ai.embeddings.semantic_search_results.new");
100100
}
101101

102102
// No results:
103103
if (this.AiResults.length === 0) {
104-
return I18n.t("discourse_ai.embeddings.semantic_search_results.none");
104+
return i18n("discourse_ai.embeddings.semantic_search_results.none");
105105
}
106106
}
107107

@@ -121,6 +121,14 @@ export default class AiFullPageSearch extends Component {
121121
);
122122
}
123123

124+
get tooltipText() {
125+
return i18n(
126+
`discourse_ai.embeddings.semantic_search_tooltips.${
127+
this.validSearchOrder ? "results_explanation" : "invalid_sort"
128+
}`
129+
);
130+
}
131+
124132
@action
125133
toggleAiResults() {
126134
if (this.showingAiResults) {
@@ -201,22 +209,17 @@ export default class AiFullPageSearch extends Component {
201209
<AiIndicatorWave @loading={{this.searching}} />
202210
{{/if}}
203211

204-
{{#unless this.validSearchOrder}}
205-
206-
<DTooltip
207-
@identifier="semantic-search-unavailable-tooltip"
208-
class="semantic-search__unavailable-tooltip"
209-
>
210-
<:trigger>
211-
{{icon "far-circle-question"}}
212-
</:trigger>
213-
<:content>
214-
{{i18n
215-
"discourse_ai.embeddings.semantic_search_unavailable_tooltip"
216-
}}
217-
</:content>
218-
</DTooltip>
219-
{{/unless}}
212+
<DTooltip
213+
@identifier="semantic-search-tooltip"
214+
class="semantic-search__tooltip"
215+
>
216+
<:trigger>
217+
{{icon "far-circle-question"}}
218+
</:trigger>
219+
<:content>
220+
{{this.tooltipText}}
221+
</:content>
222+
</DTooltip>
220223
</div>
221224
</div>
222225
</div>

assets/javascripts/discourse/connectors/full-page-search-below-search-header/ai-full-page-search.gjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import Component from "@glimmer/component";
2-
import AiSemanticSearch from "../../components/ai-full-page-search";
2+
import AiFullPageSearch from "../../components/ai-full-page-search";
33

44
export default class AiFullPageSearchConnector extends Component {
55
static shouldRender(_args, { siteSettings }) {
66
return siteSettings.ai_embeddings_semantic_search_enabled;
77
}
88

99
<template>
10-
<AiSemanticSearch
10+
<AiFullPageSearch
1111
@sortOrder={{@outletArgs.sortOrder}}
1212
@searchTerm={{@outletArgs.search}}
1313
@searchType={{@outletArgs.type}}

assets/stylesheets/modules/embeddings/common/semantic-search.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
margin-left: 8px;
3030
}
3131

32-
&__unavailable-tooltip {
32+
&__tooltip {
3333
margin-left: 4px;
34+
font-size: var(--font-down-1);
3435
}
3536
}
3637

config/locales/client.en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,10 @@ en:
486486
none: "Sorry, our AI search found no matching topics"
487487
new: "Press 'search' to begin looking for new results with AI"
488488
unavailable: "AI results unavailable"
489+
semantic_search_tooltips:
490+
results_explanation: "When enabled, additional AI search results will be added below."
491+
invalid_sort: "Search results must be sorted by Relevance to display AI results"
492+
semantic_search_unavailable_tooltip:
489493
semantic_search_unavailable_tooltip: "Search results must be sorted by Relevance to display AI results"
490494
ai_generated_result: "Search result found using AI"
491495
quick_search:

0 commit comments

Comments
 (0)