Skip to content

Commit 3712ae6

Browse files
njb90claude
andcommitted
feat: close preview panels and fix homescreen refresh on env switch
- resetAllPreviewPanels now disposes panels via the openPanels Map - HomescreenViewProvider clears _webviewView on dispose so refresh() no-ops safely instead of throwing "Webview is disposed" and halting the onDidChangeEnvironment callback Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f06ba00 commit 3712ae6

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

src/commands/previewAsset.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,10 @@ function registerPreview(context: vscode.ExtensionContext) {
121121

122122
/**
123123
* Closes all open preview panels when the active environment switches.
124-
* Uses the tab groups API so it works regardless of the openPanels tracking state.
125124
*/
126125
export function resetAllPreviewPanels(): void {
127-
for (const tabGroup of vscode.window.tabGroups.all) {
128-
for (const tab of tabGroup.tabs) {
129-
if (
130-
tab.input instanceof vscode.TabInputWebview &&
131-
tab.input.viewType === "cloudinaryAssetPreview"
132-
) {
133-
vscode.window.tabGroups.close(tab);
134-
}
135-
}
126+
for (const panel of openPanels.values()) {
127+
panel.dispose();
136128
}
137129
}
138130

src/webview/homescreenView.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export class HomescreenViewProvider implements vscode.WebviewViewProvider {
2525
): void {
2626
this._webviewView = webviewView;
2727

28+
webviewView.onDidDispose(() => {
29+
this._webviewView = undefined;
30+
});
31+
2832
webviewView.webview.options = {
2933
enableScripts: true,
3034
localResourceRoots: [vscode.Uri.joinPath(this._extensionUri, "media")],

0 commit comments

Comments
 (0)