Fix Jupyter workspace session scoping

This commit is contained in:
wuyang6
2026-05-13 16:56:14 +08:00
parent 9984d35d1f
commit 9a42b00bfe
2 changed files with 57 additions and 14 deletions
+13 -1
View File
@@ -3,6 +3,8 @@
const ACTIVE_SESSION_ID_KEY = "claw.activeSessionId";
const PENDING_WORKSPACE_SESSION_ID_KEY = "claw.pendingWorkspaceSessionId";
export const ACTIVE_SESSION_CHANGED_EVENT = "claw-active-session-changed";
export const PENDING_WORKSPACE_SESSION_CHANGED_EVENT =
"claw-pending-workspace-session-changed";
export function readActiveSessionId() {
if (typeof window === "undefined") return null;
@@ -55,6 +57,11 @@ export function writePendingWorkspaceSessionId(
}
window.sessionStorage.setItem(PENDING_WORKSPACE_SESSION_ID_KEY, normalized);
window.localStorage.setItem(PENDING_WORKSPACE_SESSION_ID_KEY, normalized);
window.dispatchEvent(
new CustomEvent(PENDING_WORKSPACE_SESSION_CHANGED_EVENT, {
detail: { sessionId: normalized },
}),
);
}
export function consumePendingWorkspaceSessionId() {
@@ -63,7 +70,7 @@ export function consumePendingWorkspaceSessionId() {
return sessionId;
}
function readPendingWorkspaceSessionId() {
export function readPendingWorkspaceSessionId() {
if (typeof window === "undefined") return null;
return (
normalizeSessionId(
@@ -79,6 +86,11 @@ function clearPendingWorkspaceSessionId() {
if (typeof window === "undefined") return;
window.sessionStorage.removeItem(PENDING_WORKSPACE_SESSION_ID_KEY);
window.localStorage.removeItem(PENDING_WORKSPACE_SESSION_ID_KEY);
window.dispatchEvent(
new CustomEvent(PENDING_WORKSPACE_SESSION_CHANGED_EVENT, {
detail: { sessionId: null },
}),
);
}
function normalizeSessionId(value: unknown) {