Skip to content

fix(vscode): restore a diagram panel across an extension update - #372

Merged
HuiJun merged 1 commit into
developfrom
fix/diagram-restore-across-versions
Sep 17, 2026
Merged

HuiJun merged 1 commit into
developfrom
fix/diagram-restore-across-versions

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

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 WebviewOptions it was created with, so its localResourceRoots still name <old extension dir>/dist. After installing another version the extension (and its bundled webview.js) lives under a differently named directory, and the script asWebviewUri points at is outside the restored roots, so the webview blocks it.

DiagramPanel now sets webview.options from the installed version's extensionUri before setting the page; create and the serializer's adopt share one webviewOptions(extensionUri):

// DiagramPanel constructor
this.panel.webview.options = webviewOptions(extensionUri);
this.panel.webview.html = html(this.panel.webview, extensionUri, docURI, selected);

With the nightly snapshot now shipping a .vsix whose 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 -- --production in editors/vscode; python3 scripts/changelog.py check.
  • The serializer path needs a real VS Code (the unit tests do not import 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 test and make lint pass locally (extension typecheck/tests/build; no Go change)
  • Tests added or updated for the change (webview restoration is not unit-testable without the vscode host; verified in VS Code)
  • Documentation extended where it already covers the surface (no documented surface changes)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (none moved)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

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>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author
Verified in real VS Code (Linux) at d144167

The restoration scenario that failed before this change now passes:

  • Installed 0.1.0-nightly-20260917-aaaaaaa and opened a rendered diagram.
  • With that panel open, installed 0.1.0-nightly-20260918-bbbbbbb and reloaded the window: nodes visible, view dropdown populated, no close/reopen needed.
  • Repeated the open-panel transition to stable 0.1.0: same result.
  • Extensions view showed each exact installed version.
nightly → nightly reload nightly → stable reload
Nightly diagram restored without reopening Stable diagram restored without reopening
Regression checks

Same-version reload and Alt+D close/reopen render normally. Introducing and fixing an unresolved reference (Enginex) updated diagnostics and the diagram label; Problems ended empty. Linux only.

@HuiJun
HuiJun marked this pull request as ready for review September 17, 2026 20:48

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@HuiJun
HuiJun merged commit 92e12ea into develop Sep 17, 2026
12 checks passed
@HuiJun
HuiJun deleted the fix/diagram-restore-across-versions branch September 17, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant