Skip to content

DoodleWidget: Persist initialState to localStorage after import#446

Merged
shravanngoswamii merged 2 commits intomainfrom
sg-DoodleBUG-fix
Mar 30, 2026
Merged

DoodleWidget: Persist initialState to localStorage after import#446
shravanngoswamii merged 2 commits intomainfrom
sg-DoodleBUG-fix

Conversation

@shravanngoswamii
Copy link
Copy Markdown
Member

@shravanngoswamii shravanngoswamii commented Mar 30, 2026

Summary

  • When initialState is loaded from an external source (e.g., a host application passing saved canvas state), the imported projects and graph contents were only set in Vue's reactive memory but never written to localStorage
  • This caused sidebar components to not re-render, and graph content to be lost on page reload or component remount
  • Fix: After importing from initialState, call saveProjects() and saveGraph() for each imported graph to keep localStorage in sync with the in-memory state

Test plan

  • Load DoodleWidget with initialState containing projects and graphs
  • Verify the left sidebar shows the imported projects and graphs immediately
  • Reload the page — verify the state persists via localStorage (before the host re-supplies initialState)
  • Verify no regression when loading without initialState (blank start still creates Default Project)

🤖 Generated with Claude Code

When initialState is loaded from an external source, the imported
projects and graph contents were only set in Vue's reactive memory
but never written to localStorage. This caused:

1. Sidebar components watching stateVersion not re-rendering
   (saveProjects increments stateVersion)
2. On component remount, setPrefix/loadProjects reading empty
   localStorage and overwriting the imported in-memory state
3. Graph content lost on page reload since loadGraph found nothing

Fix: After importing from initialState, call saveProjects() and
saveGraph() for each imported graph to keep localStorage in sync.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

A preview of this pull request has been deployed.
https://turinglang.org/JuliaBUGS.jl/DoodleBUGS/pr-previews/446

When initialState is provided, its currentGraphId represents the
latest server-saved active graph. Previously, the localStorage UI
state would override this with a stale local value, causing the
active graph to not sync across different browser sessions.

Now localStorage currentGraphId is only used when no initialState
is provided (standalone widget usage without external state).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shravanngoswamii shravanngoswamii merged commit 7d9e5a9 into main Mar 30, 2026
3 checks passed
@shravanngoswamii shravanngoswamii deleted the sg-DoodleBUG-fix branch March 30, 2026 17:44
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