From 4f8126d429e12de969124c746c0f3264e0247eac Mon Sep 17 00:00:00 2001 From: PVBLIC Foundation Date: Fri, 20 Jun 2025 08:50:45 -0700 Subject: [PATCH] fix: restore working search functionality in Step 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 **Problem**: Refactoring broke search - showing 'No results' for valid queries 🔧 **Root Cause**: Replaced working on:input handler with reactive statement ⚡ **Solution**: Restored on:input={handleInput} approach **Why the reactive statement failed:** - `$: performSearch(searchQuery)` runs before history prop is ready - Svelte reactive statements execute immediately on component init - History prop from parent may not be available yet, causing search to fail **Why on:input works better:** ✅ Explicit user-triggered execution (only when typing) ✅ Ensures history prop is available when search runs ✅ Cleaner separation of concerns (input vs reactive computations) ✅ Matches existing OpenWebUI patterns **Functionality restored:** - Real-time search through chat messages ✅ - Accurate result counting ✅ - Case-insensitive matching ✅ - Navigation between results ✅ The search now works exactly as it did before the refactoring attempt. --- src/lib/components/chat/Chat.svelte | 1 + src/lib/components/chat/ChatSearch.svelte | 84 ++++++++++++++++++----- 2 files changed, 67 insertions(+), 18 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index b20857dd0..c74459993 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -2237,6 +2237,7 @@ { showChatSearch.set(false); }} diff --git a/src/lib/components/chat/ChatSearch.svelte b/src/lib/components/chat/ChatSearch.svelte index bc83a85ab..3317c33cf 100644 --- a/src/lib/components/chat/ChatSearch.svelte +++ b/src/lib/components/chat/ChatSearch.svelte @@ -1,6 +1,6 @@ {#if show} -
- - {currentResult} of {totalResults}
+ {:else if searchQuery.trim()} +
+ No results +
{/if} @@ -108,6 +155,7 @@ disabled={totalResults === 0} title="Previous (Shift+Enter)" aria-label="Previous result" + on:click={navigateToPrevious} > @@ -117,12 +165,12 @@ disabled={totalResults === 0} title="Next (Enter)" aria-label="Next result" + on:click={navigateToNext} >
-