Skip to content

Commit 1aaa30e

Browse files
authored
Closing MCP processes when app terminates. (RooCodeInc#3876)
1 parent f7e5398 commit 1aaa30e

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/core/controller/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ export class Controller {
109109
- https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts
110110
*/
111111
async dispose() {
112-
this.outputChannel.appendLine("Disposing ClineProvider...")
113112
await this.clearTask()
114-
this.outputChannel.appendLine("Cleared task")
115113
while (this.disposables.length) {
116114
const x = this.disposables.pop()
117115
if (x) {
@@ -120,7 +118,6 @@ export class Controller {
120118
}
121119
this.workspaceTracker.dispose()
122120
this.mcpHub.dispose()
123-
this.outputChannel.appendLine("Disposed all disposables")
124121

125122
console.error("Controller disposed")
126123
}

src/core/webview/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ export class WebviewProvider implements vscode.WebviewViewProvider {
5959
return Array.from(this.activeInstances).filter((instance) => instance.view && "onDidChangeViewState" in instance.view)
6060
}
6161

62+
public static async disposeAllInstances() {
63+
const instances = Array.from(this.activeInstances)
64+
for (const instance of instances) {
65+
await instance.dispose()
66+
}
67+
}
68+
6269
async resolveWebviewView(webviewView: vscode.WebviewView | vscode.WebviewPanel) {
6370
this.view = webviewView
6471

src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,15 @@ const { IS_DEV, DEV_WORKSPACE_FOLDER } = process.env
636636

637637
// This method is called when your extension is deactivated
638638
export async function deactivate() {
639+
// Dispose all webview instances
640+
await WebviewProvider.disposeAllInstances()
641+
639642
await telemetryService.sendCollectedEvents()
640643

641644
// Clean up test mode
642645
cleanupTestMode()
643646
await posthogClientProvider.shutdown()
647+
644648
Logger.log("Cline extension deactivated")
645649
}
646650

0 commit comments

Comments
 (0)