Skip to content

Conversation

@lgh-solace
Copy link
Collaborator

@lgh-solace lgh-solace commented Nov 4, 2025

This pull request primarily refactors and improves the ChatProvider component in ChatProvider.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:

  • Updated the session switch logic to set the sessionId before 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:

  • Modified the deserializeTaskToMessages function to accept a targetSessionId parameter, ensuring that messages are always associated with the correct session, and updated all usages accordingly. [1] [2] [3]

Code Formatting and Readability:

  • Refactored several multi-line function calls and callback definitions to single-line or more concise forms, improving code readability and maintainability (e.g., artifact fetching, notification handling, artifact display state updates, and artifact status checks). [1] [2] [3] [4] [5]

Callback and Dependency List Cleanups:

  • Standardized callback definitions and dependency arrays for useCallback hooks, ensuring consistent formatting and reducing the risk of dependency-related bugs. [1] [2]

Minor Consistency Fixes:

  • Added trailing commas and minor formatting adjustments for object literals and function parameters to align with code style conventions.

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.

@github-actions
Copy link

github-actions bot commented Nov 4, 2025

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[] => {
Copy link
Collaborator Author

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([]);
Copy link
Collaborator Author

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,
Copy link
Collaborator Author

@lgh-solace lgh-solace Nov 4, 2025

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).

@lgh-solace lgh-solace changed the title fix(DATAGO-116434): session id passing and clearing messages fix(DATAGO-116434): session id passing and clearing messages. Nov 4, 2025
@sonarqube-solacecloud
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants