mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
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
This commit is contained in:
parent
a163053430
commit
2440fb9e9b
5 changed files with 125 additions and 16 deletions
|
|
@ -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<CodeIndexPopoverProps> = ({
|
|||
</div>
|
||||
|
||||
<div className="p-4">
|
||||
{/* Enable/Disable Toggle */}
|
||||
<div className="mb-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<VSCodeCheckbox
|
||||
checked={currentSettings.codebaseIndexEnabled}
|
||||
onChange={(e: any) => updateSetting("codebaseIndexEnabled", e.target.checked)}>
|
||||
<span className="font-medium">{t("settings:codeIndex.enableLabel")}</span>
|
||||
</VSCodeCheckbox>
|
||||
<StandardTooltip content={t("settings:codeIndex.enableDescription")}>
|
||||
<span className="codicon codicon-info text-xs text-vscode-descriptionForeground cursor-help" />
|
||||
</StandardTooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Status Section */}
|
||||
<div className="space-y-2">
|
||||
<h4 className="text-sm font-medium">{t("settings:codeIndex.statusTitle")}</h4>
|
||||
|
|
|
|||
|
|
@ -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<IndexingStatusBadgeProps> = ({ classN
|
|||
const { t } = useAppTranslation()
|
||||
const { showTooltip, handleMouseEnter, handleMouseLeave, cleanup } = useTooltip({ delay: 300 })
|
||||
const [isHovered, setIsHovered] = useState(false)
|
||||
const extensionState = useExtensionState()
|
||||
|
||||
const [indexingStatus, setIndexingStatus] = useState<IndexingStatus>({
|
||||
systemStatus: "Standby",
|
||||
|
|
@ -52,6 +54,12 @@ export const IndexingStatusBadge: React.FC<IndexingStatusBadgeProps> = ({ 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) {
|
||||
|
|
|
|||
59
webview-ui/src/components/settings/GeneralSettings.tsx
Normal file
59
webview-ui/src/components/settings/GeneralSettings.tsx
Normal file
|
|
@ -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<HTMLDivElement> & {
|
||||
codebaseIndexEnabled: boolean
|
||||
setCodebaseIndexEnabled: (enabled: boolean) => void
|
||||
}
|
||||
|
||||
export const GeneralSettings = ({
|
||||
codebaseIndexEnabled,
|
||||
setCodebaseIndexEnabled,
|
||||
className,
|
||||
...props
|
||||
}: GeneralSettingsProps) => {
|
||||
const { t } = useAppTranslation()
|
||||
|
||||
return (
|
||||
<div className={cn("flex flex-col gap-2", className)} {...props}>
|
||||
<SectionHeader description={t("settings:general.description")}>
|
||||
<div className="flex items-center gap-2">
|
||||
<Settings className="w-4" />
|
||||
<div>{t("settings:sections.general")}</div>
|
||||
</div>
|
||||
</SectionHeader>
|
||||
|
||||
<Section>
|
||||
{/* Codebase Indexing Enable/Disable */}
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex items-center gap-2 font-bold">
|
||||
<span className="codicon codicon-database" />
|
||||
<div>{t("settings:general.codebaseIndexing.label")}</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<VSCodeCheckbox
|
||||
checked={codebaseIndexEnabled}
|
||||
onChange={(e: any) => setCodebaseIndexEnabled(e.target.checked)}
|
||||
data-testid="codebase-indexing-enabled-checkbox">
|
||||
<span className="font-medium">{t("settings:general.codebaseIndexing.enableLabel")}</span>
|
||||
</VSCodeCheckbox>
|
||||
<StandardTooltip content={t("settings:general.codebaseIndexing.enableDescription")}>
|
||||
<span className="codicon codicon-info text-xs text-vscode-descriptionForeground cursor-help" />
|
||||
</StandardTooltip>
|
||||
</div>
|
||||
|
||||
<div className="text-vscode-descriptionForeground text-sm">
|
||||
{t("settings:general.codebaseIndexing.description")}
|
||||
</div>
|
||||
</div>
|
||||
</Section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -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<SettingsViewRef, SettingsViewProps>(({ onDone, t
|
|||
const [activeTab, setActiveTab] = useState<SectionName>(
|
||||
targetSection && sectionNames.includes(targetSection as SectionName)
|
||||
? (targetSection as SectionName)
|
||||
: "providers",
|
||||
: "general",
|
||||
)
|
||||
|
||||
const prevApiConfigName = useRef(currentApiConfigName)
|
||||
|
|
@ -176,6 +179,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
|
|||
alwaysAllowFollowupQuestions,
|
||||
alwaysAllowUpdateTodoList,
|
||||
followupAutoApproveTimeoutMs,
|
||||
codebaseIndexConfig,
|
||||
} = cachedState
|
||||
|
||||
const apiConfiguration = useMemo(() => cachedState.apiConfiguration ?? {}, [cachedState.apiConfiguration])
|
||||
|
|
@ -258,6 +262,24 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ 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<SettingsViewRef, SettingsViewProps>(({ 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<SettingsViewRef, SettingsViewProps>(({ 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<SettingsViewRef, SettingsViewProps>(({ onDone, t
|
|||
|
||||
{/* Content area */}
|
||||
<TabContent className="p-0 flex-1 overflow-auto">
|
||||
{/* General Section */}
|
||||
{activeTab === "general" && (
|
||||
<GeneralSettings
|
||||
codebaseIndexEnabled={codebaseIndexConfig?.codebaseIndexEnabled ?? true}
|
||||
setCodebaseIndexEnabled={setCodebaseIndexEnabled}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Providers Section */}
|
||||
{activeTab === "providers" && (
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue