Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive and well-architected SwiftUI renderer for A2UI. The use of modern SwiftUI features like @Observable and the Layout protocol is excellent, and the extensive test suite provides great coverage. I've identified a few critical issues related to error handling where errors are silently ignored, which could make debugging difficult. I've also suggested refactoring a particularly complex function to improve its maintainability and efficiency. Addressing these points will significantly enhance the robustness of the new renderer. Additionally, please note that the PR description template should be filled out as per the repository's contributing guidelines.
renderers/swiftui/Sources/A2UISwiftUI/Models/ComponentTypes.swift
Outdated
Show resolved
Hide resolved
renderers/swiftui/Sources/A2UISwiftUI/Processing/SurfaceViewModel.swift
Outdated
Show resolved
Hide resolved
f3e04e6 to
73f0426
Compare
0193e32 to
1a2ea60
Compare
71513e2 to
ed589dc
Compare
28fda9e to
0ba163b
Compare
fe53e0e to
02a0ac3
Compare
a631c11 to
dd7c657
Compare
…mpliance across all platforms
dd7c657 to
29ed936
Compare
|
Hi @jacobsimionato @ava-cassiopeia — this PR implements a complete v0.8 SwiftUI renderer (18 components, data binding, JSONL streaming, multi-surface, demo app with live A2A agent). All automated review Two questions:
|
Description
Native SwiftUI renderer for the A2UI protocol, enabling all Apple platforms to render agent-generated UI from A2UI JSON payloads into native SwiftUI views.
Resolves #680.
Spec v0.8 Compliance
This renderer fully implements the A2UI spec v0.8, covering all protocol messages and component types:
beginRendering,surfaceUpdate,dataModelUpdate,deleteSurface(+ v0.9createSurface/updateComponentsforward-compat)/items/0/name), bracket/dot normalization, template rendering, literal seedingformatString,formatNumber,formatCurrency,formatDate,pluralize,openUrl,required,email,regex,length,numeric,and,or,notbeginRendering.stylesparsed intoA2UIStyle, overridable per-component via SwiftUI Environment18 Native Components — Platform-Adaptive via Apple HIG
All 18 standard components render using native SwiftUI controls only — no hardcoded spacing, colors, or corner radii. Each component adapts its appearance per platform rather than forcing a single mobile-style design across all devices.
Font+AccessibilityHeadingLevelAsyncImageusageHint-driven sizing (avatar→circle clip, header→full-width)Layout.borderedProminent/.borderedTextField/SecureField/TextEditortextFieldType-driven (number→.decimalPad, longText→TextEditor, obscured→SecureField)Toggle(.automaticstyle)SwiftUI.SliderProgressViewDatePickerNavigationLinklistPicker(.segmented)/ScrollViewbuttons.wheel.sheet+NavigationStack.presentationDetentson iOS/macOS; plain sheet on watchOS/tvOSAVPlayerViewControllerAVPlayerHStack/VStackdistributionlayout (spaceBetween/spaceEvenly/center/end)ScrollView+LazyVStack/LazyHStackdirectionswitches axisSwiftUI.Divider()Platforms:
iOS 17+·macOS 14+·tvOS 17+·watchOS 10+·visionOS 1+Every platform-specific decision is documented in
COMPONENT_DECISIONS.md.Custom Component Support
Third-party components can be registered via
CustomComponentRegistryand rendered inline alongside standard components:The demo app includes a Rizzcharts example with custom
Chart(Swift Charts doughnut) andGoogleMap(MapKit) components.Demo Application
The demo app (
samples/client/swiftui/) includes 10 pages covering both static JSON demos and live agent connections. Each demo page includes an info inspector explaining what it demonstrates, and action-triggering pages display a Resolved Action log showing the resolved context payload.Static Demos (no agent required)
formatDatecatalog function in action contextA2UIStyleoverriding default text/button/card appearanceChart+GoogleMapregistered viaCustomComponentRegistrysurfaceUpdatemessages arriving over timeLive Agent Demos (connects to repo's
samples/agent/adk/agents)component_gallery:10005contact_lookup:10003restaurant_finder:10002rizzcharts:10004The live agent pages include A2A Client with SSE streaming and agent card discovery (
/.well-known/agent-card.json).Unit Tests — 106 tests across 7 files
DataBindingTestsMessageDecodingTestsPrimitivesTestsMultipleChoiceLogicTestsCatalogFunctionTestsTextFieldValidationTestsValidationTests11 JSON fixtures in
Tests/A2UITests/TestData/for integration-level decoding tests.Project Structure
All files are new additions. No existing files on
google:mainwere modified.Pre-launch Checklist
If you need help, consider asking for advice on the discussion board.