Skip to content

Draw the widget in the community's look at once - #476

Merged
neuromechanist merged 7 commits into
developfrom
feature/widget-first-paint
Sep 24, 2026
Merged

neuromechanist merged 7 commits into
developfrom
feature/widget-first-paint

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

On every page load the widget drew its launcher in the built-in defaults, the 56px bubble in #2563eb, and changed to the community's look when the community config request returned: about 450 ms later on test.nemar.org, on a reload as much as a first visit, then a 250 ms color fade (#475). For NEMAR the button also visibly shrank into the 46px capsule. This draws it in the community's look from the first frame.

What changes

  • The look is remembered. Each time the config arrives, its widget block is kept in the page's own localStorage (osa-widget-config-<communityId>), with the API endpoint it came from. The next load applies it before anything is drawn, through the same function and checks as a fresh config (applyWidgetDisplay, extracted from fetchCommunityConfig unchanged). The fresh config still arrives and wins for every field: the display fields first go back to their pre-init values, because the server leaves defaults out (a bubble launcher, the light scheme, an unset color), and a remembered capsule reverts to the bubble's markup (revertLauncherMode). An embedder's setConfig keys still outrank both, including one set while the request is in flight. The config is remembered under the community it was requested for. An entry for another endpoint, or one that cannot be read, is ignored.
  • No fade. The colors are set as custom properties before the widget joins the page (applyThemeProperties, split out of applyWidgetConfig), so its first computed style is already the community's. Setting them after it joined was measured: a reload then fades from blue.
  • A first visit waits. With nothing remembered, the launcher stays hidden, with transitions off, until the config arrives, then appears already in the community's look. It is shown in the defaults after 1.5 seconds, or at once if the request fails. The pop-out has no launcher and never waits.
  • Re-applying the same logo no longer rebuilds the header's avatar; a config that drops its logo restores the default one. The launcher's tooltip appears 1.5 s after the launcher does. An invalid color is warned about once per value.
  • The feedback dialog's "Shared with the ... community maintainers" line now follows the config; on a first visit it named the default community's maintainers.
  • startServer/waitForServer move from color-scheme-check.mjs into harness-server.js, for the new Chrome check to share.

