given my code here, how do i position the annotation box to the right- onlevel with the…
- User
given my code here, how do i position the annotation box to the right- onlevel with the user highlight? import { usePreviousDistinct } from '@react-hookz/web'; import { forwardRef, useEffect, useState, useRef } from 'react'; import { useLongPress } from 'react-aria';
import { Avatar } from '@/components/Avatar'; import IconButton from '@/components/IconButton'; import { LongPressMenu } from '@/components/LongPressMenu'; import { MessageContent } from '@/components/MessageContent'; import { Button, CopyToClipboardButton, CopyToClipboardIconButton, Icon, Markdown, Tooltip, } from '@/components/Shared'; import { ToolEvents } from '@/components/ToolEvents'; import { ReservedClasses } from '@/constants'; import { Breakpoint, useBreakpoint } from '@/hooks/breakpoint'; import { getMessageRowId } from '@/hooks/citations'; import { useCitationsStore } from '@/stores'; import { type ChatMessage, isAbortedMessage, isErroredMessage, isFulfilledMessage, isFulfilledOrTypingMessage, isFulfilledOrTypingMessageWithCitations, isUserMessage, } from '@/types/message'; import { cn } from '@/utils';
import { STYLE_LEVEL_TO_CLASSES } from '@/components/Shared';
type Props = { isLast: boolean; message: ChatMessage; delay?: boolean; className?: string; onCopy?: VoidFunction; onRetry?: VoidFunction; };
/**
- Renders a single message row from the user or from our models. */ const MessageRow = forwardRef<HTMLDivElement, Props>(function MessageRowInternal( { message, delay = false, isLast, className = '', onCopy, onRetry }, ref ) { const breakpoint = useBreakpoint();
const [isShowing, setIsShowing] = useState(false); const [isLongPressMenuOpen, setIsLongPressMenuOpen] = useState(false); const [isStepsExpanded, setIsStepsExpanded] = useState(isLast); const { citations: { selectedCitation, hoveredGenerationId }, hoverCitation, } = useCitationsStore(); const hasSteps = (isFulfilledOrTypingMessage(message) || isErroredMessage(message) || isAbortedMessage(message)) && !!message.toolEvents && message.toolEvents.length > 0;
const getMessageText = () => { if (isFulfilledMessage(message)) { return message.originalText; }
codereturn message.text;};
const enableLongPress = (isFulfilledMessage(message) || isUserMessage(message)) && breakpoint === Breakpoint.sm; const { longPressProps } = useLongPress({ onLongPress: () => setIsLongPressMenuOpen(true), });
// Delay the appearance of the message to make it feel more natural. useEffect(() => { if (delay) { setTimeout(() => setIsShowing(true), 300); } }, []);
useEffect(() => { if (isLast) { setIsStepsExpanded(true); } }, [isLast]);
const [highlightMessage, setHighlightMessage] = useState(false); const prevSelectedCitationGenId = usePreviousDistinct(selectedCitation?.generationId);
useEffect(() => { if (isFulfilledOrTypingMessage(message) && message.citations && message.generationId) { if ( selectedCitation?.generationId === message.generationId && prevSelectedCitationGenId !== message.generationId ) { setHighlightMessage(true);
- Assistant
- User
wait could i use the id of the highlighted text to help posotion?
- Assistant