'use client' import type { UIMessage } from '@/lib/types/ai' import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './ui/tooltip' interface Section { id: string userMessage: UIMessage } interface MessageNavigationDotsProps { sections: Section[] } function getUserMessagePreview(message: UIMessage): string { for (const part of message.parts ?? []) { if (part.type === 'text' && part.text) { const text = part.text.trim() return text.length > 20 ? `${text.slice(0, 20)}…` : text } } return '' } export function MessageNavigationDots({ sections }: MessageNavigationDotsProps) { const visibleSections = sections.slice(-4) const handleClick = (sectionId: string) => { const el = document.getElementById(`section-${sectionId}`) el?.scrollIntoView({ behavior: 'smooth', block: 'start' }) } return (
{visibleSections.map(section => { const preview = getUserMessagePreview(section.userMessage) return ( {preview && ( {preview} )} ) })}
) }