From 2440fb9e9b53ea5fa606a62841f6cbdd574af7c7 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Mon, 14 Jul 2025 07:39:53 +0000 Subject: [PATCH] feat: move codebase indexing enable/disable to General Settings - Create new GeneralSettings component with codebase indexing toggle - Add General Settings as first tab in SettingsView - Add translation keys for General Settings section - Update IndexingStatusBadge to conditionally render based on setting - Remove enable/disable checkbox from CodeIndexPopover - Fixes #5680 --- .../src/components/chat/CodeIndexPopover.tsx | 15 ----- .../components/chat/IndexingStatusBadge.tsx | 8 +++ .../components/settings/GeneralSettings.tsx | 59 +++++++++++++++++++ .../src/components/settings/SettingsView.tsx | 49 ++++++++++++++- webview-ui/src/i18n/locales/en/settings.json | 10 ++++ 5 files changed, 125 insertions(+), 16 deletions(-) create mode 100644 webview-ui/src/components/settings/GeneralSettings.tsx diff --git a/webview-ui/src/components/chat/CodeIndexPopover.tsx b/webview-ui/src/components/chat/CodeIndexPopover.tsx index 84703bcae26..30219f47702 100644 --- a/webview-ui/src/components/chat/CodeIndexPopover.tsx +++ b/webview-ui/src/components/chat/CodeIndexPopover.tsx @@ -7,7 +7,6 @@ import { VSCodeDropdown, VSCodeOption, VSCodeLink, - VSCodeCheckbox, } from "@vscode/webview-ui-toolkit/react" import * as ProgressPrimitive from "@radix-ui/react-progress" import { vscode } from "@src/utils/vscode" @@ -513,20 +512,6 @@ export const CodeIndexPopover: React.FC = ({
- {/* Enable/Disable Toggle */} -
-
- updateSetting("codebaseIndexEnabled", e.target.checked)}> - {t("settings:codeIndex.enableLabel")} - - - - -
-
- {/* Status Section */}

{t("settings:codeIndex.statusTitle")}

