Skip to content

Widget: do not pace a hidden page; check the paced reveal in real Chrome - #535

Merged
neuromechanist merged 4 commits into
developfrom
feature/issue-534-hidden-page-reveal
Sep 29, 2026
Merged

neuromechanist merged 4 commits into
developfrom
feature/issue-534-hidden-page-reveal

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Closes #534. Follow-up to #533.

Why

I tried to check #533 on the dev demo in a browser window that was not in front. Its timers ran once a second (document.visibilityState was hidden), which made the measurement meaningless and exposed a gap: a page that is already hidden when a reply starts is paced anyway. #533 flushes the reveal when a page becomes hidden, but visibilitychange fires before the stream in the common case (a reader sends a question and switches tab), so that flush never runs and the reveal then ticks at the throttled rate for a page nobody is reading.

What this does

  • Pacing is decided at each tick. createReveal takes paced as a boolean or a function; the widget passes () => !prefersReducedMotion() && !document.hidden. A hidden page (or one that becomes hidden mid-reply) gets everything at the next tick, still coalesced into one redraw per tick.
  • A real-Chrome check (frontend/browser-harness/paced-reveal-check.mjs, in the Frontend Tests job of both workflows). The reveal had only been tested in happy-dom. It serves the widget, a config and a /chat stream shaped like GPT-6 Luna's (1.5 s silent, then about 900 characters with a code block in about 40 ms) from its own local server, drives headless Chrome over CDP, and samples what the reader sees every 25 ms against when the chunks arrived. It needs no backend and no network, so it does not depend on mcp.nemar.org (whose outages have been failing the browser checks in the Python job).

Measured (Chrome 154, three runs, all passing)

paced prefers-reduced-motion: reduce (emulated by the browser)
stream 924 characters in 41 ms same
first words on screen 107 ms after the first chunk 107 ms
reply fully on screen about 2.0 s later, through 24 different lengths within one tick
code block drawn once, whole (186 characters) same
sources listed only those whose marker had been shown

A mid-reveal screenshot shows the first paragraph, the code block complete, the second paragraph cut mid-sentence, and only source [1] listed.

Controls, and a bug in my own first version

Every run asserts its own controls: the page is visible (timers not throttled), the stream really was a burst, the conversation is fresh, nothing is shown before the stream's first text, and the browser reports reduced motion when it is emulated. The fresh-conversation control exists because the first version of this check shared a profile between its two runs, so the second page loaded the first run's saved reply and its reduced-motion checks passed vacuously (text "shown" 1,500 ms before the stream had sent any). With the widget's pacing removed, the check now fails 5 checks and exits 1.

Testing

Bun suite 116 checks (was 112), including the hidden-page rule, broken once to see it caught. All other widget suites and the frontend parity and drift tests pass.

Not verified

The dev demo itself: the Chrome window connected to this session was in the background (visibilityState: hidden), so nothing measured there is evidence about pacing. The measurement above is the real widget code in real Chrome against a local stream, not against the dev API with Luna.

Refs #534. Pacing is asked at each tick, so a page already hidden when the
reply starts (visibilitychange fired before the stream, so the flush on hide
never ran) gets everything at the next tick, not a reveal at the throttled
one-a-second rate. Tested in the Bun suite (116 checks); broken once to see it
caught.
Refs #534. A Luna-shaped burst (1.5 s silent, then a reply with a code block
in about 40 ms) is replayed from a local server and what the reader sees is
sampled in the page. Controls: page visible, stream really a burst, fresh
conversation, and prefers-reduced-motion emulated by the browser. With pacing
removed it fails 5 checks and exits 1. In the Frontend Tests job of both
workflows; needs no backend and no network.
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-534-hidden-pag-demo.osc.earth
Branch feature/issue-534-hidden-page-reveal
Commit c8de3e2

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

…e test

Refs #534. The new check's own page loads the widget from its loopback server;
it is a dev harness page like widget-e2e.html, never embed guidance. Full
offline suite: 3273 passed.
@neuromechanist
neuromechanist merged commit b966c43 into develop Sep 29, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-534-hidden-page-reveal branch September 29, 2026 13:33
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