Skip to content

Fix shared snapshot_ui warning state#185

Merged
cameroncooke merged 1 commit intomainfrom
fix-ui-automation-snapshot-state
Jan 26, 2026
Merged

Fix shared snapshot_ui warning state#185
cameroncooke merged 1 commit intomainfrom
fix-ui-automation-snapshot-state

Conversation

@cameroncooke
Copy link
Collaborator

@cameroncooke cameroncooke commented Jan 26, 2026

Problem

UI automation tools (swipe/tap/long_press/touch) each kept their own in-memory snapshot_ui timestamp, so the warning logic always reported "snapshot_ui has not been called yet" even after a snapshot was taken.

Fix

  • Centralize snapshot_ui timestamp tracking in a shared module.
  • Record snapshot_ui calls once, and read the same state in all coordinate-based tools.
  • Move the shared helper into a subdirectory so the tool generator doesn’t treat it as a tool.

Notes

No behavior change to the UI actions themselves; this only fixes the accuracy of warning guidance.

Testing

  • npm run format:check
  • npm run lint
  • npm run typecheck
  • npm test
  • npm run build

Note

Fixes inaccurate coordinate warnings by unifying snapshot_ui call tracking.

  • New shared module src/mcp/tools/ui-automation/shared/snapshot-ui-state.ts with recordSnapshotUiCall and getSnapshotUiWarning
  • Update tap, swipe, long_press, and touch to use getSnapshotUiWarning instead of per-tool state
  • Update snapshot_ui to call recordSnapshotUiCall after successful describe-ui
  • Remove duplicated, isolated timestamp logic from each tool
  • Document fix in CHANGELOG.md

Written by Cursor Bugbot for commit 68b5fe2. This will update automatically on new commits. Configure here.

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@cameroncooke cameroncooke marked this pull request as ready for review January 26, 2026 10:15
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 26, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cameroncooke/XcodeBuildMCP/xcodebuildmcp@185

commit: 68b5fe2

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

}

return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shared directory naming violates project conventions

Low Severity · Bugbot Rules

The new shared/ directory doesn't follow the project's documented naming convention. According to docs/dev/CODE_QUALITY.md, common code should be shared via -shared directories (e.g., ui-automation-shared). The review rules also specify that docs/TOOLS.md excludes *-shared directories - since shared doesn't match this pattern, it may not be properly excluded by documentation tooling. The directory should be renamed to follow the *-shared convention.

Fix in Cursor Fix in Web

@cameroncooke cameroncooke merged commit 5faa43d into main Jan 26, 2026
7 of 8 checks passed
@cameroncooke cameroncooke deleted the fix-ui-automation-snapshot-state branch January 26, 2026 10:18
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

Walkthrough

This pull request refactors snapshot_ui warning state management by extracting per-simulator timestamp tracking from individual UI automation tool files into a centralised shared module. A new module (snapshot-ui-state.ts) exposes two functions: recordSnapshotUiCall() to track snapshot_ui invocations per simulator ID, and getSnapshotUiWarning() to generate warnings when snapshot_ui has not been called or data is stale (exceeding 60 seconds). The snapshot_ui.ts, long_press.ts, swipe.ts, tap.ts, and touch.ts files are updated to use the shared utilities, removing their duplicate in-file implementations. A changelog entry documents the fix addressing isolated warning state per UI automation tool.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix shared snapshot_ui warning state' clearly and concisely summarizes the main change: centralizing snapshot_ui timestamp tracking to fix warning inaccuracies across UI automation tools.
Description check ✅ Passed The description is directly related to the changeset, providing clear context about the problem (isolated warning state), the fix (centralized shared module), and testing performed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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