Conversation
The modal selection tests opened a Dialog or Sheet, called settle() to advance the test clock past the entrance animation, then dragged at the TextView bounds from that frame. GPUI animations measure elapsed time with wall-clock Instant, which advance_clock does not move, so the modal was still sliding in. On a slow runner it moved between the bounds read and the drag, the drag started outside the text, and the selection came back empty (seen on macOS CI as "dialog text was not selectable"). Reduce motion in setup_modal so the entrance animation settles on the first frame, as the Dialog tests already do. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ihavecoke
force-pushed
the
ihavecoke/fix-flaky-modal-selection-tests
branch
from
September 28, 2026 14:59
50496f6 to
3f8d3b4
Compare
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.
Summary
drag_inside_dialog_still_selects_its_textfailed once on macOS CI withdialog text was not selectable: "". Text selection itself is fine. The test setup races the Dialog's entrance animation: the animation runs on wall-clock time, and the test drags at bounds captured while the Dialog is still sliding in.setup_modalnow reduces motion so the animation settles on its first frame.Why it fails
The test opens a Dialog, calls
settle(), reads the TextView bounds, then drags across them.settle()callsadvance_clock(500ms)to get past the 250ms entrance animation (ANIMATION_DURATION). That only advances the test scheduler's clock. GPUI'swith_animationmeasures elapsed time withscheduler::Instant, which isweb_time::Instant, the real clock on native targets. So when the bounds are read, the animation has barely started.slide-downanimation moves the Dialog from the window top down tomargin_top(a tenth of the window height). Its easing,cubic_bezier(1/3, 0.72, 2/3, 1), moves fastest in the first frames.drag()redraws after the mouse down and after each move. If enough real time passes between the bounds read and those redraws, the Dialog has moved down, the drag points computed from the old bounds no longer sit on the text, and nothing is selected.When it fails
Normally the bounds read and the drag are microseconds apart (the whole
gpui-componentlib suite ran 618 tests in 1.76s in the failing job), so the Dialog barely moves. The test fails only when its thread stalls for about 28ms or more at exactly that point.Measured locally without this fix, sleeping N ms between the bounds read and the drag, 5 runs per delay:
With this fix, 20ms and 100ms delays pass every run.
On the macOS runners
cargo testruns tests on one thread per core, so hundreds of GPUI tests share a few vCPUs and a test thread can be descheduled for tens of milliseconds. The stall has to hit this short window, which is why the failure is rare.Previous CI failure
Test (aarch64-apple-darwin, macos-latest)on website: Fit StatusBar demo sections to narrow windows #3301 atcc2ab056, which only changes a story file. 617 passed, 1 failed. Attempt 2 on the same commit passed.Fix
setup_modalcallscx.set_reduce_motion(true), as the Dialog tests indialog.rsandcrates/kit/tests/root.rsalready do. With reduced motion a oneshot animation renders its final frame immediately, so the bounds the test reads are where the Dialog stays.The helper is shared by the five tests that open a Dialog or Sheet:
drag_inside_dialog_still_selects_its_textdrag_inside_sheet_still_selects_its_textopening_dialog_clears_base_selectionselection_behind_active_dialog_is_excludedselection_behind_active_sheet_is_excludedTest-only change; no production code or public API is affected.
Context
Branch:
ihavecoke/fix-flaky-modal-selection-testsThe change was written with AI assistance.
Generated with Claude Code