feat(cua-driver-rs): screenshot defaults — jpeg @ 85 + max_image_dimension 1568 - #1663
Conversation
All 3 platforms now return JPEG by default instead of PNG when callers omit `format`. Quality also drops from 95 → 85 (already Linux's default and the macOS Claude-Code-compat tool's default). For UI screenshots (lots of solid colors + text) the size impact is small or even neutral — PNG's deflate compresses flat regions very well. The big wins materialize for photographic content (web pages, docs with images) and at lower quality settings agents typically request. The CLI's `screenshot_png_b64` key name stays as-is — it's a cross-implementation contract with Swift (AppState.swift:97, GetWindowStateTool.swift, both SKILL.md files, all integration tests). The `screenshot_mime_type` companion key reports the actual MIME. test_cursor_visibility.py now passes `format=png` explicitly so the per-pixel cursor-colour decode keeps working. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
DriverConfig::default().max_image_dimension was 0 (no cap) on all 3 Rust platforms, while Swift's CuaDriverConfig.defaultMaxImageDimension is 1568. That divergence is why Windows-VM screenshots came back at ~10MB — full-resolution PNGs of a 1512x949 desktop. After this change, screenshots are downscaled (long edge) to 1568px before encoding, matching Swift. Combined with the prior jpeg-default commit, the size impact on a 3840x2160 macOS screenshot is: before tonight: 4,866,498 bytes (full-res PNG) jpeg default: 825,429 bytes (5.9×) + cap 1568: 167,895 bytes (29×) Users with a persisted config.json that explicitly sets `max_image_dimension` (even to 0 for "no cap") keep their value — the config loader at tools/mod.rs:150 only falls back to the default when the field is absent. Fresh installs get the new 1568 default. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Updates the `screenshot` tool entry to: - Replace the "Default JPEG quality 95 (matches Swift)" Fixed item (the prior parity work) with new wording acknowledging the move back to 85 as intentional divergence. - Add a Fixed item for `max_image_dimension` default 0 → 1568, which IS now Swift-parity. - Add two new "Intentional Rust-only" items: default `format=jpeg` (Swift still `png`) and default `quality=85` (Swift `95`). No code change in this commit; the source changes are in the two prior commits on this branch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR unifies screenshot tool defaults across all platforms (Linux, macOS, Windows) by setting JPEG as the default format with quality 85, capping image dimensions to 1568 pixels, and updating documentation and tests accordingly. ChangesScreenshot Default Format and Dimension Updates
🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Summary
Two behavior changes to the `screenshot` tool on all 3 Rust platforms, motivated by the Windows VM dogfood overnight finding that screenshots were coming back at ~10.5 MB:
Measured impact (macOS, 3840×2160 → 1568×882)
Same query on Windows VM: ~10.5 MB → 85 KB (125× reduction).
Files
Compat
The CLI's `screenshot_png_b64` structuredContent key keeps its name — it's a cross-implementation contract (Swift `AppState.swift:97`, get_window_state, both SKILL.md files, all integration tests). The companion `screenshot_mime_type` field reports the actual MIME (`image/jpeg` for the new default).
Users with a persisted `~/Library/Application Support/cua-driver/config.json` that explicitly sets `max_image_dimension` (even to 0 for "no cap") keep their value — the config loader only falls back to the default when the field is absent. Fresh installs get 1568.
Docs
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests