char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
f1357e499
char/aliceai-t5-moe
1< script lang ="ts "> 2import { browser } from '$app/environment' ; 3import { goto } from '$app/navigation' ; 4import { page } from '$app/state' ; 5import { SearchInput , SidebarNavigationSearchResults } from '$lib/components/app' ; 6import { ROUTES } from '$lib/constants' ; 7import { RouterService } from '$lib/services/router.service' ; 8import { chatStore , conversationsStore , deviceStore } from '$lib/stores' ; 9 10let searchQuery = $state ( '' ); 11let searchInputRef = $state < HTMLInputElement | null >( null ); 12 13let currentChatId = $derived ( page . params . id ); 14 15let filteredConversations = $derived . by (() => { 16const query = searchQuery . trim (). toLowerCase (); 17 18if ( query . length === 0 ) return []; 19 20return conversationsStore . conversations . filter (( c ) => c . name . toLowerCase (). includes ( query )); 21}); 22 23// Search page is intended for mobile; on desktop the sidebar already exposes 24// in-place search, so bounce back to a new-chat tab without a history entry. 25$effect (() => { 26if ( browser && ! deviceStore . isMobile ) { 27goto ( ROUTES . START , { replaceState :true }); 28} 29}); 30 31async function selectConversation ( id :string ) { 32await goto ( RouterService . chat ( id )); 33} 34 35async function handleEditConversation ( id :string ) { 36const conversation = conversationsStore . conversations . find (( c ) => c . id === id ); 37 38if ( ! conversation ) return ; 39 40const newName = window . prompt ( 'Rename conversation' , conversation . name ); 41 42if ( newName && newName . trim ()) { 43await conversationsStore . updateConversationName ( id , newName . trim ()); 44} 45} 46 47async function handleDeleteConversation ( id :string ) { 48const conversation = conversationsStore . conversations . find (( c ) => c . id === id ); 49 50if ( ! conversation ) return ; 51 52const confirmed = window . confirm ( 53`Delete " ${ conversation . name } "? This action cannot be undone.` 54); 55 56if ( ! confirmed ) return ; 57 58await conversationsStore . deleteConversation ( id , { deleteWithForks :false }); 59} 60 61function handleStopGeneration ( id :string ) { 62chatStore . stopGenerationForChat ( id ); 63} 64 65function handleBack () { 66if ( history . length > 1 ) { 67history . back (); 68} else { 69conversationsStore . openNewChat (); 70} 71} 72</ script > 73 74< svelte:head > 75< title > Search · llama.cpp</ title > 76</ svelte:head > 77 78< div class ="fixed top-0 z-10 left-0 right-0 p-2 "> 79< SearchInput 80bind:ref ={ searchInputRef } 81bind:value ={ searchQuery } 82autofocus 83onClose ={ handleBack } 84placeholder ="Search conversations... " 85/> 86</ div > 87 88< div class ="p-2 pt-16 "> 89< SidebarNavigationSearchResults 90{ currentChatId } 91{ filteredConversations } 92onDelete ={ handleDeleteConversation } 93onEdit ={ handleEditConversation } 94onSelect ={ selectConversation } 95onStop ={ handleStopGeneration } 96{ searchQuery } 97/> 98</ div >