Skip to content

feat: implement client data model synchronization#866

Open
jacobsimionato wants to merge 4 commits intogoogle:mainfrom
jacobsimionato:data-model-sync
Open

feat: implement client data model synchronization#866
jacobsimionato wants to merge 4 commits intogoogle:mainfrom
jacobsimionato:data-model-sync

Conversation

@jacobsimionato
Copy link
Collaborator

Description of Changes

This PR implements the Client Data Model Synchronization feature according to the A2UI v0.9 specification.

Key additions and modifications:

  • Schemas: Introduced client-to-server.ts to define Zod schemas for A2uiClientAction, A2uiClientError, and A2uiClientDataModel.
  • State Management: Updated SurfaceModel to accept the sendDataModel flag. Modified dispatchAction to construct a fully validated A2uiClientAction payload incorporating the sourceComponentId and an ISO 8601 timestamp.
  • Message Processing: Enhanced MessageProcessor to extract sendDataModel upon surface creation and implemented getClientDataModel() to aggregate data models for eligible surfaces.
  • Component Context: Adjusted ComponentContext so it properly passes its ID into dispatched actions.
  • Documentation: Reflected the new action payload format and data model synchronization workflow in renderer_guide.md.
  • Tests: Added test suites for the new schemas and expanded existing tests to cover data model aggregation and the updated action structures.

Rationale

To align the web core renderer with the A2UI v0.9 protocol requirements for client-to-server communication. Specifically, this ensures that the client can bundle its data model inside transport metadata whenever an action is triggered, and standardizes the structure of the action events dispatched back to the agent backend.

Testing/Running Instructions

  1. Check out the branch and navigate to renderers/web_core.
  2. Run npm install to ensure all dependencies are up to date.
  3. Run npm run build:tsc then node --test "dist/**/*.test.js" to run the test suite and confirm that all tests pass.
  4. Review the generated schemas and validation tests.

Fixes #864

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully implements the client data model synchronization feature as per the A2UI v0.9 specification. The changes are comprehensive, covering schema definitions, state management, message processing, and documentation updates. The new tests provide good coverage for the added functionality.

My review includes two main points of feedback:

  1. A high-severity suggestion to improve type safety in dispatchAction by validating the action payload before it's emitted. This will prevent potential runtime errors and ensure data integrity.
  2. A medium-severity suggestion to refactor the getClientDataModel method for better readability and simplicity.

Overall, this is a solid implementation that aligns the renderer with the new protocol requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Implement Client Data Model Synchronization in web_core v0.9 and Update Renderer Guide

2 participants