Skip to content

settings: skip unchanged saves so external edits are not swallowed - #3504

Merged
bbedward merged 1 commit into
duxlabs-dev:masterfrom
satoshoe-dev:settings-selfwrite-unchanged
Sep 20, 2026
Merged

bbedward merged 1 commit into
duxlabs-dev:masterfrom
satoshoe-dev:settings-selfwrite-unchanged

Conversation

@satoshoe-dev

Copy link
Copy Markdown
Contributor

Description

SettingsData.saveSettings() sets _selfWrite = true and then calls settingsFile.setText(...). When the serialized settings are identical to the file content, nothing is written, no fileChanged follows, and _selfWrite stays true. The next external edit of settings.json is then taken for DMS's own write: onFileChanged clears the flag and returns without reloading.

It is easy to hit. Any set with an unchanged value leaves the flag set, for example dms ipc call settings set cornerRadius 12 while it already is 12. Tools that write settings.json from outside (profile switchers, dotfile managers, a text editor) then see their first change ignored until DMS saves again or restarts.

The fix compares the serialized JSON with settingsFile.text() and returns early when nothing changed, so the flag is only set when a write happens.

How to reproduce on current master:

  1. dms ipc call settings set cornerRadius <current value> (the file's mtime does not change)
  2. Change cornerRadius in settings.json from outside
  3. DMS does not pick up the change

With this change, step 3 reloads as expected.

Type of change

  • Bug fix (non-breaking change that fixes an issue)

Related issues

None found.

Checklist

  • My code follows the conventions in CONTRIBUTING.md
  • I have tested my changes locally (DMS 1.6.1 on niri, same saveSettings() as master: unchanged value writes nothing and leaves the flag false, changed value writes and the following fileChanged is consumed as before, an external edit afterwards reloads)
  • New user-facing strings: none
  • QML changes: make lint-qml not run, I do not have the dev shell set up

I found and fixed this with help from Claude (Anthropic). I reproduced the bug, read the change and tested it myself.

🤖 Generated with Claude Code

saveSettings() set _selfWrite before setText(). When the serialized
settings were identical to the file, nothing was written, no
fileChanged followed, and the flag stayed set. The next external edit
of settings.json was then taken for our own write and never reloaded.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@bbedward

Copy link
Copy Markdown
Member

/claude review

@claude

claude Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Claude review

No issues found.

Checked: the _selfWrite/onFileChanged handshake and the debounce-reload window, _isReadOnly/_checkSettingsWritable recovery, greeter and _pendingMigration paths, key order and trailing-newline stability of JSON.stringify(Store.toJson(root), null, 2) vs settingsFile.text(), and cost on the hot on<X>Changed: saveSettings() handlers (the stringify already ran unconditionally, so this only removes disk writes). One pre-existing gap the fix does not close, for what it is worth: onSaveFailed (SettingsData.qml:3110) leaves _selfWrite set, since a failed write produces no fileChanged — so a read-only settings.json can still swallow the next external edit. Model: claude-opus-5.

@bbedward
bbedward merged commit 84594e6 into duxlabs-dev:master Sep 20, 2026
2 checks passed
bbedward pushed a commit that referenced this pull request Oct 7, 2026
…3504)

saveSettings() set _selfWrite before setText(). When the serialized
settings were identical to the file, nothing was written, no
fileChanged followed, and the flag stayed set. The next external edit
of settings.json was then taken for our own write and never reloaded.

(cherry picked from commit 84594e6)
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.

2 participants