diff --git a/apps/manacore/apps/web/src/routes/(app)/llm-test/+page.svelte b/apps/manacore/apps/web/src/routes/(app)/llm-test/+page.svelte index cc866cd7b..fd3362c54 100644 --- a/apps/manacore/apps/web/src/routes/(app)/llm-test/+page.svelte +++ b/apps/manacore/apps/web/src/routes/(app)/llm-test/+page.svelte @@ -5,7 +5,6 @@ unloadLocalLlm, isLocalLlmSupported, generate, - generateText, extractJson, classify, MODELS, @@ -24,6 +23,7 @@ let userInput = $state(''); let messages: { role: 'user' | 'assistant'; content: string }[] = $state([]); let streamingContent = $state(''); + let chatContainer: HTMLDivElement | undefined = $state(); let isGenerating = $state(false); let lastLatency = $state(null); let lastTokens = $state<{ prompt: number; completion: number } | null>(null); @@ -50,7 +50,7 @@ status.current.state === 'checking' ); let progress = $derived(status.current.state === 'downloading' ? status.current.progress : null); - let statusText = $derived(() => { + let statusText = $derived.by(() => { const s = status.current; switch (s.state) { case 'idle': @@ -72,6 +72,15 @@ let modelInfo = $derived(MODELS[selectedModel]); + // Auto-scroll chat to bottom on new messages/streaming + $effect(() => { + messages.length; + streamingContent; + if (chatContainer) { + chatContainer.scrollTop = chatContainer.scrollHeight; + } + }); + // --- Actions --- async function handleLoad() { await loadLocalLlm(selectedModel); @@ -258,7 +267,7 @@ ? 'bg-red-500' : 'bg-muted-foreground/30'}" > - {statusText()} + {statusText} @@ -300,7 +309,10 @@ /> -
+
{#if messages.length === 0 && !streamingContent}