Skip to content

Open the notebook as a tab of the widget's panel - #474

Merged
neuromechanist merged 7 commits into
developfrom
feature/issue-470-notebook-tab
Sep 24, 2026
Merged

neuromechanist merged 7 commits into
developfrom
feature/issue-470-notebook-tab

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

The capsule's notebook circle opened the notebook site in a new browser tab. This opens it inside the widget instead, as a Notebook tab of the same panel, next to the chat (first part of #470). It also makes the capsule's circles smaller and gives them the motion from the design canvas.

What changes

  • The notebook is a tab. The notebook circle opens the panel on the Notebook tab, framing the same open.html address the notebook site already serves; the chat circle goes back to chat, and the open tab's own circle, or the header's close button, closes the panel.
  • One frame, kept. It is made the first time the tab opens and stays while the reader is on chat, so its Python keeps running. A new dataset on screen replaces it; a dataset with no Zarr copy drops it and returns the panel to chat.
  • The header follows the tab. "Notebook", with a status line from notebook/osa-bridge.js's messages (Opening the notebook…, Starting Python…, Python ready, and so on). The widget acts on a message only if it comes from its own frame and from the notebook site's origin. The chat's Settings, reset and pop-out buttons are hidden on the notebook tab.
  • The theme follows the widget. The light or dark scheme is posted to the notebook's origin when the frame loads, when the notebook is ready, and on every change.
  • A notebook that cannot open here says so. No ready message 12 seconds after the frame loads, or 45 seconds after it was made, or a startup error before ready, shows a fallback with "Try again" and "Open in a new tab". The failed frame is kept, so returning to the tab shows the same fallback and a slow notebook still recovers. A failure, or a setup cell that did not finish, while the reader is on chat puts a small dot on the notebook circle. A theme the notebook could not apply, and any message it sends that the widget does not recognize, reach the console.
  • Smaller circles, with motion. Every circle is 46px, 15% larger than the 40px Send button (they were 56px). A filled indicator slides to the open tab, the pill grows out of the chat button, the notebook and HPC (high-performance computing) circles arrive 30 and 70 milliseconds after it, the views fade through, and a ring turns on the notebook circle while Python starts and the reader is on chat. With prefers-reduced-motion: reduce, only a short fade between the views remains.
  • A bigger panel. The capsule's panel resizes up to 1400px wide and the window's height; the frame takes no pointer events during a drag.
  • The config loader refuses launcher: capsule without a notebook section, since the icon would open only an error. NEMAR, the only capsule community, has one.
  • Docs. docs/community-widget.md gains "The notebook tab", including what a host page with a Content Security Policy (CSP) needs (frame-src for the notebook host). docs/community-notebook.md drops "opens a new tab today". ADR 0012 records the widget's half of the decision.

Only the capsule changes. A bubble widget, every community but NEMAR, renders as before, and test-widget-notebook-tab.js checks that first.

Not in this PR

  • The pop-out does not carry the notebook yet. Its button is hidden on the notebook tab; the pop-out's own tab strip, and loading its script by address rather than inline, is the second part of Capsule: open the notebook as a tab in the widget #470.
  • nemar.org and test.nemar.org cannot show the tab until the website allows the notebook host in frame-src. Their policy has default-src 'self' and no frame-src, so today the frame is refused and the fallback shows. That change, and the re-pin to this commit, goes in a website PR to staging after this merges.

Tests

  • frontend/test-widget-notebook-tab.js (new, 148 checks, added to both test.yml and tests.yml): the bubble untouched, and not listening for messages; the views; the frame's address and attributes; the header and buttons per tab; the chat circle's exact icon; focus, compared by identity, following the tab; reopening through either circle; the frame kept across tab switches and a closed panel; the bridge's messages driving the status, overlays and ring; messages from another origin, another source or another shape ignored, and the bridge's unrecognized ones and a failed theme logged; theme posts addressed and deduplicated; each timeout on its own; a replaced frame's timer never failing its successor; a failed frame kept on return and recovering when late; the circle's cue for a failure or a failed setup; a startup error after ready ignored; dataset changes, including setDataset(null) with a frame open; an invalid pre-set notebookUrl dropped; the resize class; 46px against the 40px Send button, and a bubble's 56px; the reduced-motion block.
  • frontend/test-widget-capsule.js updated for the tab (127), test-widget-tools.js (312) and test-widget-color-scheme.js (128) unchanged and passing.
  • Mutation sweep: 44 single changes to the widget, 39 fail a suite; the other 5 are guards backed by a second one (including focus into the chat view, which inert already refuses), and each fails when paired with removing that second guard.
  • tests/test_core/test_config/test_community.py::TestCommunityConfigCapsule (new); disabling the check fails it.
  • frontend/browser-harness/notebook-tab-check.mjs (new), 14 of 14 in Chrome 153 against widget_e2e.py --nemar and the live develop notebook: Enter on the focused circle opens the notebook and Space returns to it, as real key presses; ready 3.2 seconds after the key press and "Python ready" at 7.7 seconds on a cold profile; dark applied inside the notebook; the same frame after a switch; and a resize to 940px across the frame. Setting the capsule's width limit back to 600px fails it. It needs the network, so it is not in CI.
  • In Chrome, with the notebook pointed at a host the page's policy refuses: the fallback after 12 seconds, and the dot on the notebook circle from chat, in light and dark.
  • Measured with a one-off page in Chrome 153: a frame the host's frame-src refuses fires load once and never speaks, which is why the shorter timeout counts from the load.
  • uv run pytest (2930 passed), ruff check, ruff format --check, every Bun suite CI runs, build-runtime-bundle.js --check.
  • On test.nemar.org, after the website PR: the tab in Chrome and Safari by hand.

