Repository navigation
A three-icon capsule launcher for NEMAR's widget - #468
Conversation
Preview Deployment
This preview will be updated automatically when you push new commits. |
Widget config gains launcher (bubble default, capsule opt-in) and launcher_label (a short collapsed-launcher tooltip, replacing the hardcoded "Ask me about <title>"), following the pattern theme_color and user_bubble_color already use: resolve() omits both when unset, so a community that never sets them is unaffected. NEMAR is the first community on the capsule (#436), with the label "Explore NEMAR".
launcher: capsule converts the DOM in place (applyLauncherMode), moving
the existing chat button into a new capsule wrapper alongside a
notebook and an HPC placeholder icon, rather than branching the whole
markup template: a bubble-mode widget never builds this wrapper, so its
markup and computed styles stay exactly what they were before this
feature existed.
setDataset({id, zarr}) drives the notebook icon through four states (no
dataset, Zarr unknown, no Zarr copy, active); the active state opens
${notebookUrl}open.html?community=...&dataset=... in a new tab.
notebookUrl is validated and normalized in setConfig, defaulting to
https://notebook.osc.earth/osa/. Each icon carries aria-disabled (never
the disabled attribute) and a hover/keyboard-focus tooltip; "coming
soon" (HPC, always) additionally carries a small badge so it reads
differently from "inactive" (no dataset, or no Zarr copy).
Layout: a vertical stack above the bubble past 601px wide, with the
chat panel opening to its left; a row to the bubble's left at or below
600px, with the chat panel opening above as today. Both directions rely
on the capsule being anchored by bottom+right alone, so it grows away
from that corner and the chat button never moves.
Fixed along the way: two fixed-position siblings with equal z-index
stack by DOM order, so the capsule's own z-index has to beat the chat
window's for an icon tooltip to paint above it, not just the tooltip's
own (which is scoped to the capsule's stacking context).
Runs the real widget source in a happy-dom window, the same technique test-widget-tools.js uses: the capsule exists only under launcher: capsule; a bubble-mode widget's markup and className are byte-for-byte unchanged; all four notebook states from setDataset, including a call made before init(); invalid setDataset and notebookUrl inputs leave the prior state alone (checked via the full rendered state, not just the active/inactive flag, since a malformed id that is still "active" would otherwise pass by coincidence); the exact, encoded contract URL a click opens, and that an inactive or coming-soon icon's click opens nothing; aria-disabled as its own guard, forced out of sync with currentDataset directly on the DOM; the capsule's z-index beating the chat window's; and launcher_label overriding the collapsed tooltip, with the community-config and setConfig precedence both covered. Registered in both CI workflows alongside test-widget-tools.js.
widget-e2e-dataset.js reads ?dataset=<id>&zarr=true|false¬ebookUrl= from the page's own URL and calls OSAChatWidget.setDataset/setConfig accordingly, so a manual or scripted Chrome run against --nemar can exercise a given notebook state without a devtools console. An external file, not inline script, since the harness serves this page under a real Content-Security-Policy with no 'unsafe-inline'.
docs/community-widget-launcher.md is a self-contained section (its own level-2 heading) rather than a page of its own: it is meant to be folded into docs/community-widget.md, the WidgetConfig reference page a sibling PR is adding, once that PR merges.
setupResize only ever reads chatWindow's own offsetWidth/offsetHeight and mouse deltas; nothing about it changes when the chat button (and so the window's neighbor) moves into the capsule wrapper, but that was reasoning rather than a test. Drags the real handle via MouseEvent and checks the resulting inline width/height.
Mirrors #463's table-driven surface/foreground probe against the real stylesheet, kept here rather than in test-widget-tools.js so all capsule classification lives in one file. The active notebook icon is a themed surface (theme_color/theme_text_color, same pair the launcher button already is); the neutral icon (inactive OR coming-soon, which share a look per #436) is proven NOT themed: identical whether or not a community sets any color, which is what keeps a disabled button from ever reading as active. Mutation-checked: swapping the active icon's foreground to --osa-accent is caught by both the NEMAR-styled and unset cases.
The base PR (#463) added docs/community-widget.md, "one section per area", explicitly anticipating a section like this one being added without disturbing the others. Moves the standalone community-widget-launcher.md content in as its own "Launcher" section, between Color roles (the active icon's theme_color/theme_text_color pair) and the setConfig key table; adds launcher/launcher_label to that table, and notebookUrl to the embedder-only settings note alongside disclaimerColor/disclaimerBackground. Deletes the standalone file and repoints the CHANGELOG's reference.
A base URL is meant to carry neither: handleNotebookClick appends its own '?community=...&dataset=...' after it, so a query would produce a URL with two '?', and the trailing-slash fix would land the slash inside the query or fragment instead of at the end of the path. Reject rather than silently mangle it, in both normalizeNotebookUrl and the notebookUrl validation test's invalid cases.
launcher: capsule can arrive from the community config after the reader has already opened the chat, and the conversion previously moved the open panel's right/bottom/max-height instantly. Add a short CSS transition scoped to capsule mode alone (bubble mode is untouched), and test that opening the chat before the config resolves ends with the transitioned position and a declared transition on those properties.
The new icon tooltips' spans repeat the button's own aria-label verbatim, so a screen reader read each one twice. Mark the two new capsule tooltips aria-hidden (the pre-existing .osa-chat-tooltip has no button-owning aria-label to duplicate, so it is left alone), and assert both the hiding and that the pre-existing tooltip is untouched.
The three appendChild calls already order the icons hpc/notebook/chat for the anchoring trick; that same order is Tab order (Tab follows DOM order, not visual position) and it matches the visual order in both the desktop (top-to-bottom) and narrow (left-to-right) layouts. Say so in a comment so the order reads as deliberate, not incidental.
happy-dom defaults to a 1024px desktop viewport, so nothing exercised the narrow (<=600px) branch, and no test checked computed style for bubble mode at all: dropping the ".osa-launcher-capsule " prefix from the chat-button override (widening it to every community) passed every existing test. Let loadWidget size the happy-dom viewport, and add two tests: bubble mode's exact computed position (today's values, since outside sites embed it unpinned), and the capsule's flex-direction and chat-window position at explicit narrow and desktop widths either side of the 601px breakpoint.
The four notebook states and the HPC icon only checked that aria-label was non-empty; hard-coding 'Notebook' for every state passed. Assert the exact label per state instead.
applyLauncherMode's "&& !CONFIG.fullscreen" exclusion was untested; removing it passed every existing test since the pop-out's chat button is already hidden. Assert directly that fullscreen with launcher: capsule builds no capsule wrapper.
"guarded by aria-disabled ALONE" read as if the handler had only one guard; it has two (aria-disabled and a currentDataset re-check). Reword to describe what the test actually isolates: this scenario keeps currentDataset.zarr true so the OTHER guard would let the click through on its own, proving the aria-disabled check does real work.
isValidCommunityId and isValidDatasetId only ever admit unreserved characters, so nothing that reaches handleNotebookClick ever needs escaping; removing both encodeURIComponent calls still passed this test. Rename it and explain what it actually proves (the literal contract string for punctuation the format allows), and note that encodeURIComponent stays in the source as defense in depth for a future, less-gated caller, not because this test exercises it.
happy-dom does not turn a trusted Enter or Space keypress into a click on a focused <button>, so the aria-disabled/currentDataset guard could not be exercised through the keyboard in the Bun suite. Add a script that reuses chrome.js's own findChrome/launch/connect to drive real Chrome over CDP, Tab-focuses the notebook button, and dispatches real Input.dispatchKeyEvent presses for Enter and Space, asserting each opens the contract URL when the dataset is active and opens nothing when it is not. Run against a live widget_e2e.py --nemar server on 2026-09-23: all 7 checks passed. Mutation-tested by removing both of handleNotebookClick's guards, which the inactive-dataset checks caught (both opened the URL that should have been refused); reverted and reconfirmed green.
The Launcher section described only the desktop (vertical stack, opening above) layout. Add the 600px breakpoint: at 600px and narrower, the capsule is a row beside the chat button and the panel opens above it exactly as it always has, matching a bubble widget's panel. Also spell out high-performance computing (HPC) on its first use, in the section heading.
"What happens with a malformed value" covers only the color fields; a reader could easily assume it also covers notebookUrl or launcher, described just above it. Add a one-line pointer to where each is actually described instead.
Break at sentence end and at clause punctuation, roughly one sentence per line, matching the project's line-break convention. No content change.
a623e57 to
ba5ffd7
Compare
Review responseThree Sonnet reviewers ran (code and accessibility, tests, docs). The code reviewer proved the hard requirement by tracing every path: with Tests
Code
Docs: the Launcher section describes both breakpoints, high-performance computing (HPC) is spelled out on first use, a pointer separates Gates: |
Builds the three-icon capsule launcher the maintainer decided on in #436, opt-in per community, and turns it on for NEMAR. Every other community keeps today's single chat bubble, markup and styles unchanged.
What it does
https://notebook.osc.earth/osa/open.html?community=<id>&dataset=<id>in a new tab withnoopener(the notebook site is Host a JupyterLite notebook site at notebook.osc.earth/osa #465). An unavailable button usesaria-disabled, notdisabled, so its reason stays reachable by keyboard and screen reader. HPC is "coming soon" everywhere, with a "Soon" badge so it reads differently from an inactive button.OSAChatWidget.setDataset(null | {id, zarr}), callable before or afterinit(); nemar.org's dataset page calls it (Tell the assistant which dataset is on screen, for its notebook button nemarOrg/website#351).setConfig({notebookUrl})sets the notebook site per environment (defaulthttps://notebook.osc.earth/osa/).widget.launcher: bubble | capsule(defaultbubble) andwidget.launcher_label, the collapsed tooltip's text (Widget launcher: a three-icon capsule for chat, notebook and HPC #436's comment asked for a minimal "Explore NEMAR"). NEMAR sets both.z-index, which only applied inside the capsule's own stacking context.Docs: a Launcher section in
docs/community-widget.md.Tests
resolve()omission, and only NEMAR setslauncherorlauncher_label(every real community config).frontend/test-widget-capsule.js(90, real widget in happy-dom), in both workflow suites: capsule markup only undercapsule; each notebook state;setDatasetbeforeinit(); invalidsetDatasetandnotebookUrlignored; the exact opened URL, encoded; an inactive button opens nothing; labels andaria-disabledper state; bubble mode renders today's markup; the capsule's active and neutral surfaces in the table-driven color audit.setDatasetvalidation, the before-initrender and the bubble default are each caught; two exposed weak tests, which were strengthened.widget_e2e.py --nemar, with a?dataset=&zarr=hook): screenshots of each state and a 390 px phone, no console errors or Content Security Policy violations, and the clicked URL recorded. The phone-width overflow of the panel's header and footer predates this and affects every community (Widget header and footer overflow on phone widths #466).