From f90737f17f371813bf2433f2688ea7f612a1a82f Mon Sep 17 00:00:00 2001 From: QQ Date: Sat, 14 Nov 2026 14:53:28 +0800 Subject: [PATCH] Import packages/plugin/src/client/navigation.ts --- packages/plugin/src/client/navigation.ts | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 packages/plugin/src/client/navigation.ts diff --git a/packages/plugin/src/client/navigation.ts b/packages/plugin/src/client/navigation.ts new file mode 100644 index 0000000..3f223b3 --- /dev/null +++ b/packages/plugin/src/client/navigation.ts @@ -0,0 +1,28 @@ +import type { RemoteWorkspaceSelection, WorkspacesClientServiceLike } from './types.js' + +export const pendingWorkspaceSelectionKey = 'dsh-remote:pending-workspace-selection' + +export function storedWorkspaceSelection(): RemoteWorkspaceSelection | undefined { + const raw = window.sessionStorage.getItem(pendingWorkspaceSelectionKey) + if (raw === null) return undefined + try { + const value = JSON.parse(raw) as Partial + if (typeof value.targetDeviceId !== 'string' || typeof value.workspaceId !== 'string') throw new Error('invalid') + if (value.backend !== undefined + && value.backend !== 'harness' + && value.backend !== 'codex' + && value.backend !== 'cursor' + && value.backend !== 'antigravity' + && value.backend !== 'pi' + && value.backend !== 'claude' && value.backend !== 'opencode' && value.backend !== 'hermes') throw new Error('invalid') + if (value.sessionId !== undefined && typeof value.sessionId !== 'string') throw new Error('invalid') + return value as RemoteWorkspaceSelection + } catch { + window.sessionStorage.removeItem(pendingWorkspaceSelectionKey) + return undefined + } +} + +export function workspacesReady(snapshot: ReturnType): boolean { + return snapshot.baselinesReady === true || snapshot.phase === 'ready' +}