()
| 612 | } |
| 613 | |
| 614 | async dispose() { |
| 615 | if (this._disposed) { |
| 616 | return |
| 617 | } |
| 618 | |
| 619 | this._disposed = true |
| 620 | this.log("Disposing ClineProvider...") |
| 621 | |
| 622 | // Clear all tasks from the stack. |
| 623 | while (this.clineStack.length > 0) { |
| 624 | await this.removeClineFromStack() |
| 625 | } |
| 626 | |
| 627 | this.log("Cleared all tasks") |
| 628 | |
| 629 | // Clear all pending edit operations to prevent memory leaks |
| 630 | this.clearAllPendingEditOperations() |
| 631 | this.log("Cleared pending operations") |
| 632 | |
| 633 | if (this.view && "dispose" in this.view) { |
| 634 | this.view.dispose() |
| 635 | this.log("Disposed webview") |
| 636 | } |
| 637 | |
| 638 | this.clearWebviewResources() |
| 639 | |
| 640 | // Clean up cloud service event listener |
| 641 | if (CloudService.hasInstance()) { |
| 642 | CloudService.instance.off("settings-updated", this.handleCloudSettingsUpdate) |
| 643 | } |
| 644 | |
| 645 | while (this.disposables.length) { |
| 646 | const x = this.disposables.pop() |
| 647 | |
| 648 | if (x) { |
| 649 | x.dispose() |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | this._workspaceTracker?.dispose() |
| 654 | this._workspaceTracker = undefined |
| 655 | await this.mcpHub?.unregisterClient() |
| 656 | this.mcpHub = undefined |
| 657 | await this.skillsManager?.dispose() |
| 658 | this.skillsManager = undefined |
| 659 | this.marketplaceManager?.cleanup() |
| 660 | this.customModesManager?.dispose() |
| 661 | this.taskHistoryStore.dispose() |
| 662 | this.flushGlobalStateWriteThrough() |
| 663 | this.log("Disposed all disposables") |
| 664 | ClineProvider.activeInstances.delete(this) |
| 665 | |
| 666 | // Clean up any event listeners attached to this provider |
| 667 | this.removeAllListeners() |
| 668 | |
| 669 | McpServerManager.unregisterProvider(this) |
| 670 | } |
| 671 |
no test coverage detected