Harden webview panel lifecycle and restore panels across window reloads - #886
Open
chrisdp wants to merge 1 commit into
Open
Harden webview panel lifecycle and restore panels across window reloads#886chrisdp wants to merge 1 commit into
chrisdp wants to merge 1 commit into
Conversation
- postMessage resolves the webview inside try/catch: touching .webview
on a disposed panel throws synchronously, so a device event arriving
after the user closes a popped-out panel (e.g. the SceneGraph
Inspector) crashed instead of queueing.
- attachPanel() extracted from createOrRevealWebviewPanel; the panel's
onDidDispose now clears the stored reference so a closed panel can't
be posted to or revealed again.
- enablePanelRestore(): providers can opt into a WebviewPanelSerializer
so their popped-out panel survives a window reload (paired with an
onWebviewPanel activation event). SceneGraph Inspector adopts it.
- retainPanelContextWhenHidden: opt-in retainContextWhenHidden for the
panel flavor of a view.
- The dev-mode html reload watcher targets (view ?? panel) instead of
assuming the sidebar view exists.
- The index.html template exposes webviewContext ('sidebar' | 'panel')
so a view can persist/behave differently per surface; defaults to
'sidebar' so existing views are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Hardens the shared webview base class's popped-out-panel lifecycle and lets panels survive a window reload.
vscode.WebviewPanel.webviewthrows synchronously ("Webview is disposed") once the panel is disposed.postMessagepreviously resolved the webview outside its try/catch, so a device event arriving after the user closed a popped-out panel (e.g. the SceneGraph Inspector's) threw instead of queueing the message.this.panelwas never cleared when the user closed the tab, so the provider kept posting at (and trying to reveal) a dead panel forever.enablePanelRestore()registers aWebviewPanelSerializerso a popped-out panel comes back after a reload, paired with anonWebviewPanel:<id>activation event (same pattern as the existingonWebviewPanel:rceVideoView). The SceneGraph Inspector adopts it.retainPanelContextWhenHidden— providers can opt their panel flavor intoretainContextWhenHiddenwhen re-rendering from scratch on tab switch is too costly.this.view.webviewunconditionally and NPE'd when only a panel was open; it now targets(view ?? panel).webviewContext: the index.html template now exposeswindow.webviewContext('sidebar' | 'panel') so a view can persist state or behave differently per surface. Defaults to'sidebar', so existing views are byte-for-byte unaffected.Why now
The SceneGraph Inspector already ships an "open in panel" command, so the disposed-panel crash and the missing restore are user-visible today. The rest is groundwork any future panel-capable view gets for free.
Testing
tsc --noEmit, eslint: clean.registerWebviewPanelSerializeradded to the vscode mock).🤖 Generated with Claude Code