debug: add @mention console logs
parent
92799189e2
commit
d649d4364d
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -79,6 +90,8 @@ export default function ChatInput(props: {
|
|||
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;
|
||||
if (!textarea) return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue