Repository navigation
Conversation
… unlisted windows When the app the agent worked in restarted under a new pid (live 2026-11-19: ClippyAI reinstalled mid-run), every input was refused as FOREGROUND_CHANGED for good, and `window focus` by the new pid failed because its always-on-top window is not among UIA's desktop Window children. - control.ts: the foreground guard accepts a window of the same app when the process it was bound to no longer runs. Another app, or a second copy while the first still runs, is still refused. A reused pid counts as running (fails closed). - ps-bridge.ps1: focus-window by pid alone falls back to the pid's top-level window from the Win32 z-order (Get-PidWindowCandidates / Select-ScopeWindowHandle). A pid with a title still matches by title only. - Tests: three guard cases (restart accepted, second live copy refused, other app refused) and two focus-window system cases. Both new positive cases fail without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
Seen on Windows 11 (2026-11-19) while driving ClippyAI, an always-on-top Electron window:
computerclick and key was then refused, includingspace:"screen"clicks:foreground changed: you were working in "ClippyAI" (pid X), but "ClippyAI" (pid Y) is in front now.window focuswithprocessIdY returnedWindow not found: title='' pid=Y, because the window is not among UIA's desktop Window children. The agent stayed stuck until the test driver sent raw mouse clicks itself.Fix
src/core/control.ts: the foreground guard accepts a window of the same app (same process name, or for a Store app the same app it hosts) when the process it was bound to no longer runs. Another app, or a second copy of the app while the first still runs, is still refused. A pid that Windows reused for another process counts as running, so the guard stays shut in that case.scripts/ps-bridge.ps1:focus-windowby pid alone falls back to the pid's own top-level window from the Win32 z-order. It reuses the existingGet-PidWindowCandidates/Select-ScopeWindowHandle, which prefer a normal window over a topmost or tool one, through a new seam,Get-PidWindowElement. A pid with a title still matches by title only, with no fallback.Not changed: whether the app counts as an AI assistant. A restarted AI-assistant app is still refused until the agent focuses it again, and that now works.
Tests
control-stop.test.tshas three new cases:windows-focus-window.system.test.tsruns the realCmd-FocusWindowagainst fake windows, in two new cases:npm run test:ci: 316 files passed (6 skipped); 4302 tests passed (80 skipped).No release: this goes out with the next train.
🤖 Generated with Claude Code