Skip to content

feat: reopen diagram automatically on workspace/solution open#11

Open
DisciplinedSoftware wants to merge 5 commits intoOlegIGalkin:mainfrom
DisciplinedSoftware:feature/reopen-diagram-on-reload
Open

feat: reopen diagram automatically on workspace/solution open#11
DisciplinedSoftware wants to merge 5 commits intoOlegIGalkin:mainfrom
DisciplinedSoftware:feature/reopen-diagram-on-reload

Conversation

@DisciplinedSoftware
Copy link

Summary

Fixes the issue where the diagram closes on window reload (VS Code) or is not shown when reopening a solution (Visual Studio) and does not reopen.

VS Code changes

Auto-reopen panel (package.json, extension.ts):

  • Added onStartupFinished activation event so the extension activates on startup
  • Panel open/close state is persisted in workspaceState (panelWasOpen key)
  • On activation, the panel is reopened automatically if it was open before the reload

Diagram data loads correctly after reopen (extension.ts):

  • The importMindMapData message arrives before MindElixir.js finishes loading; the old if (mind) guard silently dropped it
  • Added pendingImportData buffer in the webview: if the message arrives before mind is initialized it is stored, then flushed at the end of initMindMap()

Dev build fix (webpack.dev.config.js):

  • Added CopyWebpackPlugin (already present in the production config) so out/MindElixir/MindElixir.js is not wiped on every dev build — missing this file caused the entire webview module script to fail silently

Visual Studio changes

Auto-show window on solution open (CodeMindMapPackage.cs):

  • When HandleSolutionOpened() finds that the solution has existing mind map data, it now calls ShowToolWindowAsync to ensure the Code Mind Map window is visible
  • Previously the window was never shown automatically; data was only loaded into it if it happened to already be open

Pierre-Luc Gagné and others added 5 commits March 2, 2026 01:52
When the extension activates (on workspace open or Developer: Reload
Window), check if the diagram panel was open before the reload using
workspaceState persistence. If it was, reopen it automatically.

- Add 'onStartupFinished' activation event so extension activates on
  startup, not just when commands are invoked
- Store 'panelWasOpen' flag in workspaceState when panel is created
- Clear flag when panel is disposed (user explicitly closed it)
- On activate, reopen panel if flag is set

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous approach sent 'importMindMapData' immediately after reading
the file, but MindElixir.js may not have loaded yet (mind === null),
causing the data to be silently dropped.

Now the webview posts 'webviewReady' at the end of initMindMap() once
'mind' is fully initialized. The extension responds by reading and
sending the saved file content, guaranteeing importData() can run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous webviewReady handshake could fail if DOMContentLoaded
had already fired before the ES module's listener was registered
(async module imports can delay script execution past the event).

New approach:
- Extension sends importMindMapData eagerly (as before), as VS Code
  queues messages for webviews that haven't loaded yet
- Webview stores any importMindMapData that arrives before mind is
  initialized in pendingImportData
- initMindMap() flushes pendingImportData at the end, once mind is
  fully ready -- guaranteeing the data is applied regardless of
  which side finishes first

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The dev webpack config had 'clean: true' but no CopyWebpackPlugin,
so every dev build wiped out/MindElixir/MindElixir.js. The webview
imports this file via ES module; without it the entire module script
fails silently -- blank canvas and non-functional buttons.

Mirrors the same fix already applied on feature/fix-keyboard-after-click-without-focus.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a solution that has associated mind map data is opened, automatically
show the Code Mind Map tool window (creating it if needed).

Previously HandleSolutionOpened() only loaded data into the window if it
was already visible; the window itself was never shown automatically.
This mirrors the VS Code behavior where the panel reopens on workspace
open.

The actual diagram data is loaded by MindMapBrowser_NavigationCompleted
once WebView2 finishes initializing, so timing is not an issue.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 2, 2026 07:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants