Clear stale active session ids
This commit is contained in:
@@ -14,7 +14,11 @@ export async function GET(req: Request) {
|
||||
if (sessionId) url.searchParams.set("session_id", sessionId);
|
||||
|
||||
try {
|
||||
const response = await fetch(url, { cache: "no-store" });
|
||||
let response = await fetch(url, { cache: "no-store" });
|
||||
if (response.status === 404 && sessionId) {
|
||||
url.searchParams.delete("session_id");
|
||||
response = await fetch(url, { cache: "no-store" });
|
||||
}
|
||||
const payload = await response.text();
|
||||
return new Response(payload, {
|
||||
status: response.status,
|
||||
|
||||
@@ -549,7 +549,7 @@ function useComposerContextStatus() {
|
||||
const statePayload = stateResponse.ok
|
||||
? ((await stateResponse.json()) as ClawState)
|
||||
: {};
|
||||
const sessionId = normalizeSessionId(
|
||||
let sessionId = normalizeSessionId(
|
||||
normalizeSessionId(latestSessionId) ||
|
||||
normalizeSessionId(
|
||||
window.localStorage.getItem("claw.activeSessionId"),
|
||||
@@ -567,9 +567,13 @@ function useComposerContextStatus() {
|
||||
cache: "no-store",
|
||||
},
|
||||
);
|
||||
sessionPayload = sessionResponse.ok
|
||||
? ((await sessionResponse.json()) as ClawStoredSession)
|
||||
: null;
|
||||
if (sessionResponse.ok) {
|
||||
sessionPayload =
|
||||
(await sessionResponse.json()) as ClawStoredSession;
|
||||
} else if (sessionResponse.status === 404) {
|
||||
window.localStorage.removeItem("claw.activeSessionId");
|
||||
sessionId = null;
|
||||
}
|
||||
}
|
||||
const budgetUrl = new URL(
|
||||
"/api/claw/context-budget",
|
||||
|
||||
Reference in New Issue
Block a user