Fix/remove ordinal position seeding#98
Closed
Dylan0203 wants to merge 2 commits intosane-apps:mainfrom
Closed
Conversation
macOS interprets seeded values (0, 1) as literal pixel X coordinates, placing the main icon at the far left of the menu bar. When HidingService expands the separator, the misplaced main icon gets pushed off-screen. Without pre-seeding, macOS auto-places new NSStatusItems near Control Center, which is the correct default behavior.
Cleans up dead code from c764cc5. Removes seedPositionsIfNeeded(), forceMainAndSeparatorAnchorSeed(), shouldForceAnchorNearControlCenterOnLaunch(), and shouldSeedPreferredPosition(). Updates corruption recovery tests to expect cleared positions (nil) instead of seeded ordinals (0, 1).
Author
|
Hi Mr. Sane, Looks like you've already addressed this from a different angle in 53f49d6 with enforceNonRemovableBehavior — preventing cmd-drag removal from persisting visibility overrides. I just tested the latest main and the icon shows up My PR was tackling what I believed to be the root cause (ordinal pre-seeding values being interpreted as pixel coordinates), but since your fix resolves the issue on my end, I'm closing this. For what it's worth, here's what I found during debugging in case it's useful for future reference:
Happy to help dig into anything else if needed. Thanks again for the thoughtful project. Dylan |
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.
Summary
Remove ordinal position pre-seeding that causes status bar icons to be placed at the far left of the menu bar instead of near Control Center.
Changes
seedPositionsIfNeeded()calls frominit(),recreateItemsWithBumpedVersion(), andrecoverStartupPositions()seedPositionsIfNeeded(),forceMainAndSeparatorAnchorSeed(),shouldForceAnchorNearControlCenterOnLaunch(),shouldSeedPreferredPosition()Related Issues
Follows up on the self-healing autosave fix adopted in v2.1.16.
Root Cause
The pre-seeding writes
main=0, separator=1toNSStatusItem Preferred Positionkeys before creating items, assuming macOS interprets these as ordinal hints (0 = rightmost). In practice, macOS treats them as literal pixel Xcoordinates — placing the main icon at X ≈ 0 (far left). When
HidingServiceexpands the separator to ~5000px, the misplaced main icon gets pushed off-screen.The version bump mechanism doesn't help because it re-seeds the same (0, 1) values each time — creating an infinite loop.
Before (all autosave versions):
Main icon: X = -1, separator width = 5002 ← icon pushed off-screen
After (macOS auto-places without seeding):
Main icon: X = 3483, Separator: X = 3461 ← correct, near Control Center
Without pre-seeding, macOS auto-places new
NSStatusItems near Control Center correctly.A Note
Sorry that my previous PR's approach (bumping
baseAutosaveVersionto 8) didn't fully solve the problem — it escaped the corrupted cache initially but the re-seeding brought the issue back. I'm not an expert on macOS internals; I justdug into the UserDefaults/ByHost state and Accessibility API output to trace the actual icon positions, then worked with Claude to get the tests passing and verify the fix on my machine. Hopefully this is closer to the real root cause
this time.
Testing
./scripts/SaneMaster.rb verify(build + tests pass)Screenshots (if UI changes)
N/A — menu bar icon returns to its expected position near Control Center.
Checklist
Sane Philosophy Check
"Not fear, but power, love, and sound mind" — 2 Timothy 1:7