lib/providers/providers.dart
.. .. @@ -92,9 +92,10 @@ 92 92 93 93 /// Switch to a new session and load its messages. 94 94 Future<void> switchSession(String sessionId) async { 95 - // Save current session before switching95 + // Force-flush current session to disk before switching96 96 if (_currentSessionId != null && state.isNotEmpty) { 97 97 MessageStore.save(_currentSessionId!, state); 98 + await MessageStore.flush();98 99 } 99 100 100 101 _currentSessionId = sessionId;