import { ArrowUpRight, Loader2, X } from 'lucide-react'; import type { Ref } from 'react'; import { TeacherAvatar } from './TeacherAvatar'; import type { useTeacherCompanion } from './use-teacher-companion'; type Companion = ReturnType; export function TeacherCompanion({ companion, open, onOpen, bubbleRef }: { companion: Companion; open: boolean; onOpen(agentId?: string): void; bubbleRef?: Ref; }) { const { definition, invitation, welcome, loading, enabled, checking, error } = companion; const name = definition?.name || '智能体'; const activeId = companion.selectedAgent?.teacher_id; const agents = companion.selectedAgent && !companion.agents.some((item) => item.teacher_id === activeId) ? [...companion.agents, companion.selectedAgent] : companion.agents; const viewConversation = () => { companion.dismiss(); onOpen(); }; const status = loading ? '正在连接智能体…' : checking ? '智能体在看看你最近的进展…' : error || (!enabled ? '智能体暂未开放,仍可查看以往讨论' : open ? '我们慢慢聊,想到什么都可以说' : '点我聊聊,想到什么都可以说'); return (
{(invitation || welcome) &&
{name}

{invitation?.response ?? welcome}

}
); }