feat(core): mirror the dock panel's localStorage state into shared state - #525
Open
dvcolomban wants to merge 2 commits into
Open
feat(core): mirror the dock panel's localStorage state into shared state#525dvcolomban wants to merge 2 commits into
dvcolomban wants to merge 2 commits into
Conversation
`panelStore` (`vite-devtools-dock-state`) is purely browser-local today — a node-side plugin has no way to observe it, including whether the panel is even open. Wrap the existing `useLocalStorage` call with a small generic helper, `useLocalStorageSharedState`, that mirrors the whole value into `rpc.sharedState` under the same key: shared-state mutations already round-trip through the server before reappearing locally, so this is the entire mechanism — no new dock-entry field, no client-script gating, no RPC command, no trust handshake. Deliberately mirrors the whole object rather than cherry-picking `open`: it's already one `useLocalStorage`-backed, fully serializable, browser-local singleton (not per-tab) — a second, narrower key for one of its fields would just be a redundant place for that field to live. Known, accepted limitation: shared state is one authoritative value, last-mutation-wins, so a node-side consumer watching `open` across two open tabs sees whichever one mutated most recently. Per-connection keying would need a way to garbage-collect a disconnected tab's entry, which nothing in the public API exposes today — revisit if that changes.
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-oxc
@vitejs/devtools-rolldown
@vitejs/devtools-vite
@vitejs/devtools-vitest
commit: |
dvcolomban
marked this pull request as ready for review
August 10, 2026 15:17
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.
Why
panelStore(thevite-devtools-dock-statekey) is purely browser-local today — nothing on the Node/server side can see it, including whether the panel is even open. Any Node-side plugin that wants to react to dock UI state — gate some behavior on visibility, log usage, sync it elsewhere — has nothing to observe.What changed
useLocalStoragecall with a small generic helper,useLocalStorageSharedState, that mirrors the whole value intorpc.sharedStateunder the same key. Shared-state mutations already round-trip through the server before reappearing locally, so that's the entire mechanism — no new dock-entry field, no client-script gating, no RPC command, no trust handshake.open: it's already oneuseLocalStorage-backed, fully serializable, browser-local singleton (not per-tab), so a second, narrower key for just one field would just be a redundant place for that field to live.Known limitation, flagging it rather than hiding it: shared state is one authoritative value, last-mutation-wins — with two tabs open, a Node-side consumer watching e.g.
opensees whichever tab mutated most recently. Per-connection keying would need a way to garbage-collect a disconnected tab's entry, and nothing in the public API exposes that today, so I went with the simpler singleton.Linked Issues
Additional context
Verified with
pnpm build,pnpm test(5 new tests for the helper, 384 passing total),pnpm typecheck,pnpm lint— all green.