Fix menu breaking when Roo is moved between primary and secondary sidebars (#4045)

* Fix menu breaking when Roo is moved between primary and secondary sidebars

Hello Roo Team! We changed this on the Kilo side and thought it might be useful to you!

The menu buttons (Settings etc.) stop working when Roo is moved between the primary and secondary sidebars.
This is because ClineProvider is prematurely disposed in that case
This change prevents the ClineProvider from being disposed when hosted in a sidebar.
It should still be disposed when hosted in a tab, because they have their own ClineProvider instance.

Found while investigating https://github.com/Kilo-Org/kilocode/issues/502.

* refactor: improve logging

* fix: extra bracket

---------

Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
This commit is contained in:
Christiaan Arnoldus 2025-05-28 23:07:03 +02:00 committed by GitHub
parent 2e5a1a8e1d
commit 57038b75a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -339,7 +339,8 @@ export class ClineProvider
this.view = webviewView
// Set panel reference according to webview type
if ("onDidChangeViewState" in webviewView) {
const inTabMode = "onDidChangeViewState" in webviewView
if (inTabMode) {
// Tag page type
setPanel(webviewView, "tab")
} else if ("onDidChangeVisibility" in webviewView) {
@ -441,7 +442,12 @@ export class ClineProvider
// This happens when the user closes the view or when the view is closed programmatically
webviewView.onDidDispose(
async () => {
await this.dispose()
if (inTabMode) {
this.log("Disposing ClineProvider instance for tab view")
await this.dispose()
} else {
this.log("Preserving ClineProvider instance for sidebar view reuse")
}
},
null,
this.disposables,