Skip to content

feat(hub-ui): restore the active dock across a reload - #223

Closed
antfubot wants to merge 1 commit into
mainfrom
feat/hub-ui-restore-active-dock
Closed

feat(hub-ui): restore the active dock across a reload#223
antfubot wants to merge 1 commit into
mainfrom
feat/hub-ui-restore-active-dock

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

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

  • selectedId now lives on the same localStorage-backed panelStore as open/mode/geometry (packages/hub-ui/src/client/state/docks.ts's new HubDockPanelStorage), instead of resetting to nothing every time createDocksContext runs.
  • 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.vue 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.

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.tspackages/hub-ui/src/client/embedded/index.ts
  • webcomponents/components/dock/DockEmbedded.vuepackages/hub-ui/src/client/components/dock/DockEmbedded.vue
  • webcomponents/state/{context,docks}.tspackages/hub-ui/src/client/state/{context,docks}.ts

The 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/HubDockPanelStorage object — #211 is still open, so this lands the selectedId field 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.

`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>
@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit c2e7d16
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a7eb26642ee140009c51e9d
😎 Deploy Preview https://deploy-preview-223--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

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