Add initial React Renderer v0.9#827
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a prototype React renderer for A2UI, including the core rendering logic, a component library for the minimal catalog, and a gallery application for demonstration and testing. The implementation is well-structured and follows the provided design document, leveraging modern React features like useSyncExternalStore for reactivity. My review includes a few suggestions to improve type safety, package configuration, and test coverage.
|
/gemini review |
|
/gemini review |
|
/gemini review |
| case 'h5': | ||
| return <h5>{text}</h5>; | ||
| case 'caption': | ||
| return <small>{text}</small>; |
There was a problem hiding this comment.
There is technically a <caption> component, though it typically requires a way of referencing it from a figure or similar. Up to you if you want to use it here.
There was a problem hiding this comment.
I'll leave this for now - very keen to get the implementation in and refine the core APIs before polishing the catalog implementation.
| const context = useMemo( | ||
| () => new ComponentContext(surface, id, basePath), | ||
| [surface, id, basePath] | ||
| ); |
There was a problem hiding this comment.
+1, this is worth addressing.
Description
This PR introduces the initial implementation of the
@a2ui/reactpackage, providing a React-based renderer for the A2UI v0.9 protocol. It follows the Unified Architecture & Implementation Guide, leveraging@a2ui/web_corefor state management and data model resolution.Key Features
@a2ui/web_core/v0_9, using its signal-based state models andGenericBinder.useSyncExternalStorehooked into the core model's reactive streams.createReactComponentutility automatically resolves A2UIDynamicValuefields (likeDynamicString) into primitive JavaScript types and generatesset<Property>setters for two-way data binding.Minimalcatalog, includingText,Button,Row,Column, andTextField, along with a logic-basedcapitalizefunction.renderers/react/a2ui_explorer) for exploring samples, inspecting the live data model, and stepping through progressive message rendering.API Examples
Rendering a Surface
The
A2uiSurfaceis the entry point for rendering an A2UI interface.Creating Custom Components
New components can be created using
createReactComponent, which handles data-binding and schema validation automatically.Implemented Components (v0.9 Minimal)
Row,ColumnTextButton,TextFieldcapitalizeProgress & Roadmap