From 5823a659fc538e8c8c59e2763fd9a6f6d9e498a4 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Thu, 22 May 2025 18:11:38 +0200 Subject: [PATCH] use sessionStorage instead --- libs/sdk-js/src/react/stream.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/sdk-js/src/react/stream.tsx b/libs/sdk-js/src/react/stream.tsx index 3ffdf7b84..61f046e1e 100644 --- a/libs/sdk-js/src/react/stream.tsx +++ b/libs/sdk-js/src/react/stream.tsx @@ -810,9 +810,9 @@ export function useStream< if (options.joinOnMount && threadId) { const rejoinKey = `lg:rejoin:${threadId}`; - const runId = window.localStorage.getItem(rejoinKey); + const runId = window.sessionStorage.getItem(rejoinKey); if (runId) client.runs.cancel(threadId, runId); - window.localStorage.removeItem(rejoinKey); + window.sessionStorage.removeItem(rejoinKey); } }; @@ -926,7 +926,7 @@ export function useStream< return { onSuccess: () => { - window.localStorage.removeItem(rejoinKey); + window.sessionStorage.removeItem(rejoinKey); return history.mutate(threadId); }, stream, @@ -1005,7 +1005,7 @@ export function useStream< onRunCreated(params) { if (options.joinOnMount) { rejoinKey = `lg:rejoin:${params.thread_id ?? "temporary"}`; - window.localStorage.setItem(rejoinKey, params.run_id); + window.sessionStorage.setItem(rejoinKey, params.run_id); } }, }) as AsyncGenerator; @@ -1013,7 +1013,7 @@ export function useStream< return { stream, onSuccess: () => { - if (rejoinKey) window.localStorage.removeItem(rejoinKey); + if (rejoinKey) window.sessionStorage.removeItem(rejoinKey); return history.mutate(usableThreadId); }, }; @@ -1027,7 +1027,7 @@ export function useStream< const joinKey = useMemo(() => { if (!joinOnMount || isLoading) return undefined; if (typeof window === "undefined") return undefined; - const runId = window.localStorage.getItem(`lg:rejoin:${threadId}`); + const runId = window.sessionStorage.getItem(`lg:rejoin:${threadId}`); if (!runId) return undefined; return { runId, threadId }; }, [joinOnMount, isLoading, threadId]);