fix: clear status.message after adding to history in TaskManager.updateWithMessage #424#425
Conversation
Summary of ChangesHello @flex-myeonghyeon, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where a task's status message was not being properly cleared after being moved into the task's history. The change ensures that the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in TaskManager.updateWithMessage where the message from the task's status was not being cleared after being moved to the history. The change correctly creates a new TaskStatus with a null message and updates the task. A new test case is also added to verify this behavior.
My review includes a couple of suggestions for improvement:
- In
TaskManager.java, I've pointed out a redundant null check that can be simplified. - In
TaskManagerTest.java, I've suggested a way to simplify the new test case to make it more readable and less confusing.
Overall, the fix is correct and the changes look good.
| @@ -105,11 +105,15 @@ public Event process(Event event) throws A2AServerException { | |||
|
|
|||
| public Task updateWithMessage(Message message, Task task) { | |||
| List<Message> history = task.getHistory() == null ? new ArrayList<>() : new ArrayList<>(task.getHistory()); | |||
There was a problem hiding this comment.
The null check for task.getHistory() is redundant. The Task constructor ensures that getHistory() will always return a non-null List (it defaults to an empty immutable list if history is null during construction). You can simplify this line.
| List<Message> history = task.getHistory() == null ? new ArrayList<>() : new ArrayList<>(task.getHistory()); | |
| List<Message> history = new ArrayList<>(task.getHistory()); |
| TaskManager taskManagerWithUpdateMessage = new TaskManager(saved.getId(), saved.getContextId(), taskStore, updateMessage); | ||
| Task retrieved = taskManagerWithUpdateMessage.getTask(); | ||
| Task updated = taskManagerWithUpdateMessage.updateWithMessage(updateMessage, retrieved); |
There was a problem hiding this comment.
The test logic can be simplified here. Creating a new TaskManager instance is unnecessary and makes the test harder to follow. The initialMessage passed to the new TaskManager is also misleading as it's not used. You can reuse the existing taskManagerWithInitialMessage and the saved task object to call updateWithMessage.
| TaskManager taskManagerWithUpdateMessage = new TaskManager(saved.getId(), saved.getContextId(), taskStore, updateMessage); | |
| Task retrieved = taskManagerWithUpdateMessage.getTask(); | |
| Task updated = taskManagerWithUpdateMessage.updateWithMessage(updateMessage, retrieved); | |
| Task updated = taskManagerWithInitialMessage.updateWithMessage(updateMessage, saved); |
ehsavoie
left a comment
There was a problem hiding this comment.
Please apply the small changes from gemini, otherwise looks good to me
|
@ehsavoie |
Description
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.Fixes #424 🦕