Skip to content

Improve native wait stability diagnostics#749

Merged
shaun0927 merged 2 commits into
developfrom
feat/745-wait-diagnostics
May 13, 2026
Merged

Improve native wait stability diagnostics#749
shaun0927 merged 2 commits into
developfrom
feat/745-wait-diagnostics

Conversation

@shaun0927
Copy link
Copy Markdown
Owner

Summary

  • Adds optional stable_ms and sample_limit inputs to app_wait_for.
  • Adds bounded timeout diagnostics (matching_count, last_matches, stability fields).
  • Adds pure helper tests without changing existing wait defaults.

Closes #745.

Direction/scope review

  • Aligned with WebdriverIO/Playwright auto-wait lessons while keeping OpenSafari's AX-native model.
  • Low risk: defaults remain compatible; diagnostics are bounded.
  • No locator rewrite or action retry engine.

Verification

  • npm test -- --runTestsByPath tests/unit/app-wait-for.test.ts tests/unit/app-wait-for-diagnostics.test.ts
  • npm run lint -- --quiet src/tools/app-wait-for.ts tests/unit/app-wait-for.test.ts tests/unit/app-wait-for-diagnostics.test.ts

Live validation after merge

  • Wait for a visible simulator app element with stable_ms=500 and confirm success includes stability fields.
  • Wait for a missing label and confirm timeout includes bounded last_matches and context metadata.

Constraint: Preserve existing app_wait_for defaults and add only optional diagnostics.
Rejected: Introduce a new locator or action retry engine | broader behavior change than the wait-diagnostics issue needs.
Confidence: high
Scope-risk: narrow
Directive: Keep timeout samples bounded so AX dumps do not become noisy or leak-heavy artifacts.
Tested: npm test -- --runTestsByPath tests/unit/app-wait-for.test.ts; npm run lint -- --quiet src/tools/app-wait-for.ts tests/unit/app-wait-for.test.ts
Not-tested: Live simulator wait timeout evidence.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

} catch {
// Query error during polling — continue to next attempt

P1 Badge Reset stability window after polling errors

When stable_ms is set, a transient bridge.query failure should break the “continuous hold” window, but this catch block just continues and preserves firstMetAtMs from earlier successful polls. In scenarios with intermittent query errors, the next successful poll can incorrectly count the errored interval toward stable_for_ms and return status: "found" even though the condition was not continuously observed, which violates the new stability guarantee and can produce false positives.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Constraint: stable_ms must mean continuously observed condition satisfaction.
Rejected: Count bridge query errors as neutral time | that can produce false positive stable waits after transient AX failures.
Confidence: high
Scope-risk: narrow
Directive: Any future wait retry layer must preserve this reset-on-unobserved-poll contract.
Tested: npm test -- --runTestsByPath tests/unit/app-wait-for.test.ts tests/unit/app-wait-for-diagnostics.test.ts; npm run lint -- --quiet src/tools/app-wait-for.ts tests/unit/app-wait-for.test.ts tests/unit/app-wait-for-diagnostics.test.ts; npm run build
Not-tested: Live simulator intermittent AX query failure.
@shaun0927
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea43c33b5e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/tools/app-wait-for.ts
Comment on lines +116 to +119
sample_limit: {
type: 'number',
description: 'Maximum matching AX nodes to include in timeout diagnostics (default: 5, max: 20).',
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return sampled matches when wait times out

The new sample_limit option is wired into polling, but on the timeout path the response still only returns { error, condition, query, timeout, elapsed, polls }, so callers never receive last_matches/stability diagnostics for the failure case this feature targets. In practice, timed-out waits get no extra debugging signal and sample_limit becomes effectively a no-op unless the condition succeeds; please include the tracked lastEvaluation/stability fields in the timeout payload.

Useful? React with 👍 / 👎.

@shaun0927 shaun0927 merged commit 4464b6e into develop May 13, 2026
4 checks passed
@shaun0927 shaun0927 deleted the feat/745-wait-diagnostics branch May 13, 2026 16:39
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.

1 participant