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
This commit is contained in:
Keegan George 2025-04-07 12:52:23 -07:00 committed by GitHub
parent f9d641dd3a
commit 97d36524cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View File

@ -73,12 +73,12 @@ export default class AiSearchDiscoveries extends Component {
withPluginApi((api) => {
api.addSearchMenuOnKeyDownCallback((searchMenu, event) => {
if (!searchMenu || this.discobotDiscoveries.loadingDiscoveries) {
if (!searchMenu) {
return;
}
if (this.discobotDiscoveries.lastQuery === this.query) {
return false;
return true;
}
if (event.key === "Enter" && this.query) {
@ -158,6 +158,11 @@ export default class AiSearchDiscoveries extends Component {
if (!personas) {
return false;
}
if (this.discobotDiscoveries.discoveryTimedOut) {
return false;
}
const discoverPersona = personas.find(
(persona) =>
persona.id === parseInt(this.siteSettings?.ai_bot_discover_persona, 10)
@ -252,9 +257,12 @@ export default class AiSearchDiscoveries extends Component {
}
timeoutDiscovery() {
if (this.discobotDiscoveries.discovery?.length > 0) {
return;
}
this.discobotDiscoveries.loadingDiscoveries = false;
this.discobotDiscoveries.discovery = "";
this.discobotDiscoveries.discoveryTimedOut = true;
}

View File

@ -21,7 +21,11 @@ export default class DiscobotDiscoveries extends Service {
}
get showDiscoveryTitle() {
return this.discovery.length > 0 || this.loadingDiscoveries;
return (
this.discovery.length > 0 ||
this.loadingDiscoveries ||
this.discoveryTimedOut
);
}
@action