From 6e006bafd0d7413d878f7aa30ceb5fce41072593 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 9 Jun 2026 23:53:29 +0200 Subject: [PATCH] fix(typeahead): surface search failures instead of an empty dropdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The document picker parsed the response without checking r.ok, so a 401/500 rendered identically to 'no matches' and the dropdown silently vanished — which is how the broken relevance path shipped invisibly. The fetch now throws on non-OK, the useTypeahead hook exposes an error flag, and the picker renders a visible failure message (de/en/es). Co-Authored-By: Claude Fable 5 --- frontend/messages/de.json | 1 + frontend/messages/en.json | 1 + frontend/messages/es.json | 1 + .../document/DocumentPickerDropdown.svelte | 4 ++- .../DocumentPickerDropdown.svelte.spec.ts | 22 +++++++++++++++ .../src/lib/document/documentTypeahead.ts | 7 ++++- .../shared/hooks/useTypeahead.svelte.test.ts | 28 +++++++++++++++++++ .../lib/shared/hooks/useTypeahead.svelte.ts | 6 ++++ 8 files changed, 68 insertions(+), 2 deletions(-) diff --git a/frontend/messages/de.json b/frontend/messages/de.json index 704425d5..7969df2a 100644 --- a/frontend/messages/de.json +++ b/frontend/messages/de.json @@ -301,6 +301,7 @@ "comp_multiselect_placeholder": "Namen tippen...", "comp_multiselect_remove": "Entfernen", "comp_multiselect_loading": "Suche...", + "comp_typeahead_error": "Suche fehlgeschlagen. Bitte versuchen Sie es erneut.", "comp_taginput_placeholder_create": "Schlagworte hinzufügen...", "comp_taginput_placeholder_filter": "Nach Schlagworten filtern...", "comp_taginput_remove": "Schlagwort entfernen", diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 24856bd1..b45711e6 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -301,6 +301,7 @@ "comp_multiselect_placeholder": "Type a name...", "comp_multiselect_remove": "Remove", "comp_multiselect_loading": "Searching...", + "comp_typeahead_error": "Search failed. Please try again.", "comp_taginput_placeholder_create": "Add tags...", "comp_taginput_placeholder_filter": "Filter by tags...", "comp_taginput_remove": "Remove tag", diff --git a/frontend/messages/es.json b/frontend/messages/es.json index 74b45118..9821ad93 100644 --- a/frontend/messages/es.json +++ b/frontend/messages/es.json @@ -301,6 +301,7 @@ "comp_multiselect_placeholder": "Escriba un nombre...", "comp_multiselect_remove": "Eliminar", "comp_multiselect_loading": "Buscando...", + "comp_typeahead_error": "La búsqueda falló. Inténtelo de nuevo.", "comp_taginput_placeholder_create": "Añadir etiquetas...", "comp_taginput_placeholder_filter": "Filtrar por etiquetas...", "comp_taginput_remove": "Eliminar etiqueta", diff --git a/frontend/src/lib/document/DocumentPickerDropdown.svelte b/frontend/src/lib/document/DocumentPickerDropdown.svelte index e7d30706..951f79b9 100644 --- a/frontend/src/lib/document/DocumentPickerDropdown.svelte +++ b/frontend/src/lib/document/DocumentPickerDropdown.svelte @@ -62,13 +62,15 @@ function handleSelect(doc: DocumentOption) { class="block w-full rounded border border-line bg-surface px-3 py-2 text-sm text-ink placeholder:text-ink-3 focus:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring" /> - {#if picker.isOpen && (picker.results.length > 0 || picker.loading)} + {#if picker.isOpen && (picker.results.length > 0 || picker.loading || picker.error)}