import * as Tooltip from '@radix-ui/react-tooltip'; import { Sparkles } from 'lucide-react'; import { useRef, type ReactElement, type Ref } from 'react'; import type { TeacherDefinition } from '../../../shared/coding-teacher'; import { TeacherAvatar } from './TeacherAvatar'; /** A temporary introduction, separate from the agent's unread messages. */ export function TeacherIntroduction({ definition, children, contentRef, open, onOpenChange }: { definition: TeacherDefinition | null; children: ReactElement; contentRef?: Ref; open: boolean; onOpenChange(open: boolean): void; }) { const description = definition?.description?.trim(); const clicked = useRef(false); return { if (!next || !clicked.current) onOpenChange(next); }}> { // Adjacent entries must switch immediately, even inside the previous // tooltip's pointer grace area used when moving into its readable card. if (event.pointerType === 'touch') return; if (event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget)) return; clicked.current = false; onOpenChange(true); }} onClick={() => { // A delayed Radix hover callback must not reopen the card after selection. clicked.current = true; onOpenChange(false); }} onFocus={() => { clicked.current = false; }} onPointerMove={(event) => { // pointerEnter owns hover opening. Skip Radix's second opening path so // moving inside an entry after clicking it cannot reopen its introduction. if (event.pointerType !== 'touch') event.preventDefault(); }}>{children} {definition && description &&
认识一下

{definition.name}

{description}

点点头像,一起聊聊

}
; }