The capsule's notebook icon opens the community's starter on the
notebook site as a tab of the widget (#470). Without a notebook section
the site has no starter for the community, so the loader now refuses
the config instead of shipping an icon that can only open an error.

Tested: pytest tests/test_core/test_config/test_community.py (new
TestCommunityConfigCapsule); disabling the check fails the rejection test.
The capsule's notebook circle opened the notebook site in a new browser
tab. It now opens the panel on a Notebook tab, framing the same
open.html address, and the chat circle goes back to chat (#470).

- One frame, made when the tab first opens and kept while the reader is
  on chat, so its Python keeps running; a new dataset replaces it, one
  with no Zarr copy drops it and returns to chat.
- The header follows the tab: "Notebook" with a status line driven by
  notebook/osa-bridge.js's messages, heard only from the widget's own
  frame at the notebook's origin. Chat-only header buttons are hidden.
- The widget's scheme is posted to the notebook's origin on load, on
  ready and on every change.
- No ready 12 s after load or 45 s after creation, or a startup error
  before ready, shows a fallback: Try again, or Open in a new tab.
- The capsule's circles are 46px (15% over the 40px Send button); a
  filled indicator slides to the open tab, the pill grows out of the
  chat button, the icons stagger in, the views fade through, and a
  ring turns on the notebook circle while Python starts off-tab.
  Reduced motion keeps only a short fade.
- The capsule's panel resizes to 1400px wide and the window's height;
  the frame takes no pointer events during a drag.

Tested: bun frontend/test-widget-notebook-tab.js (108, new, in both CI
workflows), test-widget-capsule.js (127), test-widget-tools.js (312),
test-widget-color-scheme.js (128); 30 single mutations, 26 killed, the
other 4 each backed by a second guard and killed as pairs.
notebook-tab-check.mjs drives the capsule's notebook tab against the
live develop notebook: circle sizes, the indicator, ready and setup
from the bridge's own messages, dark applied inside the frame, the
frame kept across a tab switch, and a resize across the frame.
widget_e2e.py's policy allows both notebook hosts in frame-src, as a
host page must. Needs the network, so it is not in CI.

Tested: 12/12 in Chrome 153 against widget_e2e.py --nemar; setting the
capsule's width limit back to 600px fails the resize step.
community-widget.md gains "The notebook tab" (behavior, fallback, the
host page's frame-src, the pop-out not carrying it yet) and the
capsule's new look; community-notebook.md drops "opens a new tab
today"; ADR 0012 records the widget's half of the decision.

Tested: docs only; the frame-src load behavior the ADR cites was
measured in Chrome 153 with a one-off page.
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-470-notebook-t-demo.osc.earth
Branch feature/issue-470-notebook-tab
Commit b6564f2

This preview will be updated automatically when you push new commits.

- Only a capsule listens for the notebook's messages.
- The pre-set config's notebookUrl is validated like setConfig's, so
  every reader can rely on a normalized URL; the raw fallbacks go.
- A failed frame is kept when the reader returns to the tab, so the
  fallback stays until Try again, and a slow notebook still recovers.
- A failure, or a setup that did not finish, while the reader is on
  chat puts a dot on the notebook circle, with a tooltip saying which.
- A theme the notebook could not apply, and any message from it the
  widget does not recognize, reach the console.
- The staleness check in setDataset no longer depends on operand order
  to avoid reading a null dataset.

Tested: bun frontend/test-widget-notebook-tab.js (148; new checks for
each item above, the exact chat icon, focus by identity, reopening via
the notebook circle, setDataset(null) with a frame, a bubble's 56px);
44 single mutations, 39 killed, the other 5 killed as pairs with the
guard that backs each; capsule, tools and color-scheme suites unchanged.
notebook-tab-check.mjs now opens the notebook with Enter on the
focused circle and returns to it with Space, as real key presses, and
times from the key press.

Tested: 14/14 in Chrome 153 against widget_e2e.py --nemar.
The widget guide covers the kept failed frame, the circle's cue, the
console warnings, and the resize floor at a bubble's 600 by 800; ADR
0012 records why a failed frame is kept. NEMAR's config comment and
the launcher and notebook field docstrings say the notebook opens as a
tab and that the capsule requires a notebook section.

Tested: docs and comments only; pytest (2930 passed) and ruff.
@neuromechanist

Copy link
Copy Markdown
Member Author

Review response

Four reviews (code, tests, error handling, docs and comments). Every finding is addressed in df69d4e, b90b506 and 4e7210f, except the one noted at the end.

Code

  • The window message listener was registered for every widget, bubble included. It is now added in applyLauncherMode, so only a capsule listens; a test checks that a bubble adds none and a capsule exactly one.

Tests

  • setDataset(null) with a frame open avoided reading currentDataset.id only through operand order. The check now reads currentDataset?.id, with a comment saying what "stale" means, and a test covers exactly that call.
  • The chat circle's icon was checked with includes('<svg'), which both icons satisfy. The test now compares the circle's own icon before and after opening, and the capsule swapping to the close icon fails it.
  • Focus was not checked. It is now, by identity: assertEqual serializes, and every element serializes to {}, so the first version of this check passed with focus on BODY. The mutation sweep caught that.
  • A test title promised a 56px bubble check its body never made; the check is now there.
  • Keyboard activation: the Chrome check now opens the notebook with Enter on the focused circle and returns to it with Space, as real key presses (happy-dom does not turn key presses into clicks, so a happy-dom test would test happy-dom).
  • Reopening a panel closed from the notebook tab through the notebook circle itself is now tested.

Error handling

  • The bridge's theme answer was dropped even when applied: false, and an unrecognized message from the notebook was dropped silently. Both now reach the console; a theme the notebook applied does not.
  • notebookUrlFor fell back to the raw CONFIG.notebookUrl where notebookOrigin failed closed. There was one unvalidated writer after all: the pre-set config init() reads (window.__OSA_CHAT_CONFIG__). It is now normalized like setConfig's, so both readers use CONFIG.notebookUrl directly; a test sets an invalid pre-set value and gets the default address and a warning.
  • Returning to a failed tab started a new load on its own. The failed frame is now kept until Try again, so the fallback stays put, and a slow notebook still recovers when it reports ready.
  • A failed setup was invisible once the reader left the tab. A failure or a failed setup now puts a small red dot on the notebook circle, with a tooltip and label saying which (checked in Chrome, light and dark).

Docs and comments

  • NEMAR's config.yaml comment still said the notebook opens in a new tab.
  • The launcher and notebook field docstrings now name the capsule's requirement.
  • The resize limits now state the floor at a bubble's 600 by 800.
  • "active notebook icon" is now "available", matching the rest of the change.
  • Not changed, by design: ADR 0011's body still describes frame-ancestors 'none'. Its status line points to ADR 0012, which is how this repository amends an ADR; the body stays as it was decided.

Gates

bun frontend/test-widget-notebook-tab.js 148/148; every other Bun suite in CI unchanged and passing; uv run pytest 2930 passed; ruff clean; notebook-tab-check.mjs 14/14 in Chrome 153. Mutation sweep: 44 single changes, 39 killed, and each of the other 5, a guard backed by a second one, killed when paired with removing it.

@neuromechanist
neuromechanist merged commit 98ebf1d into develop Sep 24, 2026
11 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-470-notebook-tab branch September 24, 2026 13:47
neuromechanist added a commit that referenced this pull request Sep 24, 2026
Release review: add the widget's Notebook tab (#471, #474), color_scheme auto (#472), the first-paint fix (#476) and the dark-page field colors; the capsule and notebook-site bullets described the notebook opening in a new tab, which #474 replaced.

Tested: docs-only; each claim checked against origin/develop (config.yaml color_scheme, osa-widget-config- key, ADR 0012 path).
neuromechanist added a commit that referenced this pull request Sep 24, 2026
* Title the changelog's release as 0.8.14

Tested: docs only.

* Complete the 0.8.14 changelog

Release review: add the widget's Notebook tab (#471, #474), color_scheme auto (#472), the first-paint fix (#476) and the dark-page field colors; the capsule and notebook-site bullets described the notebook opening in a new tab, which #474 replaced.

Tested: docs-only; each claim checked against origin/develop (config.yaml color_scheme, osa-widget-config- key, ADR 0012 path).
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