| .. | .. |
|---|
| 114 | 114 | }; |
|---|
| 115 | 115 | } |
|---|
| 116 | 116 | |
|---|
| 117 | | - /// Lightweight JSON for persistence (strips temp audio paths, keeps images). |
|---|
| 117 | + /// Lightweight JSON for persistence (strips base64 audio, keeps file paths and images). |
|---|
| 118 | 118 | 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('/'); |
|---|
| 119 | 122 | return { |
|---|
| 120 | 123 | 'id': id, |
|---|
| 121 | 124 | 'role': role.name, |
|---|
| 122 | 125 | 'type': type.name, |
|---|
| 123 | 126 | 'content': content, |
|---|
| 127 | + if (keepAudio) 'audioUri': audioUri, |
|---|
| 124 | 128 | 'timestamp': timestamp, |
|---|
| 125 | 129 | if (status != null) 'status': status!.name, |
|---|
| 126 | 130 | if (duration != null) 'duration': duration, |
|---|
| 127 | 131 | // 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. |
|---|
| 129 | 132 | if (imageBase64 != null) 'imageBase64': imageBase64, |
|---|
| 130 | 133 | }; |
|---|
| 131 | 134 | } |
|---|