Skip to content

Fix #292: poll preview_elements for render-readiness instead of a fixed sleep - #295

Merged
obj-p merged 1 commit into
mainfrom
fix-292-elements-poll
Jun 26, 2026
Merged

Fix #292: poll preview_elements for render-readiness instead of a fixed sleep#295
obj-p merged 1 commit into
mainfrom
fix-292-elements-poll

Conversation

@obj-p

@obj-p obj-p commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

IOSMCPTests.fullIOSWorkflow flaked: it queried preview_elements after a fixed Task.sleep(3), which raced the agent's accessibility render. The lightweight PreviewBanner registers in the a11y tree before the wrapped ToDoView content, so under load the tree was banner-only and the My Items/item assertions failed (#292).

Changes

  • Add MCPTestServer.awaitElementsText(sessionID:contains:timeout:), a poll helper that mirrors the existing awaitStderrContains/awaitSnapshotChange pattern (ContinuousClock deadline, Issue.record + throw on timeout). It retries preview_elements until the content appears.
  • It fails fast via a new MCPTestError.toolError when the tool genuinely errors, instead of polling a real failure into an opaque 30s timeout.
  • Replace the fixed sleep + single elements call in fullIOSWorkflow with the helper; drop the now-redundant elementsError/!isEmpty/duplicate My Items asserts.
  • The snapshot step needs no settling sleep: iOS preview capture reads a stale frame before the new render (sim-health flake; hits IOSPreviewE2ETests + IOSMCPTests) #269 made preview_start gate on the first frame.

Verification

  • IOSMCPTests green across 4 clean isolated runs (~22-26s each).
  • Full local suite bazel test //previewsmcp/... (serialized test jobs): 9/9 targets pass; the affected MCPIntegrationTests target passed fresh in 75s.
  • Gates: /simplify + /code-review (high) run; confirmed findings fixed.

Closes #292.

🤖 Generated with Claude Code

…ed sleep

The fullIOSWorkflow test queried preview_elements after a fixed 3s sleep, which
raced the agent's accessibility render. The lightweight PreviewBanner registers
in the a11y tree before the wrapped ToDoView content, so under load the tree was
banner-only and the "My Items"/items assertions flaked.

Replace the fixed sleep with awaitElementsText, a MCPTestServer poll helper that
mirrors awaitStderrContains/awaitSnapshotChange (ContinuousClock deadline,
Issue.record + throw on timeout) and retries preview_elements until the content
appears. It fails fast via a new MCPTestError.toolError when the tool genuinely
errors, rather than polling a real failure into an opaque timeout. The snapshot
step needs no sleep: #269 made preview_start gate on the first frame.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018StzgGyDWR45JsR94FUBmy
@obj-p
obj-p merged commit 93124e4 into main Jun 26, 2026
@obj-p
obj-p deleted the fix-292-elements-poll branch June 26, 2026 00:20
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.

Flaky: IOSMCPTests.fullIOSWorkflow preview_elements races the agent a11y render (banner-only tree)

1 participant