Skip to content

test(app): deflake cached tab paint probe - #41965

Merged
Hona merged 1 commit into
anomalyco:v2from
Hona:deflake-cached-tabs
Aug 12, 2026
Merged

test(app): deflake cached tab paint probe#41965
Hona merged 1 commit into
anomalyco:v2from
Hona:deflake-cached-tabs

Conversation

@Hona

@Hona Hona commented Aug 12, 2026

Copy link
Copy Markdown
Member

Flake

smoke: session timeline › paints cached session tabs at the latest message fails under CPU load with Expected: 0, Received: 10 on the removed assertion. On unmodified v2 it fails 4-6 of 8 with --repeat-each=8 --workers=4 --retries=0, while passing in isolation.

The ten removed nodes are exactly the ten <br> elements from the markdown renderer's synchronous fallback pass. The Markdown component renders in two passes: a sync fallback block (key initial) that escapes text and converts newlines to <br>, then an async worker-parsed result that replaces the fallback block via morphdom because the block key changes. On a fast machine the parsed result lands before the probe records first paint; under load it lands after, so the probe snapshots the fallback <br> nodes into its first-paint WeakSet and then counts their intended replacement as cached-tab row teardown.

Fix

The probe now only records first paint once markdown hydration has settled: in addition to the existing conditions (last message visible, bottom spacer aligned), the timeline root must contain no [data-markdown-key="initial"] element. The test also waits for first paint to be recorded before the 200ms observation window, so the removed === 0 assertion still observes a real post-hydration window and still guards against genuine cached-tab row teardown.

The two-pass markdown render is intended product behavior; only the test probe changes. The samples collection is unchanged, so the paint-at-latest and bottom-alignment assertions still evaluate the first non-empty sample.

Validation

  • bunx playwright test e2e/smoke/session-timeline.spec.ts:120 --repeat-each=10 --workers=4 --retries=0 → 10/10 pass
  • bunx playwright test e2e/smoke/session-timeline.spec.ts → 5/5 pass
  • bun typecheck in packages/app passes

@Hona
Hona requested a review from Brendonovich as a code owner August 12, 2026 07:42
Copilot AI lite review requested due to automatic review settings August 12, 2026 07:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Deflakes the “cached session tab paint” smoke test by delaying “first paint” recording until the timeline is fully hydrated (specifically, until markdown’s synchronous fallback pass is gone), so post-hydration DOM morphing doesn’t get misclassified as cached-tab teardown.

Changes:

  • Tightens the probe’s firstPaint gating conditions to also require no [data-markdown-key="initial"] fallback content.
  • Exposes a painted() probe method and updates the test to wait for firstPaint before starting the observation window.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +192 to +197
if (
!firstPaint &&
visible.includes(last) &&
Math.abs((bottom?.bottom ?? Infinity) - view.bottom) <= 1 &&
!root.querySelector('[data-markdown-key="initial"]')
) {
@Hona
Hona enabled auto-merge (squash) August 12, 2026 07:46
@Hona
Hona disabled auto-merge August 12, 2026 10:21
@Hona
Hona merged commit c8dffb6 into anomalyco:v2 Aug 12, 2026
7 of 9 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.

2 participants