Skip to content

fix(chat): two causes of flaky chat e2e (follow after a sideways swipe, caret placed a frame late) - #152

Merged
cachewraith merged 2 commits into
mainfrom
fix/chat-follow-sideways-20261027
Oct 26, 2026
Merged

cachewraith merged 2 commits into
mainfrom
fix/chat-follow-sideways-20261027

Conversation

@cachewraith

@cachewraith cachewraith commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Fixes the two intermittent chat e2e failures that turned main red today. Both are real app bugs, not just test timing.

1. chat.spec.ts:299: a sideways swipe paused follow (main runs after #146 and #148)
The test swipes sideways (wheel(-40, -3)). The chat's wheel handler doesn't count that as scrolling up, but Chromium sometimes still scrolls the chat by the 3 px of vertical noise; onScroll saw an upward move, paused follow and showed "Scroll to the latest message". Now, for 150 ms after a mostly sideways wheel, the chat's own upward scroll doesn't pause follow.

2. chat-history.spec.ts: caret placed a frame late (main after #150, and this PR's first CI run)
↑ recall and the / pick moved the caret in the next animation frame. That frame could land between Playwright's select-all and its insert, collapsing the selection so the text was appended: CI received second promptline one\nline two (:87) and, the same way, second prompt/ with no / menu (:94). A fast user could hit the same. The caret is now placed in a layout effect right after React commits the text, in the same task as the key.

Tests: typecheck, lint, 483 unit tests. Locally under parallel load, :299 failed 1 of 18 before and 0 of 36 after; chat-history 60/60 after. Full e2e: 49 passed, 1 failed in responsive.spec.ts:131 (Settings nav in a small window, untouched here), which passed 3/3 on rerun; noted in docs/TODO.md.

🤖 Generated with Claude Code

cachewraith and others added 2 commits October 27, 2026 00:53
Chromium sometimes scrolls the chat by a sideways swipe's few px of
vertical noise, and onScroll took that upward move as the reader going
back: the "Scroll to the latest message" button showed and follow stopped.
This is the intermittent chat.spec.ts:299 CI failure (main runs after #146
and #148). For 150 ms after a mostly sideways wheel the chat's own upward
scroll is ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a frame later

The ↑ recall and the `/` menu pick moved the caret in the next animation
frame. That frame could land between a select-all and the typing that
replaces it (Playwright's fill, or a fast user), collapsing the selection
so the new text was added after the old: CI saw "second promptline one"
and "second prompt/" (no `/` menu) in chat-history.spec.ts. The caret is
now placed in a layout effect, right after React put the text in the box,
in the same task as the key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cachewraith cachewraith changed the title fix(chat): a sideways swipe no longer pauses follow (flaky chat.spec.ts:299) fix(chat): two causes of flaky chat e2e (follow after a sideways swipe, caret placed a frame late) Oct 26, 2026
@cachewraith
cachewraith merged commit 5d8a8da into main Oct 26, 2026
4 checks passed
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