diff --git a/components/AppShell.tsx b/components/AppShell.tsx index d4d827fa7..8f3823811 100644 --- a/components/AppShell.tsx +++ b/components/AppShell.tsx @@ -250,16 +250,19 @@ export function AppShell() { // read tool resolves it the same way (it strips the @ prefix). const handleAtMention = useCallback((relativePath: string, isDir: boolean) => { chatInputRef.current?.insertText(buildAtMentionText(relativePath, isDir)); - }, []); + if (isMobile) { setRightPanelOpen(false); setSidebarOpen(false); } + }, [isMobile]); const handleAtMentions = useCallback((relativePaths: string[]) => { const mentions = buildFileAtMentionsText(relativePaths); if (mentions) chatInputRef.current?.insertText(mentions); - }, []); + if (isMobile) { setRightPanelOpen(false); setSidebarOpen(false); } + }, [isMobile]); const handleFileLineMention = useCallback((relativePath: string, startLine: number, endLine: number) => { chatInputRef.current?.insertText(buildFileLineMentionText(relativePath, startLine, endLine)); - }, []); + if (isMobile) { setRightPanelOpen(false); setSidebarOpen(false); } + }, [isMobile]); const initialSessionId = initialNavigation.sessionId; const [activeCwd, setActiveCwd] = useState(null); @@ -1598,6 +1601,7 @@ export function AppShell() { gitRefreshKey={explorerRefreshKey} initialDisplayMode={activeFileTab.initialDisplayMode} onMentionLines={rightPanelOpen ? handleFileLineMention : undefined} + onAtMention={handleAtMention} onOpenFile={(filePath) => handleOpenFile( filePath, getFileName(filePath), diff --git a/components/FileViewer.tsx b/components/FileViewer.tsx index 9635b4c6d..939c363b9 100644 --- a/components/FileViewer.tsx +++ b/components/FileViewer.tsx @@ -31,6 +31,8 @@ interface Props { sourceSessionId?: string | null; onOpenFile?: (filePath: string) => void; onMentionLines?: (relativePath: string, startLine: number, endLine: number) => void; + /** Insert this file's relative path into the chat input (@ mention). */ + onAtMention?: (relativePath: string, isDir: boolean) => void; gitRefreshKey?: number; initialDisplayMode?: DisplayMode; } @@ -783,7 +785,7 @@ function DocumentViewer({ filePath, cwd, sourceSessionId }: Props) { ); } -export function FileViewer({ filePath, cwd, sourceSessionId, onOpenFile, onMentionLines, gitRefreshKey, initialDisplayMode }: Props) { +export function FileViewer({ filePath, cwd, sourceSessionId, onOpenFile, onMentionLines, onAtMention, gitRefreshKey, initialDisplayMode }: Props) { if (isImagePath(filePath)) { return ; } @@ -793,10 +795,10 @@ export function FileViewer({ filePath, cwd, sourceSessionId, onOpenFile, onMenti if (isDocumentPreviewPath(filePath)) { return ; } - return ; + return ; } -function TextFileViewer({ filePath, cwd, sourceSessionId, onOpenFile, onMentionLines, gitRefreshKey, initialDisplayMode }: Props) { +function TextFileViewer({ filePath, cwd, sourceSessionId, onOpenFile, onMentionLines, onAtMention, gitRefreshKey, initialDisplayMode }: Props) { const { isDark } = useTheme(); const { t } = useI18n(); const [data, setData] = useState(null); @@ -965,10 +967,6 @@ function TextFileViewer({ filePath, cwd, sourceSessionId, onOpenFile, onMentionL ); }, [cwd, filePath, onMentionLines]); - const handleMentionSelectedLines = useCallback(() => { - mentionLineRange(selectedLineRange); - }, [mentionLineRange, selectedLineRange]); - useEffect(() => { if (!onMentionLines || displayMode !== "source") return; @@ -1086,19 +1084,34 @@ function TextFileViewer({ filePath, cwd, sourceSessionId, onOpenFile, onMentionL )}
+ {(onAtMention || onMentionLines) && ( + + )} {effectiveDisplayMode === "source" && ( <> -