diff --git a/src/integrations/WorkspaceTracker.ts b/src/integrations/WorkspaceTracker.ts index d868a15..3ef0685 100644 --- a/src/integrations/WorkspaceTracker.ts +++ b/src/integrations/WorkspaceTracker.ts @@ -5,6 +5,7 @@ import { ClaudeDevProvider } from "../providers/ClaudeDevProvider" const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) +// Note: this is not a drop-in replacement for listFiles at the start of tasks, since that will be done for Desktops when there is no workspace selected class WorkspaceTracker { private providerRef: WeakRef private disposables: vscode.Disposable[] = [] diff --git a/webview-ui/src/components/ChatTextArea.tsx b/webview-ui/src/components/ChatTextArea.tsx index fb9e5f7..acf3eff 100644 --- a/webview-ui/src/components/ChatTextArea.tsx +++ b/webview-ui/src/components/ChatTextArea.tsx @@ -92,6 +92,10 @@ const ChatTextArea = forwardRef( const handleMentionSelect = useCallback( (type: string, value: string) => { + if (type === "noResults") { + return + } + if (value === "file" || value === "folder") { setSelectedType(type.toLowerCase()) setSearchQuery("") @@ -147,7 +151,9 @@ const ChatTextArea = forwardRef( if (optionsLength === 0) return prevIndex // Find selectable options (non-URL types) - const selectableOptions = options.filter((option) => option.type !== "url") + const selectableOptions = options.filter( + (option) => option.type !== "url" && option.type !== "noResults" + ) if (selectableOptions.length === 0) return -1 // No selectable options @@ -170,7 +176,7 @@ const ChatTextArea = forwardRef( const selectedOption = getContextMenuOptions(searchQuery, selectedType, searchPaths)[ selectedMenuIndex ] - if (selectedOption && selectedOption.type !== "url") { + if (selectedOption && selectedOption.type !== "url" && selectedOption.type !== "noResults") { handleMentionSelect(selectedOption.type, selectedOption.value) } return @@ -297,6 +303,7 @@ const ChatTextArea = forwardRef( const newCursorPosition = cursorPosition + trimmedUrl.length + 1 setCursorPosition(newCursorPosition) setIntendedCursorPosition(newCursorPosition) + setShowContextMenu(false) return } diff --git a/webview-ui/src/components/ContextMenu.tsx b/webview-ui/src/components/ContextMenu.tsx index 8c18857..0de66ab 100644 --- a/webview-ui/src/components/ContextMenu.tsx +++ b/webview-ui/src/components/ContextMenu.tsx @@ -52,6 +52,7 @@ const ContextMenu: React.FC = ({ case "folder": case "problems": case "url": + case "noResults": return ( = ({ ? "Problems" : option.value === "url" ? "Paste URL to scrape" - : ""} + : "No results found"} ) default: @@ -113,21 +114,25 @@ const ContextMenu: React.FC = ({ {filteredOptions.map((option, index) => (
option.type !== "url" && onSelect(option.type, option.value)} + onClick={() => + option.type !== "url" && option.type !== "noResults" && onSelect(option.type, option.value) + } style={{ padding: "8px 12px", - cursor: option.type !== "url" ? "pointer" : "default", + cursor: option.type !== "url" && option.type !== "noResults" ? "pointer" : "default", color: "var(--vscode-dropdown-foreground)", borderBottom: "1px solid var(--vscode-dropdown-border)", display: "flex", alignItems: "center", justifyContent: "space-between", backgroundColor: - index === selectedIndex && option.type !== "url" + index === selectedIndex && option.type !== "url" && option.type !== "noResults" ? "var(--vscode-list-activeSelectionBackground)" : "", }} - onMouseEnter={() => option.type !== "url" && setSelectedIndex(index)}> + onMouseEnter={() => + option.type !== "url" && option.type !== "noResults" && setSelectedIndex(index) + }>
item.type === "file") .map((item) => ({ type: "file", value: item.path, icon: "file" })) + return files.length > 0 ? files : [{ type: "noResults", value: "noResults", icon: "info" }] } if (selectedType === "folder") { - return searchPaths + const folders = searchPaths .filter((item) => item.type === "folder") .map((item) => ({ type: "folder", value: item.path, icon: "folder" })) + return folders.length > 0 ? folders : [{ type: "noResults", value: "noResults", icon: "info" }] } + return [ { type: "url", value: "url", icon: "link" }, { @@ -98,17 +101,7 @@ export function getContextMenuOptions( icon: item.type === "file" ? "file" : item.type === "problems" ? "warning" : "folder", })) } else { - // If no matches, show all options - return [ - { type: "url", value: "url", icon: "link" }, - { - type: "problems", - value: "problems", - icon: "warning", - }, - { type: "folder", value: "folder", icon: "folder" }, - { type: "file", value: "file", icon: "file" }, - ] + return [{ type: "noResults", value: "noResults", icon: "info" }] } } }