Repository navigation
NEMAR's widget in the search-button blue; boot Python on the first message - #463
Conversation
Separates the color painted as a surface (theme_color, user_bubble_color) from the text drawn on it and from that color used as a foreground on the widget's white panel. Each is optional and defaults to today's behavior when unset. NEMAR's widget now matches nemar.org's home page search button: theme_color/user_bubble_color are its teal (#5bbad5) with the button's own dark text (#04121f), and accent_color keeps the earlier darkened teal (#257a92) as the foreground on the white panel. The logo moves from the old dark-header white-and-gold to nemar.org's light-header navy-and-gold.
Boots the browser Python runtime as soon as the reader sends their first message, rather than waiting for a Run gate: the download overlaps the model's own first turn instead of following it, and a reader who only opens the chat is never charged for it (unlike widget_open). Also fixes the tool panel to show a first_message boot's real progress when Run is approved mid-boot, instead of a blank bar: the runtime's own last progress event is now cached independently of the running panel, which did not exist yet to receive it. NEMAR now uses first_message.
Preview Deployment
This preview will be updated automatically when you push new commits. |
state described only the bundle/controller wiring, reading 'ready' as soon as the controller existed and never reflecting whether Pyodide itself had booted. first_message and widget_open both make an early, long-lived booting state common, so add a separate runtime field (idle/booting/ready/failed/terminated, from PyodideRuntime.state) and document it in the getBrowserRuntimeStatus JSDoc.
applyWidgetConfig() ignored a malformed value for all five theme colors and the two disclaimer colors with no feedback, so an embedder's setConfig() typo looked exactly like an unset field. Add warnInvalidColor(), naming the field and the rejected value, and keep the existing fallback to that field's own default. Test that all seven fields warn (console.warn captured) and still fall back.
Boots the real test worker through useLocalController and asserts runtime moves idle -> booting (synchronously, as soon as boot() starts) -> ready, while state stays 'ready' throughout, proving the two fields are independent.
The surface/foreground split for every themed color was unverified: reverting .osa-header-btn or .osa-message-content a's color to the old fixed value passed all 243 existing tests. Probe the real injected stylesheet (happy-dom resolves custom properties and var() through actual <style> rules) for every surface (launcher, header, header buttons, feedback send, send, settings save, Run, re-run) and every computable foreground, under both the NEMAR-style case and today's unset defaults; check the seven hover/focus-gated foregrounds against the CSS source text, since happy-dom's getComputedStyle does not resolve :hover or :focus rules.
An embedder's setConfig() value for any of the five theme colors must never be overwritten by the server config for the same field. Table-driven over all five, each proven against both the in-memory CONFIG and the rendered custom property, with a per-case placeholder change so applyWidgetConfig() always has a reason to run.
Drives the real send-button click under preload_on: first_message against the failing test worker, waits for the boot to fail, then calls the real controller's execute() and asserts the tool result carries the controller's own '[runtime] the code could not be run:' wording and that the runtime retried from FAILED and failed again against the same worker.
startBrowserTools's catch-up (booting immediately if the first message was already sent) was untested: deleting it passed every test. Intercept head.appendChild to hold the bundle script's load/error open under full manual control, send the first message while the runtime is still null, then resolve the real bundle and assert it boots without a second message.
theme_text_color's comment named "--brand-navy-dark" as the source of #04121f. nemar.org hard-codes color: #04121f directly on .hero__search button; its actual tokens are --brand-navy (#0b1a3a) and --brand-navy-deep (#06112a), neither of which is this value.
Said it painted "accent elements", which is now accent_color's own role. Describe it as the button/header surface color and name how it pairs with theme_text_color (default white) and accent_color (default theme_color), mirroring user_bubble_color's docstring.
Matches the surrounding paragraphs' style; no wording changed.
This historical note listed only widget_open/first_run for worker lifecycle and the preload_on example comment; add the third value each names now, without otherwise touching the note.
No adopter-facing page documented any WidgetConfig field, old or new; the only prior documentation was Python docstrings and OpenAPI descriptions. Document every field (text/behavior and colors), the four color roles with WCAG contrast guidance, NEMAR's own widget as a worked example, the embedder setConfig key mapping, and what happens on a malformed value. One section per area so the capsule PR's launcher fields can be added as their own section later.
A broken catch-up threw an uncaught waitUntil timeout that crashed the whole Bun process, hiding every test that would have run after it. Wrap the test in try/catch and record the same message as a normal FAIL, so the suite keeps running and still exits non-zero.
Review responseFour Sonnet reviewers ran (code, tests, error handling, docs). Every finding is addressed in commits Code and design: no defects. The CSS audit, the loader, the first-message preload's races and failure paths, and the bundle's integrity pin were each confirmed by reading and by running the suites. Tests
Error handling
Docs
Not reproduced: the one-in-35 Full suite: 2,740 passed; the one failure is the pre-existing color-terminal test (#434). Bun: |
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.
Gives NEMAR's widget the blue nemar.org uses for its home page search button, and starts Python downloading while the model writes its first reply instead of after the reader clicks Run.
Widget colors (opt-in; no other community changes)
The home page search button is
#5bbad5(the website's--brand-teal) with#04121ftext. White text on it is 2.2:1, and the widget also used the theme color as a foreground on its white panel, where#5bbad5is 2.2:1 too. So three new optionalWidgetConfigfields separate the three roles, each hex-validated and emitted byresolve()only when set, following #462'suser_bubble_color:theme_text_color(--osa-on-primary, default#ffffff): text and icons on theme-colored surfaces (launcher, header, header buttons, send, Run, re-run, settings save, feedback send).accent_color(--osa-accent, defaultvar(--osa-primary), so unset trackstheme_colorexactly): the theme as a foreground on white (links, citation links, focus borders, the footer checkbox, the local-run note, the OpenRouter link).user_bubble_text_color(--osa-user-text, default#ffffff).NEMAR sets
theme_coloranduser_bubble_colorto#5bbad5, both text colors to#04121f, andaccent_colorto#257a92(the same 193 degree hue, 4.9:1 on white). Its logo on the lighter header takes the website's light-theme colors: brain#0b1a3a(--brand-navy), electrodes#b8860b(--brand-gold-deep). Contrast, tested: dark text on the theme 8.48:1, on the derived hover shade 6.35:1, accent on white 4.91:1.preload_on: first_messageMeasured on test.nemar.org today in a cold Chrome profile: the model's first turn took 8.1 s until the Run gate, and only then did Pyodide download and boot (2.9 s on a fast link for 5.3 MB plus 13.6 MB).
first_messageboots when the reader sends their first message, so the download overlaps the model's turn, without charging a reader who only opens the chat (whichwidget_opendoes). NEMAR uses it. Boot progress that arrives before a Run gate exists is now kept, so a run approved mid-boot shows the step under way instead of an empty bar.Tests
resolve()omission for each color; only NEMAR sets any of them (every real community config); contrast for each pair;first_messageaccepted, unknown values rejected.theme_color;first_messageboots on send andfirst_rundoes not; the progress seeding.widget_e2e.py --nemar): computed--osa-primary #5bbad5,--osa-on-primary #04121f,--osa-accent #257a92, headerrgb(4,18,31)onrgb(91,186,213); the same page without NEMAR's fields computes today's#2563eband white.