Appearance setting ("Light") reverts to "Automatic" on macOS after quitting via Cmd+Q — localStorage write lost, likely missing flushStorageData() before quit

Author: m-weimerCreated Sep 14, 2026Updated Sep 15, 2026
Labelsbugpossible-duplicate

Environment: macOS, draw.io Desktop v31.4.5, system appearance set to Dark

Steps to reproduce:

  1. Set system (macOS) appearance to Dark
  2. Launch draw.io Desktop, Extras > Appearance > Light
  3. Confirm the change took: Extras > Configuration > Preferences shows "darkMode": false
  4. Quit the app with Cmd+Q
  5. Relaunch

Expected: app opens in Light mode, "darkMode": false persists.

Actual: app opens in Dark mode; Preferences now shows "darkMode": "auto" again, which resolves to Dark since the OS is in Dark mode.

Suspected root cause: mxSettings.save() (drawio's Settings.js) persists via localStorage.setItem(), which drawio Desktop backs with Electron's LevelDB-based Local Storage (app.getPath('userData')/Local Storage/leveldb, referenced in src/main/electron.js). That write is asynchronous. I checked src/main/electron.js in this repo and found no call to session.flushStorageData() anywhere — including in the before-quit handler (app.on('before-quit', ...) around line 1967, which on macOS just sets cmdQPressed before app.quit() fires via window-all-closed). Electron's own guidance (and prior reports elsewhere, e.g. asticode/go-astilectron#229) is that localStorage writes can be lost if the process exits before LevelDB flushes, unless flushStorageData() is called first. That matches this repro exactly: the setting is written correctly (confirmed via the in-app Preferences viewer) but doesn't survive a quit shortly after.

Suggested fix: call session.flushStorageData() (or the modern equivalent) in the before-quit/window-all-closed path before app.quit() completes.

Related but distinct existing issues (none mention the flush mechanism, so filing separately): #1362, #1540, #630, #1940