From cf2d88b4acdf416ef0c96e1c1685cbc50369fb68 Mon Sep 17 00:00:00 2001 From: cogwheel <172976095+cogwheel0@users.noreply.github.com> Date: Mon, 22 Dec 2025 11:25:10 +0530 Subject: [PATCH] fix(streaming): sync follow-ups to server after generation --- lib/core/services/streaming_helper.dart | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/core/services/streaming_helper.dart b/lib/core/services/streaming_helper.dart index de05d64..509a3f5 100644 --- a/lib/core/services/streaming_helper.dart +++ b/lib/core/services/streaming_helper.dart @@ -1060,6 +1060,30 @@ ActiveSocketStream attachUnifiedChunkedStreaming({ 'Follow-ups set successfully', scope: 'streaming/helper', ); + + // Sync to server to persist follow-ups (they arrive after done:true) + final chatId = activeConversationId; + if (chatId != null && chatId.isNotEmpty && suggestions.isNotEmpty) { + Future.microtask(() async { + try { + final currentMessages = getMessages(); + await api.syncConversationMessages( + chatId, + currentMessages, + model: modelId, + ); + DebugLogger.log( + 'Follow-ups persisted to server', + scope: 'streaming/helper', + ); + } catch (e) { + DebugLogger.log( + 'Failed to persist follow-ups: $e', + scope: 'streaming/helper', + ); + } + }); + } } else { DebugLogger.log( 'Follow-ups: targetId is null',