fix: persist and display multimodal messages (image/audio attachments) (#1159)

Multimodal content (list of {type, text/image_url} blocks) couldn't be
stored in the DB Text column, causing silent persist failures. On reload
the frontend fell back to String() on the array, rendering
[object Object],[object Object] in the chat.

- Serialize list content as JSON in _persist_message()
- Deserialize back to list in _db_to_session() via _parse_msg_content()
- Extract text parts from multimodal arrays in sessions.js instead of
  String() coercion
This commit is contained in:
Robin Fröhlich
2026-06-02 15:37:48 +02:00
committed by GitHub
parent 6bfe824eb4
commit 096468a29f
2 changed files with 33 additions and 4 deletions
+9 -1
View File
@@ -1610,7 +1610,15 @@ export async function selectSession(id, { keepSidebar = false } = {}) {
} else if (msgHistory.length) {
for (const msg of msgHistory) {
const meta = msg.metadata ? { ...msg.metadata, _fromHistory: true } : null;
let displayContent = typeof msg.content === 'string' ? msg.content : (msg.content ? String(msg.content) : '');
let displayContent;
if (typeof msg.content === 'string') {
displayContent = msg.content;
} else if (Array.isArray(msg.content)) {
// Multimodal (image/audio attachments): extract text parts, skip binary
displayContent = msg.content.filter(p => p.type === 'text').map(p => p.text).join('\n').trim();
} else {
displayContent = '';
}
// Clean up doc selection context for display
if (msg.role === 'user') {
// Hide "Continue where you left off" bubbles