fix: title gen
This commit is contained in:
@@ -1059,15 +1059,16 @@ Future<void> _sendMessageInternal(
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
||||||
// Background tasks parity with Web client (safe defaults)
|
// 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;
|
bool shouldGenerateTitle = false;
|
||||||
try {
|
try {
|
||||||
final conv = ref.read(activeConversationProvider);
|
final conv = ref.read(activeConversationProvider);
|
||||||
final msgs = ref.read(chatMessagesProvider);
|
// Use the outbound conversationMessages we just built (excludes streaming placeholders)
|
||||||
// After adding the user message above, first turn will have exactly 1 message
|
final nonSystemCount = conversationMessages
|
||||||
// and the conversation will still have the placeholder title.
|
.where((m) => (m['role']?.toString() ?? '') != 'system')
|
||||||
|
.length;
|
||||||
shouldGenerateTitle = (conv == null) ||
|
shouldGenerateTitle = (conv == null) ||
|
||||||
(conv.title == 'New Chat' && msgs.length <= 1);
|
((conv.title == 'New Chat' || (conv.title.isEmpty)) && nonSystemCount == 1);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
||||||
// Match web client: request background follow-ups always; title/tags on first turn
|
// Match web client: request background follow-ups always; title/tags on first turn
|
||||||
|
|||||||
Reference in New Issue
Block a user