Stop the overlay subprocess before switching virtual desktops,
then restart it on the new desktop — avoids the tkinter display
context teardown that kills the overlay during SendInput-based
Ctrl+Win+Left/Right.
- _switch_desktop_via_keybd(): stop overlay → two-phase SendInput
→ restart overlay
- switch_desktop() method on WindowsUIABackend
- Schema and dispatch updated with 'switch_desktop' action and
'direction' parameter
Co-authored-by: lEWFkRAD
Addresses review feedback on the Windows computer_use backend (#43927).
1. A failed click/drag/scroll left modifier keys - and, for drag, the
mouse button - synthetically held down: the release ran after the
action inside the same try block, so an injection error skipped it.
Move the release into a finally so Ctrl/Alt/Shift and the button are
always released and the cursor restored even when an injection raises.
2. capture (_walk_elements) and set_value (_control_at_index) each
reimplemented the same BFS + interactability filter; if the two ever
diverged, set_value would resolve an index to a different control than
the capture advertised. Both now consume one _iter_interactable
generator, so element #N is the same control in both paths.
3. That shared walk uses collections.deque.popleft() instead of the
O(n) list.pop(0).
7 new dependency-free tests (modifier/button release on failure,
capture/set_value index agreement, BFS order, Text-pattern filter); they
pass off-Windows. Full computer_use suites: 137 passed on Windows 11.
Thanks to @Icather for spotting all three and proposing the fixes
(originally raised in #45976).
Suggested-by: ChengLong Han <97326386+Icather@users.noreply.github.com>
Co-authored-by: ChengLong Han <97326386+Icather@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Three failure modes found preparing for real daytime use on a shared
desktop:
1. Vision-node outage broke captures outright. When aux-vision routing
is requested (the main model cannot consume images) and the aux call
fails, the old fallthrough returned the multimodal envelope - putting
a screenshot in front of a text-only model and erroring the capture.
Degrade to the AX/SOM text payload instead (vision_unavailable flag
set): element-index actions keep working blind until vision returns.
2. Stale coordinates after a window move. Element bounds are absolute
screen coords frozen at capture time; dragging the window between
capture and click landed clicks on whatever sat at the old position.
Track the captured window rect and translate element centers by the
origin delta; a resize (interior layout changed) fails with an
explicit re-capture message instead of guessing.
3. Input collisions with an active user. Synthetic input lands in
whatever has focus; injecting mid-keystroke sprays input across both
parties' targets. All input actions now wait for a short user-idle
window (HERMES_COMPUTER_USE_IDLE_WAIT, default 1.5s, 0 disables),
capped at 8s so the agent yields but never deadlocks.
Routing tests updated for the new degradation contract; new tests cover
all three behaviors and run dependency-free off-Windows.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Visible "PC use mode": a persistent banner pill while desktop control
is active, the numbered SOM element boxes mirrored onto the real
screen after each capture, click ripples / drag arrows where actions
land, and short action flashes (typing, key combos, scroll).
overlay.py runs as a subprocess: a fullscreen transparent
click-through topmost tkinter window spanning the virtual desktop,
driven over localhost UDP, excluded from screen capture via
SetWindowDisplayAffinity(WDA_EXCLUDEFROMCAPTURE) so the model's own
screenshots never contain it (verified by pixel-sampling a capture
taken while a box was on screen). The overlay returns foreground
focus after spawning, and the backend never targets the overlay
process as a capture subject. All overlay traffic is fire-and-forget:
any failure disables the overlay without affecting actions. Disable
with HERMES_COMPUTER_USE_OVERLAY=0.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Brings desktop control to Windows hosts: UI Automation element
discovery with SOM overlays, SendInput mouse/keyboard (virtual-
desktop-normalized absolute coords, Unicode typing), and focus-free
set_value via UIA value/selection/range patterns. Backend selection
is platform-aware (HERMES_COMPUTER_USE_BACKEND still overrides) and
check_computer_use_requirements() now gates per platform. Windows
session-killing key combos (win+l, ctrl+alt+del, alt+f4) are
hard-blocked alongside the macOS list.
Unlike cua-driver on macOS there is no background input injection on
Windows: pointer/keyboard actions briefly foreground the target
window, and the platform-aware tool schema tells the model so.
Requires uiautomation (+comtypes) in the venv; windows_backend
degrades to unavailable when imports fail. 118 computer_use tests
pass incl. 21 new dependency-free Windows tests; verified live
against Notepad (capture/SOM/type/set_value/key).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>