Prevent stale session during active runs
This commit is contained in:
@@ -402,10 +402,12 @@ function useCurrentThreadSessionId({
|
|||||||
clearPendingWorkspaceSessionId();
|
clearPendingWorkspaceSessionId();
|
||||||
}
|
}
|
||||||
}, [currentRun.sessionId, pendingSessionId]);
|
}, [currentRun.sessionId, pendingSessionId]);
|
||||||
|
const replayRunSessionId = currentRun.active ? currentRun.sessionId : null;
|
||||||
return (
|
return (
|
||||||
currentRun.sessionId ??
|
replayRunSessionId ??
|
||||||
(includePending ? pendingSessionId : null) ??
|
(includePending ? pendingSessionId : null) ??
|
||||||
(includeActive ? activeSessionId : null)
|
(includeActive ? activeSessionId : null) ??
|
||||||
|
currentRun.sessionId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1286,13 +1288,13 @@ function useComposerContextStatus() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const cleanLatestSessionId = normalizeSessionId(latestSessionId);
|
const cleanLatestSessionId = normalizeSessionId(latestSessionId);
|
||||||
if (cleanLatestSessionId) {
|
if (cleanLatestSessionId && !isRunning) {
|
||||||
writeActiveSessionId(cleanLatestSessionId);
|
writeActiveSessionId(cleanLatestSessionId);
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
window.dispatchEvent(new Event("claw-sessions-changed"));
|
window.dispatchEvent(new Event("claw-sessions-changed"));
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
}, [latestSessionId]);
|
}, [isRunning, latestSessionId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (wasRunningRef.current && !isRunning) {
|
if (wasRunningRef.current && !isRunning) {
|
||||||
@@ -1315,9 +1317,12 @@ function useComposerContextStatus() {
|
|||||||
const statePayload = stateResponse.ok
|
const statePayload = stateResponse.ok
|
||||||
? ((await stateResponse.json()) as ClawState)
|
? ((await stateResponse.json()) as ClawState)
|
||||||
: {};
|
: {};
|
||||||
|
const activeSessionId = normalizeSessionId(readActiveSessionId());
|
||||||
|
const latestMessageSessionId = normalizeSessionId(latestSessionId);
|
||||||
let sessionId = normalizeSessionId(
|
let sessionId = normalizeSessionId(
|
||||||
normalizeSessionId(latestSessionId) ||
|
(isRunning
|
||||||
normalizeSessionId(readActiveSessionId()) ||
|
? activeSessionId || latestMessageSessionId
|
||||||
|
: latestMessageSessionId || activeSessionId) ||
|
||||||
normalizeSessionId(statePayload.active_session_id),
|
normalizeSessionId(statePayload.active_session_id),
|
||||||
);
|
);
|
||||||
if (sessionId) writeActiveSessionId(sessionId);
|
if (sessionId) writeActiveSessionId(sessionId);
|
||||||
|
|||||||
Reference in New Issue
Block a user