Matthias Nott
9 days ago 1bf6e76e31383aef77e42943fc2caf350cf7e096
lib/providers/providers.dart
....@@ -99,10 +99,9 @@
9999
100100 /// Switch to a new session and load its messages.
101101 Future<void> switchSession(String sessionId) async {
102
- // Force-flush current session to disk before switching
102
+ // Write current session DIRECTLY to disk (no debounce — prevents data loss)
103103 if (_currentSessionId != null && state.isNotEmpty) {
104
- MessageStore.save(_currentSessionId!, state);
105
- await MessageStore.flush();
104
+ await MessageStore.writeDirect(_currentSessionId!, state);
106105 }
107106
108107 _currentSessionId = sessionId;