From 8d7f2a966f44568cdb7e2a222587da66a204396c Mon Sep 17 00:00:00 2001 From: "totally-not-ai[bot]" <290682512+totally-not-ai[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:08:10 +0000 Subject: [PATCH] fix: reload examples page only when the session has expired The session check sends a heartbeat for UI id 0 and reloaded the page on any non-OK response. Flow answers 404 when the session is alive but has no UI with that id, which is the normal state once the first page of a session has been closed: later pages get higher UI ids. Reloading never changes that, so the page reloaded again every five minutes as more examples were loaded. Reload only on 403, which is what Flow returns for an expired session. --- frontend/demo/session-verification.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/demo/session-verification.ts b/frontend/demo/session-verification.ts index e7532e4786..709c7aa287 100644 --- a/frontend/demo/session-verification.ts +++ b/frontend/demo/session-verification.ts @@ -7,8 +7,12 @@ function testHeartbeat() { console.debug('testHeartbeat', data); const reloadTimestamp = localStorage.getItem('reloadTimestamp'); console.debug('testHeartbeat', reloadTimestamp); - // Make sure session is still opened, otherwise reload the page - if (!data.ok && (!reloadTimestamp || Date.now() - parseInt(reloadTimestamp) > 5 * 60 * 1000)) { + // Reload only when the session has expired (403). A 404 just means there is no UI with id 0 in the + // session, for example after a previous page was closed, and reloading would not change that. + if ( + data.status === 403 && + (!reloadTimestamp || Date.now() - parseInt(reloadTimestamp) > 5 * 60 * 1000) + ) { console.debug('testHeartbeat', 'reload'); // Save the previous reload timestamp to avoid reloading in less than 5 minutes localStorage.setItem('reloadTimestamp', Date.now().toString());