diff --git a/CLAUDE.md b/CLAUDE.md index 955d322..6168c7d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -694,6 +694,11 @@ Per-user blob JSON dans `users.settings_json`, exposé via `GET/PUT hotkeys autofill, etc. **Device-only** (localStorage seulement) : `quickUnlockEnabled` (DPAPI lié au compte Windows), `autofillEnabled` (toggle hotkey Win32), `rememberedUsername` (auth screen autofill local). +Ces trois-là sont **device-only mais pas localStorage-only** : chacun est +miroité en pref DPAPI, sinon le changement de port les ramène à leur défaut +à chaque lancement (`autofillEnabled` revenait ainsi sur ON une fois +désactivé). Lu dans `enterApp` juste avant `autofillPushHotkeys`, la copie +DPAPI faisant autorité. **Piège : tout réglage lu AVANT le login doit être en pref DPAPI.** `settings_json` demande une session, et `localStorage` est vidé à chaque diff --git a/js/app.js b/js/app.js index 340656b..d4e6c61 100644 --- a/js/app.js +++ b/js/app.js @@ -7013,6 +7013,14 @@ async function enterApp() { // Fire-and-forget HIBP scan if the user opted in. Runs in background, // re-renders when done to show badges. if (state.hibpEnabled) hibpCheckAllEntries(); + // The DPAPI copy governs — localStorage was wiped by the port change. + if (Bridge.active) { + const savedAutofill = await Bridge.getPref('autofillEnabled'); + if (savedAutofill === '0' || savedAutofill === '1') { + state.autofillEnabled = savedAutofill === '1'; + localStorage.setItem('autofillEnabled', savedAutofill); + } + } // Push the user-configured hotkeys (combos + enabled state) to Delphi. // Replaces the historical "always Ctrl+Shift+L on startup" path. // silent: no success toast on every unlock — a clash still warns. @@ -8090,6 +8098,9 @@ async function init() { $('#settingAutofill').addEventListener('change', e => { state.autofillEnabled = e.target.checked; localStorage.setItem('autofillEnabled', state.autofillEnabled ? '1' : '0'); + // Mirrored in DPAPI: localStorage dies with the origin at every port + // change, so without this the toggle came back ON at each launch. + if (Bridge.active) Bridge.setPref('autofillEnabled', state.autofillEnabled ? '1' : '0'); // Push the FULL state (toggle + combos) so Delphi register/unregister // uses the user's current combos, not the defaults. autofillPushHotkeys();