diff --git a/cc-haha/desktop/src/components/chat/ChatInput.tsx b/cc-haha/desktop/src/components/chat/ChatInput.tsx index 7dbf3a4..73765b7 100644 --- a/cc-haha/desktop/src/components/chat/ChatInput.tsx +++ b/cc-haha/desktop/src/components/chat/ChatInput.tsx @@ -562,9 +562,9 @@ export function ChatInput({ variant = 'default' }: ChatInputProps) { filter={atFilter} onSelect={(_path, name) => { if (atCursorPos >= 0) { - // Insert name at cursor position, replacing filter text - const newValue = `${input.slice(0, atCursorPos)}${name}${input.slice(atCursorPos)}` - const newCursorPos = atCursorPos + name.length + const atStart = atCursorPos - atFilter.length - 1 + const newValue = `${input.slice(0, atStart)}${name}${input.slice(atCursorPos)}` + const newCursorPos = atStart + name.length setInput(newValue) setFileSearchOpen(false) setAtFilter('')