@@ -1318,6 +1318,7 @@ class MessageListBloc extends Bloc<MessageListEvent, MessageListState>
13181318 /// The CometChatStreamBubble widget handles word-by-word rendering.
13191319 void _handleAIAssistantEvent (AIAssistantBaseEvent event) {
13201320 if (isClosed) return ;
1321+ debugPrint ('[MessageListBloc] AI event received: type=${event .type }, id=${event .id }' );
13211322 final runId = event.id;
13221323 if (runId == null ) return ;
13231324
@@ -2468,6 +2469,11 @@ class MessageListBloc extends Bloc<MessageListEvent, MessageListState>
24682469 ) async {
24692470 final message = event.message;
24702471
2472+ debugPrint ('[MessageListBloc] Message received: id=${message .id }, '
2473+ 'category=${message .category }, type=${message .type }, '
2474+ 'sender=${message .sender ?.uid }, '
2475+ 'class=${message .runtimeType }' );
2476+
24712477 // For AI assistant messages, replace the thinking/stream bubble
24722478 if (message is AIAssistantMessage && message.runId != null ) {
24732479 final thinkingId = - (message.runId! );
@@ -2496,6 +2502,8 @@ class MessageListBloc extends Bloc<MessageListEvent, MessageListState>
24962502
24972503 // Check if message belongs to current conversation
24982504 if (! _isMessageForCurrentConversation (message)) {
2505+ debugPrint ('[MessageListBloc] Message FILTERED: not for current conversation. '
2506+ 'message.conversationId=${message .conversationId }' );
24992507 return ;
25002508 }
25012509
@@ -2526,6 +2534,9 @@ class MessageListBloc extends Bloc<MessageListEvent, MessageListState>
25262534
25272535 // Check message type/category filters
25282536 if (! _passesTypeAndCategoryFilters (message)) {
2537+ debugPrint ('[MessageListBloc] Message FILTERED: type/category filter failed. '
2538+ 'category=${message .category }, type=${message .type }, '
2539+ 'allowedCategories=$categories ' );
25292540 return ;
25302541 }
25312542
@@ -2569,6 +2580,7 @@ class MessageListBloc extends Bloc<MessageListEvent, MessageListState>
25692580 // If user has scrolled up (hasMoreNewer = true), don't append new messages
25702581 // This prevents messages from appearing while user is viewing older messages
25712582 if (state.hasMoreNewer) {
2583+ debugPrint ('[MessageListBloc] Message FILTERED: hasMoreNewer=true (user scrolled up)' );
25722584 return ;
25732585 }
25742586
@@ -2580,6 +2592,10 @@ class MessageListBloc extends Bloc<MessageListEvent, MessageListState>
25802592 final insertIndex = state.messages.length;
25812593 final updatedMessages = [...state.messages, intercepted];
25822594
2595+ debugPrint ('[MessageListBloc] Adding message to list: id=${intercepted .id }, '
2596+ 'category=${intercepted .category }, type=${intercepted .type }, '
2597+ 'insertIndex=$insertIndex ' );
2598+
25832599 // Update index maps incrementally
25842600 _addToIndexMaps (intercepted, insertIndex);
25852601
@@ -4115,26 +4131,44 @@ class _MessageListMessageListener with MessageListener {
41154131
41164132 @override
41174133 void onTextMessageReceived (TextMessage textMessage) {
4134+ debugPrint ('[MessageListener] onTextMessageReceived: id=${textMessage .id }, sender=${textMessage .sender ?.uid }' );
41184135 onTextMessageReceivedCallback (textMessage);
41194136 }
41204137
41214138 @override
41224139 void onMediaMessageReceived (MediaMessage mediaMessage) {
4140+ debugPrint ('[MessageListener] onMediaMessageReceived: id=${mediaMessage .id }, type=${mediaMessage .type }, sender=${mediaMessage .sender ?.uid }' );
41234141 onMediaMessageReceivedCallback (mediaMessage);
41244142 }
41254143
41264144 @override
41274145 void onCustomMessageReceived (CustomMessage customMessage) {
4146+ debugPrint ('[MessageListener] onCustomMessageReceived: id=${customMessage .id }, type=${customMessage .type }, sender=${customMessage .sender ?.uid }' );
41284147 onCustomMessageReceivedCallback (customMessage);
41294148 }
41304149
41314150 @override
41324151 void onInteractiveMessageReceived (InteractiveMessage interactiveMessage) {
4152+ debugPrint ('[MessageListener] onInteractiveMessageReceived: id=${interactiveMessage .id }, type=${interactiveMessage .type }, sender=${interactiveMessage .sender ?.uid }' );
41334153 onInteractiveMessageReceivedCallback (interactiveMessage);
41344154 }
41354155
4156+ @override
4157+ void onCardMessageReceived (CardMessage cardMessage) {
4158+ debugPrint ('[MessageListener] onCardMessageReceived: id=${cardMessage .id }, '
4159+ 'category=${cardMessage .category }, type=${cardMessage .type }, '
4160+ 'hasCard=${cardMessage .getCard () != null }, '
4161+ 'text=${cardMessage .getText ()}' );
4162+ // Route card messages through the same path as other messages
4163+ onTextMessageReceivedCallback (cardMessage);
4164+ }
4165+
41364166 @override
41374167 void onAIAssistantMessageReceived (AIAssistantMessage aiAssistantMessage) {
4168+ debugPrint ('[MessageListener] onAIAssistantMessageReceived: id=${aiAssistantMessage .id }, '
4169+ 'runId=${aiAssistantMessage .runId }, '
4170+ 'hasElements=${aiAssistantMessage .getElements ()?.isNotEmpty ?? false }, '
4171+ 'elementsCount=${aiAssistantMessage .getElements ()?.length ?? 0 }' );
41384172 onAIAssistantMessageReceivedCallback (aiAssistantMessage);
41394173 }
41404174
0 commit comments