From 14683cc3c5d76229cd47541df5bcb109e24499f0 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Sat, 1 Feb 2025 11:57:52 -0500 Subject: [PATCH] Cleanup and release --- .changeset/blue-masks-camp.md | 5 +++++ webview-ui/src/components/chat/ChatTextArea.tsx | 10 ++-------- webview-ui/src/components/chat/ContextMenu.tsx | 2 +- webview-ui/src/utils/context-mentions.ts | 12 +++++------- 4 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 .changeset/blue-masks-camp.md diff --git a/.changeset/blue-masks-camp.md b/.changeset/blue-masks-camp.md new file mode 100644 index 0000000..a67e1c4 --- /dev/null +++ b/.changeset/blue-masks-camp.md @@ -0,0 +1,5 @@ +--- +"roo-cline": patch +--- + +Add shortcuts to the currently open tabs in the "Add File" section of @-mentions (thanks @olup!) diff --git a/webview-ui/src/components/chat/ChatTextArea.tsx b/webview-ui/src/components/chat/ChatTextArea.tsx index 6a7c05a..a20922d 100644 --- a/webview-ui/src/components/chat/ChatTextArea.tsx +++ b/webview-ui/src/components/chat/ChatTextArea.tsx @@ -89,7 +89,6 @@ const ChatTextArea = forwardRef( return () => window.removeEventListener("message", messageHandler) }, [setInputValue]) - const [isTextAreaFocused, setIsTextAreaFocused] = useState(false) const [thumbnailsHeight, setThumbnailsHeight] = useState(0) const [textAreaBaseHeight, setTextAreaBaseHeight] = useState(undefined) const [showContextMenu, setShowContextMenu] = useState(false) @@ -136,18 +135,15 @@ const ChatTextArea = forwardRef( }, [inputValue, textAreaDisabled, setInputValue]) const queryItems = useMemo(() => { - const items = [ + return [ { type: ContextMenuOptionType.Problems, value: "problems" }, ...gitCommits, - // Add opened tabs ...openedTabs .filter((tab) => tab.path) .map((tab) => ({ type: ContextMenuOptionType.OpenedFile, value: "/" + tab.path, })), - - // Add regular file paths ...filePaths .map((file) => "/" + file) .filter((path) => !openedTabs.some((tab) => tab.path && "/" + tab.path === path)) // Filter out paths that are already in openedTabs @@ -156,9 +152,7 @@ const ChatTextArea = forwardRef( value: path, })), ] - - return items - }, [filePaths, openedTabs]) + }, [filePaths, gitCommits, openedTabs]) useEffect(() => { const handleClickOutside = (event: MouseEvent) => { diff --git a/webview-ui/src/components/chat/ContextMenu.tsx b/webview-ui/src/components/chat/ContextMenu.tsx index 2d12f1a..85ec865 100644 --- a/webview-ui/src/components/chat/ContextMenu.tsx +++ b/webview-ui/src/components/chat/ContextMenu.tsx @@ -102,7 +102,7 @@ const ContextMenu: React.FC = ({ const getIconForOption = (option: ContextMenuQueryItem): string => { switch (option.type) { case ContextMenuOptionType.OpenedFile: - return "star-full" + return "window" case ContextMenuOptionType.File: return "file" case ContextMenuOptionType.Folder: diff --git a/webview-ui/src/utils/context-mentions.ts b/webview-ui/src/utils/context-mentions.ts index aa517d0..5cce936 100644 --- a/webview-ui/src/utils/context-mentions.ts +++ b/webview-ui/src/utils/context-mentions.ts @@ -132,12 +132,6 @@ export function getContextMenuOptions( } if (query.startsWith("http")) { suggestions.push({ type: ContextMenuOptionType.URL, value: query }) - } else { - suggestions.push( - ...queryItems - .filter((item) => item.type !== ContextMenuOptionType.OpenedFile) - .filter((item) => item.value?.toLowerCase().includes(lowerQuery)), - ) } // Add exact SHA matches to suggestions @@ -175,12 +169,16 @@ export function getContextMenuOptions( // Separate matches by type const fileMatches = matchingItems.filter( - (item) => item.type === ContextMenuOptionType.File || item.type === ContextMenuOptionType.Folder, + (item) => + item.type === ContextMenuOptionType.File || + item.type === ContextMenuOptionType.OpenedFile || + item.type === ContextMenuOptionType.Folder, ) const gitMatches = matchingItems.filter((item) => item.type === ContextMenuOptionType.Git) const otherMatches = matchingItems.filter( (item) => item.type !== ContextMenuOptionType.File && + item.type !== ContextMenuOptionType.OpenedFile && item.type !== ContextMenuOptionType.Folder && item.type !== ContextMenuOptionType.Git, )