test: keep perf CLS setup scrolls outside measured windows - #853
Conversation
📝 WalkthroughWalkthroughThis PR introduces a measured performance window lifecycle to prevent programmatic setup operations from being recorded as layout shift in perf probe measurements. A ChangesMeasured Performance Window Guard System
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a structured mechanism for measuring performance windows in E2E tests, including a measurePerfWindow helper and a guard to prevent setup-only scroll jumps during active measurements. It also includes a new unit test for these constraints and improves the hoverTimelineScrollLane helper. A review comment identified a logic error in the session-timeline-recompute test, where scrolling up from the top of the container would likely cause an assertion failure.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/app/e2e/perf/perf-probe.spec.ts`:
- Around line 165-168: The fixed 250ms sleep in settlePerfSetup makes the test
timing-dependent; replace the waitForTimeout(250) with a measurable observable
wait (e.g., use page.waitForFunction) that waits for a stable condition before
opening the measured window. In settlePerfSetup (used by snapshotPerfProbe),
instead of sleeping, wait for a concrete signal such as document.readyState ===
'complete' and no new frames or long tasks for a short observation window (for
example poll performance.getEntriesByType('frame') or a custom window variable
and resolve when its count/lastTimestamp hasn't changed for ~200–300ms) so the
test only proceeds when the page has actually settled.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3dae00d1-2137-4b27-bbaf-0081c06f2ca1
📒 Files selected for processing (2)
packages/app/e2e/perf/perf-probe-window.unit.tspackages/app/e2e/perf/perf-probe.spec.ts
There was a problem hiding this comment.
Suggested priority: P3 (only low-risk paths changed (packages/app/e2e/perf/perf-probe-window.unit.ts, packages/app/e2e/perf/perf-probe.spec.ts)).
P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.
Perf delta summaryComparator: pass
|
Summary
Move setup-only timeline scroll alignment out of perf-probe measured windows and add a runtime guard so direct setup scrolls cannot be called while a perf measurement is active.
Why
session-scroll-readingwas resetting the perf probe before a script-drivenscrollTop = 0alignment. Chromium does not mark that jump as recent user input, so the layout-shift observer counted the helper as CLS and produced false-positive perf reports.Related Issue
Fixes #746
Human Review Status
Pending
Review Focus
Please check that
measurePerfWindow()now defines the measured window cleanly,setTimelineScrollTopForSetup()remains setup-only, andsession-timeline-recomputestarts from a position that can actually move upward before measuring negative wheel input.Risk Notes
session-timeline-recomputecan still report high CLS from its real upward wheel path; this PR only removes script-driven setup scroll pollution from the measured window. Skipped conditional checklist items: no visible UI or copy changed; no platform, packaging, updater, signing, paths, shell, or permissions surface changed; no docs, release notes, dependencies, credentials, deletion behavior, generated content, or local file changes are relevant.How To Verify
Screenshots or Recordings
Not required: no visible UI or copy changes.
Checklist
bug,enhancement,task,documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.app,ui,platform,harness,ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.P0,P1,P2,P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.Pending,Approved by @<reviewer>, orNot required: <reason>(default isPending; "not required" is restricted to bot-authored low-risk PRs).dev, and my PR title and commit messages use Conventional Commits in English.