Skip to content

feat: Retrofit existing and add new advanced A2UI v0.9 basic catalog samples#941

Merged
gspencergoog merged 3 commits intogoogle:mainfrom
jacobsimionato:more-samples
Mar 24, 2026
Merged

feat: Retrofit existing and add new advanced A2UI v0.9 basic catalog samples#941
gspencergoog merged 3 commits intogoogle:mainfrom
jacobsimionato:more-samples

Conversation

@jacobsimionato
Copy link
Collaborator

@jacobsimionato jacobsimionato commented Mar 24, 2026

Description of Changes

This PR significantly enhances the test coverage and demonstrative power of the A2UI v0.9 basic catalog examples. It addresses the gap where previously all examples were completely static.

1. Retrofitted Existing Samples:
11 existing examples have been refactored to natively utilize advanced protocol features without altering their overall look or core purpose.

  • Dynamic Templating (ChildList): Refactored hardcoded lists into ChildList object templates mapping over data model arrays in 03_calendar-day, 04_weather-current, 12_chat-message, 13_coffee-order, 18_track-list, and 21_shipping-status.
  • Client-side Formatting: Implemented formatCurrency, formatDate, formatNumber, and formatString across various samples to format raw data instead of hardcoding strings (e.g. 01, 05, 08, 11, 13, 15, 16, 17, 18, 19, 23, 24, 26, 27, 28).
  • Localization: Implemented pluralize in 05_product-card and 24_recipe-card for review counts.
  • Validation & Logic: Added checks constraints to input fields in 09_login-form and implemented a logical and to the submit button to ensure valid input.
  • Advanced Components Introduced:
    • AudioPlayer (replaced basic play button in 26_podcast-episode).
    • Modal and Video (added a trailer modal to 29_movie-card).
    • Tabs (wrapped content in 24_recipe-card).
    • ChoicePicker (replaced static billing text in 19_software-purchase).
    • CheckBox and DateTimeInput (added to 07_task-card).

2. Created New Advanced Samples:
Added 4 new high-fidelity samples designed to stress-test complex A2UI renderer behaviors.

  • 30_live-invitation-builder.json: Demonstrates reactive two-way data binding (editor fields instantly updating a live preview without a server roundtrip).
  • 31_incremental-dashboard.json: Demonstrates progressive structural updates (updateComponents replacing placeholder loading nodes with real components).
  • 32_advanced-form-validator.json: Stress-tests deeply nested formatString calls and complex checks logic (e.g., or(and(...), and(...))).
  • 33_financial-data-grid.json: Tests layout engine constraints, specifically weight and align within nested List templated rows.

Rationale

The v0.9 specification introduces powerful dynamic features (templating, client-side functions, validation) that were completely unexercised by the initial set of 29 static examples. To ensure new renderer implementations correctly handle these advanced features, we need a robust, representative set of JSON payloads that accurately model real-world, living UIs.

Testing/Running Instructions

All updated and new examples have been verified against the protocol schema. Reviewers can verify this locally:

  1. Ensure you have python installed.
  2. Run the validation script: python3 specification/scripts/validate.py
  3. Confirm that all tests under === Validating v0_9 === print [PASS] and the script exits with Overall Validation: PASSED.

Fixed #940

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 is a significant and valuable enhancement to the A2UI v0.9 examples. Retrofitting existing static samples to use dynamic features like templating, formatting, and validation, along with adding new advanced examples, greatly improves the test coverage and demonstrative power of the specification. The changes are well-structured and effectively showcase the new capabilities. My review identified a few areas for improvement: a logic bug in a form validation example, a visual regression in a refactored list, and an accessibility concern with a checkbox component. Addressing these points will further strengthen the quality of these important examples.

Comment on lines +133 to +156
"condition": {
"call": "and",
"args": {
"values": [
{
"call": "email",
"args": {
"value": {
"path": "/email"
}
}
},
{
"call": "length",
"args": {
"value": {
"path": "/password"
},
"min": 8
}
}
]
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The validation check on the login-btn is incomplete. It only validates the email format and password length, but omits the required check that is present on the individual fields. This can lead to an inconsistent UI state where the button is enabled even if a field is empty (assuming email('') is considered valid), while that field simultaneously displays a "required" error. To ensure the button is only enabled when the form is fully valid, the and condition should also include the required check for the email field.

                "condition": {
                  "call": "and",
                  "args": {
                    "values": [
                      {
                        "call": "required",
                        "args": {
                          "value": {
                            "path": "/email"
                          }
                        }
                      },
                      {
                        "call": "email",
                        "args": {
                          "value": {
                            "path": "/email"
                          }
                        }
                      },
                      {
                        "call": "length",
                        "args": {
                          "value": {
                            "path": "/password"
                          },
                          "min": 8
                        }
                      }
                    ]
                  }
                }

Comment on lines +34 to +39
"id": "status-checkbox",
"component": "CheckBox",
"label": "",
"value": {
"path": "/completed"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The status-checkbox has an empty label. This is problematic for accessibility, as screen readers won't have a description for the checkbox. A label is required to make the UI understandable for users of assistive technologies. Consider redesigning this part of the example. For instance, if the CheckBox component's label is intended to be the primary text, you could bind the task's title to the label property and adjust the layout accordingly.

Comment on lines +91 to +96
"id": "step-text",
"component": "Text",
"text": "Delivered",
"variant": "caption"
"text": {
"path": "label"
},
"variant": "body"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The refactoring to use a single template for all shipping steps has resulted in a loss of visual hierarchy. Previously, the current step was emphasized with an h4 variant, and future steps were de-emphasized. Now, all steps use the body variant, making them visually indistinct. This alters the "overall look" of the example. To preserve the intended visual distinction, you might need to consider a different structure, for example by using separate templates for past, current, and future steps, especially if the specification does not support dynamic variants on the Text component.

@gspencergoog gspencergoog merged commit cd7f8b8 into google:main Mar 24, 2026
13 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in A2UI Mar 24, 2026
wrenj pushed a commit to wrenj/A2UI that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Implement A2UI v0.9 basic catalog sample improvements and additions

2 participants