Skip to content

test(cua-driver): use canonical capture_mode "ax", drop deprecated "tree" alias - #2054

Merged
f-trycua merged 1 commit into
mainfrom
chore/capture-mode-tree-to-ax
Jun 27, 2026
Merged

test(cua-driver): use canonical capture_mode "ax", drop deprecated "tree" alias#2054
f-trycua merged 1 commit into
mainfrom
chore/capture-mode-tree-to-ax

Conversation

@f-trycua

@f-trycua f-trycua commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

What

Seven get_window_state call sites across the harness/focus tests passed capture_mode: "tree", which is not in the documented enum (som/vision/ax). Its behavior was inconsistent across platforms:

Platform "tree" resolves to
macOS explicitly aliased to "ax" (tree only)
Windows / Linux do_tree = mode != "vision", do_shot = mode != "ax"both tree + screenshot (i.e. som), wasting a capture the tests never read

The tests passed everywhere only because they assert on the tree. Switching to the canonical "ax" makes intent explicit and behavior consistent (tree-only, no wasted screenshot) on all three platforms. On macOS this is a no-op (the alias already resolved to "ax").

Files (7 sites, 5 files)

modality_focus_test, harness_wpf_test (×3), harness_appkit_test, harness_winui3_test, harness_swiftui_test.

Verification (macOS)

  • harness_appkit (5) + harness_swiftui (2) ✅ green; the get_window_state(ax) snapshot renders the full tree unchanged.
  • modality_focus's focus-steal assertion flaked because an unrelated background app grabbed focus on the dev host (com.apple.Terminalcom.superhuman.electron) — not driver behavior, not this change. The ax snapshot itself returned the expected 267-element tree.

Companion to #2053 (modality matrix docs + capture_mode coverage).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated multiple UI harness checks to capture accessibility-based window state snapshots instead of tree-based snapshots.
    • Aligned AppKit, SwiftUI, WinUI3, and WPF test flows with the new snapshot source.
    • Kept focus-related assertions intact while changing the snapshot data used immediately before validation.

…ree" alias

Seven `get_window_state` call sites across the harness/focus tests passed
`capture_mode: "tree"`, which is not in the documented enum (`som`/`vision`/`ax`).
Its behavior was inconsistent across platforms:

  * macOS  — explicitly aliased to "ax" (tree only).
  * Windows/Linux — `do_tree = mode != "vision"`, `do_shot = mode != "ax"`, so
    "tree" produced BOTH a tree AND a screenshot (i.e. `som`), wasting a capture
    the tests never read.

The tests passed everywhere only because they assert on the tree. Switching the
call sites to the canonical `"ax"` makes intent explicit and behavior consistent
(tree-only, no wasted screenshot) on all three platforms. On macOS this is a
no-op (the alias already resolved to "ax").

Verified on macOS: harness_appkit (5) + harness_swiftui (2) green; the
get_window_state(ax) snapshot renders the full tree unchanged. (modality_focus's
focus-steal assertion flaked on an unrelated background app grabbing focus on
the dev host — not driver behavior, not this change.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Jun 26, 2026 11:23pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b991c41e-3044-479a-9fd5-0b7119288d1f

📥 Commits

Reviewing files that changed from the base of the PR and between 8e2de25 and fae40bd.

📒 Files selected for processing (5)
  • libs/cua-driver/rust/crates/cua-driver/tests/harness_appkit_test.rs
  • libs/cua-driver/rust/crates/cua-driver/tests/harness_swiftui_test.rs
  • libs/cua-driver/rust/crates/cua-driver/tests/harness_winui3_test.rs
  • libs/cua-driver/rust/crates/cua-driver/tests/harness_wpf_test.rs
  • libs/cua-driver/rust/crates/cua-driver/tests/modality_focus_test.rs

📝 Walkthrough

Walkthrough

All touched tests now request get_window_state with capture_mode: "ax" instead of "tree" across AppKit, SwiftUI, WinUI3, WPF, and focus tests.

Changes

Test harness snapshot mode

Layer / File(s) Summary
AX capture mode across harness snapshots
libs/cua-driver/rust/crates/cua-driver/tests/harness_appkit_test.rs, libs/cua-driver/rust/crates/cua-driver/tests/harness_swiftui_test.rs, libs/cua-driver/rust/crates/cua-driver/tests/harness_winui3_test.rs, libs/cua-driver/rust/crates/cua-driver/tests/harness_wpf_test.rs, libs/cua-driver/rust/crates/cua-driver/tests/modality_focus_test.rs
get_window_state calls in these tests now pass capture_mode: "ax" instead of "tree", including the shared WPF helper plus the modal MessageBox and owned-popup snapshots.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Possibly related PRs

  • trycua/cua#1756: Both PRs center on get_window_state using AX-based capture instead of tree capture.
  • trycua/cua#1754: This PR updates the test-side snapshot mode while the linked PR changes the macOS AX tree generation behind get_window_state.
  • trycua/cua#2043: Both PRs adjust integration tests around get_window_state’s capture_mode, switching expectations from "tree" to "ax".

Poem

🐇 Hop, hop—AX lights the way,
Tree shapes faded, bright today.
Sniff the markers, clear and neat,
Bunny tests now land on their feet.
Soft ears twitch: “AX, hooray!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: switching test harness capture_mode from deprecated "tree" to canonical "ax".
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/capture-mode-tree-to-ax

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.

@github-actions

Copy link
Copy Markdown
Contributor

Linux visual regression artifacts

Matrix jobs now run independently. Download visual artifacts from this workflow run.
Each background-GUI job uploads a .gif of the interaction plus two annotated PNGs (<app>.png raw, <app>-atspi.png with AT-SPI element boxes); the cua-driver-linux-som-overlays artifact adds <app>-som.png cua Set-of-Marks overlays:

  • cua-driver-linux-cursor-click-gif
  • cua-driver-linux-background-terminal-gif
  • cua-driver-linux-parallel-drag-xserver
  • cua-driver-linux-background-gui-chromium
  • cua-driver-linux-background-gui-tk
  • cua-driver-linux-background-gui-gtk3-gedit
  • cua-driver-linux-background-gui-gtk3-mousepad
  • cua-driver-linux-background-gui-gtk3-scite
  • cua-driver-linux-background-gui-gtk4-characters
  • cua-driver-linux-background-gui-qt5-manuskript
  • cua-driver-linux-background-gui-qt5-klog
  • cua-driver-linux-background-gui-qt5-openambit
  • cua-driver-linux-background-gui-qt6-kate
  • cua-driver-linux-background-gui-qt6-kcalc
  • cua-driver-linux-background-gui-qt6-okular
  • cua-driver-linux-background-gui-qt6-qownnotes
  • cua-driver-linux-background-gui-electron-zettlr
  • cua-driver-linux-background-gui-electron-joplin
  • cua-driver-linux-background-gui-electron-logseq
  • cua-driver-linux-som-overlays

Open workflow run and download artifacts

@f-trycua
f-trycua merged commit a8feefa into main Jun 27, 2026
71 checks passed
@f-trycua
f-trycua deleted the chore/capture-mode-tree-to-ax branch June 27, 2026 00:56
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