This applies to every community, not only NEMAR. Every community had the same flash (HED's button, for one, drew in the platform blue before its own color), and nothing here can know a community's look before its config except what an earlier load remembered. A bubble community's settled markup and computed styles are unchanged; test-widget-capsule.js's bubble test now checks them once the config has arrived, and checks that a first visit adds exactly one class, osa-launcher-waiting, until then.

Tests

  • frontend/test-widget-first-paint.js (new, 81 checks, in both CI workflows): a stale remembered capsule, dark scheme, text color, label and logo all undone by a fresh config that leaves them out, down to the markup of a load that remembers the new config; a dropped theme color; a setConfig made during the request; a community change during the request; an exception injected right after the widget joins the page; the tooltip waiting for its button; one warning per bad color; the pop-out keeping its host's scheme; a first visit hidden until the config, then shown and remembered with its endpoint; a reload drawn in the remembered look (capsule at 46px, colors, title, launcher label, placeholder, logo) with the config still in flight; the fresh config winning and replacing the memory as sent rather than merged; setConfig outranking it; another endpoint's, unreadable, and oddly shaped entries ignored, quietly when they parse; storage that throws on every call; the 1.5 s cap, and a failed request showing the launcher at once; invalid remembered colors warned about and not applied; a bubble community; the pop-out; the logo not rebuilt.
  • Mutations: 31 single changes, 29 fail a suite; the other 2 are equivalent (loadCommunityConfig never rejects, so its finally is a backstop; a parsed null now returns early either way).
  • frontend/browser-harness/first-paint-check.mjs --serve (new, in CI beside the light and dark check), 42/42 in Chrome 153: a recorder installed before any page script samples the chat button, and whether the widget is dark, on every animation frame, with the config held 600 ms; NEMAR on a light and a dark device, and a bubble community with color_scheme: auto on a dark device. First visits first shown between 650 and 665 ms, reloads between 19 and 27 ms, and no visible frame in any run shows anything but the final look. Controls: develop's widget fails 12 checks, and each of these fails it too: transitions left on while waiting, colors set after the widget joins the page, nothing remembered, no first-visit wait.
  • color-scheme-check.mjs --serve (26), and notebook-tab-check.mjs against the live develop notebook (14/14), with the new startup.
  • Every Bun suite CI runs; build-runtime-bundle.js --check.
  • On test.nemar.org after the website re-pin: the same timeline, and Safari by hand.

Closes #475.

On every load the launcher appeared in the built-in defaults (the 56px
bubble, #2563eb) and changed to the community's look when its config
request returned, about 450 ms later on test.nemar.org, a reload
included (#475).

- The config's widget block is remembered in localStorage, per
  community and API endpoint, and applied before anything is drawn,
  through the same checks as a fresh one. The fresh config still wins
  and replaces it; setConfig still outranks both.
- The colors are set before the widget joins the page, so the first
  style is already the community's, with nothing to fade from.
- A first visit keeps the launcher hidden, with transitions off, until
  the config arrives (at most 1.5 s, or a failed request), then shows it.
- Re-applying the same logo no longer rebuilds the avatar.

Tested: bun frontend/test-widget-first-paint.js (56, new, in both CI
workflows); test-widget-capsule.js's bubble test now checks the settled
markup and what a first visit adds while it waits; 15 mutations, 13
killed, 2 equivalent; every other Bun suite unchanged and passing.
startServer and waitForServer move out of color-scheme-check.mjs into
harness-server.js, for the first paint check to use too; the caller now
reports a server that did not start.

Tested: color-scheme-check.mjs --serve, 26 checks, 0 failures; a server
that cannot start is reported with its output.
first-paint-check.mjs records the launcher on every animation frame
from document start, with the config request held 600 ms, and requires
every visible frame to show the community's look, on a first visit and
on a reload. Runs in CI beside the light and dark check.

Tested: 12/12 in Chrome 153; develop's widget fails it, as does each of
four mutations (transitions on while waiting, colors set after the
widget joins the page, nothing remembered, no first-visit wait).
community-widget.md gains a section on the remembered look: what is
kept and where, how a fresh config and setConfig rank against it, the
first-visit wait and its cap, and blocked storage.

Tested: docs only.
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-widget-first-paint-demo.osc.earth
Branch feature/widget-first-paint
Commit 7bf7dac

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

Review of #476: the server leaves defaults out (a bubble launcher, the
light scheme, an unset color), so a remembered value for a field the
fresh config omits survived the whole load, and a remembered capsule
could not turn back into a bubble at all.

- After a remembered look, the display fields go back to their
  pre-init values before the fresh config is applied; setConfig keys,
  including ones set while the request was in flight, are kept.
- revertLauncherMode undoes the capsule to the bubble's markup; unset
  colors remove their properties; a dropped logo restores the avatar.
- The config is remembered under the community it was requested for.
- The first-visit cap is scheduled before the widget is built, so an
  exception cannot leave the launcher hidden; the tooltip's timer
  starts when the launcher is shown.
- One warning per invalid color and value, not one per application.
- The feedback dialog's "shared with" line follows the config; a first
  visit named the default community's maintainers.

Tested: bun frontend/test-widget-first-paint.js (81; a stale capsule
reverts to the markup of a load remembering the new config, dropped
fields, mid-flight setConfig and community change, an injected fault,
the tooltip, one warning); 16 mutations, all killed; other suites pass.
first-paint-check.mjs records whether the widget is dark on every
frame, and runs three times: NEMAR on a light and a dark device, and the
harness's bubble community (color_scheme auto) on a dark device.

Tested: 42/42 in Chrome 153; develop's widget fails 12 of them.
The first paint section now says what happens to a field the fresh
config leaves out, including the launcher's shape, when a changed look
reaches a reader, the tooltip's timing, and one warning per bad color.

Tested: docs only.
@neuromechanist

Copy link
Copy Markdown
Member Author

Review response

Three reviews (code and docs, tests, error handling). Every finding is addressed in 9177747, d620ff1 and 13d15aa, except the two noted at the end.

  • A remembered capsule could not become a bubble again (all three reviews). The cause was wider than the launcher: WidgetConfig.resolve() leaves defaults out (a bubble launcher, the light scheme, an unset color, no label), and the API sends them as null, so a remembered value for any of them survived the fresh config for the whole load. Now, after a remembered look, the display fields go back to their pre-init values before the fresh config is applied; unset colors remove their custom properties; revertLauncherMode undoes the capsule; a dropped logo restores the default avatar. The test compares the reverted widget's markup with a load that remembers the new config, and they are identical.
  • setConfig during the request. The reset keeps every key an embedder set, including one set after init() (tested); a mutation dropping that guard fails.
  • Remembered under the wrong community when communityId changes during the request: the key now comes from what the request was made for (tested).
  • An exception after the widget joins the page could hide the launcher for good: the cap is now scheduled before anything is built (tested by injecting a throw right after appendChild). initialized staying true after a thrown init() is unchanged: retrying would append a second widget.
  • Up to three warnings for one bad color: now one per field and value (tested by count).
  • The tooltip's 1.5 s timer raced the 1.5 s cap: it now starts when the launcher is shown (tested).
  • The Chrome check covered only NEMAR on a light device: it now records the dark class on every frame and runs NEMAR on a light and a dark device and a bubble community on a dark device (42 checks).
  • The real 1.5 s cap test had a 2x margin: its budget is now 6 s; the cap itself is also tested with a shortened wait.
  • The pop-out with a host scheme and a remembered config: tested; the host's scheme wins.
  • Docs: "one more page load" was wrong for the launcher's shape and imprecise for the rest; the section now says exactly when a changed look reaches a reader.
  • Found while testing the revert: the feedback dialog's "Shared with the ... community maintainers" line was drawn from the default title and never updated, so a first visit named the wrong community. It now follows the config.

Not changed, with reasons:

  • The startup render runs renderMessages/renderSuggestions twice on a remembered load. Both rebuild from state and are idempotent, and both run before the first frame; not worth another ordering constraint.
  • A background tab slows the cap's timer. The config's arrival, which ends the wait too, is not a timer; noted beside LAUNCHER_WAIT_MS.

Gates: every Bun suite in CI, first-paint-check.mjs --serve 42/42, color-scheme-check.mjs --serve, build-runtime-bundle.js --check. Mutations: 31 single changes, 29 killed, 2 equivalent.

@neuromechanist
neuromechanist merged commit 1a79aa8 into develop Sep 24, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/widget-first-paint branch September 24, 2026 15:11
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