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

Commit 97d3652

Browse files
authored
FIX: search discovery quirks (#1249)
This update fixes a few small quirks with Discobot discoveries: - [X] subsequent searches should work correctly - [X] discovery timeout should maintain UI - [X] key up/down traversal of regular search results should still work
1 parent f9d641d commit 97d3652

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

assets/javascripts/discourse/components/ai-search-discoveries.gjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ export default class AiSearchDiscoveries extends Component {
7373

7474
withPluginApi((api) => {
7575
api.addSearchMenuOnKeyDownCallback((searchMenu, event) => {
76-
if (!searchMenu || this.discobotDiscoveries.loadingDiscoveries) {
76+
if (!searchMenu) {
7777
return;
7878
}
7979

8080
if (this.discobotDiscoveries.lastQuery === this.query) {
81-
return false;
81+
return true;
8282
}
8383

8484
if (event.key === "Enter" && this.query) {
@@ -158,6 +158,11 @@ export default class AiSearchDiscoveries extends Component {
158158
if (!personas) {
159159
return false;
160160
}
161+
162+
if (this.discobotDiscoveries.discoveryTimedOut) {
163+
return false;
164+
}
165+
161166
const discoverPersona = personas.find(
162167
(persona) =>
163168
persona.id === parseInt(this.siteSettings?.ai_bot_discover_persona, 10)
@@ -252,9 +257,12 @@ export default class AiSearchDiscoveries extends Component {
252257
}
253258

254259
timeoutDiscovery() {
260+
if (this.discobotDiscoveries.discovery?.length > 0) {
261+
return;
262+
}
263+
255264
this.discobotDiscoveries.loadingDiscoveries = false;
256265
this.discobotDiscoveries.discovery = "";
257-
258266
this.discobotDiscoveries.discoveryTimedOut = true;
259267
}
260268

assets/javascripts/discourse/services/discobot-discoveries.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ export default class DiscobotDiscoveries extends Service {
2121
}
2222

2323
get showDiscoveryTitle() {
24-
return this.discovery.length > 0 || this.loadingDiscoveries;
24+
return (
25+
this.discovery.length > 0 ||
26+
this.loadingDiscoveries ||
27+
this.discoveryTimedOut
28+
);
2529
}
2630

2731
@action

0 commit comments

Comments
 (0)