Skip to content

fix(cua-driver): Linux list_windows emits bounds for cross-platform parity (#2017)#2018

Merged
f-trycua merged 1 commit into
mainfrom
fix/linux-list-windows-bounds-parity
Jun 25, 2026
Merged

fix(cua-driver): Linux list_windows emits bounds for cross-platform parity (#2017)#2018
f-trycua merged 1 commit into
mainfrom
fix/linux-list-windows-bounds-parity

Conversation

@f-trycua

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

Copy link
Copy Markdown
Collaborator

cat <<'EOF'
Fixes #2017.

What

list_windows returned window geometry under a nested bounds: {x,y,width,height} object on macOS and Windows, but as flat top-level x/y/width/height on Linux (and omitted app_name / is_on_screen). Any cross-platform consumer reading window.bounds.width worked on macOS/Windows and silently broke on Linux. This surfaced while wiring a Gemini computers/desktop backend, which had to add a _window_dims() shim purely to tolerate the two shapes.

How

In crates/platform-linux/src/tools/impl_.rs, each list_windows record now emits:

  • bounds: { x, y, width, height } — the canonical cross-platform field, matching macOS/Windows
  • app_name and is_on_screen — companion fields the other backends already emit
  • the historical flat x/y/width/height fields, kept inline as a legacy alias so existing Linux callers don't break (mirrors the additive pattern Windows uses)

The per-record JSON is extracted into a window_record_json helper, with a no-display unit test asserting both the nested bounds and the flat legacy fields are present.

Defaults

app_name is "" and is_on_screen is true. The Linux WindowInfo struct (crate::x11::WindowInfo) exposes only xid, pid, title, x, y, width, height — no app-name or visibility field — so these are best-effort defaults matching the Windows backend. No new lookup was invented.

Schema

Purely additive — no field removed — so schema_version is not bumped.

Testing

  • Added list_windows_tests::record_has_bounds_and_flat_legacy_fields (synthetic WindowInfo, no display required).
  • ⚠️ Could not run cargo check -p platform-linux on the macOS dev host: the x11 crate's build script fails cross-compiling to x86_64-unknown-linux-gnu ("pkg-config has not been configured to support cross-compilation"). Manual review confirms the Rust is sound (imports, field accesses, json! macro, balanced braces). Needs CI / a Linux box to confirm the build + run the test.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KMXCW4M5uK1HRGjjH4wueZ
EOF

Summary by CodeRabbit

  • New Features

    • Window listings on Linux now include a standardized bounds object for each window, making window geometry consistent across platforms.
    • Each window record now also includes app_name and is_on_screen fields.
  • Bug Fixes

    • Kept the older flat x, y, width, and height fields in place for compatibility with existing Linux integrations.

… parity (#2017)

Linux list_windows returned flat x/y/width/height while macOS and Windows
nest geometry under `bounds: {x,y,width,height}`. Emit `bounds` (plus
app_name / is_on_screen) to match, keeping the flat fields as a legacy
alias so existing Linux callers keep working. Additive — no schema_version bump.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMXCW4M5uK1HRGjjH4wueZ
@vercel

vercel Bot commented Jun 25, 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 25, 2026 12:36am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 25, 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: 9067d026-4e30-4918-bcdc-99b9177e263e

📥 Commits

Reviewing files that changed from the base of the PR and between 3a4b11e and fd2d253.

📒 Files selected for processing (1)
  • libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs

📝 Walkthrough

Walkthrough

Linux list_windows now emits structured window records with nested bounds, plus app_name and is_on_screen, while keeping legacy flat x/y/width/height fields. A unit test checks the record shape and default values.

Changes

Linux window record shape

Layer / File(s) Summary
Structured window record shape and validation
libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
list_windows now builds each window record through window_record_json, which adds nested bounds, app_name, is_on_screen, and legacy flat geometry aliases; the unit test asserts the emitted fields and defaults.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hopped through windows, one by one,
With bounds tucked in, the shape is done.
Flat fields still wink, a legacy trail,
app_name and is_on_screen join the tale.
🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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 Linux list_windows bounds parity fix and matches the main change.
Linked Issues check ✅ Passed The PR adds nested bounds, app_name, and is_on_screen, keeps legacy flat fields, and adds a shape test, satisfying #2017.
Out of Scope Changes check ✅ Passed The changes stay focused on Linux list_windows parity and its test, with no unrelated scope introduced.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ 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 fix/linux-list-windows-bounds-parity

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 9e84c1d into main Jun 25, 2026
71 checks passed
@f-trycua f-trycua deleted the fix/linux-list-windows-bounds-parity branch June 25, 2026 00:51
f-trycua added a commit to trycua/computer-use-preview that referenced this pull request Jun 25, 2026
… on all platforms

trycua/cua#2018 normalized Linux list_windows to nest geometry under
`bounds: {x,y,width,height}`, matching macOS/Windows. The tolerate-both-shapes
helper is no longer needed; read window dims directly from `bounds`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMXCW4M5uK1HRGjjH4wueZ
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.

cua-driver: Linux list_windows emits flat x/y/width/height instead of bounds: {...} — breaks cross-platform parity

1 participant