Skip to content

chore(cua-driver-rs): delete dead screenshot tool code surfaced by PR #1692 warnings - #1694

Merged
f-trycua merged 1 commit into
mainfrom
cua-driver-rs-cleanup-dead-code
May 25, 2026
Merged

chore(cua-driver-rs): delete dead screenshot tool code surfaced by PR #1692 warnings#1694
f-trycua merged 1 commit into
mainfrom
cua-driver-rs-cleanup-dead-code

Conversation

@f-trycua

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

Copy link
Copy Markdown
Collaborator

Summary

PR #1692 stopped registering the standalone screenshot tool but left the structs / DEF statics / Tool impls in place as a deletion-deferred follow-up. The Windows daemon's release build flagged 5 warnings as a result:

warning: unused import: `background_unavailable_error`
warning: struct `ScreenshotTool` is never constructed
warning: static `SCREENSHOT_DEF` is never used
warning: struct `ScreenshotCompatTool` is never constructed
warning: static `SCREENSHOT_COMPAT_DEF` is never used

This PR is the deletion follow-up:

  • platform-windows/src/tools/impl_.rs: drop dead ScreenshotTool + ScreenshotCompatTool struct/impl/static (~225 lines).
  • platform-linux/src/tools/impl_.rs: same, ~170 lines.
  • platform-macos/src/tools: delete screenshot.rs + screenshot_compat.rs entirely + drop their mod lines.
  • platform-windows/src/tools/impl_.rs ScrollTool: drop the now-unused background_unavailable_error from the import set (replaced by scroll-specific structured error in 9e30d2c).

5 files changed, +23 / −675.

Test plan

  • cargo build --release -p cua-driver — clean, no warnings on Windows
  • cargo check --workspace — clean except for 4 pre-existing platform-linux/overlay.rs warnings (RenderState::tick, apply_command, etc. — present on main too, out of scope)
  • No behavior change: get_window_state capture_mode:"vision" still calls into the same underlying capture::* and wgc::* helpers — only the dead Tool impl wrappers were removed.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Refactor
    • Unified screenshot capture functionality across all platforms to use a consolidated get_window_state approach with capture_mode: "vision" instead of separate platform-specific screenshot tools.

Review Change Stack

…ol after PR #1692 removed their registration

PR #1692 stopped registering the standalone `screenshot` tool on
all three platforms but left the structs + DEF statics + `Tool`
impls in place as a deletion-deferred follow-up. The result was 5
dead-code / unused-import warnings on the Windows daemon build:
  - `unused import: background_unavailable_error` (from ScrollTool's
    old import set — the helper's no longer used after the scroll-
    specific error was added in 9e30d2c)
  - `struct ScreenshotTool` never constructed
  - `static SCREENSHOT_DEF` never used
  - `struct ScreenshotCompatTool` never constructed
  - `static SCREENSHOT_COMPAT_DEF` never used

Cleanup:
- platform-windows/src/tools/impl_.rs: drop the dead struct + impl
  + static for both ScreenshotTool and ScreenshotCompatTool (~225
  lines), replace with a short pointer-comment to PR #1692 and
  GetWindowStateTool as the canonical capture site.
- platform-linux/src/tools/impl_.rs: same shape, ~170 lines gone.
- platform-macos/src/tools: delete screenshot.rs and
  screenshot_compat.rs entirely + drop the `mod` lines in
  tools/mod.rs.
- platform-windows/src/tools/impl_.rs ScrollTool import: drop
  `background_unavailable_error` from the use statement (kept
  `DispatchMode` and `EventKind` — both still used by the
  scroll-specific error path).

The underlying capture functions
(`crate::capture::screenshot_window_bytes*`,
`screenshot_display_bytes`, `wgc::screenshot_window_via_wgc`, and
the macOS/Linux equivalents) stay — GetWindowStateTool calls them
directly. No behavior change.

The 4 remaining platform-linux warnings (RenderState::tick /
apply_command / etc.) are pre-existing and out of scope.

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

vercel Bot commented May 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 May 25, 2026 6:53pm

Request Review

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR removes the standalone screenshot tool implementations across Linux, macOS, and Windows platforms, consolidating screenshot functionality under the get_window_state endpoint. Removed code is replaced with documentation comments explaining the architectural change.

Changes

Screenshot Tool Consolidation

