Roo-Code/src/services/code-index/interfaces/config.ts
Murilo Pires 4a78f51fe5
Feat/issue 5149 configurable max search results (#5402)
* feat: add configurable max search results for codebase indexing (#5149)

- Add codebaseIndexSearchMaxResults to configuration schema with validation (10-1000)
- Update Qdrant client to accept maxResults parameter in search method
- Add UI slider in Experimental Settings to configure max search results
- Rename constants to DEFAULT_MAX_SEARCH_RESULTS and DEFAULT_SEARCH_MIN_SCORE for clarity
- Add translations for new setting across all 17 supported languages
- Add comprehensive test coverage for config manager, Qdrant client, and UI components

fix: settings persistence for codebase index configuration

- Add new updateCodebaseIndexConfig message type to properly merge config updates
- Update SettingsView to send entire codebaseIndexConfig object instead of just enabled flag
- Add backend handler to merge configuration updates instead of overwriting
- Add tests for the new message handler functionality

This ensures the max search results setting persists correctly when saved.

* fix: correct property name in updateCodebaseIndexConfig message

The frontend was sending 'config' but the backend expects 'codebaseIndexConfig'.
This mismatch was preventing the max search results setting from persisting.

* feat: refactor codebase index constants and update search result defaults

* feat(chat): add advanced settings for maximum search results configuration

* refactor: remove updateCodebaseIndexConfig and integrate max search results into saveCodeIndexSettingsAtomic

- Removed updateCodebaseIndexConfig message type and handler as per PR feedback
- Added codebaseIndexSearchMaxResults to codeIndexSettings type in WebviewMessage.ts
- Updated saveCodeIndexSettingsAtomic to save codebaseIndexSearchMaxResults
- Fixed SettingsView.tsx to use codebaseIndexEnabled message instead of updateCodebaseIndexConfig

* Delete webview-ui/src/components/settings/__tests__/ExperimentalSettings.spec.tsx

* refactor: remove updateCodebaseIndexConfig tests to streamline codebase indexing logic

* revert this

---------

Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
2025-07-04 20:55:15 -04:00

38 lines
1 KiB
TypeScript

import { ApiHandlerOptions } from "../../../shared/api" // Adjust path if needed
import { EmbedderProvider } from "./manager"
/**
* Configuration state for the code indexing feature
*/
export interface CodeIndexConfig {
isEnabled: boolean
isConfigured: boolean
embedderProvider: EmbedderProvider
modelId?: string
openAiOptions?: ApiHandlerOptions
ollamaOptions?: ApiHandlerOptions
openAiCompatibleOptions?: { baseUrl: string; apiKey: string; modelDimension?: number }
geminiOptions?: { apiKey: string }
qdrantUrl?: string
qdrantApiKey?: string
searchMinScore?: number
searchMaxResults?: number
}
/**
* Snapshot of previous configuration used to determine if a restart is required
*/
export type PreviousConfigSnapshot = {
enabled: boolean
configured: boolean
embedderProvider: EmbedderProvider
modelId?: string
openAiKey?: string
ollamaBaseUrl?: string
openAiCompatibleBaseUrl?: string
openAiCompatibleApiKey?: string
openAiCompatibleModelDimension?: number
geminiApiKey?: string
qdrantUrl?: string
qdrantApiKey?: string
}