Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/client/src/components/hermes/chat/VirtualMessageList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ const props = withDefaults(defineProps<{
rowGap?: number;
padding?: string;
topThreshold?: number;
autoScroll?: boolean;
autoScrollThreshold?: number;
}>(), {
estimatedItemHeight: 180,
overscan: 8,
rowGap: 16,
padding: "20px",
topThreshold: 120,
autoScroll: true,
autoScrollThreshold: 200,
});

const emit = defineEmits<{
Expand Down Expand Up @@ -361,9 +365,18 @@ onBeforeUnmount(() => {
resizeObserver?.disconnect();
});

watch(messageKeys, () => {
watch(messageKeys, (newKeys, oldKeys) => {
cancelAnchorAlignment();
nextTick(syncViewport);
nextTick(() => {
syncViewport();
// Auto-scroll to bottom when new messages are added and autoScroll is enabled
if (props.autoScroll && oldKeys && newKeys.length > oldKeys.length) {
// Only auto-scroll if the user was already near the bottom
if (isNearBottom(props.autoScrollThreshold)) {
scrollToBottom({ frames: 3, keepAliveMs: 1000 });
}
}
});
});

defineExpose({
Expand Down