Repository navigation
test(chat): the pending-row regression waits for its new connection's own input-ready - #579
Conversation
… own input-ready After the reconnect in the "sent before the snapshot" step, the server can send its snapshot before the page has sent its attach. pendingReady() kept input-ready per pane only, so it resolved on the closed connection's last input-ready, the message reached the bridge before the new attachment was ready, and the server answered input_not_ready (draft kept, no pending row). Each input state now records the connection that reported it, and a pane is ready only on the page's current, open connection; the step also waits for that connection to exist.
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe UI regression script now tracks which WebSocket reported pane readiness. It requires readiness from the latest open socket to remain stable for 500 ms. The reconnect test waits for a replacement socket to open before checking readiness. ChangesSocket-scoped readiness
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Other Suggested reviewers: Merge Risk: ⚪ Minimal · up to No concrete current-head defect is established that should block this test-only change; proceed with normal checks. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
devswha
left a comment
There was a problem hiding this comment.
Independent review (merge-own lane).
Classification: test fix for the flaky required browser lane. scripts/ui-regression.ts:604 ("the message sent before the snapshot is a live pending row") failed about one run in five, including on #574 today (run 37675014452), so every merge paid for it.
What I checked:
- The race is real. The server sends
snapshotas soon as a socket opens (server/AGENTS.md: "On open every client immediately receivessnapshot"), which can come before the page'sattach.inputStateswas keyed by pane only, so the closed connection's lastinput-readysatisfiedpendingReady, and the send reached the bridge before the new attachment was ready (input_not_ready, draft kept, no row). The PR's frame log shows exactly that order. - The new wait cannot pass vacuously. A pane counts as ready only when the newest socket (
sockets.at(-1)) reportedready: true, is still open, and has held that for at least 500 ms. The app opens one kind of websocket (src/lib/ws.ts:83), sosockets.at(-1)is the page's current connection. If some other socket were newest, the wait would time out loudly rather than pass. The four otherpendingReadycallers run on a single live connection, so the stricter check holds for them too. The added wait for the page's new connection usesuntil, so it is bounded; there are no new sleeps. - No product code changed. A send before the attachment is ready is still refused, and the draft stays (never queued while offline).
Evidence (fix-flake's runs, in the PR body): before, 2 of 14 normal runs failed with this assertion, and the widened race failed 3 of 3. After, the widened race passed 3 of 3 and normal runs 10 of 10. My own run on the merged head 6d5f24d (bun run build, then bun run check run bun scripts/ui-regression.ts): all 80 checks PASS. Updated with main before merging; Fast checks and Integration and browser are green on the merged head. There are no review threads.
Change
scripts/ui-regression.tsraced the page in the "sent before the snapshot" step and failed about one run in five withTimed out: the message sent before the snapshot is a live pending row(CI runs 37631750944, 37675014452).The step closes the routed socket, holds the reconnect's
snapshot, waits forpendingReady(pendingPane), sends, then releases the snapshot.pendingReadyreadinputStates, which was keyed by pane only. The server sends its snapshot as soon as the socket opens, and that can be before the page has sent itsattach. In that order the held-snapshot wait finished whileinputStatesstill held the closed connection's lastinput-ready, sopendingReadyresolved at once. The message then reached the bridge before the new attachment was ready. The server answeredinput_not_ready, and the composer kept the draft with "Not sent: The pane is not attached and ready". So no pending row appeared.An instrumented copy of the script (frame log, not committed) caught the failing order:
In passing runs,
attachgoes out before the snapshot is held, andpendingReadywaits for the new connection'sinput-ready.The product behaves as intended: a send before the pane's attachment is ready is refused and the draft stays (never queued while offline). So the fix is in the test. Each input state now records the Playwright WebSocket that reported it, and a pane counts as ready only on the page's current, open connection. After the close, the step also waits for the page to open its new connection. There are no new timeouts or sleeps.
Validation
On a herdr of the run's own (
bun run check run bun scripts/ui-regression.ts):openhandler (which sends the attach) is stalled 300 ms, and the route holds that connection's frames to the server, attach first and in order, for 1 s. That is the failing order above, made certain.bun run check fast: passed (1699 pass, 4 skip, 0 fail). It does not coverscripts/, which the runs above exercise.No CHANGELOG entry: the change is test-only.