-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: improve button click handling during extension initialization #7037
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 retry logic when ClineProvider is not immediately available - Attempt to activate sidebar view if no visible provider found - Add user-friendly error messages when initialization is incomplete - Improve error handling in getInstance method with longer wait times - Check for function existence before calling showErrorMessage (test compatibility) Fixes #7036
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 production - technically possible but morally questionable.
await vscode.commands.executeCommand(`${Package.name}.SidebarProvider.focus`) | ||
|
||
// Wait a bit for the view to initialize | ||
await new Promise((resolve) => setTimeout(resolve, 500)) |
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 timeout values between this file (500ms on line 36) and ClineProvider.ts (500ms twice for total 1s) are inconsistent. Consider using a shared constant like PROVIDER_INIT_TIMEOUT_MS = 500 for better maintainability. This would make it clearer what the intended initialization strategy is.
// Try to get the provider again | ||
visibleProvider = ClineProvider.getVisibleInstance() | ||
} catch (error) { | ||
outputChannel.appendLine(`Failed to activate sidebar view: ${error}`) |
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 type-checking the error before logging:
outputChannel.appendLine(`Failed to activate sidebar view: ${error}`) | |
outputChannel.appendLine(`Failed to activate sidebar view: ${error instanceof Error ? error.message : String(error)}`) |
This ensures better type safety when accessing error properties.
visibleProvider = ClineProvider.getVisibleInstance() | ||
} | ||
} catch (error) { | ||
console.error(`Failed to activate Roo Code sidebar: ${error}`) |
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.
Is the double console output intentional? You have both console.error here and console.warn on line 490. Since the error is already being handled, perhaps one logging method would be sufficient?
@@ -19,13 +19,40 @@ | |||
|
|||
/** |
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 JSDoc could be more explicit about the retry behavior. Consider updating it to mention that it 'Attempts to activate the sidebar view if no provider is visible, with retry logic.'
Summary
This PR fixes issue #7036 where users were experiencing errors when clicking buttons in the Roo Code extension after installing version 3.25.13 via .vsix package.
Problem
The extension buttons (settings, account, plus, etc.) were failing when clicked immediately after installation because the ClineProvider instance was not yet initialized or visible. This resulted in errors being shown to users and buttons not functioning properly.
Solution
Changes Made:
Enhanced
getVisibleProviderOrLog
function insrc/activate/registerCommands.ts
:Improved
getInstance
method insrc/core/webview/ClineProvider.ts
:Test compatibility fix:
vscode.window.showErrorMessage
existence before calling it to prevent test failuresTesting
Related Issues
Fixes #7036
Screenshots
The user will now see a helpful message: "Roo Code is still initializing. Please wait a moment and try again, or restart VS Code if the issue persists."
Instead of the previous error messages shown in the issue.
Important
Improves button click handling in Roo Code extension by enhancing initialization logic and error handling for
ClineProvider
.getVisibleProviderOrLog
inregisterCommands.ts
to ensureClineProvider
is initialized.getInstance
inClineProvider.ts
to handle initialization delays up to 1 second with error handling.registerCommands.ts
are now async to wait for provider initialization.getVisibleProviderOrLog
when initialization is incomplete.ClineProvider.ts
.registerCommands.spec.ts
to reflect new async behavior and logging changes.This description was created by
for 2c51307. You can customize this summary. It will automatically update as commits are pushed.