Add useAgUi hook for AG-UI protocol integration#83
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-party AG-UI protocol support to the library via a new useAgUi React hook, enabling <Chat> to connect to AG-UI-compatible agent endpoints over SSE without external AG-UI client dependencies.
Changes:
- Introduces
useAgUihook with session management, SSE parsing, streaming response updates, and tool-call callbacks. - Adds self-contained AG-UI protocol TypeScript types + public exports.
- Adds documentation and Storybook demos for basic usage and tool calls.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| stories/AgUi.stories.tsx | Adds Storybook demos showing useAgUi integration with <Chat> and tool calls. |
| src/useAgUi/useAgUi.ts | Implements the hook: session state, POST-to-agent run calls, SSE parsing, streaming updates, tool call handling. |
| src/useAgUi/types.ts | Defines AG-UI event/message/tool/input types and event type enum. |
| src/useAgUi/index.ts | Re-exports the hook and AG-UI types for public consumption. |
| src/useAgUi/README.md | Adds end-user docs and examples for integrating AG-UI endpoints. |
| src/index.ts | Exposes useAgUi module from the package root. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deploying reachat-storybook with
|
| Latest commit: |
7353b25
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8aebd563.reachat-storybook.pages.dev |
| Branch Preview URL: | https://claude-ag-ui-protocol-adapte.reachat-storybook.pages.dev |
Add a React hook that connects to any AG-UI protocol compatible agent endpoint and returns all the props needed for the reachat <Chat> component. - Implements SSE streaming parser for AG-UI events - Handles text message streaming (TEXT_MESSAGE_CONTENT/CHUNK) - Supports tool calls with onToolCall callback - Manages sessions/conversations state internally - Provides session CRUD (create, select, delete) - Supports abort/cancel via stopMessage - Zero external dependencies (no @ag-ui/client or RxJS needed) - Includes Storybook stories demonstrating usage https://claude.ai/code/session_015b5wa5VYLPgMqspBpffpSj
- Fix session timestamp: updateConversationInSession now updates the parent session's updatedAt during streaming - Complete AG-UI event types: add missing interfaces and union members for STATE_SNAPSHOT, STATE_DELTA, TOOL_CALL_CHUNK, and RAW events - Fix SSE parser buffer loss: process remaining buffer after stream ends so the last event isn't dropped if stream lacks a trailing newline - Align activeSessionId type: use string | undefined to match Chat component's prop type instead of string | null - Use AgUiRole type: role fields on text message events now use the AgUiRole union type instead of bare string - Add unmount cleanup: useEffect abort on unmount prevents state updates on unmounted components and stops background network requests - Surface parse failures: malformed SSE JSON is now reported via onError instead of being silently swallowed https://claude.ai/code/session_015b5wa5VYLPgMqspBpffpSj
RichTextInput.tsx imports directly from @floating-ui/dom, but it was only available as a transitive dependency of @floating-ui/react. The rollup-plugin-peer-deps-external plugin externalizes all dependencies, so Rollup couldn't resolve the bare @floating-ui/dom import. Adding it as a direct dependency fixes the build. https://claude.ai/code/session_015b5wa5VYLPgMqspBpffpSj
Use absolute positioning with dark:bg-gray-950 wrapper to match the layout pattern used by all other Console stories. The previous height: 80vh approach didn't work with Storybook's centered layout mode. https://claude.ai/code/session_015b5wa5VYLPgMqspBpffpSj
Apply flex: 1 + minHeight: 0 directly on the Chat component via its style prop and add overflow: hidden on the outer container. Removes the intermediate wrapper div so the Chat's h-full theme class resolves against the flex parent correctly, preventing the input bar from overflowing past the bottom edge. https://claude.ai/code/session_015b5wa5VYLPgMqspBpffpSj
bf2b6d8 to
c1e26ac
Compare
Contributor
|
@amcdnl - i rebased with master so that PR #79 from this morning wasn't lost. there was a pnpm lock file checked in alongside the package-lock so i removed it. also made a few changes - look at my commit, but here's a summary:
|
ebassity
approved these changes
Feb 12, 2026
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.
PR Checklist
PR Type
What is the current behavior?
Reachat did not have built-in support for connecting to AG-UI protocol-compatible agent endpoints. Users had to implement their own SSE parsing, session management, and state handling.
What is the new behavior?
This PR introduces
useAgUi, a React hook that provides complete AG-UI protocol integration with zero external dependencies. The hook:onToolCallcallback for custom tool implementationsThe hook returns all props needed for the
<Chat>component, making integration as simple as:Does this PR introduce a breaking change?
Other information
Files added:
src/useAgUi/useAgUi.ts- Main hook implementation with SSE parsing, session management, and event handlingsrc/useAgUi/types.ts- Self-contained AG-UI protocol type definitions (no external dependencies)src/useAgUi/index.ts- Public exportssrc/useAgUi/README.md- Comprehensive documentation with examplesstories/AgUi.stories.tsx- Storybook demos (basic and with tool calls)Files modified:
src/index.ts- Added exports for useAgUi and related typesKey features:
https://claude.ai/code/session_015b5wa5VYLPgMqspBpffpSj