Răsfoiți Sursa

feat: add settings tab titles to search index (#10761)

Co-authored-by: Roo Code <[email protected]>
roomote[bot] 1 lună în urmă
părinte
comite
245e0f66c6
1 a modificat fișierele cu 18 adăugiri și 3 ștergeri
  1. 18 3
      webview-ui/src/components/settings/SettingsView.tsx

+ 18 - 3
webview-ui/src/components/settings/SettingsView.tsx

@@ -588,18 +588,33 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
 	const initialTab = useRef<SectionName>(activeTab)
 	const isIndexing = indexingTabIndex < sectionNames.length
 	const isIndexingComplete = !isIndexing
+	const tabTitlesRegistered = useRef(false)
 
 	// Index all tabs by cycling through them on mount
 	useLayoutEffect(() => {
 		if (indexingTabIndex >= sectionNames.length) {
-			// All tabs indexed, return to initial tab
-			setActiveTab(initialTab.current)
+			// All tabs indexed, now register tab titles as searchable items
+			if (!tabTitlesRegistered.current && searchContextValue) {
+				sections.forEach(({ id }) => {
+					const tabTitle = t(`settings:sections.${id}`)
+					// Register each tab title as a searchable item
+					// Using a special naming convention for tab titles: "tab-{sectionName}"
+					searchContextValue.registerSetting({
+						settingId: `tab-${id}`,
+						section: id,
+						label: tabTitle,
+					})
+				})
+				tabTitlesRegistered.current = true
+				// Return to initial tab
+				setActiveTab(initialTab.current)
+			}
 			return
 		}
 
 		// Move to the next tab on next render
 		setIndexingTabIndex((prev) => prev + 1)
-	}, [indexingTabIndex])
+	}, [indexingTabIndex, searchContextValue, sections, t])
 
 	// Determine which tab content to render (for indexing or active display)
 	const renderTab = isIndexing ? sectionNames[indexingTabIndex] : activeTab