Repository navigation
fix: see an already frontmost app when focusing, and say why focus stopped - #61
Merged
Merged
Conversation
…opped Co-Authored-By: Claude <noreply@anthropic.com>
iamnbutler
force-pushed
the
fix/focus-activation
branch
from
October 17, 2026 03:31
210b367 to
6b82423
Compare
This was referenced Oct 17, 2026
Merged
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.
Addresses #23. This is a partial fix; live evidence is pending.
What the error was
"Timeout while waiting for condition" has only one source on the
desktop_focuspath:FocusManagementService.focusWindow's wait for the window's app to become active, before the raise. Both branches of that wait polled only:NSRunningApplication.isActive, on a fresh instance fromNSRunningApplication(processIdentifier:)NSWorkspace.shared.frontmostApplicationBoth are cached by AppKit and refreshed by workspace notifications on the host's main run loop. In the report,
desktop_activatesucceeded and the focus right after it still timed out, with nothing sent.desktop_activate's own verification requiresisActiveandfrontmostApplicationto agree, but on its ownNSRunningApplicationinstance. So the likeliest causes are:Change
New patch
peekaboo-focus-activation.patch, at the end of the stack after element-depth. It is independent of #58 and #57: no shared files.FocusManagementService.isFrontmostacceptsisActive,frontmostApplication, or the system-wideAXFocusedApplication. That last one is read directly from the Accessibility server, with a 50 ms messaging timeout. Two places use it:FocusError.activationNotObserved. For example: "TextEdit (pid 4242) did not become the active app within 3 seconds of the activation request, so its window was not raised. macOS can decline activation requested from the background. Activate the app, then retry; if it still isn't frontmost, ask the user to click the window." Whenactivate()returned false, the message says macOS did not accept the request.desktop_activatefalls back to settingAXFrontmostwhenactivate()doesn't take. Focus could do the same, but that would be a new dispatch inside the focus accounting, so I'd rather see live evidence first. If the live check shows (b), that's the follow-up.Tests
swift test --filter 'FocusActivationObservationTests|FocusDispatchAccountingTests|ForegroundModifierClickAcceptedActivationTests|FocusRaise'in Core/PeekabooAutomationKit: 34/34 pass. It ran in the foreground in its own process group with a 600 s limit, with an uncommitted isolation edit that was reverted. No helper was left behind.npm run checkpasses. The native build applies the full stack from a restored checkout and is green.Live checks (pending: screen locked)
desktop_restoreit, thendesktop_focus→ completed, oractivationNotObservedwith a clear reason. Record which, and whether TextEdit was frontmost beforehand.desktop_activate) → completed.AXFrontmostfallback.🤖 Generated with Claude Code