Skip to content

test(ui): pause fake clock before send so working-timer e2e assertions are deterministic - #115187

Merged
steipete merged 1 commit into
mainfrom
steipete/silly-liskov-a6b549
Jul 28, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/silly-liskov-a6b549

Conversation

@steipete

@steipete steipete commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

ui/src/e2e/mantis-chat-proof.e2e.test.ts has a flaky timing assertion: on PR #115123's checks-ui-e2e attempt 2 (2026-07-28, unrelated branch) it failed with expected '2m 57s', received '2m 59s'. The sibling test in ui/src/e2e/chat-run-lifecycle.e2e.test.ts ("shows compaction savings and live working time") has the identical pattern and the same latent flake.

Why This Change Was Made

Both tests install a fake Playwright clock but never pause it. page.clock.install() keeps the virtual clock ticking at real-time rate until it is paused, and the working indicator's startMs is captured from the page's Date.now() at the send click (queue item createdAt, min-reduced in ui/src/pages/chat/chat-progress.ts). So the elapsed value the test asserts is fastForward(177_000) plus however many real seconds CI took between the send click and the fastForward call — on a slow runner that inflates "2m 57s" to "2m 59s".

The fix pauses the virtual clock (page.clock.pauseAt(now + 5s)) immediately before the send click, so virtual time advances only through fastForward and the elapsed reading is exactly 177s, deterministically. This matches the existing repo pattern in ui/src/e2e/lobster-pet.e2e.test.ts.

User Impact

None — test-only change. CI's checks-ui-e2e lane stops flaking on this assertion.

Evidence

Both changed specs pass locally:

$ node scripts/run-vitest.mjs ui/src/e2e/mantis-chat-proof.e2e.test.ts
 Test Files  1 passed (1)
      Tests  1 passed (1)

$ node scripts/run-vitest.mjs ui/src/e2e/chat-run-lifecycle.e2e.test.ts
 Test Files  1 passed (1)
      Tests  4 passed (4)

Determinism proof (before/after with simulated CI slowness). Injecting a real-time await page.waitForTimeout(2_500) between the send click and fastForward(177_000) simulates the slow-runner gap that caused the observed CI failure.

Before (pause removed, delay injected) — reproduces the exact flake class from PR #115123's checks-ui-e2e:

 FAIL  |ui-e2e| ui/src/e2e/mantis-chat-proof.e2e.test.ts > Mantis Control UI web chat proof > sends a chat message and captures visible browser proof
AssertionError: expected '3m 1s' to be '2m 57s' // Object.is equality

Expected: "2m 57s"
Received: "3m 1s"

 ❯ ui/src/e2e/mantis-chat-proof.e2e.test.ts:123:10
 Test Files  1 failed (1)
      Tests  1 failed (1)

(The received value exceeds 2.5s of injected delay because the unpaused clock also ticks during the send/waitFor steps — the same mechanism that produced "2m 59s" on CI.)

