feat: Enhance chat functionality with follow-up message handling

- Added logic to determine the visibility of follow-up messages based on the presence of user and assistant bubbles below the current message.
- Updated the AssistantMessageWidget to accept a new parameter `showFollowUps`, allowing for conditional rendering of follow-up messages.
- Improved the user experience by ensuring follow-up messages are displayed appropriately based on the chat context.
This commit is contained in:
cogwheel0
2025-10-18 15:03:06 +05:30
parent f81237e374
commit f36ebfd630
2 changed files with 23 additions and 1 deletions

View File

@@ -869,6 +869,23 @@ class _ChatPageState extends ConsumerState<ChatPage> {
matchedModel,
);
var hasUserBubbleBelow = false;
var hasAssistantBubbleBelow = false;
for (var i = index + 1; i < messages.length; i++) {
final role = messages[i].role;
if (role == 'user') {
hasUserBubbleBelow = true;
break;
}
if (role == 'assistant') {
hasAssistantBubbleBelow = true;
break;
}
}
final showFollowUps =
!isUser && !hasUserBubbleBelow && !hasAssistantBubbleBelow;
// Wrap message in selection container if in selection mode
Widget messageWidget;
@@ -888,6 +905,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
key: ValueKey('assistant-${message.id}'),
message: message,
isStreaming: isStreaming,
showFollowUps: showFollowUps,
modelName: displayModelName,
modelIconUrl: modelIconUrl,
onCopy: () => _copyMessage(message.content),