Skip to content

Scope persisted visualizer state to each <Visualizer> with storageKey - #1205

Merged
Micheal Parks (micheal-parks) merged 3 commits into
mainfrom
scoped-persist
Nov 25, 2026
Merged

Micheal Parks (micheal-parks) merged 3 commits into
mainfrom
scoped-persist

Conversation

@micheal-parks

Copy link
Copy Markdown
Member

Scopes everything the visualizer persists to each <Visualizer> instance, so an embedded viewer such as a test widget no longer reads or overwrites the standalone app's state.

Library

  • <Visualizer> gains storageKey?: string. Omitted, every persisted value lives in memory for that visualizer alone. With a key, values persist under <storageKey>:<baseKey>, and visualizers given the same key share them.
  • New usePersistedStates() (src/lib/hooks/usePersistedStates.svelte.ts) returns a lookup that resolves each base key to one live value per visualizer. Components in the same visualizer now see each other's writes, which fixes SharedPoseFields and MoveControls holding separate copies of the orientation format.
  • provideSettings(storageKey) and createEnvironment(storageKey?) persist only when given a key. Settings live in IndexedDB under <storageKey>:settings.
  • Every persisted value goes through it: settings, environment mode, details tab, orientation format, the Settings tab, world-tree folders, open control widgets and their rects, per-resource widget expansion, and the per-frame Move JSON and tab.
  • Storage keys drop the motion-tools prefix, since storageKey now scopes them. For example motion-tools:environment-mode is now environment-mode.
  • expandedFolders and useControlWidgets no longer hold module-level state. useControlWidgets() must now be called while a component initializes.

App

@changeset-bot

changeset-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f7defc2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@viamrobotics/visualization Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-11-25 16:51 UTC

@micheal-parks
Micheal Parks (micheal-parks) merged commit 487f3e7 into main Nov 25, 2026
8 checks passed
@micheal-parks
Micheal Parks (micheal-parks) deleted the scoped-persist branch November 25, 2026 16:51
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