fix(web): a check whose control the click replaces passes and replays

Merged
OK
2mo ago
+275-17

What and why

Fixes ENG-814. A user reported check failing with LOCATOR_NOT_FOUND on a radio the app replaces with its selected view after the pick. The page did show the selection, but the action was left out of the recording, so the next run replayed only the earlier actions and handed off with end-mismatch.

  • Cause: Playwright's check() clicks, then reads the element again to confirm it. If the click removed the element, that read throws Element is not attached to the DOM. classifyActionError turned this into NODE_STALE (retryable, "nothing dispatched"), even though the click had already landed. The agent then tried to find the radio again, found nothing, and threw LOCATOR_NOT_FOUND. A locator check() re-resolved inside Playwright until it timed out.
  • check and uncheck now run on a single element (packages/web/src/actions.ts, setChecked):
    1. read the state; if it's already right, do nothing
    2. refuse to uncheck a radio, before any click
    3. click
    4. read the state again. A control that's gone by now (detached, or its document navigated away) took the click, so the action is done. A state that didn't change fails with NOT_ACTIONABLE.
  • A control that's gone before the click is still a retryable NODE_STALE.
  • Unchecking a checked radio and a click that changes nothing were ENGINE_FAILURE; both are now NOT_ACTIONABLE.
  • Limitation, by choice: whatever replaced the control is not read. If the app renders an unchecked copy in its place (e.g. a server rejected the change), check() still passes, the same as a tap. The next observation or assertion shows the real state. Documented in docs/migrate/playwright.mdx and the changeset, and pinned by a test.
  • Web benchmark Control Inventory has a new Delivery exercise: picking a radio replaces it with "Express delivery selected". It has a deterministic test and an agent test. The core gestures fixture page has the same radio, with a scripted-model flow that records the step and then replays it.
flowchart LR
  A[read checked] -->|already set| Z[done]
  A --> B[click]
  B --> C{read again}
  C -->|wanted state| Z
  C -->|element gone| Z
  C -->|unchanged| X[NOT_ACTIONABLE]

Verified

Ran it locally: yes

  • packages/web/tests/integration/check-actions.test.ts: real Chromium, both target kinds (locator, and an element pinned by an observation)
  • web benchmark: e2e run tests/control-inventory.e2e.ts against a main build in a separate worktree and against this branch
  • packages/e2e/tests/integration/agent-act-verbs.test.ts: scripted model, check on the replaced radio, then a replay from cache
mainthis branch
check-actions.test.ts8 of 15 fail17 pass
benchmark: getByRole('radio', 'Express').check()ACTION_FAILED: check timed out after its input was dispatched after 30spasses in 182ms
agent check on the replaced radiocheck:failed, and the replay needs 2 model callscheck:passed, and the replay makes 0 model calls
main:
 × control inventory > check picks a radio the pick replaces with its summary 30.15s
   → check timed out after its input was dispatched: locator.check: Timeout 2…
branch:
 ✓ control inventory > check picks a radio the pick replaces with its summary 182ms

The 6 existing Control Inventory agent recordings still replay with --strict-cache on the changed page.

The new agent step check picks a radio the pick replaces with its summary ran against the live model in this PR's web agent job and passed. Its recording is not committed yet: this machine has no model access. Until it is recorded with test:agent and committed, the web agent job calls the model for that one step.