Skip to content

Load the pop-out by address, and give it the panel's tabs - #482

Merged
neuromechanist merged 11 commits into
developfrom
feature/issue-470-popout
Sep 24, 2026
Merged

neuromechanist merged 11 commits into
developfrom
feature/issue-470-popout

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

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:blank pop-out inherits the host page's Content Security Policy (CSP), so on a page whose script-src has no 'unsafe-inline' it opened blank.
It now loads the widget by its address, with the page tag's integrity and crossorigin, 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 with curl on 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

  • openPopout writes 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 own JSON so it holds data of its own realm, and appends a <script src> with the widget's address and the host tag's integrity and crossorigin (never data-no-auto-init)
  • The widget-source fetch is gone; window.open now runs in the click itself, with no await before it
  • A pop-out whose script the browser refuses says so in its own window, and the page's console names the address
  • setColorScheme and setDataset keep 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 dataset
  • The pop-out's tab strip reuses setTab, ensureNotebookFrame, the notebook's status line and its busy and attention cues; applyLauncherMode is split so a pop-out gets the panel's tabs without the launcher
  • A pop-out opened on the notebook tab is drawn there at once (showTabAtOnce): with the fade, Chrome showed the chat first and faded to the notebook as the window started drawing
  • frontend/test-widget-popout.js (new, 119 checks), in both test.yml and tests.yml; the opener-side pop-out checks in the color scheme and dataset question suites moved into it, against a real pop-out window
  • frontend/browser-harness/popout-check.mjs --serve (new), in both workflows beside the first paint check; widget_e2e.py serves widget-e2e-sri.html, the page with the widget's tag pinned as nemar.org pins it
  • color-scheme-check.mjs no longer adds 'unsafe-inline' to the page's policy for its pop-out step, and first checks that the page refuses inline script
  • Docs: "The pop-out window" in docs/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.md no 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 Fixed

Testing

  • 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 unchanged
  • Rebased on develop after Point the develop chat at its deployment's NEMAR hosts #481; every gate below was rerun on the rebased tree
  • Every other Bun suite CI runs: tools 312, capsule 131, color scheme 126, notebook tab 148, first paint 81, dataset questions 60, citation markers 10, streaming 72, endpoint resolution 13, worker routing 132, mounted hosts 10, runtime lifecycle 184, egress 80, output 80, controller 144, workspace 81, notebook bootstrap 52, worker core 190, data lane 60, runtime bundle 25; bun scripts/build-runtime-bundle.js --check current
  • Chrome 153, headless: popout-check.mjs --serve 49 of 49, color-scheme-check.mjs --serve 25 of 25, first-paint-check.mjs --serve 42 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)
  • A review (one reviewer, Sonnet) found nothing significant; its one suggestion, handing an open pop-out's API its own copy of the dataset as its preset gets, is done and tested
  • Controls: the page and every pop-out refuse an inline script; on the pinned page, a wrong digest on the tag makes the browser refuse the next pop-out, which says so; develop's widget times out waiting for the pop-out's widget in both Chrome checks
  • Mutation sweep, 39 single changes to the pop-out's code in the dangerous direction, each run against all seven widget suites with the file restored and checked after each: 36 fail a suite. Two of the other three are guards backed by a second one (the strip's disabled check by setTab's own, the chat input's focus guard by inert), and each pair fails together; the third, the fade on the initial tab, shows only in Chrome, where popout-check.mjs fails 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 copying integrity fails the pinned checks
  • uv run pytest -q --no-cov -m "not live": 2996 passed, 58 skipped (TestVersionCommand::test_version_shows_version deselected, 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 tests clean

Refers to #470.

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.
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-470-popout-demo.osc.earth
Branch feature/issue-470-popout
Commit d9bf5fb

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.
@neuromechanist

Copy link
Copy Markdown
Member Author

Review response

Two 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.

  • A nonce-based policy. The pop-out copies the tag's integrity and crossorigin, not a nonce. Not fixed in code, on purpose: the widget adds a second script element of its own, the browser runtime's bundle (loadRuntimeBundle), also without one. Copying a nonce into the pop-out alone would half-support a policy the widget does not support. docs/community-widget.md now says so, and says to allow the widget's host in script-src (3b05482).
  • The multiple-tag fallback in widgetScriptForPopout. No change. It applies only when the running widget was inlined with no src, which the docs do not describe, and it predates this PR.

Tests and documentation

  • A pop-out opened from the notebook tab whose dataset drops before it starts. __OSA_TAB__ is set once, while __OSA_DATASET__ follows the page until the pop-out starts, so the tab could name a notebook the dataset no longer has. Only setTab's fallback turned it back to chat, and no test covered that. A new case clears the dataset, or names one with no Zarr copy, before the pop-out starts. It checks the pop-out opens on chat with no frame (c83d48e). With the fallback disabled, four checks fail.
  • The documented boundary, pinned. A later setConfig({ title }) does not reach an open pop-out.

Gates: bun frontend/test-widget-popout.js passes (132). CI is dispatched on 3b05482.

@neuromechanist
neuromechanist merged commit a300fd5 into develop Sep 24, 2026
13 of 14 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-470-popout branch September 24, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant