feat: implement service failure handling in background streaming

- Added a method to send failure notifications to Flutter when the background service fails to enter the foreground.
- Implemented a broadcast receiver to handle service failure notifications and notify Flutter about the failure.
- Enhanced the persistent streaming service to attempt recovery for failed streams.
- Introduced heartbeat monitoring for SSE streams to detect stale connections and trigger recovery actions.
This commit is contained in:
cogwheel0
2025-10-28 13:59:17 +05:30
parent 81eb38dc52
commit 7fb199b2e4
7 changed files with 265 additions and 25 deletions

View File

@@ -1447,7 +1447,7 @@ Future<void> regenerateMessage(
modelItem: modelItem,
sessionId: effectiveSessionId,
activeConversationId: activeConversation.id,
api: api,
api: api!,
socketService: socketService,
registerDeltaListener: registerDeltaListener,
appendToLastMessage: (c) =>
@@ -1719,7 +1719,7 @@ Future<void> _sendMessageInternal(
final List<String> ids = msg.attachmentIds ?? const <String>[];
if (ids.isNotEmpty) {
final messageMap = await _buildMessagePayloadWithAttachments(
api: api,
api: api!,
role: msg.role,
cleanedText: cleaned,
attachmentIds: ids,
@@ -1995,7 +1995,7 @@ Future<void> _sendMessageInternal(
modelItem: modelItem,
sessionId: effectiveSessionId,
activeConversationId: activeConversation?.id,
api: api,
api: api!,
socketService: socketService,
registerDeltaListener: registerDeltaListener,
appendToLastMessage: (c) =>