-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: sse handler & store messages #53
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
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
Introduces a TypeScript SSE client using fetch and ReadableStream, supporting custom headers, auto-reconnect, connection state tracking, and type-safe event handling. Includes usage example and comprehensive API for managing SSE connections.
Updated usage of useParams to leverage typed route parameters in agent and stock components. Refactored agentData to use a typed Record for improved type safety. Added .react-router/types to tsconfig.json rootDirs and include for better type resolution. Added redirect in AgentConfig if agentId is missing.
Moved ScrollContainer to a dedicated scroll directory and updated imports across multiple files. Added a new ScrollTextarea component for improved input handling in the chat interface. Enhanced the agent chat UI with a new background effect, updated header, and improved input card styling and logic.
Reworked the agent chat to support real-time streaming via SSE, modularized the chat background into its own component, and added a custom useSSE React hook for managing SSE connections. Updated types and constants for agent events, message, and component handling. Improved chat UI to display streaming, tool calls, reasoning, and error states.
Unified SSE event handling to use a single onData callback with a typed SSEData wrapper. Refactored agent event types for clarity and type safety, updated chat message structure, and simplified component and tool call rendering logic. Improves maintainability and extensibility for agent chat and SSE integration.
Replaces useRef-based client management in useSSE with useMemo and explicit state tracking via useState. Removes unused onReconnect handler from SSEEventHandlers. This improves reliability of state updates and simplifies client lifecycle management.
Refactored SSE client and hook to remove generic event typing and simplify handler signatures. Updated agent types for improved clarity and reduced repetition. Added agent-store.ts to manage agent conversation state and event handling.
Replaces manual immutable update logic in agent-store.ts with mutative for concise state updates. Refactors event handling to a handler map, reducing code complexity and improving maintainability. Updates agent.ts types to split tool call messages and add explicit plan/task failure message types. Adds mutative dependency to package.json.
Replaces local chat message state with a centralized agent conversations store for improved state management and scalability. Updates message rendering logic to handle different message types based on payload structure. Adjusts types to support role in message_chunk events.
Refactored chat message rendering by introducing a memoized MessageItem component for improved performance. Switched agent store state management from useState to useReducer for more efficient updates. Cleaned up message rendering logic and centralized message type handling.
Extracted the chat message rendering logic into a new memoized ChatMessage component for improved modularity and performance. Removed user input required state and related logic from AgentChat, simplifying the message flow. Updated @React-router dependencies to version 7.9.1 in package.json and bun.lock.
Replaces conversation/thread state with refs in AgentChat, updates SSE event handling to support thread_started, and improves rendering for multiple threads. Simplifies useSSE hook API, removes unnecessary memoization, and updates SSEClient to better handle options, headers, and connection lifecycle. Adds thread_started event type to agent types.
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.
No description provided.