Skip to content

test(ui): assert smooth scroll intent instead of frame counts in chat-motion e2e - #160506

Merged
VACInc merged 1 commit into
mainfrom
fix/chat-motion-e2e-frame-count
Sep 28, 2026
Merged

VACInc merged 1 commit into
mainfrom
fix/chat-motion-e2e-frame-count

Conversation

@VACInc

@VACInc VACInc commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Summary

High Level TLDR

chat-motion.e2e.test.ts flakes on CI with expected 2 to be greater than 2, including on PRs that do not touch ui/. The check counted distinct scrollTop values seen by a requestAnimationFrame sampler. That count measures the runner's frame rate, not the product. This PR replaces it with deterministic checks of the page's side of the contract: a smooth scroll is requested while the viewport is still away from the end, no scroll command jumps instantly, and the viewport ends at the transcript end. Test-only change; no product code changes.

Root Cause

  • Before behavior: finishSendMotion asserted new Set(visible.map((frame) => frame.top)).size > 2 (line 81, added by fix(ui): prevent chat jumps and prompt flicker when sending #160109). Chromium runs smooth scrolling as a time-based animation. When the main thread is starved, rAF callbacks fire rarely, and the whole scroll can finish between two samples. The sampler then sees only {start, end} and the count is exactly 2.
  • CI evidence: three unrelated runs failed on this assertion alone. PR #160018 checks-ui-e2e (2/9) failed the multiline case (4105 ms). Run 36423624274 checks-ui-e2e (8/9) failed multiline (5325 ms). Run 36421667092 checks-ui-e2e (2/9) failed desktop (7852 ms). The same cases take about 2.5 s locally, so those runners were heavily loaded. The failed cases are the three non-reduced-motion cases that make this assertion.
  • Local reproduction (scratch, not committed): I added Emulation.setCPUThrottlingRate through CDP right after the probe was installed, and logged the probe data.
    • Unthrottled: 11–14 distinct sampled tops; the thread's scrollTo calls are smooth with a synchronous jump of 0; final end distance is 0.
    • rate: 10: 4–5 distinct tops; still passes.
    • rate: 30: tops [4031, 4229], [4195, 4374], etc. 3 of 4 cases fail with the exact CI error expected 2 to be greater than 2. In the failing cases the product did the right thing: every command was smooth, every synchronous jump was 0, and the final end distance was 0.
  • Classification (per the flake triage doc): a timing-dependent test assertion. It is not a product race, and it is not a fixture or ordering leak.

Exact change

ui/src/e2e/chat-motion.e2e.test.ts only:

  • The existing instance thread.scrollTo interceptor (the one that already feeds the instant-jump check) now also records each call's behavior and the distance to the end when the call was issued (remaining).
  • The frame-count assertion is replaced with:
    1. at least one scrollTo with behavior: "smooth" issued while remaining > 8, and
    2. the final scrollHeight - scrollTop - clientHeight <= 8 (the product's CHAT_TRANSCRIPT_END_THRESHOLD_PX).
  • These checks are kept unchanged:
    • no scroll command moves the offset by more than 1 px synchronously (instant-jump check);
    • the prompt bubble stays opaque, keeps the same element, and moves monotonically upward;
    • reduced motion is exempt;
    • arrival-animation counts and horizontal overflow.

What the frame count was protecting: the send moves the viewport as an animation rather than a snap. Checks 1 and 2, together with the existing instant-jump check, still prove that. The viewport travels more than 8 px to the end, a smooth command carries it, and no command jumps. They also still catch a snap that comes before the smooth scroll. As a mutation check, I made queued manual scrolls set scrollTop = scrollHeight before applyChatScroll. All three motion cases then failed on the new assertion (remaining: 0 on every smooth call), and reduced motion still passed. The browser's own interpolation is Chromium's contract; the test no longer depends on how many frames the runner can paint.

Scope boundary: this is one flake in one file. I found an unrelated flake in sidebar-selection-overflow.e2e.test.ts during the shard runs. It also reproduces on unmodified origin/main and is not addressed here (see Verification).

Real behavior proof

  • The behavior fixed is the test's stability under frame starvation. The product contract is still asserted.
  • Environment: local Linux host, Node 24 (repo-pinned toolchain), cached Playwright Chromium headless shell, mocked-Gateway bundled UI E2E project.
  • Same scratch CDP setCPUThrottlingRate(30) injection, applied to the fixed test: 3/3 runs, 4/4 tests passed. At that throttle rate the original fails 3/4 tests (above).
  • Mutation (pre-smooth instant snap) on the fixed test: 3/4 fail on the new smooth-intent assertion, as intended.

What was not tested

  • A real overloaded CI runner. Local reproduction used CDP CPU throttling as the stand-in.
  • Direct scrollTop assignments made during an in-flight smooth scroll are not intercepted. The old frame count only caught those when frames were plentiful, so it was not a reliable guard either. The probe did not observe any direct scrollTop writes during sends in the unthrottled or throttled runs.
  • $autoreview was not run for this test-only diff.

Verification

Flake validation

Check Command Result
Original test, before fix, standalone ×5 pnpm test:ui:e2e ui/src/e2e/chat-motion.e2e.test.ts 5/5 pass: it does not reproduce unthrottled on this host (wall 24.0–26.8 s)
Original test under CDP CPU throttle 30× (scratch) same, with scratch throttle injection fails 3/4 tests with expected 2 to be greater than 2
Fixed test under CDP CPU throttle 30× (scratch) ×3 same 3/3 pass
Fixed test, standalone ×20, sequential pnpm test:ui:e2e ui/src/e2e/chat-motion.e2e.test.ts 20/20 pass, 80/80 tests; wall min 22.3 s / mean 23.3 s / max 24.7 s
Original CI shard checks-ui-e2e (2/9) in recorded order ×4 (fixed head) OPENCLAW_UI_E2E_SKIP_REAL_GATEWAY=1 OPENCLAW_VITEST_INCLUDE_FILE=<include list decoded from the job's OPENCLAW_NODE_TEST_GROUPS_GZIP_BASE64> node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner --maxWorkers 3 --shard 2/8 chat-motion 4/4 pass. Shard: 2 fully clean (369/369, 272 s and 245 s); 2 had 1 unrelated failure (sidebar-selection-overflow.e2e.test.ts "overflow=true at 1280 px", 231 s and 232 s)
Same shard on unmodified base ×2 same, with the file at origin/main chat-motion 2/2 pass; sidebar-selection-overflow failed 2/2, so it is pre-existing and unrelated
Sibling chat scroll/send E2E pnpm test:ui:e2e on chat-scroll, chat-scroll-dock, chat-collaborator-scroll, chat-follow-maintenance, chat-send-pending-handoff, chat-send-ack-ownership, chat-composer-input-measurement, chat-flow.messaging 8/8 files, 45/45 tests pass (81 s)

The shard's include list has 667 patterns, and all of them exist on this base, so --shard 2/8 selects the same 79 files as the failing job. The decoded list comes from the job's env. Only two of four fixed-head shard runs were fully clean, so the "3 clean shard runs" bar is not met. The shard noise is the separate sidebar-selection-overflow flake, which fails on base too. The chat-motion file passed in every shard run.

Other checks

  • pnpm exec oxfmt ui/src/e2e/chat-motion.e2e.test.ts: clean.
  • pnpm exec oxlint ui/src/e2e/chat-motion.e2e.test.ts: clean.
  • git diff --check: clean.
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.ui-e2e.json: pass (13 s).
  • node scripts/check-changed.mjs: fails only on config/env-var-count-budget.txt: OPENCLAW_* count 484 exceeds budget 483. The same failure occurs with the base version of this file, and this diff adds no env vars, so it is pre-existing on origin/main.

Test cost

No new tests. The standalone file wall is 22.3–24.7 s after the fix, versus 24.0–26.8 s before. Per-case durations are unchanged (about 2.5 s). No timers, sleeps, retries, or timeout changes were added.

Inherited CI failures (admin exception)

Exact-head run 36441076802 is red only in UI e2e shards 1/9, 4/9, 5/9, 7/9 on tests in other spec files (chat-flow.sidebar-presentation, session-owner-filter-keyboard, chat-user-avatar-alignment, model-catalog-partial-refresh, chat-session-companion-focus), all red on main's own scheduled runs 36437289300 / 36444547317 since d769e31 (#160002). This PR changes only ui/src/e2e/chat-motion.e2e.test.ts (whose tests pass) and no shared helper. ClawSweeper: no findings. Landed under the AGENTS.md pre-existing-red exception by the maintainer.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 11:11 AM ET / 15:11 UTC.

ClawSweeper review

What this changes

The PR changes the Control UI chat-motion browser test to check for a smooth scroll request, absence of synchronous jumps, and arrival at the transcript end instead of counting sampled animation frames.

Merge readiness

✅ Ready for maintainer review

Current main still has the frame-count assertion that can fail when Chromium samples a smooth scroll only twice. This focused PR addresses that test flake, and the reported throttled-browser runs support the change; it remains useful for review.

Priority: P2
Reviewed head: 42481ada62adb28782c12bc60fbe7439ae41d076

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused assertion change has a clear failure mechanism and detailed reported browser validation, with no actionable defect found in review.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its body reports before/after runs of the changed mocked-Gateway Chromium test under CDP CPU throttling, including the original failure and the fixed result; those reported runs were not independently replayed here. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its body reports before/after runs of the changed mocked-Gateway Chromium test under CDP CPU throttling, including the original failure and the fixed result; those reported runs were not independently replayed here. No stored-data contract changes.
Evidence reviewed 7 items Current main retains the flaky assertion: The current-main test requires more than two distinct requestAnimationFrame scroll offsets.
Introduced PR behavior: The pinned merge-base-to-head diff replaces the frame count with smooth-intent and final-position assertions while retaining the synchronous-jump check; the verified test merge changes only this test file.
Production scroll contract: The chat scroll owner resolves smooth versus reduced-motion behavior and passes the choice to the transcript controller.
Findings None None.
Security None None.

How this fits together

The Control UI browser test sends a chat message through a mocked Gateway and observes how the transcript moves in Chromium. Its assertions determine whether the chat-motion check passes in CI.

flowchart LR
  A[Mock chat history] --> B[Control UI send]
  B --> C[Transcript scroll controller]
  C --> D[Chromium scroll]
  D --> E[Motion probe]
  E --> F[Browser test result]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +21. Total +21 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 29 8 +21
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 29 8 +21

Review metrics

Metric Value Why it matters
Changed E2E test runtime 22.3–24.7 s after; 24.0–26.8 s before The contributor reports the required cost of the changed browser test without an added per-PR test.

Technical review

Best possible solution:

Keep a browser-level chat send check that verifies smooth scroll intent, guards against synchronous jumps, and confirms the final viewport position without depending on the runner's frame rate.

Do we have a high-confidence way to reproduce the issue?

Yes. The current-main assertion and the reported CDP-throttled Chromium run give a high-confidence path to the two-sample failure; I did not execute the scratch throttle injection in this read-only review.

Is this the best way to solve the issue?

Yes. Checking the scroll command and settled viewport removes the frame-rate dependency while retaining the existing prompt-opacity and synchronous-jump checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 03f92a56beca.

Labels

Label changes:

  • add P2: The timing-sensitive browser assertion disrupts validation of unrelated PRs, while the repair is confined to one test.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its body reports before/after runs of the changed mocked-Gateway Chromium test under CDP CPU throttling, including the original failure and the fixed result; those reported runs were not independently replayed here. No stored-data contract changes.

Label justifications:

  • P2: The timing-sensitive browser assertion disrupts validation of unrelated PRs, while the repair is confined to one test.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its body reports before/after runs of the changed mocked-Gateway Chromium test under CDP CPU throttling, including the original failure and the fixed result; those reported runs were not independently replayed here. No stored-data contract changes.

Evidence

What I checked:

  • Current main retains the flaky assertion: The current-main test requires more than two distinct requestAnimationFrame scroll offsets. (ui/src/e2e/chat-motion.e2e.test.ts:81, 03f92a56beca)
  • Introduced PR behavior: The pinned merge-base-to-head diff replaces the frame count with smooth-intent and final-position assertions while retaining the synchronous-jump check; the verified test merge changes only this test file. (ui/src/e2e/chat-motion.e2e.test.ts:99, 42481ada62ad)
  • Production scroll contract: The chat scroll owner resolves smooth versus reduced-motion behavior and passes the choice to the transcript controller. (ui/src/pages/chat/scroll.ts:171, 03f92a56beca)
  • Documented user behavior: The Control UI documentation says local sends scroll smoothly after layout settles, while reduced motion disables smooth scrolling. Public docs: docs/web/control-ui/chat.md. (docs/web/control-ui/chat.md:608, 03f92a56beca)
  • Reported browser validation: The PR body reports that CDP 30× CPU throttling made the original test fail in three of four cases with the CI error, while the changed test passed three throttled runs; these results were reported by the contributor and were not replayed in this read-only review. (42481ada62ad)
  • Feature history and related discussion: The test's current-main history includes merged chat-motion work by RoboClaw, with Vyctor H. Brzezowski and Peter Steinberger credited in the merged PR. The open related PR reports this assertion failing in an unrelated CI shard; its owner-authority change is distinct. (ui/src/e2e/chat-motion.e2e.test.ts:81, 2b8c65c47fd2)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vyctorbrzezowski: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

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

Labels

app: web-ui App: web-ui P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant