mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
Bind chatContainer to ChatArea component and implement scrollToBottom functionality
This commit is contained in:
parent
dbe9068b0b
commit
854aa2a98d
2 changed files with 19 additions and 2 deletions
|
|
@ -5,10 +5,10 @@
|
|||
import ChatAreaThought from "./ChatAreaThought.svelte";
|
||||
|
||||
export let messages: Array<{id: string, content: string, isUser: boolean, isStreaming: boolean}> = [];
|
||||
export let chatContainer: HTMLDivElement;
|
||||
|
||||
let streamingMarkdownService: StreamingMarkdownService = Resolve(Services.StreamingMarkdownService);
|
||||
|
||||
let chatContainer: HTMLDivElement;
|
||||
let messageElements = new Map<string, HTMLElement>();
|
||||
let lastProcessedContent = new Map<string, string>();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,15 +5,18 @@
|
|||
import { Services } from "Services/Services";
|
||||
import ChatArea from "./ChatArea.svelte";
|
||||
import type { IAIClass } from "AIClasses/IAIClass";
|
||||
import { tick } from "svelte";
|
||||
|
||||
let ai: IAIClass = Resolve(Services.IAIClass);
|
||||
let actioner: IActioner = Resolve(Services.IActioner);
|
||||
|
||||
let semaphore: Semaphore = new Semaphore(1, false);
|
||||
let textareaElement: HTMLTextAreaElement;
|
||||
let chatContainer: HTMLDivElement;
|
||||
|
||||
let userRequest = "";
|
||||
let isSubmitting = false;
|
||||
let userHasScrolled = false;
|
||||
let messages: Array<{
|
||||
id: string,
|
||||
content: string,
|
||||
|
|
@ -45,6 +48,9 @@
|
|||
isStreaming: true
|
||||
}];
|
||||
|
||||
scrollToBottom();
|
||||
userHasScrolled = false;
|
||||
|
||||
try {
|
||||
// Create AI message placeholder
|
||||
const aiMessageId = `ai-${Date.now()}`;
|
||||
|
|
@ -112,11 +118,22 @@
|
|||
textareaElement.style.height = textareaElement.scrollHeight + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
function scrollToBottom() {
|
||||
tick().then(() => {
|
||||
if (chatContainer) {
|
||||
chatContainer.scroll({
|
||||
top: chatContainer.scrollHeight,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<main class="container">
|
||||
<div id="chat-container">
|
||||
<ChatArea bind:messages />
|
||||
<ChatArea bind:messages bind:chatContainer={chatContainer}/>
|
||||
</div>
|
||||
|
||||
<div id="input-container">
|
||||
|
|
|
|||
Loading…
Reference in a new issue