Download tools/ui/src/lib/hooks/use-settings-navigation.svelte.ts from Brunobkr/llama.cpp_AlgMor24_github: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github/resolve/main/tools/ui/src/lib/hooks/use-settings-navigation.svelte.ts
- Command line
-
hf download hf://datasets/Brunobkr/llama.cpp_AlgMor24_github/tools/ui/src/lib/hooks/use-settings-navigation.svelte.ts
-
curl -L -o use-settings-navigation.svelte.ts https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github/resolve/main/tools/ui/src/lib/hooks/use-settings-navigation.svelte.ts
1.1 kB
| import { beforeNavigate } from '$app/navigation'; | |
| import { page } from '$app/state'; | |
| import { ROUTES } from '$lib/constants/routes'; | |
| import { settingsReferrer } from '$lib/stores/settings-referrer.svelte'; | |
| export interface ChatSettings { | |
| reset: () => void; | |
| } | |
| export function useSettingsNavigation() { | |
| const subroute = $state({ | |
| activePanel: 'chat' as 'chat' | 'settings' | 'mcp', | |
| chatSettingsRef: undefined as ChatSettings | undefined | |
| }); | |
| const isSettingsRoute = $derived(!!page.route.id?.startsWith('/settings')); | |
| beforeNavigate(({ from, to }) => { | |
| if (to?.route?.id?.startsWith('/settings') && !from?.route?.id?.startsWith('/settings')) { | |
| settingsReferrer.url = window.location.hash || ROUTES.START; | |
| } | |
| }); | |
| $effect(() => { | |
| if (subroute.activePanel === 'settings' && subroute.chatSettingsRef) { | |
| subroute.chatSettingsRef.reset(); | |
| } | |
| }); | |
| // Return to chat when navigating to a new route | |
| $effect(() => { | |
| void page.url; | |
| subroute.activePanel = 'chat'; | |
| }); | |
| return { | |
| get isSettingsRoute() { | |
| return isSettingsRoute; | |
| }, | |
| get panel() { | |
| return subroute; | |
| } | |
| }; | |
| } | |