-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: add workspace-level toggle for codebase indexing #7927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add workspace-specific indexing settings that override global settings - Implement UI toggle in CodeIndexPopover for workspace-level control - Store workspace settings using VSCode workspace state API - Support multi-root workspaces with per-folder settings - Add comprehensive unit tests for new functionality - Update translations for new UI elements Fixes #7926
if (this.context) { | ||
// Use a hash of the workspace path as the key to avoid issues with special characters | ||
const key = `codebaseIndexEnabled_${Buffer.from(workspacePath).toString("base64")}` | ||
await this.context.workspaceState.update(key, enabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good implementation of workspace-specific settings. Consider adding a try/catch block around the context.workspaceState.update call (line 529) to log or handle potential errors during saving.
There was a problem hiding this 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 is like debugging in a mirror - everything looks backwards but somehow still broken.
<div className="mb-4 ml-6"> | ||
<div className="flex items-center gap-2"> | ||
<VSCodeCheckbox | ||
checked={currentSettings.workspaceIndexEnabled !== false} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workspace toggle condition currentSettings.workspaceIndexEnabled !== false
could be more explicit about handling the three-state logic (true/false/undefined). When undefined, it inherits the global setting, but this implicit behavior might be confusing. Consider using a more explicit check for clearer intent.
return this.workspaceIndexEnabled.get(workspacePath) | ||
} | ||
// Use a hash of the workspace path as the key to avoid issues with special characters | ||
const key = `codebaseIndexEnabled_${Buffer.from(workspacePath).toString("base64")}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base64 encoding logic for workspace paths is duplicated here and on line 530. Consider extracting to a private helper method:
private getWorkspaceStateKey(workspacePath: string): string {
return `codebaseIndexEnabled_${Buffer.from(workspacePath).toString("base64")}`;
}
This would improve maintainability and ensure consistency.
@@ -480,4 +501,57 @@ | |||
public get currentSearchMaxResults(): number { | |||
return this.searchMaxResults ?? DEFAULT_MAX_SEARCH_RESULTS | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new workspace-specific methods would benefit from more detailed JSDoc comments explaining:
- The base64 encoding strategy for workspace paths
- The inheritance model (undefined = inherit global)
- How this interacts with multi-root workspaces
This would help future maintainers understand the design decisions.
// Initialize config manager with mocks | ||
configManager = new CodeIndexConfigManager(mockContextProxy, testWorkspacePath, mockContext) | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding edge case tests for workspace paths with special characters (spaces, unicode, etc.) to ensure the base64 encoding handles them correctly. This would increase confidence in the robustness of the implementation.
Fixes #7926
Summary
This PR adds a workspace-level toggle to enable/disable codebase indexing per folder, accessible from the settings pop-up below the chatbox.
Changes
How it works
Testing
Screenshots
The new workspace toggle appears in the Code Index settings popover when indexing is enabled globally.
Important
Adds a workspace-level toggle for codebase indexing, allowing per-workspace control and persistence across sessions, with comprehensive UI and backend support.
CodeIndexPopover.tsx
.CodeIndexConfigManager
to manage workspace-specific settings.workspaceIndexEnabled
tocodebaseIndexConfigSchema
incodebase-index.ts
.CodeIndexPopover.tsx
for workspace-level control.settings.json
for new UI elements.workspace-indexing-toggle.spec.ts
for unit tests of new functionality.manager.spec.ts
to test integration withCodeIndexManager
.This description was created by
for b887bd2. You can customize this summary. It will automatically update as commits are pushed.