-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: streamline Chat component and introduce useStreamingChat hook #141
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This update refactors the Chat component by removing unused state and logic, consolidating streaming functionality into a new custom hook, useStreamingChat. The new hook manages stream events, error handling, and user messages more efficiently, improving code readability and maintainability. Additionally, tests for the useStreamingChat hook have been added to ensure its functionality and reliability.
…nd response validation This update improves the test suite for the useStreamingChat hook by adding cases for handling empty and whitespace-only user messages, ensuring that the stream buffer behaves correctly under these conditions. Additionally, it introduces validation for timestamps in user messages and refactors mock response creation for better clarity and maintainability. These changes enhance the robustness of the tests and ensure comprehensive coverage of the hook's functionality.
…ge validation This update improves the test suite for the useStreamingChat hook by introducing type guards for stream events, enhancing type safety and readability. Additionally, it refactors error message handling to use constants for better maintainability and clarity. The tests now validate the correct behavior of the stream buffer under various conditions, ensuring comprehensive coverage of the hook's functionality.
…essage, and WebSearchMessage components This refactor enhances type safety by replacing the previous Message type with specific stream event types (AssistantStreamEvent, UserStreamEvent, ReasoningStreamEvent, and WebSearchStreamEvent) in the respective components. This change improves clarity and maintainability of the code, ensuring that each message component accurately reflects the structure of the data it handles. Additionally, the use of type guards in the useStreamingChat hook has been streamlined to support these updates.
…, and ReasoningMessage components This refactor improves type safety by introducing a new Message interface in BotMessage and UserMessage components, which extends the respective stream event types. The ReasoningMessage component has also been updated to use an interface that omits the 'type' property. These changes enhance clarity and maintainability, ensuring that message components accurately reflect the structure of the data they handle.
… input validation This update refines the test suite for the useStreamingChat hook by removing redundant type guards and adding comprehensive validation for various input scenarios, including empty and whitespace-only messages. It also enhances error handling by ensuring that appropriate console warnings and errors are logged for invalid inputs and malformed responses. These changes improve the robustness and clarity of the tests, ensuring thorough coverage of the hook's functionality.
This update improves the test suite for streaming functionality by removing unnecessary comments that clutter the code. It also enhances error handling in the tests, ensuring that errors during streaming are properly logged to the console. These changes contribute to cleaner, more maintainable tests while ensuring comprehensive coverage of the streaming logic.
✅ Deploy Preview for mcp-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ent code This refactor streamlines the message type definitions by moving the MessageStatus type to UserMessage and removing the unused MCPRequest and Message types from the client module. The changes enhance code clarity and maintainability by ensuring that only relevant types are retained, while also cleaning up the MCP client file to focus on its core functionality.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This update refactors the Chat component by removing unused state and logic, consolidating streaming functionality into a new custom hook,
useStreamingChat
. The new hook manages stream events, error handling, and user messages more efficiently, improving code readability and maintainability. Additionally, tests for the useStreamingChat hook have been added to ensure its functionality and reliability.Visually there are no changes.
Closes #87