-
Notifications
You must be signed in to change notification settings - Fork 58
fix(DATAGO-116434): session id passing and clearing messages. #504
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
base: main
Are you sure you want to change the base?
Conversation
WhiteSource Policy Violation Summary✅︎ No Blocking Whitesource Policy Violations found in solaceai/solace-agent-mesh-ui-pr-504! |
| }, | ||
| [sessionId] | ||
| ); | ||
| const deserializeTaskToMessages = useCallback((task: { taskId: string; messageBubbles: any[]; taskMetadata?: any; createdTime: number }, targetSessionId: string): MessageFE[] => { |
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.
Passing in targetSessionId to avoid using a stale id.
| setSessionId(newSessionId); | ||
|
|
||
| // Clear messages IMMEDIATELY after updating sessionId | ||
| setMessages([]); |
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.
Moving this down.
| isError: bubble.isError, | ||
| metadata: { | ||
| messageId: bubble.id, | ||
| sessionId: targetSessionId, |
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.
Note: all the formatting changes here are due to my workspace settings - the functional changes are small (just passing the id and moving the clearing of messages).
|





This pull request primarily refactors and improves the
ChatProvidercomponent inChatProvider.tsx, focusing on session management, code clarity, and consistent state updates. The most significant changes ensure that session switching is more reliable, deserialization of messages is more robust, and code formatting is cleaner throughout the file.Session Management Improvements:
sessionIdbefore clearing messages, ensuring all dependent components/hooks receive the correct session context and preventing display of stale messages. The clearing of messages is now performed immediately after updating the session ID, and other session-related state is reset accordingly. [1] [2]Message Deserialization and State Consistency:
deserializeTaskToMessagesfunction to accept atargetSessionIdparameter, ensuring that messages are always associated with the correct session, and updated all usages accordingly. [1] [2] [3]Code Formatting and Readability:
Callback and Dependency List Cleanups:
useCallbackhooks, ensuring consistent formatting and reducing the risk of dependency-related bugs. [1] [2]Minor Consistency Fixes:
These changes collectively improve the robustness of session handling, reduce the risk of stale or inconsistent UI state, and make the codebase easier to read and maintain.