Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 29, 2025

This PR implements per-workspace codebase indexing control as requested in issue #7511.

Summary

Users working with multiple VS Code windows experience high GPU usage when indexing is enabled globally. This PR adds granular control to enable/disable indexing for specific projects/workspaces.

Changes

  • ✅ Added workspace-specific storage support to ContextProxy with methods to get/set workspace-specific state
  • ✅ Updated CodeIndexConfigManager to check workspace settings before falling back to global settings
  • ✅ Modified the webview message handler to support workspace-specific indexing toggles
  • ✅ Added necessary message types to WebviewMessage and ExtensionMessage interfaces
  • ✅ Modified the CodeIndexPopover React component to include workspace override checkboxes
  • ✅ Added translation keys for the new UI elements
  • ✅ Updated tests to support the new workspace-specific methods

How it works

  1. Users can now enable a workspace-specific override in the Code Index settings
  2. When the override is enabled, they can toggle indexing on/off for that specific workspace
  3. Workspace settings take precedence over global settings when present
  4. Each workspace maintains its own indexing state independently

Testing

  • All existing tests pass ✅
  • Type checking passes ✅
  • Linting passes ✅

Fixes #7511


Important

Adds per-workspace codebase indexing control, allowing users to manage indexing settings for individual workspaces, with updates to ContextProxy, webviewMessageHandler, and CodeIndexPopover.

  • Behavior:
    • Adds per-workspace codebase indexing control, allowing users to enable/disable indexing for specific workspaces.
    • Workspace settings take precedence over global settings when present.
  • Implementation:
    • Updates ContextProxy to support workspace-specific state with getWorkspaceState() and updateWorkspaceState() methods.
    • Modifies webviewMessageHandler to handle workspace-specific indexing settings.
    • Updates CodeIndexConfigManager to prioritize workspace settings over global settings.
    • Enhances CodeIndexPopover to include UI elements for workspace-specific settings.
  • Testing:
    • Updates tests in config-manager.spec.ts and manager.spec.ts to cover new workspace-specific functionality.
  • Misc:
    • Adds new message types to WebviewMessage and ExtensionMessage interfaces.
    • Adds translation keys for new UI elements in settings.json.

This description was created by Ellipsis for cfc5529. You can customize this summary. It will automatically update as commits are pushed.

- Add workspace-specific storage support to ContextProxy
- Update CodeIndexConfigManager to check workspace settings before global
- Add message handlers for workspace-specific indexing settings
- Add UI support with workspace override toggle in CodeIndexPopover
- Add translation keys for new UI elements
- Update tests to support new workspace-specific methods

Fixes #7511
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 29, 2025 04:34
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Aug 29, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code because apparently I trust no one, not even myself.

const contextProxy = await ContextProxy.getInstance(context)
// Set the workspace path for the ContextProxy to enable workspace-specific settings
const workspacePath = getWorkspacePath()
if (workspacePath) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? The workspace path is set after getting the ContextProxy instance. Could this cause issues if multiple workspaces try to initialize simultaneously? Consider setting the workspace path as part of the getInstance call or ensuring thread safety.

* Get workspace-specific state value
* Falls back to global state if workspace value doesn't exist
*/
public getWorkspaceState<T>(key: string, defaultValue?: T): T | undefined {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workspace state operations don't have error handling. What happens if VSCode storage operations fail? Consider wrapping these in try-catch blocks to handle potential failures gracefully.

if (!this._configManager) {
// Ensure the ContextProxy has the workspace path set for workspace-specific settings
if (this.workspacePath && contextProxy.workspacePath !== this.workspacePath) {
contextProxy.setWorkspacePath(this.workspacePath)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workspace path mismatch check only updates the path but doesn't handle potential conflicts. Should this be more defensive? What if two different CodeIndexManager instances are trying to use different workspace paths?

await this.initialize()
}

/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding more detailed JSDoc comments for these new public methods. It would help future developers understand the behavior, especially around edge cases like what happens when workspace path is undefined.

</div>

{/* Workspace-specific override */}
{cwd && (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice UI addition! Consider adding a visual indicator to show which setting (global vs workspace) is currently active. This would help users understand the override hierarchy better.

getSecret: vi.fn().mockReturnValue(undefined),
refreshSecrets: vi.fn().mockResolvedValue(undefined),
updateGlobalState: vi.fn(),
getWorkspaceState: vi.fn().mockReturnValue(undefined),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that you updated the mocks! Consider adding specific test cases for the workspace override scenarios - like testing what happens when workspace setting exists vs when it doesn't, and verifying the fallback behavior.

@daniel-lxs
Copy link
Member

The issue needs proper scoping

@daniel-lxs daniel-lxs closed this Aug 29, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 29, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 29, 2025
@daniel-lxs daniel-lxs deleted the feat/per-workspace-codebase-indexing branch August 29, 2025 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Feature: Per-Workspace Codebase Indexing Control

3 participants