Skip to content

Fix two flaky browser specs at their cause (iPad touch highlight, audio moment) - #3954

Draft
backnotprop wants to merge 3 commits into
mainfrom
fix/flaky-ipad-longpress-and-soak
Draft

backnotprop wants to merge 3 commits into
mainfrom
fix/flaky-ipad-longpress-and-soak

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Two browser specs that failed now and then on CI, fixed where they go wrong. No retries, no skips, no raised limits. A third, the memory soak, is not a flaky test: it is catching a real slowdown in the window, and it is left as main has it (see the end).

iPad: a long press dragged on in steps is highlighted once (inbox-touch-highlight-webkit.spec.ts:139)

Fault: the test. Both failures (main 76cbbec, run 45190576260; PR #3886 head c31a96d, run 45245882767) were the same line:

> 162 |     expect(done.toolbar).toBe(true);
Expected: true
Received: false

Line 161 passed in both runs, so the right words were highlighted. The spec waited for the highlight's marks, then read the toolbar at once. The marks go into the text synchronously (highlighter.fromRange). The toolbar comes later: it is React state set in the CREATE handler (setToolbarState in useAnnotationHighlighter.ts), and AnnotationToolbar returns null until its passive effect has placed it (setPosition, then if (!position) return null). That is at least one more render and a paint after the marks. On an iPad the toolbar shows a frame later. Nothing in that flow closes it: it is dismissed only by a mousedown outside it, Escape, or the selection scrolled out of sight. Every green run reads it still up 1.5 s later.

The spec now waits until there is one highlight and the toolbar is up, then checks everything as before. A toolbar that never comes still fails it. It failed 2 times in about 150 runs (1 of 13 full runs on main), only in the iPad case, which is the first test in the file.

Audio: Send carries the moment (inbox-audio.spec.ts:254)

Fault: the test. It failed 3 times (runs 45100384479, 45268491267 on #3948, 45267877621 on #3949), and once more on this PR's first head before the fix (run 45271746661). Each time it showed At 0:01 (1.3 s of 0:02) against an expected 1.2 s. It did not fail in any of the 13 full main runs I read.

The 2 s recording is playing when the test seeks it to 1.2 s. If the two screenshots just before were quick, it is still playing, so it plays on from 1.2 s until the first key pauses it. pin() in VideoAttachmentView.tsx reads currentTime after the pause, so from 1.25 s the comment reads 1.3 s. That is the real moment: the product is right. The spec now reads where typing paused the recording (between 1.19 and 2 s, so the 0:01 chip checks still hold). It checks that the dot and the time pill seek back to that moment, and that the agent's text carries it to the tenth. The old < 1.3 check on the dot had the same race.

Memory soak long task (inbox-memory-soak.spec.ts:129): a real regression, not fixed here

The spec's own summary line on main, by date (CI, longest task while messages arrive / slowest response):

So #3616 ("Inbox list: the N new bar sticks; the New pill shows only after Show") made the window do 5 to 6 times more main-thread work per agent message on a large store. The first head of this PR measured the main thread's CPU time around each long task and found it equal to the wall time: 1,803 of 1,803 ms, 124 s of CPU over the run. It is real work, not a loaded runner. The 2,000 ms limit is right (the header assumed CI about 3 times slower than the Mac, and before #3616 it was), so the spec is unchanged. I could not profile the window here, so the cause inside #3616's change is not found: heldLines in useListShown (more passes over the whole list on every render), and the sticky notice bar's layout and measuring in HeldNoticeLine.tsx, are where I would start.

Tests

  • The two changed specs pass a typecheck. Neither was run locally (browser specs run on CI only).

inbox-touch-highlight-webkit.spec.ts:139 (iPad): the spec waited for the
highlight's marks and then read the toolbar at once. The marks go into the
text synchronously in highlighter.fromRange; the toolbar is React state set
in the CREATE handler, and AnnotationToolbar draws nothing until its effect
has placed it, so it comes a render later. Both CI failures (runs
45190576260 and 45245882767) were exactly that read: highlighted text
right, toolbar not up yet. The spec now waits for one highlight and the
toolbar together.

inbox-memory-soak.spec.ts:129: the long-task limit compared wall time,
which counts the time a loaded runner keeps the renderer's main thread off
the CPU. In 12 green full runs on main the longest task was 1,321 to
1,812 ms; it failed at 2,174 and 2,721 ms with the slowest response at
about 9.4 s (4.8 to 7.6 s when green): the whole runner was slow. Each long
task now counts the main thread's CPU time during it (ThreadTime from
Performance.getMetrics, sampled every 100 ms, bracketing the task, never
more than its duration). The 2,000 ms limit is unchanged and the check is
never stricter than before; the summary prints wall and CPU time for the
slowest tasks.
@backnotprop backnotprop added the ci:e2e Run the full browser suite (Inbox window e2e) on this PR label Nov 23, 2026
inbox-audio.spec.ts:254 failed three times (runs 45100384479, 45268491267,
45267877621), each time with "At 0:01 (1.3 s of 0:02)" against an expected
1.2 s. The recording is playing when the test seeks it to 1.2 s; when the
two screenshots before were quick it is still playing, so it plays on from
1.2 s until the first key pauses it and pins that moment (pin() reads
currentTime after pause), and from 1.25 s it reads 1.3. The product
carries the real moment. The spec now reads where typing paused the
recording, and checks that the dot and the time pill seek back to it and
that the agent's text carries it to the tenth.
@backnotprop backnotprop changed the title Fix two flaky browser specs at their cause (iPad touch highlight, memory soak long task) Fix three flaky browser specs at their cause (iPad touch highlight, memory soak long task, audio moment) Nov 23, 2026
…lowdown

The first CI sample of the CPU-time check showed the soak's slowest tasks
use as much main-thread CPU as wall time (1,803 of 1,803 ms; 124 s of CPU
over the run): the window really does that work, the runner was not
holding it off the CPU. The spec's history on main says why. Through
2026-11-17 the longest task while messages arrived was 217 to 315 ms on
CI, as the header's budget assumed; every run since #3616 (the held "N new"
bar) is 1.1 to 1.9 s with the slowest response 4 to 8 s, and every PR run
without it stayed fast. The 2,000 ms limit is right, so the spec goes back
to main's.
@backnotprop backnotprop changed the title Fix three flaky browser specs at their cause (iPad touch highlight, memory soak long task, audio moment) Fix two flaky browser specs at their cause (iPad touch highlight, audio moment) Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:e2e Run the full browser suite (Inbox window e2e) on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant