Skip to content

Live dictation test: wait for the box to empty after Send, and answer the composer's reads - #2911

Merged
davidmckayv merged 1 commit into
mainfrom
fix/dictation-flake
Dec 3, 2026
Merged

davidmckayv merged 1 commit into
mainfrom
fix/dictation-flake

Conversation

@davidmckayv

@davidmckayv davidmckayv commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

A test-only fix for the flake that failed the 1.2.10 publish: app/tests/composer-live-dictation.test.tsx, "default desktop: Send while listening stops, waits for the last words, and sends them in one press", which read the whole message still in the box (Expected: "", Received: "Existing draft book a table for two tonight").

Why it was flaky. The test saw the message sent, then read the box at once. The composer empties its state before it hands the message on, but prompt-area writes the box's text in its own effect, a few of React's scheduler turns after onSubmit runs. The waitFor on the sent message can resolve on a DOM change in between, while the box still shows the words, and after that the test only had two setTimeout(0) drains (from waitFor and findByRole) before it read the box. Whether React's turns land before those drains is down to timing, so on a busy runner the read came first. The product is fine: the box empties a moment later. The race is inside the test itself: it reproduces with the file run alone, so nothing leaks in from another test.

The ECONNREFUSED in the log are real, but they are not the cause. Every test in the file made two real requests to port 80 on the runner: the composer's free-trial line (TrialNote) reads the plan (/api/v2/organizations/default/plan) and the signed-in person (/people/me), and the page is addressed at http://127.0.0.1/. Passing tests logged them too, and the race happens with those requests answered.

The changes:

  • The test waits for the box to empty (await waitFor(...)), as it waits for everything else.
  • The file now answers those two reads in the test, the way plan-free-trial.test.tsx answers its own: no plan needed and a member signed in, as a self-hosted OpenBot answers. Any other request fails the test that made it. The file no longer touches the network.

No app code changes.

Where it runs

Test only. Answers to the checklist: none on every point.

  • New state that outlives a request? None.
  • What happens on the second replica? Nothing changes.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No.

Boundary and audit

  • No acting call changes.
  • No new refusals or failures.
  • Nothing new trusted from the client.

API and database

  • This changes nothing under api/, no app's requests, no database change and no release-policy.json.

Changelog

none

Proof

Red before, green after, made deterministic. A busy runner delays React's scheduler. To get that without loading the machine, a scratch preload (put first, so it runs before app/tests/react-teardown.ts captures setImmediate) makes each immediate the scheduler posts wait 3 ms:

  • main's file under it: 2 fail. Both Send tests fail at line 157 with CI's exact Expected: "" / Received: "Existing draft book a table for two tonight".
  • this branch's file under it: 19 pass, 0 fail. The same file with only the requests answered, before the waitFor change, still failed both tests, which is how the requests were ruled out as the cause.

Repeat runs (this branch):

  • bun test app/tests/composer-live-dictation.test.tsx --rerun-each=30: 570 pass, 0 fail, 0 ECONNREFUSED.
  • The same with the slowed scheduler: 570 pass, 0 fail.
  • 30 separate processes, the Send tests only: 30 passed, 0 failed.
  • Shuffled run of CI's shard 2 (the 333 files from the failed run's log, in one process as CI runs them, --randomize --seed=20261203): 2690 tests ran, 1 failure, and it is in another file. composer-live-dictation.test.tsx passed every test there, with 0 ECONNREFUSED. The failure is "New Bot is a fixed action outside the auto-highlighted recipient options" in channel-new-error-state.test.tsx. That file is untouched here and fails the same way run alone with that seed, so it depends on test order inside its own file. CI doesn't shuffle, so it isn't the 1.2.10 flake. It is left for its own fix.
  • A second shuffled run of the same shard (--seed=7): composer-live-dictation.test.tsx passed again, with 0 ECONNREFUSED. The one failure was again in channel-new-error-state.test.tsx ("+ with only one Bot opens To: empty, ..."), and it fails the same way with that file run alone with seed 7.

biome format, biome lint --error-on-warnings and the app's tsc --noEmit are clean.

There is no screen to show: nothing under app/src changes, so there are no Chrome or Safari screenshots.

… the composer's reads

"Send while listening stops, waits for the last words, and sends them in one
press" failed the 1.2.10 publish: it read the box straight after seeing the
message sent, and found the whole message still there. The composer empties
its state before it hands the message on, but the box's text is written by
prompt-area's own effect a few scheduler turns later, so the test raced it.
It now waits for the box to empty, as it waits for everything else.

The file also let the composer's free-trial line read the plan and the
signed-in person for real, at port 80 on the runner: two ECONNREFUSED per
test. Those reads are answered in the test now, as a self-hosted OpenBot
answers them, and any other request fails the test that made it.
@davidmckayv
davidmckayv marked this pull request as ready for review December 3, 2026 23:35
@davidmckayv
davidmckayv merged commit 474f661 into main Dec 3, 2026
20 checks passed
@davidmckayv
davidmckayv deleted the fix/dictation-flake branch December 3, 2026 23:36
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