Skip to content

Port feature from vitejs/devtools#527: session-scoped dock UI state across reloads #213

Description

@antfubot

Context

vitejs/devtools#527 ("session-scoped dock UI state — restore open/selected dock, tab, and scroll across reloads") by @dvcolomban restored the active ViewJsonRender spec tab + scroll position via sessionStorage, and which dock is open/selected via a new selectedId field folded into the existing localStorage-backed panelStore, so a dev-server restart or HMR full-reload doesn't drop back to the default dock. It touched packages/core/src/client/inject/runtime.ts, webcomponents/components/dock/DockEmbedded.vue, webcomponents/components/views/ViewJsonRender.vue, the json-render Select.ts/Switch.ts/Tabs.ts/TextInput.ts components, json-render/composables/{dock-entry-id,useUncontrolledValue}.ts, and webcomponents/state/{context,docks}.ts in vitejs/devtools, which moved here as part of the v0.9 migration. Equivalents today: packages/hub-ui/src/client/embedded/index.ts, packages/hub-ui/src/client/components/dock/DockEmbedded.vue, packages/hub-ui/src/client/state/{context,docks}.ts for the dock-side pieces, and packages/json-render-ui/src/components/{Select,Switch,Tabs,TextInput}.ts for the json-render pieces (composables likely live alongside them or in a shared packages/json-render-ui/src/ utils area — check current structure).

Original PR description

Why

Reloading the page (dev-server restart, an HMR full-reload, etc.) always dropped back to whatever dock is open by default, which gets annoying mid-debugging.

What changed

  • Restores the active spec tab and scroll position inside a ViewJsonRender dock — sessionStorage, keyed per dock and tab, since nothing server-side needs to see these and syncing them across tabs would be unwanted UX.
  • Restores which dock is open and selected — selectedId, folded into the existing localStorage-backed panelStore alongside open/mode/position/geometry, rather than a second store, since it's a browser-local singleton exactly like those already are.

Additional context

selectedId living in the same object as open means it inherits #525's shared-state mirror for free, if that one lands — no separate wiring needed there.

Diff: https://github.com/vitejs/devtools/pull/527/files

For agents picking this up

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions