Repository navigation
Widget: do not pace a hidden page; check the paced reveal in real Chrome - #535
Merged
Merged
Conversation
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.
Contributor
Preview Deployment
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.
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.visibilityStatewashidden), 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, butvisibilitychangefires 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
createRevealtakespacedas 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.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/chatstream 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 onmcp.nemar.org(whose outages have been failing the browser checks in the Python job).Measured (Chrome 154, three runs, all passing)
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.