Skip to content

docs(v0.9): update renderer guide architecture and implementation details#812

Open
jacobsimionato wants to merge 2 commits intogoogle:mainfrom
jacobsimionato:guide-improvements
Open

docs(v0.9): update renderer guide architecture and implementation details#812
jacobsimionato wants to merge 2 commits intogoogle:mainfrom
jacobsimionato:guide-improvements

Conversation

@jacobsimionato
Copy link
Copy Markdown
Collaborator

This PR updates the v0.9 renderer_guide.md with expanded architecture and implementation details for renderer development.

Changes Included:

  • Data Layer Enhancements: Adds requirements for synchronous state support in declarative frameworks and clarifies the role of DataContext.
  • New Section: Catalog API & Bindings: Introduces a framework-agnostic layer to define catalogs, schemas, and dynamic value bindings, including examples of generic binders and binderless implementations.
  • Framework Binding Layer Updates: Clarifies that framework developers should use adapters instead of interacting with raw ComponentContext or ComponentBinding.
  • Agent Implementation Guide: Adds a new requirement (Step 8) for generating a comprehensive README.md that covers sample app usage, chat interface integration, catalog extension, and client logic (functions) implementation.

Copy link
Copy Markdown
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 significantly enhances the v0.9 renderer guide by adding detailed architecture and implementation guidance. The new sections on the Catalog API, Binder Layer, Gallery App, and Agent Implementation Guide are well-structured and provide crucial information for developers building A2UI renderers. My review focuses on ensuring consistency and clarity in the new documentation. I've identified a minor inconsistency in a code example and a case of redundant content that could be consolidated. Overall, these are excellent improvements to the documentation.

Note: Security Review has been skipped due to the limited scope of the PR.

Widget renderButton(ComponentContext context, Widget Function(String) buildChild) {
// Manually observe the dynamic value and manage the stream
return StreamBuilder(
stream: context.dataContext.observeDynamicValue(context.componentModel.properties['label']),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The method observeDynamicValue is used here, which is a reasonable name for a Dart/Flutter implementation that returns a Stream. However, the DataContext API described earlier in the guide and in the web_core implementation uses subscribeDynamicValue with a callback pattern. To prevent confusion for implementers, it would be beneficial to add a brief note clarifying that observeDynamicValue is an illustrative, framework-specific adaptation for reactive stream integration (like StreamBuilder).

Comment on lines +544 to +549
### Component Subscription Lifecycle Rules
To ensure performance and prevent memory leaks, framework adapters MUST strictly manage their subscriptions:
1. **Lazy Subscription**: Only bind and subscribe to data paths or property updates when the component is actually mounted/attached to the UI.
2. **Path Stability**: If a component's property changes via an `updateComponents` message, the adapter/binder MUST unsubscribe from the old path before subscribing to the new one.
3. **Destruction / Cleanup**: When a component is removed from the UI (e.g., via a `deleteSurface` message), the framework binding MUST hook into its native lifecycle to trigger `binding.dispose()`.
4. **Remount Resilience**: Many declarative frameworks (e.g., React Strict Mode, virtualized lists in mobile) frequently unmount and immediately remount UI components. The binding architecture should support re-establishing severed data subscriptions (e.g. using a connect/disconnect pattern) if a component is remounted after being disposed.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This new 'Component Subscription Lifecycle Rules' section is a great addition. It appears to supersede the existing 'Component Subscription Lifecycle' section found later in the document under 'Component Traits'. The new section is more comprehensive. To avoid redundancy and potential confusion, consider removing the older, less detailed section.

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.

1 participant