|
1 | | -import type { DockPanelStorage } from '@devframes/hub/client' |
| 1 | +import type { DockPanelStorage, DockSessionStorage } from '@devframes/hub/client' |
2 | 2 | import { getDevframeRpcClient, setDevframeClientContext } from '@devframes/hub/client' |
3 | | -import { useLocalStorage } from '@vueuse/core' |
| 3 | +import { useLocalStorage, useSessionStorage } from '@vueuse/core' |
4 | 4 | import { applyPrimaryColor, setBranding } from '../state/branding' |
5 | | -import { DEFAULT_DOCK_PANEL_STORE } from '../state/docks' |
| 5 | +import { DEFAULT_DOCK_PANEL_STORE, DEFAULT_DOCK_SESSION_STORE } from '../state/docks' |
6 | 6 | import { setupEmbeddedVisibility } from './visibility' |
7 | 7 |
|
8 | 8 | /** |
@@ -59,13 +59,23 @@ async function mountDock(): Promise<void> { |
59 | 59 | { mergeDefaults: true }, |
60 | 60 | ) |
61 | 61 |
|
| 62 | + // Per-tab session UI state (open dock + its route). `sessionStorage`, not |
| 63 | + // `localStorage`: selection is per-tab navigation state, so two tabs against |
| 64 | + // the same server keep their own rather than fighting over a shared one. It |
| 65 | + // survives a reload and is restored after the auth handshake. |
| 66 | + const session = useSessionStorage<DockSessionStorage>( |
| 67 | + 'devframes-dock-session', |
| 68 | + DEFAULT_DOCK_SESSION_STORE(), |
| 69 | + { mergeDefaults: true }, |
| 70 | + ) |
| 71 | + |
62 | 72 | // Resolve branding before the dock exists so the primary color and logo are |
63 | 73 | // in place on the first paint. Read from `ConnectionMeta.configs.ui.branding`, |
64 | 74 | // carried by the connection we just established above. |
65 | 75 | const branding = setBranding(rpc.connectionMeta.configs?.ui?.branding || {}) |
66 | 76 |
|
67 | 77 | const { createDocksContext } = await import('../state/context') |
68 | | - const context = await createDocksContext('embedded', rpc, state) |
| 78 | + const context = await createDocksContext('embedded', rpc, state, session) |
69 | 79 | setDevframeClientContext(context) |
70 | 80 |
|
71 | 81 | const { DockEmbedded } = await import('../components/DockEmbedded') |
|
0 commit comments