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 <noreply@anthropic.com>
This commit is contained in:
2026-05-17 13:18:15 +08:00
co-authored by Claude Opus 4.6
parent 20ca3421ab
commit 2172045a7a
@@ -562,9 +562,9 @@ export function ChatInput({ variant = 'default' }: ChatInputProps) {
filter={atFilter} filter={atFilter}
onSelect={(_path, name) => { onSelect={(_path, name) => {
if (atCursorPos >= 0) { if (atCursorPos >= 0) {
// Insert name at cursor position, replacing filter text const atStart = atCursorPos - atFilter.length - 1
const newValue = `${input.slice(0, atCursorPos)}${name}${input.slice(atCursorPos)}` const newValue = `${input.slice(0, atStart)}${name}${input.slice(atCursorPos)}`
const newCursorPos = atCursorPos + name.length const newCursorPos = atStart + name.length
setInput(newValue) setInput(newValue)
setFileSearchOpen(false) setFileSearchOpen(false)
setAtFilter('') setAtFilter('')