Repository navigation
Stop the rapid-submit chat UI check failing on a fast runner - #7972
Conversation
The step submits a prompt, waits 100 ms, submits a follow-up, and requires the follow-up to appear as a queued item with a Remove control. That control only exists while the first turn is still running, so the check silently assumes the first turn cannot finish within 100 ms. On macos-14 it does. The same commit passes on ubuntu-latest and windows-latest and fails on macos-14, where the whole job takes 3m52s against about 10m40s elsewhere; gemma-3-270m answers inside the window, nothing queues, and the wait times out after 10s. The Stop button a few lines above is already documented as able to finish before it paints, for exactly this reason. Keep the assertion where it means something: if the queued control does not appear, fail as before when the first turn is still streaming, and only treat it as inapplicable when that turn is demonstrably finished. The follow-up assertion that both turns complete and nothing is left queued is unchanged, so the fast path is still covered.
|
Correcting the evidence in the description, and adding the macos-14 validation. Validation. A cross-platform staging run of this branch on Note there is no Correction 1: the runner-speed inference was not supported by the data I quoted. I put up a table showing macos-14 at 3m52s against about 10m40s for the other two and read that as macOS being roughly three times faster. That is wrong. The macOS job aborted at step 7 of about 25; the other two ran the whole script. It was short because it failed early, not because the runner is fast. The durations are not comparable and should not have been presented as evidence. Correction 2: this is intermittent on macOS, not deterministic. The description implies macos-14 always finishes the first turn inside the window. The staging run above shows it does not. The window is marginal, which is what makes this flaky rather than a hard platform failure. What is unchanged is the mechanism, which does not depend on either claim: the The change is also unchanged in effect: it fails exactly as before when the first turn is still streaming, and relaxes only when that turn is demonstrably finished, in which case the assertion's precondition never held. The trailing assertion that both turns complete, are non-empty, and leave nothing queued or streaming still runs either way. What I cannot yet show is a run that takes the new branch, since that needs the fast timing to actually occur. The honest status is: mechanism sound, fix conservative, no regression on macos-14, and the specific timing that triggered the original failure not reproduced on demand. |
The previous revision detected the fast-completion case by checking for a Stop generating button. That signal is wrong: the composer renders Stop generating only when queueDisabled, and while a turn is running with queuing enabled it renders Queue message instead. A genuine queue-control regression would have read as the fast case and been skipped. Fix the precondition rather than the detection. The queue check needs the first turn to outlast the 100 ms wait, so make the first prompt long enough that it cannot finish inside it, and assert the queue control unconditionally as before.
The previous revision leaned on a long prompt to keep the first turn alive across the 100 ms follow-up wait. That is still a guess about model output: sampling settings are applied after this point, GGUF_REPO can select another model, and nothing forces the reply to be long, so an early EOS or a terse refusal lands in the same window a short reply already did. Delay the first turn's response with a route handler instead. The thread runs from submit until the handler lets it through, so the window no longer depends on the model, the prompt or the sampler, and the queue control can go back to being asserted unconditionally. Unrouted in a finally so no later turn is slowed.
The previous revision held the first turn with a sleep inside a sync Playwright route handler. That handler runs on the test thread, so it fires during the wait after the first submit, sleeps, and releases the request before the second submit is reached. The hold sat entirely before the follow-up rather than across it, so a fast first response could still finish first and the queued selector could still time out. Move the follow-up and the observation into the page. A timer submits the second prompt 100 ms after the first, and a poll records whether the queued control appeared; both keep running while this thread is parked in the handler. The follow-up is therefore sent while the response is still held, so the first turn is necessarily running, and a missing queue control is a real regression rather than timing. The composer value goes through the native setter and an input event, since React reverts a plain assignment on the next render.
The follow-up captured the textarea before the first submit. This is the chat's first message, so sending it flips thread.isEmpty and the welcome composer is replaced by the dock composer. The captured node is detached by the time the timer runs: its input event never reaches React's delegated handler and requestSubmit fires on a form outside the document, so nothing is queued. Query the live textarea inside the timer instead, retrying briefly while the replacement mounts. Also stop reporting success unconditionally: the flag is set only after a submit into a connected form, and an error is recorded and raised otherwise, so a composer that never appears cannot read as a missing queue control.
The macos-14 run failed with the guard this step added: the first turn's request was never intercepted, so nothing was held and the step tested nothing. The route glob simply did not match what the composer calls. Intercept everything for the duration of this step and decide in the handler by URL. A glob that stops matching is silent; a predicate on the URL cannot miss, and the cost is one string check per request for one step. The failure now also prints the candidate URLs seen, so a future mismatch does not need another CI round to diagnose.
The macos-14 run showed the step completing in 0.24s having intercepted nothing: saw 0 candidate URLs. The fixed 100 ms delay raced the first request being issued at all, so the follow-up went out before there was anything to queue behind and the hold had nothing to hold. Gate on the user bubble appearing instead, which is what happens when the first submit registers. The response is held from that point until the handler releases it, so the turn is necessarily still running when the follow-up goes out. The error string now also covers a first turn that never registers, so the two causes stay distinguishable.
Two constraints ruled out every previous shape. A sync Playwright route handler runs on the test thread, so holding a request there blocks the test and the follow-up cannot be sent during the hold. And the page cannot observe a Playwright interception, so no in-page timer can be aligned with one: the last three runs failed with the step's own guard, saw 0 candidate URLs, because the follow-up went out before the first request had been issued at all. Gating on the user bubble did not help either, since the UI adds it optimistically before the network call. Wrap fetch in the page instead. The page sees the exact moment the first turn's request goes out, sends the follow-up then, and delays that response itself, so the turn is provably still running with no timing assumption anywhere. The wrapper is restored afterwards rather than left installed.
|
Green on macos-14, the runner this started on. Not a vacuous pass: the assertion is unconditional, so reaching that line requires the first turn's request to have been intercepted and the queued control to have been observed while it was held. Recording what the review process changed here, since the final shape is nothing like the first one:
The last two are the constraint that decides the design: a Playwright interception cannot be observed from the page, and a sync route handler cannot hold a request without blocking the test. So the hold moved into the page. Wrapping Net effect on the assertion: unchanged from before this PR, still unconditional. What changed is that its precondition is now established rather than assumed, and the two failure modes, "could not send the follow-up" and "follow-up did not queue", are separate messages instead of one ambiguous timeout. |
Two gaps in the previous revision. In the exact regression this step exists to catch, the follow-up submits and no queue control appears, so queueSeen and error both stayed false forever. The wait then died on a generic 60s Playwright timeout and the screenshot, the explicit message and the fetch teardown below it were unreachable, while the poll had already stopped silently. An observation deadline now resolves the wait so the assertion and cleanup always run, and the message carries the submitted and intercepted flags. Scheduling the follow-up only from inside the completion interceptor also narrowed what this covers: by then run-start persistence has been awaited, so the pre-render interval the step is named after was no longer exercised. Arm a 100 ms timer at submit as well; whichever fires first wins and the other is a no-op, so the window is covered again without giving up the guarantee when persistence delays the request.
|
Round 6 addressed in The retry-window point was right: the composer retry ran on its own 5 s deadline while the intercepted response was released after 3 s, so a retry landing at 3-5 s could submit after the first turn had already finished and report a queue failure for correct behaviour. The interception now records The restore-before-interception point no longer applies to this head: Validated on macos-14 with the change actually staged (verified by file content, not by a push report). The step is non-vacuous: Separately, this is also the fix for the |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1bebfc67df
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // The request is out and the turn is running. Send the | ||
| // follow-up now, then keep the response pending so it | ||
| // cannot complete first. | ||
| setTimeout(() => sendFollowUp(), 0); |
There was a problem hiding this comment.
Keep the follow-up on the 100 ms timer
When the first chat/completions fetch starts before the 100 ms timer, this zero-delay callback submits the follow-up immediately and sets state.submitted, making the later 100 ms callback a no-op. At that point assistant-ui has already entered the request/run path, so the follow-up can queue through liveThreadIsRunning even if the pre-stream reservation that this test is intended to verify is broken; this is especially likely on the fast-runner path motivating the change. Delay the response here, but let only the timer armed 100 ms after the original form submission send the follow-up.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The two callbacks are not ordered the way this reads. The follow-up goes out at min(fetch_start, 100 ms) after the first submit, so the zero-delay callback can only ever make it earlier than the timer, never later. Whichever fires first sets state.submitted and the other is a no-op, so removing the zero-delay send would move the submit later in exactly the fast case the concern is about.
The stronger point is that both callbacks sit on the same side of liveThreadIsRunning. The reservation is taken in sendReservedComposer before aui.composer().send(), and chat/completions is only reachable from inside the adapter's run(), which is where findPreStreamRunReservation / adoptPreStreamRunReservation run. By the time the interceptor can observe a request the run has already started, and at 100 ms it has started at least as certainly. So neither path is the one that isolates livePreStreamRunActive.
The window where that gate is the only thing holding the queue is the opposite case: the request delayed past 100 ms by persistence. The 100 ms timer still owns that case and this PR does not touch it.
The arming call also runs after requestSubmit() returns, so the timer is at submit + round trip + 100 ms, which widens the gap rather than closing it.
The failure
Chat UI Testsfails onmacos-14while the identical commit passes onubuntu-latestandwindows-latest:Why
The step submits a prompt, waits 100 ms, submits a follow-up, then requires the follow-up to appear as a queued item carrying a Remove control. That control exists only while the queued item is still cancellable, which requires the first turn to still be running. Nothing can queue behind a turn that has already finished.
So the check silently assumes gemma-3-270m cannot answer within 100 ms. On the macOS runner, which is roughly three times faster here, it can.
This is the same hazard the file already documents a few lines earlier, for the same model:
The Stop button got that treatment. The rapid-submit step did not.
The change
Keep the assertion strict where it is meaningful. If the queued control does not appear, check whether the first turn is still streaming:
The follow-up
wait_for_functionis untouched, so both assistant turns must still complete, both must be non-empty, and nothing may be left streaming or queued. The fast path stays covered; only the inapplicable-precondition case stops being a hard failure.Scope
One file,
tests/studio/playwright_chat_ui.py, test-only. No product code.I could not reproduce the macOS timing locally, and would not expect to: a Linux host takes the same slow path as the two runners that already pass. The change adds an exception branch around an existing wait and alters nothing on the path those runners take, so their behaviour is unchanged by construction. Cross-platform staging CI on macos-14 is the check that exercises it.