After (this PR's pause in place, same 2.5s delay injected) — deterministic:

$ node scripts/run-vitest.mjs ui/src/e2e/mantis-chat-proof.e2e.test.ts
 Test Files  1 passed (1)
      Tests  1 passed (1)
   Duration  9.38s

@steipete
steipete marked this pull request as ready for review July 28, 2026 12:28
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XS maintainer Maintainer-authored PR labels Jul 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 8:32 AM ET / 12:32 UTC.

ClawSweeper review

What this changes

The PR pauses Playwright’s fake clock immediately before sending chat messages in two Control UI end-to-end tests, so working-time assertions advance only through explicit virtual-time fast-forwarding.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 4 items remain

Keep this PR open for normal protected-label review. The narrow test-only change plausibly removes a genuine virtual-clock timing race and introduces no concrete functional or security defect in the supplied diff, but the provided evidence does not include inspectable after-fix output for the stated delayed-run reproduction. Likely related people: steipete (high confidence, prior merged feature/test work).

Priority: P3
Reviewed head: d4a8882db42b0a26191226aecdd5e908036b9d67

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation is small and coherent, but uninspectable real-behavior proof keeps the merge-ready rating low.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The PR body describes real delayed-run evidence, but it does not provide inspectable after-fix terminal output, logs, recording, or a linked artifact; please add redacted proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR body describes real delayed-run evidence, but it does not provide inspectable after-fix terminal output, logs, recording, or a linked artifact; please add redacted proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Focused deterministic change: The PR changes only the two affected Control UI E2E tests, adding a fake-clock pause immediately before the send action and leaving runtime production code unchanged.
Sibling test coverage: The identical pause is added to the Mantis chat proof test, matching the report that both tests capture the working-timer start time at send and then assert after a virtual-time advance.
Feature provenance: The underlying Ask OpenClaw UI work that exposed this test path was merged in the related PR, providing concrete history context for the affected chat-test surface.
Findings None None.
Security None None.

How this fits together

The Control UI chat tests simulate sending a message through the browser and then fast-forward virtual time to verify the visible working timer. The tests depend on the chat progress calculation capturing a start timestamp at send time and rendering elapsed time in the chat interface.

flowchart LR
  A[Control UI E2E test] --> B[Install fake browser clock]
  B --> C[Pause clock before send]
  C --> D[Chat send captures start time]
  D --> E[Fast-forward virtual time]
  E --> F[Working timer assertion]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR body describes real delayed-run evidence, but it does not provide inspectable after-fix terminal output, logs, recording, or a linked artifact; please add redacted proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The branch is behind current main and the relevant UI E2E check is still in progress, so merge readiness should be confirmed against the exact merge result.
  • Resolve merge risk (P1) - The stated delayed-run determinism experiment is not backed by inspectable live output or an artifact in the provided PR evidence.
  • Complete next step (P2) - The protected maintainer label and remaining proof/CI confirmation call for normal human review rather than an automated repair lane.
Agent review details

Security

None.

PR surface

Tests +8. Total +8 across 2 files.

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

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the pause directly before each send action, then land after the current-head UI E2E run completes and the PR includes a redacted terminal transcript or equivalent artifact showing the delayed-run reproduction no longer drifts.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the pause directly before each send action, then land after the current-head UI E2E run completes and the PR includes a redacted terminal transcript or equivalent artifact showing the delayed-run reproduction no longer drifts.

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

Unclear for a live current-main run: the PR describes a concrete delayed-send reproduction in the affected E2E tests, and the changed timing boundary is clear from the supplied diff, but no independently inspectable run output was provided.

Is this the best way to solve the issue?

Yes, provisionally: pausing the already-installed virtual clock immediately before the timestamp-producing send action is narrower and more maintainable than weakening the exact elapsed-time assertions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 981a3dfad302.

Labels

Label changes:

  • add P3: This is a narrow test-determinism repair with no reported production-user impact.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body describes real delayed-run evidence, but it does not provide inspectable after-fix terminal output, logs, recording, or a linked artifact; please add redacted proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P3: This is a narrow test-determinism repair with no reported production-user impact.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body describes real delayed-run evidence, but it does not provide inspectable after-fix terminal output, logs, recording, or a linked artifact; please add redacted proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Focused deterministic change: The PR changes only the two affected Control UI E2E tests, adding a fake-clock pause immediately before the send action and leaving runtime production code unchanged. (ui/src/e2e/chat-run-lifecycle.e2e.test.ts:112, d4a8882db42b)
  • Sibling test coverage: The identical pause is added to the Mantis chat proof test, matching the report that both tests capture the working-timer start time at send and then assert after a virtual-time advance. (ui/src/e2e/mantis-chat-proof.e2e.test.ts:99, d4a8882db42b)
  • Feature provenance: The underlying Ask OpenClaw UI work that exposed this test path was merged in the related PR, providing concrete history context for the affected chat-test surface. (ui/src/e2e/mantis-chat-proof.e2e.test.ts:96, 699315e7d75f)
  • Proof supplied in PR body: The author reports focused test passes and a delayed-run experiment that reproduces drift without the pause and passes with it, but no terminal output, recording, log, or linked artifact was included to independently inspect that result. (d4a8882db42b)

Likely related people:

  • steipete: Authored the related merged Ask OpenClaw UI change that introduced the affected test surface and authored this focused follow-up. (role: feature owner and recent area contributor; confidence: high; commits: 699315e7d75f, d4a8882db42b; files: ui/src/e2e/mantis-chat-proof.e2e.test.ts, ui/src/e2e/chat-run-lifecycle.e2e.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted terminal transcript or artifact showing the injected delay drifts without the pause and remains exact with it.
  • Allow the in-progress checks-ui-e2e run to complete on the current PR head.

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.

@steipete
steipete merged commit f8283ef into main Jul 28, 2026
118 of 131 checks passed
@steipete
steipete deleted the steipete/silly-liskov-a6b549 branch July 28, 2026 12:50
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant