fix(streaming): sync follow-ups to server after generation

This commit is contained in:
cogwheel
2025-12-22 11:25:10 +05:30
parent 64d960e7a1
commit cf2d88b4ac

View File

@@ -1060,6 +1060,30 @@ ActiveSocketStream attachUnifiedChunkedStreaming({
'Follow-ups set successfully', 'Follow-ups set successfully',
scope: 'streaming/helper', 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 { } else {
DebugLogger.log( DebugLogger.log(
'Follow-ups: targetId is null', 'Follow-ups: targetId is null',