Layer / File(s) Summary
Remove standalone screenshot tools across platforms
libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs, libs/cua-driver/rust/crates/platform-macos/src/tools/mod.rs, libs/cua-driver/rust/crates/platform-macos/src/tools/screenshot.rs, libs/cua-driver/rust/crates/platform-macos/src/tools/screenshot_compat.rs, libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
ScreenshotTool and ScreenshotCompatTool struct implementations are deleted from all platforms. Module declarations and imports are removed. Documentation comments explain that get_window_state with capture_mode: "vision" is now the canonical screenshot interface, with underlying capture machinery still accessible through GetWindowStateTool. Windows ScrollTool imports are cleaned up to remove an unused error helper.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • trycua/cua#1678: Adds the platform ScreenshotTool/ScreenshotCompatTool implementations that this PR removes.
  • trycua/cua#1663: Modifies ScreenshotTool parameters and defaults that are being fully removed by this PR.

Poem

🐰 A screenshot's tale told true,
Once many tools, now consolidated through,
One vision path replaces them all,
The window speaks, and tools heed the call.

🚥 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: removal of dead screenshot tool code resulting from PR #1692, with specifics about the scope (chore/cleanup).
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.

✏️ 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 cua-driver-rs-cleanup-dead-code

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs`:
- Around line 2831-2838: The file now states that ScreenshotTool and
ScreenshotCompatTool were removed and that get_window_state with
capture_mode:"vision" plus the capture backends
(crate::capture::screenshot_window_bytes_with_occlusion,
screenshot_display_bytes, crate::wgc::screenshot_window_via_wgc) and
GetWindowStateTool are the canonical paths; locate the older registry note block
that still mentions keeping ScreenshotTool/ScreenshotCompatTool in this file for
a follow-up and either remove or rewrite that block to match the new state
(i.e., say the two structs were removed and point readers to get_window_state
and GetWindowStateTool and the listed capture functions) so the file no longer
describes two different states.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55bf565a-074e-4057-b730-965d64e1bc01

📥 Commits

Reviewing files that changed from the base of the PR and between 892edd4 and a94d2e4.

📒 Files selected for processing (5)
  • libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
  • libs/cua-driver/rust/crates/platform-macos/src/tools/mod.rs
  • libs/cua-driver/rust/crates/platform-macos/src/tools/screenshot.rs
  • libs/cua-driver/rust/crates/platform-macos/src/tools/screenshot_compat.rs
  • libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
💤 Files with no reviewable changes (2)
  • libs/cua-driver/rust/crates/platform-macos/src/tools/screenshot_compat.rs
  • libs/cua-driver/rust/crates/platform-macos/src/tools/screenshot.rs

Comment on lines +2831 to +2838
// `ScreenshotTool` and `ScreenshotCompatTool` were removed in PR #1692 —
// `get_window_state` with `capture_mode:"vision"` is the single canonical
// screenshot path. The underlying capture functions
// (`crate::capture::screenshot_window_bytes_with_occlusion`,
// `screenshot_display_bytes`, etc.) and the WGC backend
// (`crate::wgc::screenshot_window_via_wgc`) are still in use by
// `GetWindowStateTool` — that's where the actual screenshot machinery
// lives now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update the later registry note to match this deletion.

This new comment says both screenshot tool structs are gone, but Lines 4908-4912 still say they're kept in this file for a follow-up. Please clean up that older block too so the file doesn't describe two different states.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs` around lines
2831 - 2838, The file now states that ScreenshotTool and ScreenshotCompatTool
were removed and that get_window_state with capture_mode:"vision" plus the
capture backends (crate::capture::screenshot_window_bytes_with_occlusion,
screenshot_display_bytes, crate::wgc::screenshot_window_via_wgc) and
GetWindowStateTool are the canonical paths; locate the older registry note block
that still mentions keeping ScreenshotTool/ScreenshotCompatTool in this file for
a follow-up and either remove or rewrite that block to match the new state
(i.e., say the two structs were removed and point readers to get_window_state
and GetWindowStateTool and the listed capture functions) so the file no longer
describes two different states.

@f-trycua
f-trycua merged commit c4c8471 into main May 25, 2026
6 of 7 checks passed
@f-trycua
f-trycua deleted the cua-driver-rs-cleanup-dead-code branch May 25, 2026 19:30
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