fix(cua-driver)(windows): surface get_window_state screenshot error - #1977
Conversation
Follow-up to #1974. The iconic-window bail from `screenshot_window_bytes` correctly fires for minimized targets, but `get_window_state` swallowed the error at impl_.rs:708: Err(_) => None, So the call returned an empty response (no image, no error) and the upstream agent had no signal that the window was minimized — it just saw 'no screenshot' and kept retrying, exactly the loop pattern from the original Hermes bug report. Capture the screenshot error alongside the (optional) image, and on the no-image branch surface it in BOTH: - the human-readable `content` stream as 'screenshot unavailable: <err>' so models with content-only parsing see it next to the UIA tree they did get; - `structuredContent.screenshot_error` for MCP clients that consume the structured side (Hermes' cua_backend.py, downstream wrappers). Now a minimized-window `get_window_state` returns the typed bail ('cannot capture minimized window 0x… : it has no rendered content. Restore the window first via list_windows / raise_window…'), making the issue actionable end-to-end instead of stopping at a silent empty response. Single file change, +25 / -6.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIn ChangesScreenshot error propagation in GetWindowStateTool
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
✨ 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 |
Linux visual regression artifactsMatrix jobs now run independently. Download visual artifacts from this workflow run.
|
Follow-up to #1974 / #1973.
Problem
PR #1974's
IsIconicguard inscreenshot_window_bytes_with_occlusion_unsafecorrectly bails on minimized targets, butget_window_statediscarded the error atimpl_.rs:708:End-to-end behaviour:
get_window_stateresponsecontent:[], no errorraise_window/list_windowsand retriesReproduced live on the Windows VM after PR #1974 shipped as v0.6.3: a minimized Notepad's
get_window_state(capture_mode=vision) returns{"content":[],"structuredContent":{"pid":…, "window_id":…}}— theIsIconicerror is firing insidescreenshot_window_bytesbutget_window_statewas throwing it away.Fix
Capture the screenshot error alongside the (optional) image in the spawn_blocking closure, and on the no-image branch surface it in BOTH:
contentstream (so models with content-only parsing see"screenshot unavailable: cannot capture minimized window 0x…"next to any UIA tree they got);structuredContent.screenshot_error(so MCP clients that consume the structured side —cua_backend.pyand downstream wrappers — can detect and act on it).Single-file change in
crates/platform-windows/src/tools/impl_.rs:+25 / -6.Test plan
cargo check -p cua-driverclean.get_window_state { pid, window_id, capture_mode: "vision" }and confirmstructuredContent.screenshot_errorcontains the iconic-bail message +content[0].textcarries"screenshot unavailable: cannot capture minimized window 0x…".screenshot_errorfield set.Out of scope
Summary by CodeRabbit