Repository navigation
Conversation
A proxied frame runs in an opaque origin by default, so `localStorage` throws on first touch. A dashboard that keeps a token or a theme there dies mid-boot and paints its own loading screen forever — the Halo WebUI tab that started this work was a spinner with nothing in the log to explain it. The injected runtime script now reports the blocked access once per load (`codeman:webview-needs-origin`), and the tab turns it into a named choice: the loading screen is replaced by the reason plus **Reload unsandboxed**, which flips that one setting and remounts, and **Dismiss**. The frame is identified by `event.source` against the iframes this tab mounted — a sandboxed frame's origin is `null`, so the message itself proves nothing — and a tab that is already unsandboxed ignores it. The notice also owns the failure panel until dismissed or remounted: the frame's `load` handler used to clear that overlay after the notice had been written, which hid the one thing that explained the dead page. Verified in a real sandboxed iframe against Halo WebUI: notice visible, one click flips `trusted` to true, the frame remounts with `allow-same-origin` and lands on the sign-in page.
The panel borrowed the failure overlay's `background: var(--bg, #0f1319)`, and `--bg` exists in no skin, so the hardcoded dark fallback won every time while the text kept following the theme: a light skin drew dark text on a dark plate. Use `--bg-card`, the surface that steps with the skin, and set the text colour explicitly so the contrast cannot depend on what the iframe painted. The paragraph also wrapped across source lines, so its text node never matched a dictionary key and stayed English under zh-CN. It is one line now, with the four strings added to ZH_CN (the existing `Dismiss` key is reused, not duplicated). Verified by computed styles in daylight-blue and paper-gray plus zh-CN: dark #1b222c/#f3f6fa, light #ffffff/#1f2328, and 这个面板需要非沙盒模式.
Both panels asked for `btn-secondary`, a class no stylesheet defines, so the actions fell through to the browser's default button: system chrome sitting on a themed surface, with Reload and Dismiss carrying identical weight. Paint them from the same tokens as the rest of the shell (surface, border, text) and give the one action worth taking the accent. Verified by computed styles in daylight-blue and paper-gray — #202833/#2a323d and #eef1f4/#e4e9ef surfaces, accent #38b6f0 and #0969da — with the notice translated under zh-CN.
The injected shim probed `window.localStorage` at boot. In a frame without `allow-same-origin` that getter always throws, so every sandboxed dashboard posted `codeman:webview-needs-origin`, including a page that never touched storage and never ran any of its own script. The tab then covered that page with the unsandboxed-mode notice. Wrap the `localStorage` and `sessionStorage` getters instead. Page code that reads either one hits the original getter; a throw is rethrown unchanged, so the page sees the same SecurityError, and the failure is reported to the parent once per load. A working accessor returns the real Storage object and posts nothing, so an unsandboxed frame sees no change. Defining the wrapper is guarded: a context where defineProperty refuses simply keeps the native accessor and reports nothing. The jsdom tests boot the shim in a frame with throwing storage getters: no message on load, one after the first page read, and the original error still surfaces. A working frame returns its Storage object and stays silent.
jsdom cannot reproduce the opaque origin a sandboxed iframe gets: its `localStorage` is a normal object, so the boot-probe bug could not be seen there. Drive the rewritten proxy pages in real Chromium instead. The parent page mounts its iframe with the same sandbox tokens the tab uses (no `allow-same-origin`). A page whose body is a single <h1> must not produce `codeman:webview-needs-origin`; a page that reads `localStorage` must produce exactly one and still catch the original SecurityError. Both pages are served by request interception, so no Codeman server is needed. Use a cached Chromium build when the revision this Playwright release pins is absent; the browser suite excludes this file like every other Playwright test.
The docs and the changeset said the report fires once per load, which was the old boot-probe behaviour. Say what the shim does now: it reports the first time page code touches `localStorage` or `sessionStorage`, and a page that never does stays quiet. The notice's copy called unsandboxed mode 'the same trust a proxied dashboard already relies on'. It is not: a trusted frame shares Codeman's origin and can read the page and call its API. Say that plainly, and update the zh-CN entry with the new English key. Prettier also normalises docs/web-tabs.md (table widths and emphasis markers).
The first button in the failure panel carried the accent, which made 'Reload unsandboxed' the visually preferred action in a panel whose other choice is to stay sandboxed. Unsandboxing is a security change, not an upgrade, so paint both actions from the same surface and border tokens. Reload stays first and Dismiss second; the test now pins the neutral rule and the absence of a first-child accent instead of asserting it.
The previous docs commit ran Prettier over two markdown files the repo does not format: table column widths and emphasis markers were rewritten across docs/web-tabs.md, and the changeset frontmatter changed quotes. That churn hides the actual wording change. Restore both files to their pre-formatting branch state, then re-apply only the intended edits by hand: the storage-trigger paragraph in docs/web-tabs.md and the two body paragraphs of the changeset. The frontmatter stays "aicodeman" with double quotes.
|
Thanks for this, and for the tests. The real-Chromium check that a plain page reports nothing is the right test to have. The PR makes a web tab explain why a sandboxed dashboard is stuck when its page hits blocked There is one open design question on my side. Two smaller fixes apply to any version of the notice that stays. Open question: should the page itself be able to raise the unsandbox offer? The listener at 1. The notice covers dashboards that work ( The shim reports the first storage access that throws, whether or not the page catches it. Many dashboards probe storage in a 2. The notice outlives an in-place navigation ( Only Dismiss or a remount clears Two smaller things:
The theming fix for the failure panel ( The open question decides the final shape of this PR. Items 1 and 2 apply to any version of the notice that stays, so you can start on them now. |
|
The open question is decided: the notice may keep its one-click switch, with one exception. A web tab that Codeman opened by itself from a link in agent output ( Since that button is then the only place the user reads the consequence before switching, please use the settings checkbox's wording in the notice and in its zh-CN entry: the page will be able to "call the API that starts agents". The rest of the review stands as written:
Please add a test that a tab created from an agent link shows the notice without the switch. With these in, the PR goes through its final review. Thanks for waiting on this one. |
What happens now
A proxied tab runs in an iframe without
allow-same-origin, so its origin is opaque andlocalStorage/sessionStoragethrow on access. Apps that keep a session there — SvelteKit among them — die halfway through boot and leave their own loading screen up, with nothing in Codeman to explain it.The tab now names the cause and offers a way out, once the page actually touches storage.
Behaviour
localStorageandsessionStoragegetters instead of probing them. The first access calls the original getter, rethrows the originalSecurityError, and posts one message to the parent.event.source); the payload alone proves nothing.trustedfor that tab and remounts it, and Dismiss, which only closes the notice.trusted.Tests
11 jsdom tests and 3 in a real Chromium:
SecurityError;trustedand remounts; Dismiss leaves the setting alone;Also in this PR
The notice uses
--bg-card; the old--bgfallback was a hardcoded dark and fought light skins. Its paragraph is one source line so thezh-CNdictionary matches it. The failure panels'btn-secondary, a class no stylesheet defines, now uses the shell's surface, border and accent tokens.docs/web-tabs.mddescribes when the notice fires. One patch changeset.