Repository navigation
Load the pop-out by address, and give it the panel's tabs - #482
Merged
Merged
Conversation
The pop-out wrote the widget's source inline into an about:blank window, which inherits the host page's Content Security Policy, so on a page without script-src 'unsafe-inline' it opened blank. It now writes a script-free document, sets its presets on the pop-out's window as the pop-out's own data, and adds a script element with the widget's address and the host tag's integrity and crossorigin. The widget source is no longer fetched. A script that does not load says so in the pop-out, and setColorScheme and setDataset keep the presets current for a pop-out that has not started yet. The light and dark Chrome check no longer adds 'unsafe-inline' to the page's policy for its pop-out step, and checks the page refuses inline script first. Tested: bun frontend/test-widget-popout.js (new, 49 passed); the tools (312), capsule (128), color scheme (126), notebook tab (148), first paint (81) and dataset question (60) suites; color-scheme-check.mjs --serve in Chrome 153, all passing, and the widget before this change times out waiting for the pop-out's widget there.
A capsule community's pop-out now has the panel's tabs as a strip under its header, since a pop-out has no launcher to hold the circles. It opens on the tab the reader was on (a new __OSA_TAB__ preset), drawn there at once rather than fading in from chat, and its notebook tab is a frame of its own, a fresh notebook session. The strip reuses setTab, ensureNotebookFrame and the notebook's status line and cues, and follows the page's dataset. The pop-out button now stays on the notebook tab. A bubble community's pop-out is unchanged. Tested: bun frontend/test-widget-popout.js (115 passed), the capsule (131), notebook tab (148), tools (312), color scheme (126), first paint (81) and dataset question (60) suites; in Chrome 153, a pop-out opened from the notebook tab with the fading setTab shows the chat and records its fade, and with this change does neither.
popout-check.mjs --serve starts widget_e2e.py --nemar and opens the pop-out from the capsule's chat and notebook tabs, attaching to it as the new target whose opener is the page. It checks that the pop-out renders on the tab it came from, that its document has no inline script, that the notebook's frame is at the contract address, and that the page's policy is in force in both windows (an inline script is refused). On widget-e2e-sri.html, a new harness route that pins the widget's tag with integrity and crossorigin as nemar.org does, the pop-out carries both and renders, and with a wrong digest on the tag the browser refuses the next pop-out, which says so. Runs in CI beside the first paint check, in both workflows. Tested: popout-check.mjs --serve in Chrome 153, 46 of 46; with the initial tab set by the fading setTab it fails two checks; ruff check and format on widget_e2e.py.
docs/community-browser-runtime.md said the pop-out can run on another origin and see neither the chat history nor the workspace. It is an about:blank window of the page's own origin, so it has the page's storage. popout-check.mjs now checks that every pop-out has the page's origin and reads a localStorage value only the page wrote. Tested: popout-check.mjs --serve in Chrome 153, 49 of 49.
docs/community-widget.md gains "The pop-out window": what it carries and shares with the page, the tab strip, its notebook as a frame and a fresh notebook session of its own, and what a host page's policy needs for it (nothing beyond the widget's own; integrity and crossorigin kept together). The notebook tab's text says the pop-out button stays there, and the "does not carry the notebook yet" note is gone. ADR 0012 gets an update section for the two sentences the pop-out now contradicts, and docs/community-notebook.md stops saying "once it carries the notebook". CHANGELOG entries under Added and Fixed. Tested: docs only; the paths and names they cite were checked against the branch.
The sweep over the pop-out's widget code left three changes uncaught: a strip on the page's own panel, the busy cue on the open notebook tab, and the strip's Chat tab not focusing the input, which passed because focus never left the input in happy-dom. Each now has a check that fails under it. Tested: bun frontend/test-widget-popout.js (118 passed); each of the three mutations now fails it, and the file is restored after each.
widget_e2e.py's widget-e2e-sri.html route carries a widget script tag, which TestEveryWidgetScriptTagIsAccountedFor requires to be parsed or exempted by name. It is a dev harness page with a relative src, like widget-e2e.html, so it joins that allowlist with its reason. Tested: uv run pytest tests/test_frontend/test_embed_snippet_hygiene.py (17 passed; the tripwire failed before this).
popout-check.mjs --live-notebook points the notebook at the develop notebook site and requires the pop-out's own notebook to report "Python ready" through the bridge, which shows the site's frame-ancestors admits a pop-out and the bridge's messages reach the pop-out's widget. It needs the network, so CI runs the check without it. Tested: popout-check.mjs --serve --live-notebook in Chrome 153, all passing, "Python ready" 8.9 s after the tab showed; --serve alone still 49 of 49.
forwardDatasetToPopout copied the dataset into the pop-out's realm for its preset but passed the page's own object to its setDataset. Both now get the same copy, as openPopout's presets do. Harmless before, since setDataset rebuilds the object from its fields; a review raised it. Tested: bun frontend/test-widget-popout.js (119 passed); passing the page's object again fails the new check; dataset question (60), notebook tab (148) and capsule (131) suites.
Contributor
Preview Deployment
This preview will be updated automatically when you push new commits. |
Opened from the notebook tab, the pop-out is told that tab once, while its dataset preset follows the page until it starts. A new case clears the dataset, or names one with no Zarr copy, before the pop-out starts, and checks it opens on chat with no frame. Another pins that a later setConfig does not reach an open pop-out, as documented. Review findings on #482. Tested: bun frontend/test-widget-popout.js (132 passed); disabling setTab's notebook fallback now fails four checks.
The widget adds script elements of its own, the pop-out's and the browser runtime's, without a nonce, so a policy that allows scripts only by nonce refuses them. Review finding on #482. Tested: docs only.
Member
Author
Review responseTwo Sonnet reviews: code and error handling, and tests with documentation. Code and error handling: no finding at the reviewer's confidence bar. It noted two items below it.
Tests and documentation
Gates: |
This was referenced Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The second part of #470: the widget's pop-out window, which the first part (#474) left open.
The pop-out loaded the widget by writing its source into itself as inline script.
An
about:blankpop-out inherits the host page's Content Security Policy (CSP), so on a page whosescript-srchas no'unsafe-inline'it opened blank.It now loads the widget by its address, with the page tag's
integrityandcrossorigin, so a policy that loads the widget allows its pop-out too.A capsule community's pop-out (NEMAR's) also gets the panel's Chat and Notebook tabs, as a strip under its header, since a pop-out has no launcher.
It opens on the tab the reader was on, and its notebook tab is a frame of its own, a fresh notebook session.
The pop-out button now stays on the notebook tab. A bubble community's pop-out is unchanged.
A note on nemar.org: its live policy does include
'unsafe-inline'today (checked withcurlon 2026-09-24, nemar.org and test.nemar.org), so its pop-out was not blank there; the harness's copy of its policy, which predates that, does not.The blank pop-out was real on any stricter host page, and this removes the need for
'unsafe-inline'should nemar.org drop it.Changes
openPopoutwrites a script-free document, sets__OSA_CHAT_CONFIG__,__OSA_HOST_COLOR_SCHEME__,__OSA_DATASET__and the new__OSA_TAB__as properties of the pop-out's window, parsed by the pop-out's ownJSONso it holds data of its own realm, and appends a<script src>with the widget's address and the host tag'sintegrityandcrossorigin(neverdata-no-auto-init)window.opennow runs in the click itself, with noawaitbefore itsetColorSchemeandsetDatasetkeep the pop-out's presets current as well as calling its API, so one whose script has not run, or has run but not started, opens in the latest scheme and datasetsetTab,ensureNotebookFrame, the notebook's status line and its busy and attention cues;applyLauncherModeis split so a pop-out gets the panel's tabs without the launchershowTabAtOnce): with the fade, Chrome showed the chat first and faded to the notebook as the window started drawingfrontend/test-widget-popout.js(new, 119 checks), in bothtest.ymlandtests.yml; the opener-side pop-out checks in the color scheme and dataset question suites moved into it, against a real pop-out windowfrontend/browser-harness/popout-check.mjs --serve(new), in both workflows beside the first paint check;widget_e2e.pyserveswidget-e2e-sri.html, the page with the widget's tag pinned as nemar.org pins itcolor-scheme-check.mjsno longer adds'unsafe-inline'to the page's policy for its pop-out step, and first checks that the page refuses inline scriptdocs/community-widget.md, with what a host page's policy needs for it; an update section in ADR 0012 for the two sentences the pop-out now contradicts;docs/community-notebook.md;docs/community-browser-runtime.mdno longer says the pop-out can run on another origin (it has the page's origin and storage, now checked in Chrome); CHANGELOG under Added and FixedTesting
bun frontend/test-widget-popout.js: 119 passed. The widget is loaded by its script tag in a happy-dom host page, and the pop-out's script element is fetched and run by happy-dom in the real pop-out window: no inline script, presets as window properties of the pop-out's realm, the tag's attributes, the load-failure message, reuse and a blocked pop-up, forwarding into an open and a not-yet-started pop-out, the strip on either tab, a frame of its own, the cues, the dataset following, the bubble unchangeddevelopafter Point the develop chat at its deployment's NEMAR hosts #481; every gate below was rerun on the rebased treebun scripts/build-runtime-bundle.js --checkcurrentpopout-check.mjs --serve49 of 49,color-scheme-check.mjs --serve25 of 25,first-paint-check.mjs --serve42 of 42,chrome.js(the runtime harness: 43, the control failing as it must, 40, 14, warm, lock change)popout-check.mjs --serve --live-notebook: the develop notebook, framed by the pop-out, reported "Python ready" 8.9 s after its tab showed (needs the network, so not in CI)develop's widget times out waiting for the pop-out's widget in both Chrome checkssetTab's own, the chat input's focus guard byinert), and each pair fails together; the third, the fade on the initial tab, shows only in Chrome, wherepopout-check.mjsfails two checks under it. Three tests the first sweep found weak were tightened. In Chrome, a policy with'unsafe-inline'fails all five inline-script controls, and not copyingintegrityfails the pinned checksuv run pytest -q --no-cov -m "not live": 2996 passed, 58 skipped (TestVersionCommand::test_version_shows_versiondeselected, test_version_shows_version fails locally and passes in CI, because rich colorizes on a TTY #434);ruff check src tests,ruff format --check src testscleanRefers to #470.