Fix live activity session tracking
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
const ACTIVE_SESSION_ID_KEY = "claw.activeSessionId";
|
||||
export const ACTIVE_SESSION_CHANGED_EVENT = "claw-active-session-changed";
|
||||
|
||||
export function readActiveSessionId() {
|
||||
if (typeof window === "undefined") return null;
|
||||
@@ -19,12 +20,22 @@ export function writeActiveSessionId(sessionId: string | null | undefined) {
|
||||
}
|
||||
window.sessionStorage.setItem(ACTIVE_SESSION_ID_KEY, normalized);
|
||||
window.localStorage.setItem(ACTIVE_SESSION_ID_KEY, normalized);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(ACTIVE_SESSION_CHANGED_EVENT, {
|
||||
detail: { sessionId: normalized },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function clearActiveSessionId() {
|
||||
if (typeof window === "undefined") return;
|
||||
window.sessionStorage.removeItem(ACTIVE_SESSION_ID_KEY);
|
||||
window.localStorage.removeItem(ACTIVE_SESSION_ID_KEY);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(ACTIVE_SESSION_CHANGED_EVENT, {
|
||||
detail: { sessionId: null },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeSessionId(value: unknown) {
|
||||
|
||||
Reference in New Issue
Block a user