Преглед изворни кода

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 <[email protected]>
Christiaan Arnoldus пре 7 месеци
родитељ
комит
57038b75a0
1 измењених фајлова са 8 додато и 2 уклоњено
  1. 8 2
      src/core/webview/ClineProvider.ts

+ 8 - 2
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,