Skip to content

docs: add Lit custom component registration guide for v0.9 and v0.8#1428

Open
shahabl wants to merge 3 commits into
google:mainfrom
shahabl:docs/surface-enable-custom-elements-lit
Open

docs: add Lit custom component registration guide for v0.9 and v0.8#1428
shahabl wants to merge 3 commits into
google:mainfrom
shahabl:docs/surface-enable-custom-elements-lit

Conversation

@shahabl
Copy link
Copy Markdown

@shahabl shahabl commented May 13, 2026

Adds documentation for registering custom components with the @a2ui/lit
renderer, covering both protocol versions. This addresses a gap noted in
#506 — the original PR was
closed because its docs targeted a file that no longer exists in the
updated structure.
The new section is added to docs/guides/authoring-components.md under
step 3 (Registering with the Renderer), as a Lit-specific counterpart to
the existing Angular example.
v0.9 (primary path): Define a Catalog with a Zod schema, pass it
to MessageProcessor alongside other supported catalogs, and let the
agent select it via createSurface.catalogId. No client-side flags
needed.
v0.8 (legacy): Register components in componentRegistry, then set
enableCustomElements = true on the <a2ui-surface> element before
assigning surface and processor. Without this flag the components
silently don't render even if correctly registered — a footgun worth
calling out explicitly.

Pre-launch Checklist

Document how to register custom components with the Lit renderer in
both protocol versions. The v0.9 path (Catalog + MessageProcessor +
catalogId) is documented as the primary approach. The v0.8 path
(componentRegistry + enableCustomElements) is documented as legacy.

The enableCustomElements property on Surface was easy to discover
as a footgun — custom components silently don't render if the flag
is not set before the surface/processor properties.
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 updates the 'authoring-components.md' guide to include instructions for registering components with the Lit Renderer, covering both the recommended v0.9 protocol and the legacy v0.8 protocol. The review feedback suggests several improvements to the documentation's code snippets, including removing an unused import and adding clarifying comments for variables that are referenced but not defined within the examples.

Comment thread docs/guides/authoring-components.md Outdated
Comment thread docs/guides/authoring-components.md
Comment thread docs/guides/authoring-components.md Outdated
Shahab Layeghi and others added 2 commits May 13, 2026 15:43
- Remove unused A2uiLitElement import from v0.9 snippet
- Add clarifying comment that MyChartElement is the user's Lit component class
- Add inline comments for surface and processor variables in v0.8 snippet
- **Lazy Loading**: Use `import()` to lazy-load the component code.
- **Input Bindings**: Use `inputBinding` to map properties from the schema to Angular inputs.

### Registering with the Lit Renderer
Copy link
Copy Markdown
Collaborator

@ditman ditman May 15, 2026

Choose a reason for hiding this comment

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

Thanks for adding this!

I think the angular renderer needs a level-3 title as well so the structure ends up as:

## 3. Registering with the Renderers (Client)

... probably nothing here, or a short intro ...

### Angular renderer

... instructions for angular ...

### Lit v0.9

... instructions for lit 0.9...

### Lit v0.8 (legacy)

...

What do you think @zeroasterisk?

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.

2 participants