Skip to content

test(webviews): U1 waits for conditions, not fixed times (114 waits) - #23416

Merged
teamleaderleo merged 14 commits into
feat-cmux-nextfrom
fixed-waits/u1
Oct 21, 2026
Merged

teamleaderleo merged 14 commits into
feat-cmux-nextfrom
fixed-waits/u1

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Part of the fixed-wait sweep that followed the ratchet in #23365. This PR removes 114 fixed-time waits from 20 webview unit-test files, counted against current feat-cmux-next.

  • Hover and dwell delays run on bun:test's fake timers. These cover the session hover card, the sidebar preview, the minimap turn preview, the URL chip grace, the settings backdrop and theme dwell, the scroll anchor settle, the warm New Tab post, and the prompt delivery deadlines. Each test checks that the behavior is absent one tick before its delay and present at it, so a slow runner can't change the result.
  • Async results are awaited with bounded until loops. Each loop yields with setTimeout 0 and fails with a message naming what it waited for. This covers shell reads, sign-in polls, client reconnects and resyncs, pasted image chips, KaTeX and diagram rendering, the code-card handoff, changelog and settings host calls, and menu picks.
  • The settings claim-paint test counts calls and stream events in flight and waits until all are delivered, instead of waiting 300 ms.
  • Left for a follow-up: the 3 reveal-frame waits in transcript-switch-back.test.tsx will move to the shared post-paint helper from webviews tests: frame tests read layout after the frame paints #23374.

It also carries #23414 (the base-red marker fix), which drops out once that merges.

Verification: an independent subagent review said SHIP. Each changed file passed 3 runs of bun test, and bun run check passes, including check:fixed-waits (878 on the baseline).

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

Removes 114 fixed-time waits from 20 webview unit-test files, so a loaded runner that wakes a wait late can no longer change a test's result.

  • Hover and dwell delays run on bun:test's fake timers; each test checks the behavior is absent one tick before its delay and present at it.
  • Async results are awaited with bounded until loops that yield with setTimeout 0 and fail naming what they waited for.
  • The fixed-wait check now also counts waits inside helpers, block-body timer callbacks, and exported helpers, so a new wait anywhere raises the count.
  • The settings claim-paint test counts calls and stream events in flight and waits until all are delivered.
  • The 3 reveal-frame waits in transcript-switch-back.test.tsx stay for a follow-up to the shared post-paint helper, and the baseline ratchet is lowered accordingly.

Written for commit b3b55b4. Summary will update on new commits.

View guided diff Turn on auto-fix

teamleaderleo and others added 11 commits October 21, 2026 11:52
…soned marker

