Skip to content

Widget: draw the first text at once and bound the reveal to half a second - #539

Merged
neuromechanist merged 6 commits into
developfrom
feature/issue-538-tighter-reveal-progress
Sep 29, 2026
Merged

neuromechanist merged 6 commits into
developfrom
feature/issue-538-tighter-reveal-progress

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Refs #538 (the reveal half; the progress-status half is a separate PR).

Why

The paced reveal from #533 started within about 0.1 s of the first chunk but finished about 2 s after the last one, which reads as delay. Measured against real Bedrock (same prompt, no tools), the wait before Luna's first word is the model's own and OSA adds nothing to it:

Luna effort first text, raw Bedrock first text, through OSA text finished
max (unchanged) 5.9 s 5.2 s about 6 s
medium 2.4 s 2.5 s about 3.3 s
low 0.6 s 0.7 s about 1.8 s

With tools it is much longer (NEMAR: 15.8 s to the first word, 48.8 s in total). Luna's effort stays at max; this PR only removes what the widget adds after the text arrives.

What this does

  • The first text is drawn the moment it arrives, not a tick later.
  • Every later character is drawn no more than about 500 ms after it arrived. This is a bound, not a tuned pace: an arrival log gives each chunk its own deadline, each tick shows what those deadlines call for, and a chunk within a tick of its deadline is drawn now, so the bound does not rest on timers firing exactly on time. A backlog small enough to draw at 1,000 characters per second or less is drawn at once, so a model that streams slowly is drawn as it arrives, at most one 80 ms tick late, and text arriving on an idle reveal is drawn at once (a line or so).
  • A finished reply waits at most 700 ms for the reveal (was 4 s).
  • Code blocks are still shown whole; markers, sources, reduced motion, hidden pages, focus and scroll behavior are unchanged.

Measured (real Chrome 154, headless, three runs)

before now
first words after the first chunk 107 ms 0.3 to 15 ms
whole reply on screen after the last chunk about 2,000 ms about 500 ms
distinct lengths a reader sees 24 7

The burst is still spread over a visible window (7 steps), so it does not flash in, but it adds at most half a second.

Testing

  • Bun suite: 140 checks (was 116), including the delay promise pinned independently of the constants (my first mutation check showed a 4 s drain cap passing because the test read the bound from the constant), a seeded property over 300 random arrival schedules (bursts of 100 to 9,000 characters, trickles, mixed) asserting no character is drawn more than 580 ms after it arrived (worst case measured), a starved-timer test for the drain bound, and the first-text-at-once check. Each new behavior was broken once and the named check failed.
  • Real-Chrome check (frontend/browser-harness/paced-reveal-check.mjs) updated to the new contract; 3 of 3 runs pass.
  • All other frontend suites pass; full offline Python suite: 3,273 passed.

Not verified

Not run against the dev API with Luna in a foreground browser window (the Chrome window connected to my session was in the background). The numbers above are the real widget in real Chrome against a local stream shaped like Luna's.

Review

An independent review confirmed the bound (a randomized search over arrivals up to 200,000 characters, gaps of 0 to 1,000 ms, and late-timer models found a worst delay of 499 ms) and found these, all addressed:

  • A burst landing late in an earlier reveal was flashed in one step (one deadline for the whole backlog: a second 3,000 character burst 400 ms in was drawn in a single 3,000 character step). Each chunk now has its own deadline; the same burst takes 6 steps and no step exceeds about 200 characters.
  • A flaky assertion (>= 5 distinct lengths had zero margin; 1 of 18 runs failed under CPU load): >= 3.
  • Test gaps proven by mutation (two mutants passed all 123 checks and the Chrome check): new tests for a burst after a pause, a burst landing late in an earlier reveal, bursts every 430 ms, idle arrivals, timers 1 ms early and 20 and 60 ms late, drain on an unpaced reveal. Each hardening was broken once and a named check failed.
  • The Chrome check did not discriminate the synchronous first paint (a tick-late first paint passed about 1 run in 4): the bound is now 50 ms; with a tick-late first paint it fails 6 of 6 runs, the real code passes 3 of 3 (0 to 20 ms).
  • The page-hide test now asserts synchronously, and its saved-history assertion can fail.
  • Docs: claims restated to what the code and measurements support (no untraceable numbers, first-paint figures given at the sampler's resolution, "a line or so" not "the first chunk").
  • Hardening: a chunk within a tick of its deadline is drawn now (early timers left a residue, worst 643 ms against 580); the reveal reads performance.now() (a system time change made a burst look younger; tested by stepping Date.now back 10 s, and broken once to see it caught); drain() on an unpaced reveal shows everything at once instead of waiting on a throttled timer.
  • Noted, not changed: the known counter is redundant with the arrival pruning (a memory guard only).

…cond

Refs #538. The reveal took about 2 s after the last chunk. Now the first
text is drawn when it arrives and each later character no later than 500 ms
after it arrived (an arrival log sets the pace against the oldest undrawn
character's deadline; a backlog under 1000 chars/s is drawn at once); a finished
reply waits at most 700 ms. Tested in the Bun suite (123 checks, including a
300-schedule property of the bound) and in real Chrome.
…schedules, real Chrome

Refs #538. The delay bound is pinned in the tests (not derived from the
constants, which let a 4 s drain cap pass), a seeded property checks that no
character is drawn more than 580 ms after it arrived, and the Chrome check is
updated: first words 0.3 to 15 ms after the first chunk, whole reply about
0.5 s after the last.
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-538-tighter-re-demo.osc.earth
Branch feature/issue-538-tighter-reveal-progress
Commit 8f418d3

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

…ap at once, harden the bound

Refs #538, review findings. One deadline for the whole backlog let a burst
landing late in an earlier reveal be drawn in a single step; each chunk now
sets its own pace and a chunk within a tick of its deadline is drawn now, so
the bound no longer rests on timers firing exactly on time. Text arriving on
an idle reveal is drawn at once (a line or so), the reveal reads a monotonic
clock, and drain() on an unpaced reveal shows everything at once.
…em time change

Refs #538, review findings. New checks for a burst after a pause and one that
lands late in an earlier reveal, text arriving on an idle reveal, timers 1 ms
early and 20 or 60 ms late, the default clock surviving a system time change,
drain on an unpaced reveal and page hide (asserted synchronously). A count of
distinct lengths with no margin is relaxed to 3 (it flaked under load); the
Chrome check now fails a first paint of 50 ms or more. Each new behavior
broken once and caught.
@neuromechanist
neuromechanist merged commit e790cb8 into develop Sep 29, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-538-tighter-reveal-progress branch September 29, 2026 14:59
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