From 17aba52fc83d118ea927f976c0af9e53acecaf0b Mon Sep 17 00:00:00 2001 From: cogwheel <172976095+cogwheel0@users.noreply.github.com> Date: Wed, 17 Dec 2025 18:50:11 +0530 Subject: [PATCH] fix(api): Always assistant messages as done when persisting --- lib/core/services/api_service.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/core/services/api_service.dart b/lib/core/services/api_service.dart index 4ab7266..8b47748 100644 --- a/lib/core/services/api_service.dart +++ b/lib/core/services/api_service.dart @@ -966,7 +966,10 @@ class ApiService { if (msg.role == 'assistant' && msg.model != null) 'modelName': msg.model, if (msg.role == 'assistant') 'modelIdx': 0, - if (msg.role == 'assistant') 'done': !msg.isStreaming, + // Always set done: true when persisting to server. + // If streaming is interrupted, the message should still be marked done + // to prevent the web client from treating it as an in-progress stream. + if (msg.role == 'assistant') 'done': true, if (msg.role == 'user' && model != null) 'models': [model], if (msg.attachmentIds != null && msg.attachmentIds!.isNotEmpty) 'attachment_ids': List.from(msg.attachmentIds!), @@ -1005,7 +1008,8 @@ class ApiService { if (msg.role == 'assistant' && msg.model != null) 'modelName': msg.model, if (msg.role == 'assistant') 'modelIdx': 0, - if (msg.role == 'assistant') 'done': !msg.isStreaming, + // Always set done: true when persisting to server. + if (msg.role == 'assistant') 'done': true, if (msg.role == 'user' && model != null) 'models': [model], if (msg.attachmentIds != null && msg.attachmentIds!.isNotEmpty) 'attachment_ids': List.from(msg.attachmentIds!),