From fee149c1fbc63f52aa66148018e569e30cca6161 Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Sun, 22 Mar 2026 20:04:15 +0100
Subject: [PATCH] fix: voice transcript display, audio file persistence, debug logging

---
 lib/models/message.dart |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/models/message.dart b/lib/models/message.dart
index 48dc9c0..8a034ec 100644
--- a/lib/models/message.dart
+++ b/lib/models/message.dart
@@ -114,18 +114,21 @@
     };
   }
 
-  /// Lightweight JSON for persistence (strips temp audio paths, keeps images).
+  /// Lightweight JSON for persistence (strips base64 audio, keeps file paths and images).
   Map<String, dynamic> toJsonLight() {
+    // Keep audioUri if it's a file path (starts with '/') — these are saved audio files.
+    // Strip base64 audio data (large, temp) — those won't survive restart.
+    final keepAudio = audioUri != null && audioUri!.startsWith('/');
     return {
       'id': id,
       'role': role.name,
       'type': type.name,
       'content': content,
+      if (keepAudio) 'audioUri': audioUri,
       'timestamp': timestamp,
       if (status != null) 'status': status!.name,
       if (duration != null) 'duration': duration,
       // Keep imageBase64 — images are typically 50-200 KB and must survive restart.
-      // audioUri is intentionally omitted: it is a temp file path that won't survive restart.
       if (imageBase64 != null) 'imageBase64': imageBase64,
     };
   }

--
Gitblit v1.3.1