mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 16:30:27 +00:00
refactor: make scroll behavior configurable in ChatArea
Add behavior parameter to scrollChatArea to allow explicit control over scroll animation (smooth vs instant) based on context. Use instant scroll when loading conversations, smooth for user-initiated actions, and none for completion states.
This commit is contained in:
parent
23721246bd
commit
d9e47357ae
2 changed files with 9 additions and 7 deletions
|
|
@ -28,7 +28,7 @@
|
|||
chatContainer.scroll({ top: 0, behavior: "instant" });
|
||||
}
|
||||
|
||||
export function scrollChatArea() {
|
||||
export function scrollChatArea(behavior: ScrollBehavior | undefined) {
|
||||
tick().then(() => {
|
||||
settled = false;
|
||||
|
||||
|
|
@ -57,7 +57,9 @@
|
|||
chatAreaPaddingElement.style.padding = `${Math.max(0, padding / 2)}px`;
|
||||
|
||||
tick().then(() => {
|
||||
chatContainer.scroll({ top: chatContainer.scrollHeight, behavior: "smooth" })
|
||||
if (behavior) {
|
||||
chatContainer.scroll({ top: chatContainer.scrollHeight, behavior: behavior })
|
||||
}
|
||||
tick().then(() => settled = true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
chatService.stop();
|
||||
currentThought = null;
|
||||
isSubmitting = false;
|
||||
chatArea.scrollChatArea();
|
||||
chatArea.scrollChatArea("smooth");
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
await chatService.submit(conversation, editModeActive, currentRequest, {
|
||||
onSubmit: () => {
|
||||
chatArea.scrollChatArea();
|
||||
chatArea.scrollChatArea("smooth");
|
||||
isSubmitting = true;
|
||||
},
|
||||
onStreamingUpdate: (streamingId) => {
|
||||
|
|
@ -123,7 +123,7 @@
|
|||
},
|
||||
onComplete: () => {
|
||||
isSubmitting = false;
|
||||
chatArea.scrollChatArea();
|
||||
chatArea.scrollChatArea(undefined);
|
||||
chatService.updateTokenDisplay(conversation);
|
||||
}
|
||||
});
|
||||
|
|
@ -164,7 +164,7 @@
|
|||
$: if ($conversationStore.conversationToLoad) {
|
||||
conversation.contents = [];
|
||||
chatArea.resetChatArea();
|
||||
|
||||
|
||||
tick().then(() => {
|
||||
if ($conversationStore.conversationToLoad) {
|
||||
const { conversation: loadedConversation, filePath } = $conversationStore.conversationToLoad;
|
||||
|
|
@ -173,7 +173,7 @@
|
|||
chatService.onNameChanged?.(loadedConversation.title);
|
||||
chatService.updateTokenDisplay(loadedConversation);
|
||||
conversationStore.clearLoadFlag();
|
||||
chatArea.scrollChatArea();
|
||||
chatArea.scrollChatArea("instant");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue