Pull requests / #2568

#2568 web: the API Monitor page works when the browser refuses site storage

closed · @qiuzan2001 · 0 Kommentare · Auf GitHub

Server & APISecurity

Beschreibung

**What it changes.** `serve/web/monitor.js` (the `/api-monitor` page, on with `"api_monitor": true`) read `sessionStorage` (the API key) and `localStorage` (the theme) at the top of the script without a `try`. A browser that refuses site storage (cookies blocked for the site, or all cookies) throws `SecurityError` there, and the whole page stayed at "Connecting…": no polling, no request list, no Load / Unload, no theme toggle. The chat page (`app.js`) already catches this. The four uses now go through a small `stored(area, op, ...args)` helper that ignores the error, so the page works and only does not remember the key or the theme.

**What it leaves alone.** Everything where storage works: the same keys (`strata.monitor.key` in sessionStorage, `strata.theme` in localStorage), the same values and defaults. `app.js` and `monitor.html` are unchanged.

**How it was checked.**
- Headless Chromium (Playwright) on a `serve.server.serve(...)` test server (MockEngine, `api_monitor` on), with an init script that makes both storage getters throw `SecurityError`: before, "Connecting…" after 2.5 s and the page error "The operation is insecure."; after, "Loaded", "Live · updated …", the theme toggle works, no page error. With storage working, the same before and after.
- New `test_monitor.Monitor.test_the_page_works_without_site_storage` (fails without the change); `python -m unittest serve.test_monitor` passes. A sub-agent reviewer also ran the helper under Node.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Mehr auf der Site

Links zu Install, Modellen, Releases.