Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac937ea01c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Domains that were never written cannot be exported either; skip them. | ||
| defaults export "$d" "$BACKUP_DIR/$d.plist" 2>/dev/null \ | ||
| || defaults read "$d" >"$BACKUP_DIR/$d.txt" 2>/dev/null \ | ||
| || true |
There was a problem hiding this comment.
Abort before deletion when a required backup fails
If both defaults export and the fallback defaults read fail for an existing domain—for example because the backup volume fills—the final || true lets the script continue deleting preferences with no usable backup, contradicting its stated backup-first safety guarantee. Treat an unbacked existing domain as fatal before entering the deletion phase.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
| d="${entry%%|*}" | ||
| k="${entry#*|}" | ||
| if defaults read "$d" "$k" >/dev/null 2>&1; then | ||
| defaults delete "$d" "$k" >/dev/null 2>&1 || true |
There was a problem hiding this comment.
Treat failed preference deletions as errors
When defaults delete returns nonzero, this suppression still prints restored, increments deleted, and ultimately reports success even though the key remains unchanged. This can leave a partially restored system after a managed-preference or transient write failure; check the exit status and verify the key is absent instead of counting the operation as successful.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
| echo "" | ||
| echo "Done: $deleted key(s) restored, $absent already at the default." | ||
| echo "Backup location: $BACKUP_DIR" | ||
| echo "Roll back one domain with: defaults import <domain> \"$BACKUP_DIR/<domain>.plist\"" |
There was a problem hiding this comment.
Use the actual fallback filename in rollback instructions
For NSGlobalDomain, the script explicitly expects export to fail and writes the backup as NSGlobalDomain.txt, but this final instruction always points users to NSGlobalDomain.plist, which does not exist on that path. Consequently, the advertised rollback command fails for the domain containing twenty affected keys; print the recorded fallback path or normalize every successful backup to the documented filename.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
Motivation
While investigating the System Optimization feature on a real machine, I ran into two restore-related gaps:
com.apple.sound.beep.feedback(interface sound effects — volume beeps, drag-to-Trash sound). I observed that after deleting this key, macOS treated it as off on some systems, even though the documented default is on.What this PR adds
scripts/restore-macos-defaults.sh, a maintenance script that restores every macOS preference System Optimization can touch:src-tauri/crates/mangodisk-platform/src/macos/system_settings.rsand the values insrc-tauri/crates/mangodisk-core/src/system_settings/catalog.rs). Deleting a key restores the OS factory default instead of a guessed value.com.apple.sound.beep.feedbackback totrueexplicitly instead of deleting it, for the reason above.~/Desktop/mango-restore-backup-<timestamp>/before anything is deleted, so any domain can be rolled back withdefaults import.README updates (en / zh-CN / zh-TW / ja) document the script under "System Optimization".
Validation
bash -npasses; the script was executed end-to-end on a real macOS machine (Apple Silicon, macOS 26): it restored 51 previously overwritten keys, correctly skipped 20 keys that were already at their defaults, and the interface sound effects key was written back totrue. Finder animations and Dock genie effect were confirmed restored after the restart.pnpm checkandcargo testare unaffected by this change.AGENTS.md; the script filename and paths follow the repository naming conventions.Follow-up ideas (not in this PR)
defaults exportbackup) before applying optimizations in-app.