Matthias Nott
2026-03-22 fee149c1fbc63f52aa66148018e569e30cca6161
lib/models/message.dart
....@@ -114,18 +114,21 @@
114114 };
115115 }
116116
117
- /// Lightweight JSON for persistence (strips temp audio paths, keeps images).
117
+ /// Lightweight JSON for persistence (strips base64 audio, keeps file paths and images).
118118 Map<String, dynamic> toJsonLight() {
119
+ // Keep audioUri if it's a file path (starts with '/') — these are saved audio files.
120
+ // Strip base64 audio data (large, temp) — those won't survive restart.
121
+ final keepAudio = audioUri != null && audioUri!.startsWith('/');
119122 return {
120123 'id': id,
121124 'role': role.name,
122125 'type': type.name,
123126 'content': content,
127
+ if (keepAudio) 'audioUri': audioUri,
124128 'timestamp': timestamp,
125129 if (status != null) 'status': status!.name,
126130 if (duration != null) 'duration': duration,
127131 // Keep imageBase64 — images are typically 50-200 KB and must survive restart.
128
- // audioUri is intentionally omitted: it is a temp file path that won't survive restart.
129132 if (imageBase64 != null) 'imageBase64': imageBase64,
130133 };
131134 }