fix(vscode): restore a diagram panel across an extension update - #372
Merged
Merged
Conversation
A webview panel VS Code restores after a reload comes back with the options it was created with, and its resource roots name the directory of the extension version that created it. After installing another version the bundled webview script lives in a different directory, so the restored panel's script was blocked: it drew nothing and listed no views until closed and reopened. A same-version reload was unaffected. The panel now sets its resource roots from the installed version before its page is set, on creation and restoration alike. Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
Author
Verified in real VS Code (Linux) at d144167The restoration scenario that failed before this change now passes:
Regression checksSame-version reload and Alt+D close/reopen render normally. Introducing and fixing an unresolved reference ( |
HuiJun
marked this pull request as ready for review
September 17, 2026 20:48
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 and why
A diagram panel left open across an extension update restored blank after the reload: no drawing, an empty view selector. Closing and reopening it recovered, and a same-version reload was never affected.
VS Code restores a serialized webview panel with the
WebviewOptionsit was created with, so itslocalResourceRootsstill name<old extension dir>/dist. After installing another version the extension (and its bundledwebview.js) lives under a differently named directory, and the scriptasWebviewUripoints at is outside the restored roots, so the webview blocks it.DiagramPanelnow setswebview.optionsfrom the installed version'sextensionUribefore setting the page;createand the serializer'sadoptshare onewebviewOptions(extensionUri):With the nightly snapshot now shipping a
.vsixwhose version changes every night (#371), this becomes the ordinary update path, so it is worth fixing before users hit it.How it was verified
npm run typecheck,npm test(159 tests),npm run build -- --productionineditors/vscode;python3 scripts/changelog.py check.vscode), so it is verified by hand: install one version of the.vsix, open a diagram, install a package stamped with another version, reload the window — the restored panel draws.Checklist
make testandmake lintpass locally (extension typecheck/tests/build; no Go change)vscodehost; verified in VS Code)changes/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (none moved)F4,K5) in the body, docs, or changelog