From 8245a697962608571410b28134be6476d4de11d3 Mon Sep 17 00:00:00 2001 From: cogwheel0 <172976095+cogwheel0@users.noreply.github.com> Date: Fri, 5 Sep 2025 11:20:39 +0530 Subject: [PATCH] fix: title gen --- lib/features/chat/providers/chat_providers.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/features/chat/providers/chat_providers.dart b/lib/features/chat/providers/chat_providers.dart index 16a721d..a648537 100644 --- a/lib/features/chat/providers/chat_providers.dart +++ b/lib/features/chat/providers/chat_providers.dart @@ -1059,15 +1059,16 @@ Future _sendMessageInternal( } catch (_) {} // Background tasks parity with Web client (safe defaults) - // Only enable title generation on the very first turn of a new chat. + // Enable title/tags generation on the very first user turn of a new chat. bool shouldGenerateTitle = false; try { final conv = ref.read(activeConversationProvider); - final msgs = ref.read(chatMessagesProvider); - // After adding the user message above, first turn will have exactly 1 message - // and the conversation will still have the placeholder title. + // Use the outbound conversationMessages we just built (excludes streaming placeholders) + final nonSystemCount = conversationMessages + .where((m) => (m['role']?.toString() ?? '') != 'system') + .length; shouldGenerateTitle = (conv == null) || - (conv.title == 'New Chat' && msgs.length <= 1); + ((conv.title == 'New Chat' || (conv.title.isEmpty)) && nonSystemCount == 1); } catch (_) {} // Match web client: request background follow-ups always; title/tags on first turn