diff --git a/src/pages/chat/components/ChatInput.tsx b/src/pages/chat/components/ChatInput.tsx index a1cf3bd..43b7f1e 100644 --- a/src/pages/chat/components/ChatInput.tsx +++ b/src/pages/chat/components/ChatInput.tsx @@ -60,14 +60,25 @@ export default function ChatInput(props: { const textBeforeCursor = value.slice(0, cursorPos); const atIndex = textBeforeCursor.lastIndexOf('@'); + console.log('[@mention] input change:', { + value, + cursorPos, + textBeforeCursor, + atIndex, + agentListLength: agentList.length, + agentList: agentList.map(a => ({ id: a.id, name: a.name })) + }); + if (atIndex !== -1 && (atIndex === 0 || /\s$/.test(textBeforeCursor.slice(0, atIndex)))) { const query = textBeforeCursor.slice(atIndex + 1); + console.log('[@mention] matched @ at position:', { atIndex, query }); if (!query.includes(' ')) { setMentionQuery(query); // 计算位置 const textarea = e.target; const rect = textarea.getBoundingClientRect(); setMentionPos({ top: rect.bottom, left: rect.left + 10 }); + console.log('[@mention] show popover:', { top: rect.bottom, left: rect.left + 10, query }); setShowMentionPopover(true); return; } @@ -78,6 +89,8 @@ export default function ChatInput(props: { const filteredAgents = agentList.filter(a => a.name.toLowerCase().includes(mentionQuery.toLowerCase()) ); + + console.log('[@mention] filtered:', { mentionQuery, count: filteredAgents.length, agents: filteredAgents.map(a => a.name) }); const handleSelectAgent = (agent: Agent) => { const textarea = inputRef.current;