Scope active session to browser tab
This commit is contained in:
@@ -1320,10 +1320,9 @@ function useComposerContextStatus() {
|
||||
const activeSessionId = normalizeSessionId(readActiveSessionId());
|
||||
const latestMessageSessionId = normalizeSessionId(latestSessionId);
|
||||
let sessionId = normalizeSessionId(
|
||||
(isRunning
|
||||
isRunning
|
||||
? activeSessionId || latestMessageSessionId
|
||||
: latestMessageSessionId || activeSessionId) ||
|
||||
normalizeSessionId(statePayload.active_session_id),
|
||||
: latestMessageSessionId || activeSessionId,
|
||||
);
|
||||
if (sessionId) writeActiveSessionId(sessionId);
|
||||
let sessionPayload: ClawStoredSession | null = null;
|
||||
|
||||
@@ -492,9 +492,7 @@ function AccountMenu({
|
||||
: [];
|
||||
setState(nextState);
|
||||
setSessions(nextSessions);
|
||||
const activeSessionId = normalizeSessionId(
|
||||
readActiveSessionId() ?? nextState?.active_session_id,
|
||||
);
|
||||
const activeSessionId = normalizeSessionId(readActiveSessionId());
|
||||
if (!activeSessionId) {
|
||||
setActiveSession(null);
|
||||
return;
|
||||
|
||||
@@ -13,9 +13,8 @@ declare global {
|
||||
|
||||
export function readActiveSessionId() {
|
||||
if (typeof window === "undefined") return null;
|
||||
return (
|
||||
normalizeSessionId(window.sessionStorage.getItem(ACTIVE_SESSION_ID_KEY)) ??
|
||||
normalizeSessionId(window.localStorage.getItem(ACTIVE_SESSION_ID_KEY))
|
||||
return normalizeSessionId(
|
||||
window.sessionStorage.getItem(ACTIVE_SESSION_ID_KEY),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -27,7 +26,7 @@ export function writeActiveSessionId(sessionId: string | null | undefined) {
|
||||
return;
|
||||
}
|
||||
window.sessionStorage.setItem(ACTIVE_SESSION_ID_KEY, normalized);
|
||||
window.localStorage.setItem(ACTIVE_SESSION_ID_KEY, normalized);
|
||||
window.localStorage.removeItem(ACTIVE_SESSION_ID_KEY);
|
||||
const pendingSessionId = readPendingWorkspaceSessionId();
|
||||
if (pendingSessionId && pendingSessionId !== normalized) {
|
||||
clearPendingWorkspaceSessionId();
|
||||
|
||||
Reference in New Issue
Block a user