hermes-agent/web/src
Teknium fe5c8ec4ad
fix(dashboard): auto-reload SPA on stale-token 401 in loopback mode (#33861)
The dashboard's loopback auth uses an ephemeral '_SESSION_TOKEN' that
rotates on every server restart (hermes update, hermes gateway restart,
etc.). A tab kept open across the restart holds the OLD token in
window.__HERMES_SESSION_TOKEN__ from the previous HTML render, so every
'/api/*' fetch returns '401 Unauthorized' — surfacing in the UI as
'Failed to load Kanban board: 401: Unauthorized', 'Analytics 401', etc.
(#24186, #25275).

Before this patch the workaround was to manually clear site data or
hard-reload — annoying enough that users reported it as a regression
even though the token rotation is by design (security property:
stolen tokens can't survive a server restart).

The HTML response already sets 'Cache-Control: no-store, no-cache,
must-revalidate', so a reload reliably picks up the freshly-injected
token. fetchJSON now triggers that reload automatically on the first
loopback-mode 401, guarded by a sessionStorage flag so a genuine
auth bug (where even the new token fails) falls through to throw
on the second attempt instead of reload-looping. The flag is
cleared on any 2xx so a subsequent server restart in the same tab
gets its own reload cycle.

Gated mode is unaffected — that path already redirects to login_url
via the structured 401 envelope (Phase 6), and the new code is
explicitly skipped when window.__HERMES_AUTH_REQUIRED__ is set.

Refs #24186, #25275
2026-05-28 10:53:23 -07:00
..
components feat(web): add collapsible sidebar for the dashboard (#33421) 2026-05-27 23:58:41 -04:00
contexts feat(web): mobile dashboard UX polish (#28127) 2026-05-18 15:20:31 -04:00
hooks feat(web): mobile dashboard UX polish (#28127) 2026-05-18 15:20:31 -04:00
i18n feat(web): add collapsible sidebar for the dashboard (#33421) 2026-05-27 23:58:41 -04:00
lib fix(dashboard): auto-reload SPA on stale-token 401 in loopback mode (#33861) 2026-05-28 10:53:23 -07:00
pages feat(web): add collapsible sidebar for the dashboard (#33421) 2026-05-27 23:58:41 -04:00
plugins refactor(web): dashboard typography & contrast pass 2026-05-22 19:50:32 -07:00
themes feat(web): mobile dashboard UX polish (#28127) 2026-05-18 15:20:31 -04:00
App.tsx feat(web): add collapsible sidebar for the dashboard (#33421) 2026-05-27 23:58:41 -04:00
index.css fix(web): allow mobile dashboard scrolling (#28051) (#28577) 2026-05-28 00:02:50 -04:00
main.tsx fix(dashboard): remove country flags from language picker (#29997) 2026-05-21 13:10:52 -07:00