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