Repository navigation
Conversation
On macOS 27 the Dock no longer hosts the Mission Control accessibility tree. While Mission Control is showing, the Dock still exposes its `mc` group, but as an empty stub; the `mc.display` groups are now direct children of the WindowManager application (com.apple.WindowManager). findSpacesSubgroup() therefore never found a display and gotoSpace, removeSpace, addSpaceToScreen and missionControlSpaceNames all failed with "no display with specified id found". getMissionControlGroup() now returns the element that actually holds the `mc.display` groups: the Dock's `mc` group if populated (macOS 26 and earlier), otherwise the WindowManager application element, and nil while the tree is not populated yet, so findSpacesSubgroup's existing poll waits for it instead of failing on the stub. Open/closed detection keeps using the presence of the Dock `mc` group, which still only exists while Mission Control is showing; the WindowManager element is always valid and cannot be used for that. Adds Lua tests for the lookup (Dock layout, WindowManager layout, empty stub, closed). Fixes Hammerspoon#3897
When Mission Control is reopened right after being closed (back to back hs.spaces calls, e.g. addSpaceToScreen() followed by gotoSpace()), the WindowManager on macOS 27 briefly exposes a partially built tree: the Dock's `mc` stub is already back and WindowManager has some `mc.display` groups, but not all of them, or one without its `mc.spaces` group yet. Observed on 27.0.1 with three displays: one `mc.display` (of three) with no spaces bar, about 60ms after the reopen. findSpacesSubgroup() only waited for the Mission Control group itself and then did a single pass, so it failed straight away with "no display with specified id found" or "unable to locate mc.spaces group for display". It now retries the whole lookup within the same 2 second window. The success path is unchanged; lookups that cannot succeed now return their error after that window instead of immediately. The single pass is split out as spacesSubgroupFrom() and exposed to the test suite like _missionControlGroupFrom. The fake AX element used by the tests now returns a copy of its children, as hs.axuielement does, since the lookup consumes that table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
missionControlSpaceNames() turns the Mission Control button descriptions
("exit to Desktop", "exit to full screen Safari") into space names with
templates read from the Dock's localized Accessibility.strings.
On macOS 27 the buttons come from WindowManager, which looks these
strings up with CFBundleCopyLocalizedString(mainBundle, key, default,
"Accessibility"). WindowManager.app has no Accessibility table (as of
27.0.1 its .lproj folders are empty and it only ships Localizable and
InfoPlist loctables), so it always uses the English defaults "exit to %@"
and "exit to full screen %@", while Dock.app still ships the localized
templates. For any non-English user the templates never matched and the
full description was returned as the name.
Try the English defaults after the localized templates, so names that
matched before still match the same way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested this on macOS 27.0.1 (26A434) with three displays; the WindowManager lookup works. Found two gaps (a partial tree right after reopening Mission Control, and WindowManager's space buttons always using English names) and opened a PR against your branch with fixes and tests: SirVer#1 |
hs.spaces: handle partial Mission Control tree and English space names on macOS 27
Author
|
@mit-bach Your changes look good to me; on my system they did not make a differences, but feel generally more defensive, so I merged them in. I think this branch should go in. |
|
I've applied the changes in this PR to my own local install, and it's fixed the issues with OS 27. I look forward to seeing this merged, and I give my thanks to @SirVer! |
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.
I updated to macOS 27 over the weekend and my automatic workspace switching did no longer work. I did a round of AI investigation and put together this fix. It is written by AI, reviewed by me and tested on my machine and works. It is carefully written so older OS versions should be unaffected. It is presented for your consideration for merging, but I am not angry if you do not want to merge this.
Root cause:
On macOS 27 the Dock no longer hosts the Mission Control accessibility tree. While Mission Control is showing, the Dock still exposes its
mcgroup, but as an empty stub; themc.displaygroups are now direct children of the WindowManager application (com.apple.WindowManager). findSpacesSubgroup() therefore never found a display and gotoSpace, removeSpace, addSpaceToScreen and missionControlSpaceNames all failed with "no display with specified id found".getMissionControlGroup() now returns the element that actually holds the
mc.displaygroups: the Dock'smcgroup if populated (macOS 26 and earlier), otherwise the WindowManager application element, and nil while the tree is not populated yet, so findSpacesSubgroup's existing poll waits for it instead of failing on the stub.Open/closed detection keeps using the presence of the Dock
mcgroup, which still only exists while Mission Control is showing; the WindowManager element is always valid and cannot be used for that.Adds Lua tests for the lookup (Dock layout, WindowManager layout, empty stub, closed).
Fixes #3897