From 2172045a7a142d678550f00cb8ad66d5fb6596f3 Mon Sep 17 00:00:00 2001 From: chenchen Date: Sun, 17 May 2026 13:18:15 +0800 Subject: [PATCH] fix(desktop): correct @ file search replacement in ChatInput The onSelect handler inserted the filename at cursor position without removing the @filter trigger text, producing "@foofilename.ts" instead of replacing the whole "@foo" with "filename.ts". Co-Authored-By: Claude Opus 4.6 --- cc-haha/desktop/src/components/chat/ChatInput.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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('')