Skip to content

[FIX] Make Preferences win over .subzillarc in the Mac app - #22

Merged
onyxdevs merged 1 commit into
mainfrom
fix/mac-preferences-precedence
Sep 21, 2026
Merged

onyxdevs merged 1 commit into
mainfrom
fix/mac-preferences-precedence

Conversation

@onyxdevs

Copy link
Copy Markdown
Owner

Summary

Implements the decision: in the Mac app, Preferences wins.

Once the Preferences window has been saved, Preferences is the only source of settings. Until then, a .subzillarc file seeds the initial values over the built-in defaults — and the window shows them, so saving locks them in. Restore Defaults hands control back.

What was actually happening

Neither side cleanly won. electron-store writes every default into the store, so the old RC < stored merge meant:

  • .subzillarc was ignored for almost every key — lineEndings: crlf, strip.html: true never applied in the app;
  • yet it leaked through for the few keys that have no default (output.directory, output.format, batch.maxDepth, include/exclude dirs) — even after the user had saved their preferences.

Also found while fixing it:

  • A race: the RC file was loaded without being awaited, so the first conversion after launch could run before it had been read. (Jest independently flagged this as "Cannot log after tests are done".)
  • A second, hidden lookup via ConfigManager.loadConfig(): it searched process.cwd() on its own, returned schema-filled defaults, and never applied the environment variables its comment promised. Removed.
  • RC loading had never been exercised by any test: the electron import threw and the error was swallowed.

Changes

  • userSavedConfig marker set on save. Installs that predate it count as saved when their stored values differ from the defaults, so an existing customised setup is never overridden by a file.
  • getConfig() awaits the RC load.
  • An RC file that is not a map, or fails schema validation, is ignored entirely rather than half-applied. The raw object is merged (the schema's own defaults would otherwise override the app's).
  • The rule is stated in the Preferences window (Advanced tab) and the README.

Verification

  • 14 new tests against real .subzillarc files and a store that materialises defaults the way electron-store does. 4 fail on the previous logic (checked by adding only the test seam first, with no behaviour change).
  • Real Electron + real electron-store, isolated with a temp HOME and userData:
1 fresh install + RC        lineEndings=crlf  directory=/tmp/from-rc  html=true
2 after saving prefs        lineEndings=lf    (no directory)          html=false
3 after relaunch            lineEndings=lf    (no directory)          html=false
4 after Reset to Defaults   lineEndings=crlf  directory=/tmp/from-rc  html=true
  • All 739 tests, lint and format pass.

Note for your own machine

Your stored preferences will count as "saved" only if they differ from the defaults. If they don't, the app will now start honouring a ~/.subzillarc until your next save in Preferences.

🤖 Generated with Claude Code

- Rule: once the Preferences window has been saved, Preferences is the only source of settings. Until then a .subzillarc file seeds the initial values over the built-in defaults, and the window shows them, so saving locks them in. Restore Defaults hands control back.
- The old "RC < stored" merge could not express any rule: electron-store materialises every default, so .subzillarc was ignored for almost every key (lineEndings, strip.html, ...) yet leaked through for the few keys without a default (output.directory, output.format, batch.maxDepth), even after the user had saved their preferences.
- A userSavedConfig marker records the save. Installs that predate it count as saved when their stored values differ from the defaults, so an existing setup is never overridden.
- getConfig() now awaits the RC load; previously the first conversion after launch could run before the file had been read.
- Removed a second, hidden lookup through ConfigManager.loadConfig(): it searched process.cwd() on its own, returned schema-filled defaults, and never applied the environment variables its comment promised.
- An RC file that is not a map or fails schema validation is ignored entirely instead of being half-applied.
- The Preferences window and README now state the rule.

Tests: 14 new cases against real .subzillarc files and a store that materialises defaults like electron-store does; 4 of them fail on the previous logic. Also verified in a real Electron process against the real electron-store (seed, save, relaunch, reset).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@onyxdevs
onyxdevs merged commit b79a3bc into main Sep 21, 2026
6 checks passed
@onyxdevs
onyxdevs deleted the fix/mac-preferences-precedence branch September 21, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant