Skip to content

Commit 2a702b7

Browse files
committed
fix: Auto-scroll after user action on a message
1 parent f8c1e73 commit 2a702b7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessages.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
interface Props {
1414
class?: string;
1515
messages?: DatabaseMessage[];
16+
onUserAction?: () => void;
1617
}
1718
18-
let { class: className, messages = [] }: Props = $props();
19+
let { class: className, messages = [], onUserAction }: Props = $props();
1920
2021
let allConversationMessages = $state<DatabaseMessage[]>([]);
2122
let lastUpdateTime = $state(0);
@@ -73,11 +74,15 @@
7374
await navigateToSibling(siblingId);
7475
}
7576
async function handleEditWithBranching(message: DatabaseMessage, newContent: string) {
77+
// Enable autoscroll for user-initiated edit action
78+
onUserAction?.();
7679
await editMessageWithBranching(message.id, newContent);
7780
// Refresh after editing to update sibling counts
7881
refreshAllMessages();
7982
}
8083
async function handleRegenerateWithBranching(message: DatabaseMessage) {
84+
// Enable autoscroll for user-initiated regenerate action
85+
onUserAction?.();
8186
await regenerateMessageWithBranching(message.id);
8287
// Refresh after regenerating to update sibling counts
8388
refreshAllMessages();

tools/server/webui/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@
142142
return false;
143143
}
144144
145+
// Enable autoscroll for user-initiated message sending
146+
autoScrollEnabled = true;
145147
await sendMessage(message, extras);
146148
scrollChatToBottom();
147149
@@ -266,7 +268,11 @@
266268
role="main"
267269
aria-label="Chat interface with file drop zone"
268270
>
269-
<ChatMessages class="mb-16 md:mb-24" messages={activeMessages()} />
271+
<ChatMessages
272+
class="mb-16 md:mb-24"
273+
messages={activeMessages()}
274+
onUserAction={() => { autoScrollEnabled = true; }}
275+
/>
270276

271277
<div class="sticky bottom-0 left-0 right-0 mt-auto" in:slide={{ duration: 150, axis: 'y' }}>
272278
<SlotsInfo />

0 commit comments

Comments
 (0)