-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean and improve chat messages widgets #926
base: main
Are you sure you want to change the base?
Conversation
I'm sorry, but I can't provide a review or generate a summary as the variable Uplevel your code reviews with Entelligence.AI ProEntelligence.AI ProIf you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, Entelligence.AI Pro is free for open source projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (1)
- app/lib/pages/chat/widgets/ai_message.dart (6)
Files not summarized due to errors (1)
- app/lib/pages/chat/widgets/ai_message.dart (diff tokens exceeds limit)
Review comments generated (10)
- Review: 3
- LGTM: 7
Tips
Chat with Entelligence.AI Bot (@Entelligence.AI
)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@Entelligence.AI
in a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@Entelligence.AI: ignore
anywhere in the PR description to pause further reviews from the bot.
Widget buildMessageWidget(ServerMessage message, Function(String) sendMessage, bool showTypingIndicator, | ||
bool displayOptions, Plugin? pluginSender, Function(ServerMemory) updateMemory) { | ||
if (message.memories.isNotEmpty) { | ||
return MemoriesMessageWidget( | ||
showTypingIndicator: showTypingIndicator, | ||
messageMemories: message.memories.length > 3 ? message.memories.sublist(0, 3) : message.memories, | ||
messageText: message.isEmpty ? '...' : message.text.decodeSting, | ||
updateMemory: updateMemory, | ||
); | ||
} else if (message.type == MessageType.daySummary) { | ||
return DaySummaryWidget(showTypingIndicator: showTypingIndicator, messageText: message.text); | ||
} else if (displayOptions) { | ||
return InitialMessageWidget( | ||
showTypingIndicator: showTypingIndicator, messageText: message.text, sendMessage: sendMessage); | ||
} else { | ||
return NormalMessageWidget(showTypingIndicator: showTypingIndicator, messageText: message.text); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a potential issue with the message.isEmpty
check. It seems like you're checking if the entire message object is empty, but I believe you want to check if the text of the message is empty. You should use message.text.isEmpty
instead.
- messageText: message.isEmpty ? '...' : message.text.decodeSting,
+ messageText: message.text.isEmpty ? '...' : message.text.decodeSting,
if (m == null) return; | ||
idx = memProvider.addMemoryWithDate(m); | ||
MixpanelManager().chatMessageMemoryClicked(m); | ||
setState(() => memoryDetailLoading[data.$1] = false); | ||
context.read<MemoryDetailProvider>().updateMemory(idx); | ||
await Navigator.of(context).push( | ||
MaterialPageRoute( | ||
builder: (c) => MemoryDetailPage( | ||
memory: m, | ||
), | ||
), | ||
); | ||
//TODO: Not needed anymore I guess because memories are stored in provider and read from there only | ||
if (SharedPreferencesUtil().modifiedMemoryDetails?.id == m.id) { | ||
ServerMemory modifiedDetails = SharedPreferencesUtil().modifiedMemoryDetails!; | ||
widget.updateMemory(SharedPreferencesUtil().modifiedMemoryDetails!); | ||
var copy = List<MessageMemory>.from(widget.message.memories); | ||
copy[data.$1] = MessageMemory( | ||
modifiedDetails.id, | ||
modifiedDetails.createdAt, | ||
MessageMemoryStructured( | ||
modifiedDetails.structured.title, | ||
modifiedDetails.structured.emoji, | ||
)); | ||
widget.message.memories.clear(); | ||
widget.message.memories.addAll(copy); | ||
SharedPreferencesUtil().modifiedMemoryDetails = null; | ||
setState(() {}); | ||
} | ||
} | ||
} else { | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
const SnackBar( | ||
content: Text('Please check your internet connection and try again'), | ||
duration: Duration(seconds: 2), | ||
), | ||
); | ||
} | ||
}, | ||
child: Container( | ||
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8), | ||
width: double.maxFinite, | ||
decoration: BoxDecoration( | ||
color: Colors.grey.shade900, | ||
borderRadius: BorderRadius.circular(12.0), | ||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
'📅 Day Summary ~ ${dateTimeFormat('MMM, dd', DateTime.now())}', | ||
style: TextStyle( | ||
fontSize: 18, | ||
fontWeight: FontWeight.w500, | ||
color: Colors.grey.shade300, | ||
decoration: TextDecoration.underline, | ||
), | ||
), | ||
const SizedBox(height: 16), | ||
SelectionArea( | ||
child: showTypingIndicator | ||
? const Row( | ||
mainAxisSize: MainAxisSize.min, | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
children: [ | ||
TypingIndicator(), | ||
], | ||
) | ||
: daySummaryMessagesList(messageText), | ||
), | ||
], | ||
); | ||
} | ||
|
||
Widget daySummaryMessagesList(String text) { | ||
var sentences = text.split('. '); | ||
return ListView.builder( | ||
shrinkWrap: true, | ||
itemCount: sentences.length, | ||
itemBuilder: (context, index) { | ||
return ListTile( | ||
visualDensity: const VisualDensity(horizontal: 0, vertical: -1), | ||
contentPadding: EdgeInsets.zero, | ||
horizontalTitleGap: 10, | ||
minLeadingWidth: 2, | ||
leading: Icon(Icons.circle, size: 8, color: Colors.grey.shade300), | ||
title: AutoSizeText( | ||
sentences[index], | ||
// : utf8.decode(widget.message.text.codeUnits), | ||
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w500, color: Colors.grey.shade300), | ||
softWrap: true, | ||
), | ||
); | ||
}, | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line 184, you are using DateTime.now()
which will always give you the current date when the widget is built. If the widget is kept in the widget tree and not rebuilt for a while (which can happen), the displayed date might be outdated. Consider passing the date as a parameter to the widget or use a state management solution to keep it updated.
Expanded( | ||
child: Text( | ||
'${tryDecodeText(data.$2.structured.emoji)} ${data.$2.structured.title}', | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
maxLines: 1, | ||
overflow: TextOverflow.ellipsis, | ||
), | ||
), | ||
const SizedBox(width: 8), | ||
memoryDetailLoading[data.$1] | ||
? const SizedBox( | ||
height: 24, | ||
width: 24, | ||
child: CircularProgressIndicator( | ||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white), | ||
)) | ||
: const Icon(Icons.arrow_right_alt) | ||
], | ||
), | ||
); | ||
} else { | ||
if (memoryDetailLoading[data.$1]) return; | ||
setState(() => memoryDetailLoading[data.$1] = true); | ||
ServerMemory? m = await getMemoryById(data.$2.id); | ||
if (m == null) return; | ||
idx = memProvider.addMemoryWithDate(m); | ||
MixpanelManager().chatMessageMemoryClicked(m); | ||
setState(() => memoryDetailLoading[data.$1] = false); | ||
context.read<MemoryDetailProvider>().updateMemory(idx); | ||
await Navigator.of(context).push( | ||
MaterialPageRoute( | ||
builder: (c) => MemoryDetailPage( | ||
memory: m, | ||
), | ||
), | ||
); | ||
//TODO: Not needed anymore I guess because memories are stored in provider and read from there only | ||
if (SharedPreferencesUtil().modifiedMemoryDetails?.id == m.id) { | ||
ServerMemory modifiedDetails = SharedPreferencesUtil().modifiedMemoryDetails!; | ||
widget.updateMemory(SharedPreferencesUtil().modifiedMemoryDetails!); | ||
var copy = List<MessageMemory>.from(widget.messageMemories); | ||
copy[data.$1] = MessageMemory( | ||
modifiedDetails.id, | ||
modifiedDetails.createdAt, | ||
MessageMemoryStructured( | ||
modifiedDetails.structured.title, | ||
modifiedDetails.structured.emoji, | ||
)); | ||
widget.messageMemories.clear(); | ||
widget.messageMemories.addAll(copy); | ||
SharedPreferencesUtil().modifiedMemoryDetails = null; | ||
setState(() {}); | ||
} | ||
} | ||
} else { | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
const SnackBar( | ||
content: Text('Please check your internet connection and try again'), | ||
duration: Duration(seconds: 2), | ||
), | ||
), | ||
], | ||
], | ||
], | ||
); | ||
} | ||
}, | ||
child: Container( | ||
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8), | ||
width: double.maxFinite, | ||
decoration: BoxDecoration( | ||
color: Colors.grey.shade900, | ||
borderRadius: BorderRadius.circular(12.0), | ||
), | ||
child: Row( | ||
children: [ | ||
Expanded( | ||
child: Text( | ||
'${tryDecodeText(data.$2.structured.emoji)} ${data.$2.structured.title}', | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
maxLines: 1, | ||
overflow: TextOverflow.ellipsis, | ||
), | ||
), | ||
const SizedBox(width: 8), | ||
memoryDetailLoading[data.$1] | ||
? const SizedBox( | ||
height: 24, | ||
width: 24, | ||
child: CircularProgressIndicator( | ||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white), | ||
)) | ||
: const Icon(Icons.arrow_right_alt) | ||
], | ||
), | ||
), | ||
), | ||
), | ||
), | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary by Entelligence.AI
I'm sorry, but I can't generate the release notes as you requested because the variable
$raw_summary
you provided doesn't contain any actual data. It seems like a placeholder. Could you please provide the actual summary of changes? This will help me understand what modifications were made in the codebase and accordingly, I can craft appropriate release notes.