fix(tools): keep switch_desktop from resurrecting a disabled overlay - #46678
Closed
lEWFkRAD wants to merge 1 commit into
Closed
Conversation
_switch_desktop_via_keybd force-cleared overlay_client._dead before start() on every virtual-desktop switch, so an overlay the user had turned off (computer_use.overlay: false / HERMES_COMPUTER_USE_OVERLAY=0, or one that had already failed itself off) was respawned on screen on each switch, overriding the kill switch. Capture liveness before stop() clears _proc and only restart an overlay that was actually running; drop the _dead force-clear. start() already no-ops while _dead is set, so the guard is the single source of truth for whether the overlay comes back. Re-adds the dedicated switch_desktop overlay-safety tests, including the disabled-stays-down regression that fails on the force-clear path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Makes sense — closing this in step with #46667 now that Windows desktop-control is consolidating on the trycua cua-driver-rs path (#44221). The semantic this fix protects (don't resurrect a user-disabled overlay on a desktop switch) and its regression test sit above the driver layer, so they're exactly the "safety semantics above the driver layer" you mentioned carrying over — worth keeping if the trycua path grows an equivalent overlay/escape-hatch. Happy to rebase the test onto #44221 whenever that's useful. Thanks again for the credit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a kill-switch regression in the
switch_desktopaction on thesalvage/windows-uia-computer-usebranch behind #46667._switch_desktop_via_keybdforce-clearedoverlay_client._deadand calledstart()unconditionally on every virtual-desktop switch:So an overlay the user had deliberately turned off —
computer_use.overlay: false,or the
HERMES_COMPUTER_USE_OVERLAY=0escape hatch (both set_dead=Truewith nosubprocess) — was respawned on screen on every desktop switch, overriding the
off switch. An overlay that had already failed itself off was likewise force-retried
on each switch.
This restores the guard from
ea294afb5(dropped in the salvage): capture livenessbefore
stop()clears_proc, and only restart an overlay that was actuallyrunning. The
_deadforce-clear is removed —_OverlayClient.start()alreadyno-ops
if self._dead or self._proc is not None, so theoverlay_was_liveguard isthe single source of truth for whether the overlay comes back.
Verified in code:
start()intools/computer_use/windows_backend.pyreturnsearly while
_deadis set, so clearing_deadimmediately beforestart()isexactly what defeats the kill switch.
Related Issue
Stacked on #46667 — targets the
salvage/windows-uia-computer-usebranch so the fixlands with the salvage rather than after it. Restores behavior introduced in the
original #43927 (
ea294afb5). (NoFixes #keyword on purpose — this shouldn'tauto-close #46667.)
Type of Change
Changes Made
tools/computer_use/windows_backend.py—_switch_desktop_via_keybd: computeoverlay_was_live = overlay_client._proc is not None and not overlay_client._deadbefore
stop(); gate both the success-path and the except-path overlay restart onit; remove the two
overlay_client._dead = Falseforce-clears. Docstring updated tostate a deliberately-disabled overlay is never resurrected by a switch.
tests/tools/test_computer_use_windows.py— re-add theTestSwitchDesktopOverlaySafetysuite (with a_FakeOverlaymirroring the realstart/stop/_proc/_deadsemantics):test_live_overlay_is_restarted_after_switch,test_disabled_overlay_is_not_resurrected(the regression guard), andtest_invalid_direction_is_rejected_without_side_effects.How to Test
Before → after, against the branch's own backend code:
test_disabled_overlay_is_not_resurrectedon the unpatched branch → FAILS:AssertionError: assert 'start' not in ['stop', 'start']— the disabled overlay wasrevived on the switch.
_FakeOverlay(dead=True, proc=None)is never started,_deadstaysTrue, and the desktop still switches.scripts/run_tests.sh's subprocess-per-fileisolation), venv python on Windows 11:
Checklist
Code
fix(tools): ...)Documentation & Housekeeping
_switch_desktop_via_keybddocstring; README/docs/— N/A (no user-facing surface change)cli-config.yaml.example— N/A (no config keys added/changed)CONTRIBUTING.md/AGENTS.md— N/A (no architecture/workflow change)windows_backend.py, gated towin32); no behavior change on macOS/Linuxswitch_desktoptool surface and schema unchanged)Screenshots / Logs
Regression reproduced, then fixed (same
_FakeOverlay, run against each version of the backend):Windows-footgun scan + ruff on the diff: clean.