Skip to content

NEMAR's widget in the search-button blue; boot Python on the first message - #463

Merged
neuromechanist merged 16 commits into
developfrom
feature/nemar-search-blue
Sep 24, 2026
Merged

neuromechanist merged 16 commits into
developfrom
feature/nemar-search-blue

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

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 #04121f text. White text on it is 2.2:1, and the widget also used the theme color as a foreground on its white panel, where #5bbad5 is 2.2:1 too. So three new optional WidgetConfig fields separate the three roles, each hex-validated and emitted by resolve() only when set, following #462's user_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, default var(--osa-primary), so unset tracks theme_color exactly): 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_color and user_bubble_color to #5bbad5, both text colors to #04121f, and accent_color to #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_message

Measured 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_message boots when the reader sends their first message, so the download overlaps the model's turn, without charging a reader who only opens the chat (which widget_open does). 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

  • Python: field validation and resolve() omission for each color; only NEMAR sets any of them (every real community config); contrast for each pair; first_message accepted, unknown values rejected.
  • Bun (real widget and runtime code): each variable applied when set, ignored when malformed, defaults when unset; the accent default tracks theme_color; first_message boots on send and first_run does not; the progress seeding.
  • Chrome (widget_e2e.py --nemar): computed --osa-primary #5bbad5, --osa-on-primary #04121f, --osa-accent #257a92, header rgb(4,18,31) on rgb(91,186,213); the same page without NEMAR's fields computes today's #2563eb and white.
  • Eight mutations, each caught by a test.
  • Full suite: 2,740 passed; the one failure is the pre-existing color-terminal test (test_version_shows_version fails locally and passes in CI, because rich colorizes on a TTY #434).

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

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-nemar-search-blue-demo.osc.earth
Branch feature/nemar-search-blue
Commit 152f3df

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

Copy link
Copy Markdown
Member Author

Review response

Four Sonnet reviewers ran (code, tests, error handling, docs). Every finding is addressed in commits 9d8c4cf through 4ee01bd.

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

  • The CSS classification had no coverage (restoring color: white on .osa-header-btn, or var(--osa-primary) on message links, passed every test). A table-driven test now checks the computed color of every surface and every computable foreground under both NEMAR's values and the defaults; hover- and focus-gated rules are checked against the stylesheet, since happy-dom does not compute :hover. Both mutations now fail (4777b0b).
  • The catch-up boot, for a first message sent before the runtime bundle resolves, was untested; it now is, and deleting it is a counted failure (69d27dd, 4ee01bd).
  • Embedder overrides survive the server config for all five color fields (4e2e001).
  • A failed first-message preload is retried from FAILED, and the next run's result reports [runtime] the code could not be run: ... (7715d4c).

Error handling

  • A malformed color now warns, naming the field and the value, for all seven color fields, and still falls back to the default (1aebf5b).
  • getBrowserRuntimeStatus() gains a runtime field with Pyodide's own state (idle, booting, ready, failed, terminated); the existing state keeps its meaning (9d8c4cf, a3879fe).

Docs

  • NEMAR's config no longer names a nonexistent --brand-navy-dark; nemar.org hard-codes #04121f on its search button (7cdbd8f).
  • theme_color's docstring describes the surfaces it paints and its two partner fields (98ac615).
  • The first_message paragraph uses semantic line breaks (d421d72); the design note lists first_message (0e33214).
  • New docs/community-widget.md documents every widget field, the four color roles with the contrast rule the tests enforce, and the matching setConfig keys, linked from the README (256d810). No adopter-facing page documented any widget field before.

Not reproduced: the one-in-35 test-widget-tools.js failure the code reviewer saw did not recur in about 830 runs (sequential and 20-way parallel) on this branch, on 7f840f9, or on develop. The two fixed waits in that file wait on state set synchronously, so they are padding, not races. If it recurs, the failing assertion's text is the next step.

Full suite: 2,740 passed; the one failure is the pre-existing color-terminal test (#434). Bun: test-widget-tools.js 312 passed, every other listed suite green, chrome.js passed.

@neuromechanist
neuromechanist merged commit e4f007a into develop Sep 24, 2026
16 checks passed
@neuromechanist
neuromechanist deleted the feature/nemar-search-blue branch September 24, 2026 04:57
neuromechanist added a commit that referenced this pull request Sep 24, 2026
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.
neuromechanist added a commit that referenced this pull request Sep 24, 2026
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.
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