feat(hub-ui): restore the active dock across a reload - #223
Open
antfubot wants to merge 1 commit into
Open
Conversation
`selectedId` used to reset to nothing every time the embedded dock mounted. It now lives on the same localStorage-backed `panelStore` as `open`/mode/geometry, so a dev-server restart or HMR full-reload keeps the dock open on whatever was selected. A restored id that no longer resolves to a selectable entry (removed, or pointing at a group/subTabs anchor) is cleared once on boot without forcing the panel open; `DockEmbedded` then falls back to the first available entry if the panel is open with nothing selected, mirroring `DockStandalone`'s existing boot guard. Adds `packages/hub-ui`'s first vitest suite (registered in the root `vitest.config.ts`) covering the restore/validation behavior via the existing `createMockDocksContext` story helper. Co-authored-by: dvcolomban <90617742+dvcolomban@users.noreply.github.com>
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This was referenced Aug 14, 2026
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
Reloading the page (dev-server restart, an HMR full-reload, etc.) always dropped the embedded dock back to nothing selected — annoying mid-debugging.
What changed
selectedIdnow lives on the same localStorage-backedpanelStoreasopen/mode/geometry (packages/hub-ui/src/client/state/docks.ts's newHubDockPanelStorage), instead of resetting to nothing every timecreateDocksContextruns.subTabsanchor) is cleared once on boot without forcing the panel open.DockEmbedded.vuefalls back to the first available entry if the panel is open with nothing selected, mirroringDockStandalone's existing boot guard.packages/hub-ui's first vitest suite (registered in the rootvitest.config.ts), covering the restore/validation behavior via the existingcreateMockDocksContextstory helper.Context
Ports the dock-selection half of vitejs/devtools#527 ("session-scoped dock UI state — restore open/selected dock, tab, and scroll across reloads") by @dvcolomban, adapted to this repo's post-migration shape:
packages/core/src/client/inject/runtime.ts→packages/hub-ui/src/client/embedded/index.tswebcomponents/components/dock/DockEmbedded.vue→packages/hub-ui/src/client/components/dock/DockEmbedded.vuewebcomponents/state/{context,docks}.ts→packages/hub-ui/src/client/state/{context,docks}.tsThe json-render half (session-persisted uncontrolled tab/select/switch/input state + scroll position) is split out to a separate PR against
packages/json-render-ui, since the two are independent file sets.This PR is coupled to #211 (the vitejs/devtools#525 port, mirroring the dock panel's localStorage state into shared state) via the shared
panelStore/HubDockPanelStorageobject — #211 is still open, so this lands theselectedIdfield first; #211 will need to cover the merged shape when it lands.Part of #213 (closes once the companion json-render-ui PR also merges).
Created with the help of an agent.