Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Jun 26, 2025

Summary

This PR addresses two main areas:

  1. It fixes a critical bug where changes to API keys in the code index settings were not being applied, preventing the system from using the new secrets.
  2. It significantly improves the user experience for code index settings by separating the global enable/disable toggle from the provider-specific configuration.

## Key Changes

1. Fixed Secret Persistence and Configuration Handling

  • Secret Refresh: Implemented a refreshSecrets() method in ContextProxy to ensure that the application always has the latest secrets from VSCode's secret storage.
  • Atomic Settings Update: The CodeIndexConfigManager now refreshes secrets before loading a new configuration, ensuring that any new API keys are immediately available.
  • Service Recreation: The CodeIndexManager now correctly recreates services when settings are changed, ensuring that the new configuration is applied.

2. Improved Settings UI/UX

  • Global Toggle: The "Enable codebase indexing" checkbox has been moved to the global "Experimental" settings tab, making it clear that this is a global setting.
  • Dedicated Settings Popover: A new CodeIndexPopover component has been introduced to manage provider-specific settings, accessible from the chat input's status badge. This keeps the settings in context and easily accessible.
  • Secret Placeholders: API key fields now show "••••••••" as a placeholder, preventing accidental exposure of secrets.
  • Disabled State: A "disabled" message is now shown in the popover when indexing is turned off, guiding the user to the global settings to enable it.

3. Translation Cleanup

  • Standardized Keys: All translation keys in webview-ui/src/i18n/locales/*/settings.json have been standardized to use the openAi (camelCase with capital 'A') naming convention.
  • Removed Duplicates: All duplicate translation keys have been removed, fixing JSON syntax errors and ensuring consistency across all languages.

Screenshots

image
image
image

Testing

  • All existing tests pass.
  • Manual testing confirms:
    • Changing API keys correctly recreates services with the new keys.
    • Toggling the feature on and off works as expected.
    • Secret fields display placeholders correctly.
    • Only modified fields are saved.

Related Issues

  • Fixes issues with code index API key changes not taking effect.

@delve-auditor
Copy link

delve-auditor bot commented Jun 26, 2025

No security or compliance issues detected. Reviewed everything up to e6df6a3.

Security Overview
  • 🔎 Scanned files: 35 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 26, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Draft / In Progress] in Roo Code Roadmap Jun 26, 2025
@hannesrudolph hannesrudolph added PR - Draft / In Progress and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 26, 2025
@seedlord
Copy link
Contributor

seedlord commented Jul 1, 2025

you may have a look at the refactoring here #5314

@daniel-lxs daniel-lxs force-pushed the fix-code-index-secret-persistence branch 3 times, most recently from 86b6376 to beb1de4 Compare July 3, 2025 15:35
daniel-lxs added 16 commits July 3, 2025 15:30
- Add async secret methods to CodeIndexConfigManager
- Implement direct VSCode secret storage access bypassing ContextProxy cache
- Update loadConfiguration to use async secret loading
- Modify webview message handler to use new async secret storage
- Add public secret methods to CodeIndexManager
- Enhance debugging throughout secret flow

This fixes the issue where API keys were saved but not loaded immediately
into services due to ContextProxy cache synchronization issues.
- Add async secret handling to CodeIndexConfigManager with new methods:
  - getSecretAsync(), storeSecretAsync() for individual secrets
  - loadSecretsAsync(), storeSecretsAsync() for batch operations
- Update doesConfigChangeRequireRestart() to check OpenAI Compatible modelDimension changes
- Fix all failing tests by using setupSecretMocks() helper consistently
- Update manager.spec.ts to properly mock _recreateServices to avoid real service creation

This ensures API keys and other secrets are properly loaded from VSCode's async secret storage
and that configuration changes requiring service restart are correctly detected.
- Show placeholder dots (••••••••••••••••) in password fields when secrets are already set
- Only send modified secret fields to prevent overwriting existing secrets with empty values
- Track which fields have been modified by the user
- Add requestCodeIndexSecretStatus message handler to check if secrets exist
- Fix console.log to handle empty string keys without errors
- Ensure changing one setting doesn't clear other unmodified secrets
- Rename handleExternalSettingsChange to handleSettingsChange for clarity
- Remove handleSettingsChange call from ClineProvider (not related to code index)
- Remove codebaseIndexConfig from general settings save in SettingsView
- Delete unused codebaseIndexConfig message handler
- Remove codebaseIndexConfig from WebviewMessage type definition
- Code index settings are now fully independent with their own dedicated UI
- Move 'Enable codebase indexing' toggle to global settings in Experimental section
- Keep indexing-specific settings (API keys, URLs, models) in dedicated Code Index Settings component
- Add codebaseIndexEnabled handler to webview message handler
- Update translations with new settings title and disabled message
- Ensure code index service properly responds to enable/disable changes
- Maintain backward compatibility with existing codebaseIndexConfig structure
…ntext directly

- Updated CodeIndexConfigManager to accept vscode.ExtensionContext in constructor
- Modified CodeIndexManager to pass context directly to CodeIndexConfigManager
- Updated webviewMessageHandler to use provider.context.secrets directly
- Removed getVSCodeContext() method from ContextProxy
- Updated all related tests to reflect these changes
- Fixed CodeIndexSettings webview tests after UI changes
…Manager, CodeIndexServiceFactory, and QdrantVectorStore
- Add advancedConfigLabel, searchMinScoreLabel, searchMinScoreDescription, searchMinScoreResetTooltip keys
- Update startIndexingButton and clearIndexDataButton labels to match main
- Preserve all CodeIndexPopover translations added in this PR
This reverts commit beb1de4924ac1475731fcd06d994ddb96eb1e5fd.
- Added codeIndex.advancedConfigLabel
- Added codeIndex.searchMinScoreLabel
- Added codeIndex.searchMinScoreDescription
- Added codeIndex.searchMinScoreResetTooltip

These keys exist on main but were missing from non-English locales after rebase.
@daniel-lxs daniel-lxs force-pushed the fix-code-index-secret-persistence branch from 54a5333 to a4f9ba9 Compare July 3, 2025 20:31
@daniel-lxs daniel-lxs marked this pull request as ready for review July 3, 2025 20:32
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners July 3, 2025 20:32
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. bug Something isn't working UI/UX UI/UX related or focused labels Jul 3, 2025
@daniel-lxs daniel-lxs moved this from PR [Draft / In Progress] to PR [Needs Review] in Roo Code Roadmap Jul 3, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 3, 2025
@mrubens mrubens merged commit e508eaf into main Jul 3, 2025
24 of 25 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 3, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jul 3, 2025
@mrubens mrubens deleted the fix-code-index-secret-persistence branch July 3, 2025 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:XXL This PR changes 1000+ lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants