From 57038b75a0410cc6512149ba27c0dee4e3fc27fd Mon Sep 17 00:00:00 2001 From: Christiaan Arnoldus Date: Wed, 28 May 2025 23:07:03 +0200 Subject: [PATCH] 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> --- src/core/webview/ClineProvider.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 13121531a7..932809202e 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -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,