fix(dock): clear stale CurrentHost shadow so Dock reads AnyHost value#4
Merged
fix(dock): clear stale CurrentHost shadow so Dock reads AnyHost value#4
Conversation
defaults(1) and System Settings store com.apple.dock values in the AnyHost domain, but Dock at runtime reads the CurrentHost (ByHost) domain first when a value exists there. On machines with ByHost residue (stale values from OS migrations or Host UUID changes), writing only AnyHost is not enough: Dock keeps using the shadow and ignores the declared configuration. - Align macos_dock read/write with AnyHost (matches the apps-write path that was already using AnyHost via CFPreferencesSetAppValue). - On every write, also clear the same CurrentHost key (CFPreferencesSetValue(..., null, ..., CurrentHost)) and synchronize both domains; propagate the CurrentHost sync failure instead of swallowing it so cleanup failures aren't reported as success. - Add currentHostHasShadow(key) and OR it into needs_change for all five managed scalars (tilesize, orientation, autohide, magnification, largesize). Machines where AnyHost already matches the target but CurrentHost still shadows now trigger the write path to self-heal. - Fix use-after-free when logging current_*_value: lift defer val.deinit() from the inner blk scope to the outer if scope so the value stays valid during logger.debug (previously crashed with largesize stored as a string in the plist). Fixes #3
Add diagnostics to the hola dock exporter so users notice ByHost residue that macos_dock will self-heal on the next provision, even when they only run the read-only exporter. - Refactor into readDockPrefFromHost / scalarValuesEqual / fmtScalarValue / defaultsTypeFlag helpers so both AnyHost and CurrentHost can be read for comparison. - Warn to stderr when AnyHost and CurrentHost disagree (CurrentHost stale, AnyHost authoritative) and hint the defaults -currentHost delete command. - When AnyHost is unset but CurrentHost still holds a value, fall back to CurrentHost for compatibility and hint a defaults write migration so legacy ByHost-only installs still export the live config instead of the hardcoded defaults. - Route the final DSL to stdout via std.fs.File.stdout so the stderr warnings no longer pollute or shadow the exported text when the user redirects command output.
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
autohide/magnification/etc. declared viamacos_docknow actually take effect on machines that still carry ByHost (CurrentHost) residue. Dock reads the CurrentHost domain first at runtime, so writing AnyHost alone was not enough — the live Dock process kept using the stale shadow.largesizeis stored as a string.hola dockexporter so users notice residue even from the read-only command, without polluting the exported DSL (warnings go to stderr, DSL goes to stdout).Commits
fix(dock): clear stale CurrentHost shadow so Dock reads AnyHost value— the actual behavioral fix (shadow cleanup on write,currentHostHasShadowinneeds_change, CurrentHost sync error propagation, UAF fix). Fixes Autohide dock isn't working #3.feat(dock): warn on stale CurrentHost preference residue—hola docknow reads both domains for comparison, warns on mismatch, falls back to CurrentHost when AnyHost is unset for legacy installs, and routes the final DSL to stdout.Test plan
zig build/zig build testdefaults write com.apple.dock autohide -bool false && defaults -currentHost write com.apple.dock autohide -bool false(both already match targetautohide false) →hola provisiontriggersshadow=true, needs_change=true, cleanup runs,defaults -currentHost read com.apple.dock autohidereports "does not exist".autohide true.hola dock > out 2> errproduces a clean DSL in stdout and warnings only in stderr.logger, notstd.debug.print).