Fails until scripts/check-fixed-waits.ts exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15c78-27ca-7140-a6c7-95f0db83b18c&host=huge-blue
check:fixed-waits (in `bun run check`) names each test wait for a fixed number
of ms: page.waitForTimeout, Bun.sleep, a setTimeout that resolves a promise
after a non-zero delay, and calls to a local helper built on one. A fixed wait
passes on an idle machine and fails on a loaded runner that wakes it late, or
hides the bug it waits out (#23323). A test waits for a condition instead, uses
fake timers when the timing is the behavior, or keeps the wait with a
`// fixed-wait: <reason>` comment.

The 398 waits from before the rule have per-file counts in
scripts/fixed-waits-baseline.tsv. A file fails with more unmarked waits than
its row, and with fewer until the row is lowered (--update-baseline), so the
count only moves down; the sweep PRs lower it. pageSwitch's 16 ms
no-requestAnimationFrame fallback keeps its wait with a reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15c78-27ca-7140-a6c7-95f0db83b18c&host=huge-blue
…imers and exported helpers

Fails on the first detector: a helper with no delay parameter counted only at
its definition, a helper passed as a value (act(settle)) not at all, a timer
callback with a block body was missed, and so was an exported helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15c78-27ca-7140-a6c7-95f0db83b18c&host=huge-blue
From review. A wait inside a named function makes it a helper, and each use
counts instead of the definition: a call, or the helper passed or returned as a
value (act(settle), return { open }), applied outward through helpers built on
helpers. So another `await settle()` in a file raises its count. A helper whose
delay parameter defaults to 0 waits only when a use passes a delay. An exported
helper also counts at its definition, since its callers are in other files.

Also caught: timer callbacks with a block body that resolve the promise,
window/globalThis.setTimeout and Bun.sleepSync. A marker counts anywhere in the
wait's statement, or on a comment-only line above it, so a trailing marker no
longer covers the next line. The scan covers every source under test/
(harnesses, latency helpers), not just *.test files, and skips fixtures. A
malformed baseline row now fails instead of passing as NaN.

The baseline is regenerated: 819 waits in 132 files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15c78-27ca-7140-a6c7-95f0db83b18c&host=huge-blue
…ixed-wait count

Review of #23365 found that a second wait or helper call added inside a
function that already waits was not counted. These cases fail on the
current detector.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15c78-27ca-7140-a6c7-95f0db83b18c&host=huge-blue
…lpers too

A wait counted only through the outer uses of its enclosing helper, so a new
wait or helper call inside a helper that already waited changed nothing. Now
each unmarked wait site counts, and each use of a helper outside its own
body, so any new wait raises the count. Waits in exported helpers count at
the site, which replaces the export rule. Export lists, typeof and member
declaration names are no longer uses. The baseline is regenerated: 989 waits
in 132 files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15c78-27ca-7140-a6c7-95f0db83b18c&host=huge-blue
Removes the fixed sleeps from the U1 batch's 20 unit-test files.

- Hover and dwell delays (session hover card, sidebar preview, minimap turn
  preview, URL chip grace, settings backdrop and theme dwell, scroll anchor
  settle, warm New Tab post, prompt delivery deadlines) run on bun:test's fake
  timers: each test checks the behavior is absent one tick before its delay and
  present at it, so a slow runner cannot change the result.
- Async results (shell reads, sign-in polls, client reconnects and resyncs,
  pasted image chips, KaTeX and diagram rendering, the code-card handoff,
  changelog and settings host calls, menu picks) are awaited with bounded
  `until` loops that yield with setTimeout 0 and fail naming what they waited for.
- The settings claim-paint test counts calls and stream events in flight and
  waits until all are delivered, rather than waiting 300 ms.
- The reveal frame helper in transcript-switch-back is left for the shared
  post-paint frame helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15c78-27ca-7140-a6c7-95f0db83b18c&host=huge-blue
#23374 merged after the fixed-wait ratchet (#23365) ran CI, and it added a
3 s waitForTimeout in two tests, which puts feat-cmux-next over its baseline.
Both waits are observation windows: the test records every painted frame for
3 s after the chat opens and asserts none jumped, so the time is the test.
They carry a fixed-wait marker instead of a raised baseline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15c78-27ca-7140-a6c7-95f0db83b18c&host=huge-blue
…its/u1

# Conflicts:
#	webviews/scripts/fixed-waits-baseline.tsv
@teamleaderleo teamleaderleo added the risk:normal Risk tier (docs/ci/risk-tiers.md) label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Review b3b55b4: HQ feed card · gallery before/after runs · checks

App of this head (app.zip, kept 1 day)

gh workflow run reload-build.yml -R manaflow-ai/cmux --ref feat-cmux-next -f tag=pr23416 -f ref=fixed-waits/u1 -f platform=macos -f backend_mode=local

Gallery before/after for b3b55b4: 16 states rendered, 14 images differ, 676 more touched states not rendered. Images are in the run's artifact, not on this public PR.

gh run download 39619741034 -R manaflow-ai/cmux -n gallery-advisory-23416-b3b55b44d3982a23c842644297ee1d8ce3728632 (then read gallery-review.json)

States
State Theme Status Diff Picked by
agent-pane.add-project-panel/environment Apple System Colors Light unchanged 0% same-folder promptDelivery.test.ts
agent-pane.add-project-panel/environment Apple System Colors unchanged 0% same-folder promptDelivery.test.ts
agent-pane.add-project-panel/sources Apple System Colors Light unchanged 0% same-folder promptDelivery.test.ts
agent-pane.add-project-panel/sources Apple System Colors unchanged 0% same-folder promptDelivery.test.ts
agent-pane.add-project-panel/directory Apple System Colors Light unchanged 0% same-folder promptDelivery.test.ts
agent-pane.add-project-panel/directory Apple System Colors unchanged 0% same-folder promptDelivery.test.ts
agent-pane.add-project-panel/keyboard Apple System Colors Light unchanged 0% same-folder promptDelivery.test.ts
agent-pane.add-project-panel/keyboard Apple System Colors unchanged 0% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/pr-queue Apple System Colors changed 0.0396% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/pr-queue Apple System Colors Light changed 0.019% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trust-permission-queue Apple System Colors Light changed 0.0625% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trust-permission-queue Apple System Colors changed 0.0256% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trust-individual-queue Apple System Colors Light changed 0.03% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trust-individual-queue Apple System Colors changed 0.0193% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trust-then-permission Apple System Colors Light changed 0.0438% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trust-then-permission Apple System Colors changed 0.0387% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trust-then-individual Apple System Colors Light changed 0.0523% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trust-then-individual Apple System Colors changed 0.0111% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trusted-permission-queue Apple System Colors Light changed 0% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trusted-permission-queue Apple System Colors changed 0% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trusted-individual-queue Apple System Colors Light changed 0% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trusted-individual-queue Apple System Colors changed 0% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trusted-individual-waiting Apple System Colors Light unchanged 0% same-folder promptDelivery.test.ts
agent-pane.bottom-stack/trusted-individual-waiting Apple System Colors unchanged 0% same-folder promptDelivery.test.ts
agent-pane.chat-display-menu/a-popover-recommended Apple System Colors Light unchanged 0% same-folder promptDelivery.test.ts
agent-pane.chat-display-menu/a-popover-recommended Apple System Colors unchanged 0% same-folder promptDelivery.test.ts
agent-pane.chat-display-menu/b-preset-submenu Apple System Colors Light unchanged 0% same-folder promptDelivery.test.ts
agent-pane.chat-display-menu/b-preset-submenu Apple System Colors unchanged 0% same-folder promptDelivery.test.ts
agent-pane.chat-display-menu/c-inline-steppers Apple System Colors Light unchanged 0% same-folder promptDelivery.test.ts
agent-pane.chat-display-menu/c-inline-steppers Apple System Colors unchanged 0% same-folder promptDelivery.test.ts
agent-pane.chat-width/standard Apple System Colors Light unchanged 0% same-folder promptDelivery.test.ts
agent-pane.chat-width/standard Apple System Colors unchanged 0% same-folder promptDelivery.test.ts

Pick other states with a Gallery: entry.id, entry.id/variant line in the PR body.

Unclear: web / react-apps-check (1) failed: no known signature; failed step: Fail on the gate checks.

CI failed on b3b55b44d3 (run 39619740920 attempt 1): 2 unknown.

Job Verdict Why
web / react-apps-check (1) unknown no known signature; failed step: Fail on the gate checks
web / react-apps-check unknown no known signature; failed step: Check webview test shards

Not re-run automatically: web / react-apps-check (1), web / react-apps-check are not machine failures.

Written by scripts/ci/classify_failures.py (ci-failure-attribution.yml); signatures are its SIGNATURES table. A machine verdict is the runner's fault, not this PR's; yours means the failing file is one this PR changes, also red on main that main's latest full suite fails the same way, seen on other PRs that it failed on another pull request's run lately.

red: web / Web status; NEW: green on the base bc5ce39; do not merge until green; see lane-rules
red: web / react-apps-check; no finished base run on bc5ce39 to compare; do not merge until green; see lane-rules
red: web / react-apps-check (1); no finished base run on bc5ce39 to compare; do not merge until green; see lane-rules

CI fast guards failed on b3b55b44d3 (https://github.com/manaflow-ai/cmux/actions/runs/39619740920). It does not block the merge; a red guard merged into main breaks it for every open PR.
The log named no failed step; see the run.

Agents: python3 scripts/ci/guard_attribution.py fix applies the mechanical fixes locally.

Tour of b3b55b44d3 (run): no media. The tour job failed before the tour ran (build or setup); the run log has the output.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Bead cx-lo41f created for this PR by the cmux coordinator.

@blacksmith-sh

blacksmith-sh Bot commented Oct 21, 2026

Copy link
Copy Markdown

Found 2 test failures on Blacksmith runners:

Failures

Test View Logs
test/secret-card.test.ts/secret-card.test View Logs
test/secret-card.test.ts/secret-card.test View Logs

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

…its/u1

# Conflicts:
#	webviews/test/session-sidebar-preview.test.tsx
# Conflicts:
#	webviews/scripts/fixed-waits-baseline.tsv
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

cmux-next guards / defaults-snapshot is red on 20 of 21 fresh feat-cmux-next PR heads in the last 2:00:00, so it is most likely a base red, not this PR's. The base-reds lane has it; a base merge picks up the fix once it lands.

…its/u1

# Conflicts:
#	webviews/scripts/fixed-waits-baseline.tsv
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Owned by window-focus-opacity on huge-blue · session

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Review (subagent): SHIP at b3b55b4 (re-review of the base merges: same test change; the baseline only lowers this PR's own rows; check:fixed-waits passes). Reds aren't this PR's: check:browser-lanes on test/diff-paint-perf.test.ts (from #23154, fixed on base by #23480), defaults-snapshot (base), and gallery health (it renders app source; this PR changes test files only). fast gates follows from these.

@teamleaderleo
teamleaderleo merged commit d5c7a22 into feat-cmux-next Oct 21, 2026
@teamleaderleo
teamleaderleo deleted the fixed-waits/u1 branch October 21, 2026 15:47
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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

Labels

risk:normal Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant