Skip to content

Commit 6d42e66

Browse files
committed
Fix agent session history loading
1 parent 4faf216 commit 6d42e66

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

frontend/src/pages/Agent.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,11 @@ export function Agent() {
300300
}, [connect, disconnect, scrollToBottom]);
301301

302302
useEffect(() => {
303-
const gen = ++genRef.current;
304303
const { sessionId: curSid, messages: curMsgs, cacheSession, reset, getCachedSession, switchSession } = act();
305304

306305
if (urlSessionId && urlSessionId !== curSid) {
306+
const gen = genRef.current + 1;
307+
genRef.current = gen;
307308
doDisconnect();
308309
if (curSid && curMsgs.length > 0) cacheSession(curSid, curMsgs);
309310

@@ -317,8 +318,9 @@ export function Agent() {
317318
}
318319
setupSSE(urlSessionId);
319320
} else if (!urlSessionId && curSid) {
321+
genRef.current += 1;
320322
doDisconnect();
321-
if (curMsgs.length > 0) cacheSession(curSid, curMsgs);
323+
if (curSid && curMsgs.length > 0) cacheSession(curSid, curMsgs);
322324
reset();
323325
}
324326
}, [urlSessionId, doDisconnect, loadSessionMessages, setupSSE, forceScrollToBottom]);

0 commit comments

Comments
 (0)