Merged
Conversation
Added explicit type validation for agent_thinking and agent_decision message data in ReasoningFeed to prevent invalid data from being processed. This improves robustness against malformed WebSocket messages.
Add type checks for agent message handling
Added stricter checks for the presence and type of agent_id in agent_thinking WebSocket messages to prevent potential errors from malformed data.
Improve agent_thinking message validation
Update ReasoningFeed.tsx
Introduced stricter type checking and filtering for WebSocket message data in LatestNews, Leaderboard, and ReasoningFeed components. This improves robustness by ensuring only valid and expected data shapes are processed, reducing the risk of runtime errors from malformed messages. Also updated WebSocketMessage interface to use 'unknown' for the data property.
Add type guards for WebSocket message data
Improves data validation in Dashboard, Leaderboard, and ReasoningFeed components by adding stricter type checks for API responses before updating state. This prevents potential runtime errors from malformed or unexpected data structures returned by the backend.
Add robust type checks for API responses in frontend
Update ReasoningFeed.tsx
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
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 pull request focuses on improving type safety and data validation for WebSocket and API responses across several frontend components. The main changes ensure that data received from the backend is thoroughly checked before being used, which reduces the risk of runtime errors and makes the codebase more robust.
Type safety and data validation improvements:
Dashboard,Leaderboard, andLatestNewscomponents to ensure only well-formed data is processed and rendered. This includes checking the structure and types of objects and arrays before updating state. [1] [2] [3] [4]ReasoningFeed, including stricter checks on the shape and type of incoming data for both agent thinking and decision events. [1] [2]Type definition and import cleanup:
WebSocketMessageto useunknownfor thedataproperty and moved its definition to a shared module, updating imports and removing duplicate interface declarations in components. [1] [2] [3] [4]These changes collectively increase the reliability of frontend data handling and make the codebase easier to maintain.