feat: add @ file mention support in chat input and unify directory attachment
Support typing "@" in the chat input to trigger a file list popup with filtering, keyboard navigation, and file/directory attachment. Directories from the sidebar file tree now attach as resource links instead of injecting text into the input. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -36,10 +36,7 @@ import {
|
||||
startFileTreeWatch,
|
||||
stopFileTreeWatch,
|
||||
} from "@/lib/api"
|
||||
import {
|
||||
emitAttachFileToSession,
|
||||
emitAppendTextToSession,
|
||||
} from "@/lib/session-attachment-events"
|
||||
import { emitAttachFileToSession } from "@/lib/session-attachment-events"
|
||||
import type {
|
||||
FileTreeChangedEvent,
|
||||
FileTreeNode,
|
||||
@@ -86,16 +83,7 @@ import {
|
||||
CollapsibleTrigger,
|
||||
} from "@/components/ui/collapsible"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
|
||||
function joinFsPath(basePath: string, relPath: string): string {
|
||||
if (!relPath) return basePath
|
||||
const separator = basePath.includes("\\") ? "\\" : "/"
|
||||
const normalizedRel = relPath.replace(/[\\/]/g, separator)
|
||||
if (basePath.endsWith("/") || basePath.endsWith("\\")) {
|
||||
return `${basePath}${normalizedRel}`
|
||||
}
|
||||
return `${basePath}${separator}${normalizedRel}`
|
||||
}
|
||||
import { joinFsPath } from "@/lib/path-utils"
|
||||
|
||||
function parentDir(filePath: string): string {
|
||||
const slashIndex = filePath.lastIndexOf("/")
|
||||
@@ -618,12 +606,9 @@ function RenderNode({
|
||||
|
||||
const handleAttachDirToSession = () => {
|
||||
if (!activeSessionTabId) return
|
||||
const relativePath = node.path.endsWith("/")
|
||||
? `@${node.path} `
|
||||
: `@${node.path}/ `
|
||||
emitAppendTextToSession({
|
||||
emitAttachFileToSession({
|
||||
tabId: activeSessionTabId,
|
||||
text: relativePath,
|
||||
path: absolutePath,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user