-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: detect newly added folders in workspace dynamically #8887
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
Conversation
- Added workspace folder change listener in extension.ts - Convert codeIndexManagers from array to Map for better tracking - Implement logic to create CodeIndexManager for added folders - Implement logic to dispose CodeIndexManager for removed folders - Add handleWorkspaceFoldersChanged method to ClineProvider - Fixes #8886
PR Review CompleteI've reviewed the changes in this pull request that adds dynamic workspace folder detection. Issues Found
SummaryThe implementation approach is sound, but there's a critical ordering issue that will cause the code to fail at runtime when workspace folders change. The listener registration needs to be moved after the provider initialization. |
| context.subscriptions.push( | ||
| vscode.workspace.onDidChangeWorkspaceFolders(async (event) => { | ||
| // Handle removed folders | ||
| for (const removedFolder of event.removed) { | ||
| const manager = codeIndexManagers.get(removedFolder.uri.fsPath) | ||
| if (manager) { | ||
| outputChannel.appendLine( | ||
| `[CodeIndexManager] Error during background CodeIndexManager configuration/indexing for ${folder.uri.fsPath}: ${error.message || error}`, | ||
| `[CodeIndexManager] Removing CodeIndexManager for removed folder: ${removedFolder.uri.fsPath}`, | ||
| ) | ||
| // Dispose the manager | ||
| manager.dispose() | ||
| // Remove from our map | ||
| codeIndexManagers.delete(removedFolder.uri.fsPath) | ||
| // Remove from context subscriptions | ||
| const index = context.subscriptions.indexOf(manager) | ||
| if (index > -1) { | ||
| context.subscriptions.splice(index, 1) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| context.subscriptions.push(manager) | ||
| // Handle added folders | ||
| for (const addedFolder of event.added) { | ||
| outputChannel.appendLine( | ||
| `[CodeIndexManager] Adding CodeIndexManager for new folder: ${addedFolder.uri.fsPath}`, | ||
| ) | ||
| await initializeCodeIndexManagerForFolder(addedFolder) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Notify the provider about workspace changes | ||
| provider.handleWorkspaceFoldersChanged() | ||
| }), | ||
| ) |
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 provider variable is referenced before it's initialized. The workspace folder change listener (lines 133-165) calls provider.handleWorkspaceFoldersChanged() on line 163, but provider is not created until line 168. This will cause a ReferenceError when workspace folders are added or removed. The listener registration should be moved to after the provider initialization, or the provider reference should be captured differently.
Description
This PR fixes issue #8886 where RooCode fails to detect newly added folders in an existing workspace.
Problem
When users add a new folder to their current VS Code workspace, RooCode does not automatically recognize it. The extension continues to behave as if the folder does not exist, meaning any files inside the new folder are ignored and unavailable for interaction.
Solution
Implemented dynamic workspace folder detection by:
onDidChangeWorkspaceFoldersAPIcodeIndexManagersfrom array to Map for efficient O(1) folder trackingChanges
handleWorkspaceFoldersChangedmethod to update stateTesting
Fixes #8886
Important
Adds dynamic detection of newly added folders in VS Code workspace by managing
CodeIndexManagerinstances and updatingClineProviderstate.onDidChangeWorkspaceFoldersAPI.codeIndexManagersfrom array toMapfor efficient folder tracking.CodeIndexManagerinstances for added and removed folders.ClineProviderto update workspace path and refresh webview state.src/extension.ts: Implements workspace folder change listener and managesCodeIndexManagerinstances.src/core/webview/ClineProvider.ts: AddshandleWorkspaceFoldersChangedmethod to update state.This description was created by
for eb36d95. You can customize this summary. It will automatically update as commits are pushed.