diff --git a/webview-ui/src/components/chat/IndexingStatusBadge.tsx b/webview-ui/src/components/chat/IndexingStatusBadge.tsx index ff5a0171b5a..0349d7445b9 100644 --- a/webview-ui/src/components/chat/IndexingStatusBadge.tsx +++ b/webview-ui/src/components/chat/IndexingStatusBadge.tsx @@ -5,6 +5,7 @@ import { vscode } from "@src/utils/vscode" import { useAppTranslation } from "@/i18n/TranslationContext" import { useTooltip } from "@/hooks/useTooltip" import { CodeIndexPopover } from "./CodeIndexPopover" +import { useExtensionState } from "@/context/ExtensionStateContext" import type { IndexingStatus, IndexingStatusUpdateMessage } from "@roo/ExtensionMessage" interface IndexingStatusBadgeProps { @@ -15,6 +16,7 @@ export const IndexingStatusBadge: React.FC = ({ classN const { t } = useAppTranslation() const { showTooltip, handleMouseEnter, handleMouseLeave, cleanup } = useTooltip({ delay: 300 }) const [isHovered, setIsHovered] = useState(false) + const extensionState = useExtensionState() const [indexingStatus, setIndexingStatus] = useState({ systemStatus: "Standby", @@ -52,6 +54,12 @@ export const IndexingStatusBadge: React.FC = ({ classN [indexingStatus.processedItems, indexingStatus.totalItems], ) + // Don't render the badge if codebase indexing is disabled + const codebaseIndexEnabled = extensionState.codebaseIndexConfig?.codebaseIndexEnabled ?? true + if (!codebaseIndexEnabled) { + return null + } + // Get tooltip text with internationalization const getTooltipText = () => { switch (indexingStatus.systemStatus) { diff --git a/webview-ui/src/components/settings/GeneralSettings.tsx b/webview-ui/src/components/settings/GeneralSettings.tsx new file mode 100644 index 00000000000..2eaceacd6cc --- /dev/null +++ b/webview-ui/src/components/settings/GeneralSettings.tsx @@ -0,0 +1,59 @@ +import React, { type HTMLAttributes } from "react" +import { Settings } from "lucide-react" +import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" +import { useAppTranslation } from "@src/i18n/TranslationContext" +import { SectionHeader } from "./SectionHeader" +import { Section } from "./Section" +import { StandardTooltip } from "@src/components/ui" +import { cn } from "@src/lib/utils" + +type GeneralSettingsProps = HTMLAttributes & { + codebaseIndexEnabled: boolean + setCodebaseIndexEnabled: (enabled: boolean) => void +} + +export const GeneralSettings = ({ + codebaseIndexEnabled, + setCodebaseIndexEnabled, + className, + ...props +}: GeneralSettingsProps) => { + const { t } = useAppTranslation() + + return ( +
+ +
+ +
{t("settings:sections.general")}
+
+
+ +
+ {/* Codebase Indexing Enable/Disable */} +
+
+ +
{t("settings:general.codebaseIndexing.label")}
+
+ +
+ setCodebaseIndexEnabled(e.target.checked)} + data-testid="codebase-indexing-enabled-checkbox"> + {t("settings:general.codebaseIndexing.enableLabel")} + + + + +
+ +
+ {t("settings:general.codebaseIndexing.description")} +
+
+
+
+ ) +} diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index cf9e779cbde..6ff2152ef9c 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -22,6 +22,7 @@ import { Globe, Info, MessageSquare, + Settings, LucideIcon, } from "lucide-react" @@ -65,6 +66,7 @@ import { LanguageSettings } from "./LanguageSettings" import { About } from "./About" import { Section } from "./Section" import PromptsSettings from "./PromptsSettings" +import { GeneralSettings } from "./GeneralSettings" import { cn } from "@/lib/utils" export const settingsTabsContainer = "flex flex-1 overflow-hidden [&.narrow_.tab-label]:hidden" @@ -79,6 +81,7 @@ export interface SettingsViewRef { } const sectionNames = [ + "general", "providers", "autoApprove", "browser", @@ -111,7 +114,7 @@ const SettingsView = forwardRef(({ onDone, t const [activeTab, setActiveTab] = useState( targetSection && sectionNames.includes(targetSection as SectionName) ? (targetSection as SectionName) - : "providers", + : "general", ) const prevApiConfigName = useRef(currentApiConfigName) @@ -176,6 +179,7 @@ const SettingsView = forwardRef(({ onDone, t alwaysAllowFollowupQuestions, alwaysAllowUpdateTodoList, followupAutoApproveTimeoutMs, + codebaseIndexConfig, } = cachedState const apiConfiguration = useMemo(() => cachedState.apiConfiguration ?? {}, [cachedState.apiConfiguration]) @@ -258,6 +262,24 @@ const SettingsView = forwardRef(({ onDone, t }) }, []) + const setCodebaseIndexEnabled = useCallback((enabled: boolean) => { + setCachedState((prevState) => { + const currentConfig = prevState.codebaseIndexConfig || {} + if (currentConfig.codebaseIndexEnabled === enabled) { + return prevState + } + + setChangeDetected(true) + return { + ...prevState, + codebaseIndexConfig: { + ...currentConfig, + codebaseIndexEnabled: enabled, + }, + } + }) + }, []) + const isSettingValid = !errorMessage const handleSubmit = () => { @@ -323,6 +345,22 @@ const SettingsView = forwardRef(({ onDone, t vscode.postMessage({ type: "upsertApiConfiguration", text: currentApiConfigName, apiConfiguration }) vscode.postMessage({ type: "telemetrySetting", text: telemetrySetting }) vscode.postMessage({ type: "profileThresholds", values: profileThresholds }) + + // Save codebase index settings with proper defaults + const codeIndexSettingsToSave = { + codebaseIndexEnabled: codebaseIndexConfig?.codebaseIndexEnabled ?? true, + codebaseIndexQdrantUrl: codebaseIndexConfig?.codebaseIndexQdrantUrl ?? "http://localhost:6333", + codebaseIndexEmbedderProvider: codebaseIndexConfig?.codebaseIndexEmbedderProvider ?? "openai", + codebaseIndexEmbedderBaseUrl: codebaseIndexConfig?.codebaseIndexEmbedderBaseUrl, + codebaseIndexEmbedderModelId: codebaseIndexConfig?.codebaseIndexEmbedderModelId ?? "", + codebaseIndexEmbedderModelDimension: codebaseIndexConfig?.codebaseIndexEmbedderModelDimension, + codebaseIndexSearchMaxResults: codebaseIndexConfig?.codebaseIndexSearchMaxResults, + codebaseIndexSearchMinScore: codebaseIndexConfig?.codebaseIndexSearchMinScore, + codebaseIndexOpenAiCompatibleBaseUrl: codebaseIndexConfig?.codebaseIndexOpenAiCompatibleBaseUrl, + codebaseIndexOpenAiCompatibleModelDimension: + codebaseIndexConfig?.codebaseIndexOpenAiCompatibleModelDimension, + } + vscode.postMessage({ type: "saveCodeIndexSettingsAtomic", codeIndexSettings: codeIndexSettingsToSave }) setChangeDetected(false) } } @@ -392,6 +430,7 @@ const SettingsView = forwardRef(({ onDone, t const sections: { id: SectionName; icon: LucideIcon }[] = useMemo( () => [ + { id: "general", icon: Settings }, { id: "providers", icon: Webhook }, { id: "autoApprove", icon: CheckCheck }, { id: "browser", icon: SquareMousePointer }, @@ -539,6 +578,14 @@ const SettingsView = forwardRef(({ onDone, t {/* Content area */} + {/* General Section */} + {activeTab === "general" && ( + + )} + {/* Providers Section */} {activeTab === "providers" && (
diff --git a/webview-ui/src/i18n/locales/en/settings.json b/webview-ui/src/i18n/locales/en/settings.json index 25428cfb16c..039f0ae66af 100644 --- a/webview-ui/src/i18n/locales/en/settings.json +++ b/webview-ui/src/i18n/locales/en/settings.json @@ -21,6 +21,7 @@ "discardButton": "Discard changes" }, "sections": { + "general": "General", "providers": "Providers", "autoApprove": "Auto-Approve", "browser": "Browser", @@ -33,6 +34,15 @@ "language": "Language", "about": "About Roo Code" }, + "general": { + "description": "Configure general application settings and preferences.", + "codebaseIndexing": { + "label": "Codebase Indexing", + "enableLabel": "Enable Codebase Indexing", + "enableDescription": "Enable code indexing for improved search and context understanding", + "description": "When enabled, Roo can index your codebase to provide better search and context understanding capabilities." + } + }, "prompts": { "description": "Configure support prompts that are used for quick actions like enhancing prompts, explaining code, and fixing issues. These prompts help Roo provide better assistance for common development tasks." },