test(webviews): B2 waits for conditions, not fixed times (110 waits)

Merged
TE
15d ago
+492-136

Batch B2 of the fixed-wait sweep: 18 webview test files wait for the condition they assert instead of a fixed time. 110 waits removed (124 โ†’ 14 in these files on the ratchet baseline).

What the waits became:

  • Daemon messages: tests wait for the exact message they expect (steer, seen, btw, suggested-tasks, recap-card, reopened-chat-history). "Nothing was sent" checks first wait for a later signal on the same socket (the page's refetch after a lag notice, a drawn failover note or a marker chunk), so the forbidden message would have arrived first.
  • Fake clock: steer's 5 s Stop grace and focus-content's activation settle and press window run on Playwright's page.clock.
  • Painted frames: layout settles use the shared helper from #23374 (installPaintedFrames, cmuxPaintFrame): animations finished, then two painted frames (edited-copy, recap-card, step-rows, model-picker, reasoning-chip, thin-scrollers, latency-harness).
  • DOM state: turn-footer waits for opacity 0 or 1, working-counts for the row in view, diff-find reads until the state holds.

Left: 14 counted waits, all frame waits in agent-pane-stream-jitter.test.ts, where scroll glides run in JS and finished animations don't mean the view is at rest. Two new // fixed-wait: markers: the chunk cadence in stream-jitter is the input under test, and dev-server-stop polls the process table, since nothing reports when a grandchild process exits.

Verification: every changed file ran 3 times with CMUX_BROWSER_TESTS=1, one file at a time; all passed. The one failure was a single steer run during a concurrent bun run check, in a test this PR doesn't change (a 1.6 s window). Breaking the behavior on purpose (steer's Stop grace, focus-content's press window, recap's toggle and Not now, seen's view after attach) made the affected tests fail. check:fixed-waits (882), bun run check, scripts/web-lint.sh and the prepush gate pass. The independent review ran all 17 changed browser files once more: all pass.

check:fixed-waits may be red here until #23452 lands: #23094 added 9 fixed waits to base after the guard merged.

Agent session: huge-blue

๐Ÿค– Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Replaces fixed-time sleeps in 18 webview browser-test files with waits on the conditions they assert, removing 110 fixed waits (124 โ†’ 14 on the ratchet baseline).

What the waits became

  • Daemon round trips wait for the message they expect (cancel, prompt, view, /btw) and fail naming what never arrived.
  • "Nothing was sent" assertions first wait for a later positive signal โ€” the page's refetch, a drawn failover note, or a marker chunk โ€” so a forbidden message would have arrived first.
  • Stop's 5 s grace and the composer's activation settle run on Playwright's page.clock instead of sleeping through them.
  • Layout settles finish the page's finite animations, then wait for painted frames via the shared installPaintedFrames helper.
  • The turn footer waits for opacity 0 or 1; working-counts wait for the row in view; diff-find reads until its state holds.
  • The 14 waits left are frame waits in agent-pane-stream-jitter.test.ts (scroll glides run in JS) plus four marked fixed waits: the chunk cadence under test, dev-server-stop's process-table poll, and two 3 s frame-watch observation windows added by the #23374 merge.
  • Each changed file ran 3 times, and an independent review reran all 17 changed files: all passed.