Skip to content

feat: add SwiftUI rendering support#706

Open
BBC6BAE9 wants to merge 7 commits intogoogle:mainfrom
BBC6BAE9:feat/swiftui-renderer
Open

feat: add SwiftUI rendering support#706
BBC6BAE9 wants to merge 7 commits intogoogle:mainfrom
BBC6BAE9:feat/swiftui-renderer

Conversation

@BBC6BAE9
Copy link

@BBC6BAE9 BBC6BAE9 commented Feb 24, 2026

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.

iOS iPadOS macOS visionOS watchOS tvOS

⚠️ Important:
The implementation can be compiled and rendered across all platforms. However, the UI and UX of the core components still need to be refined according to the Human Interface Guidelines.

  • Platforms: iOS 17+, macOS 14+, watchOS 10+, visionOS 1+tvOS 17+
  • Spec compatibility: Targeting v0.8, since all current Agent demos and web-core implementations are based on v0.8. Support for v0.9/v0.10 will follow as the project evolves.
  • All 18 standard components: Text, Image, Icon, Video, AudioPlayer, Row, Column, List, Card, Tabs, Divider, Modal, Button, TextField, CheckBox, DateTimeInput, ChoicePicker, Slider
  • All catalog functions: formatString, formatNumber, formatCurrency, formatDate, pluralize, openUrl, required, email, regex, length, numeric, and, or, not
  • 84 unit tests across 5 test files, 0 failures — core logic line coverage 74%
  • A2A Client with SSE streaming and agent card discovery
  • Custom component support via CustomComponentRegistry
Design area Approach
State management @Observable with per-key ObservableValue for fine-grained SwiftUI updates
List rendering LazyVStack/LazyHStack for scroll performance
Streaming AsyncThrowingStream-based JSONL parser
Styling Customizable via SwiftUI Environment (A2UIStyle)
Accessibility AccessibilityModifier applies labels/hints from component metadata

Test coverage (core logic modules)

Module                         Lines    Cover
SurfaceViewModel.swift           830    74.0%
CatalogFunctionEvaluator.swift   310    74.8%
Primitives.swift                 133    97.0%
JSONLStreamParser.swift          144    98.6%
ChecksEvaluator.swift            164    66.5%
SurfaceManager.swift              54    79.6%
AnyCodable.swift                  73    86.3%

View layer (SwiftUI components) is not unit-testable without a host app — covered by the demo app's 11 pages.

renderers/swift/              # Swift package (A2UI)
├── Sources/A2UI/             # Renderer library
├── Tests/A2UITests/          # 84 tests + 12 JSON fixtures
│   ├── MessageDecodingTests.swift      # Decoding, component parsing, JSONL, SurfaceManager
│   ├── DataBindingTests.swift          # Path resolution, templates, actions, incremental updates
│   ├── CatalogFunctionTests.swift      # Catalog functions, interpolation, date parsing
│   ├── ValidationTests.swift           # Checks: required, email, length, and/or/not
│   ├── PrimitivesTests.swift           # Codable round-trip for all value types
│   └── TestData/                       # 12 JSON fixtures
└── README.md
samples/client/swift/         # Demo app (11 pages incl. live A2A agent)
└── A2UIDemoApp/

All files are new additions. No existing files on google:main were modified.

Pre-launch Checklist

If you need help, consider asking for advice on the discussion board.

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 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.

@BBC6BAE9 BBC6BAE9 changed the title feat: swiftUI render feat: add SwiftUI rendering support Feb 24, 2026
@BBC6BAE9 BBC6BAE9 force-pushed the feat/swiftui-renderer branch 2 times, most recently from f3e04e6 to 73f0426 Compare February 24, 2026 19:16
@BBC6BAE9 BBC6BAE9 marked this pull request as draft February 25, 2026 09:26
@BBC6BAE9 BBC6BAE9 force-pushed the feat/swiftui-renderer branch 2 times, most recently from 0193e32 to 1a2ea60 Compare February 25, 2026 15:51
@BBC6BAE9 BBC6BAE9 marked this pull request as ready for review February 25, 2026 15:55
@BBC6BAE9 BBC6BAE9 marked this pull request as draft February 26, 2026 01:17
Implements a complete native SwiftUI renderer covering the full A2UI
protocol: JSONL stream parsing, surface management, data binding with
path resolution, template expansion, action handling, and all standard
component types.

Includes:
- ChecksEvaluator with validation engine (required, email, regex, etc.)
- CatalogFunctionEvaluator (formatString, formatNumber, formatCurrency, etc.)
- Custom component support with CustomComponentRegistry
- A2A networking client with SSE streaming
- Icon SVG path support, accessibility attributes
- RizzCharts demo (Swift Charts + MapKit)
- Demo app with catalog/samples/live-agent modes
- Full Apple platform support (iOS, macOS, tvOS, watchOS, visionOS)
- 71+ unit tests
@BBC6BAE9 BBC6BAE9 force-pushed the feat/swiftui-renderer branch from 71513e2 to ed589dc Compare February 27, 2026 01:56
@BBC6BAE9 BBC6BAE9 marked this pull request as ready for review February 27, 2026 01:57
@BBC6BAE9 BBC6BAE9 requested a review from yjbanov as a code owner February 27, 2026 01:57
- Rename renderers/swiftui/ → renderers/swift/, module A2UISwiftUI → A2UI
  to align with repo naming convention (angular, lit, flutter, swift)
- Move demo app to samples/client/swift/ matching repo convention
- Split tests into 5 focused files (84 tests, 74% core logic coverage)
- Extract shared helpers in A2AClient (buildJSONRPCBody, parseSSEStream)
- Fix README installation path and test count
@BBC6BAE9 BBC6BAE9 force-pushed the feat/swiftui-renderer branch from d9a3ef5 to 2a7a618 Compare February 27, 2026 08:32
Move data storage, path resolution, and read/write logic into a
dedicated DataStore class to reduce SurfaceViewModel from 968 to
785 lines. Thin delegation methods preserve the existing public API
so no call sites or tests require changes.
Align directory naming with framework convention (angular/, lit/, flutter/)
rather than language name. Update path references in Xcode project,
README, and docs. SPM module name A2UI remains unchanged.
@BBC6BAE9 BBC6BAE9 force-pushed the feat/swiftui-renderer branch from 28fda9e to 0ba163b Compare February 27, 2026 11:08
@BBC6BAE9
Copy link
Author

Hi @dmandar @gspencergoog @jacobsimionato @nan-yu @ditman @zeroasterisk @yjbanov — ready for review. Feedback welcome, happy to address any questions or concerns.

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.

Swift UI renderer

1 participant