import type {Ref} from 'vue';
import {nextTick} from 'vue';

export function useAiChatScroll(containerRef: Ref<HTMLElement | undefined>) {
  async function scrollToBottom() {
    await nextTick();
    const container = containerRef.value;
    if (!container) return;
    container.scrollTop = container.scrollHeight;
  }

  return { scrollToBottom };
}
