Share pending workspace id across frontend chunks
This commit is contained in:
@@ -5,7 +5,11 @@ export const ACTIVE_SESSION_CHANGED_EVENT = "claw-active-session-changed";
|
||||
export const PENDING_WORKSPACE_SESSION_CHANGED_EVENT =
|
||||
"claw-pending-workspace-session-changed";
|
||||
|
||||
let pendingWorkspaceSessionId: string | null = null;
|
||||
declare global {
|
||||
interface Window {
|
||||
__clawPendingWorkspaceSessionId?: string | null;
|
||||
}
|
||||
}
|
||||
|
||||
export function readActiveSessionId() {
|
||||
if (typeof window === "undefined") return null;
|
||||
@@ -56,7 +60,7 @@ export function writePendingWorkspaceSessionId(
|
||||
clearPendingWorkspaceSessionId();
|
||||
return;
|
||||
}
|
||||
pendingWorkspaceSessionId = normalized;
|
||||
window.__clawPendingWorkspaceSessionId = normalized;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(PENDING_WORKSPACE_SESSION_CHANGED_EVENT, {
|
||||
detail: { sessionId: normalized },
|
||||
@@ -66,12 +70,12 @@ export function writePendingWorkspaceSessionId(
|
||||
|
||||
export function readPendingWorkspaceSessionId() {
|
||||
if (typeof window === "undefined") return null;
|
||||
return pendingWorkspaceSessionId;
|
||||
return normalizeSessionId(window.__clawPendingWorkspaceSessionId);
|
||||
}
|
||||
|
||||
export function clearPendingWorkspaceSessionId() {
|
||||
if (typeof window === "undefined") return;
|
||||
pendingWorkspaceSessionId = null;
|
||||
window.__clawPendingWorkspaceSessionId = null;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(PENDING_WORKSPACE_SESSION_CHANGED_EVENT, {
|
||||
detail: { sessionId: null },
|
||||
|
||||
Reference in New Issue
Block a user