Skip to content

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

Open
shahabl wants to merge 4 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 4 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
Comment thread docs/guides/authoring-components.md Outdated
Add a '### Angular renderer' subheading so that the registration
section has a symmetric three-subsection structure as suggested by
@ditman. The Lit subsections are promoted from level-4 (####) to
level-3 (###) to match, and the section heading is updated to the
plural 'Renderers'. A one-sentence intro is added to the section.
Copy link
Copy Markdown
Collaborator

@ditman ditman left a comment

Choose a reason for hiding this comment

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

This is looking great! Can you extend the Lit v0.9 a little bit to demonstrate how the message processor is used? Also other small comments.

Thanks again for your contribution!

Comment on lines +212 to +213
// 3. Register it with the MessageProcessor alongside any other catalogs you support
const processor = new MessageProcessor<LitComponentApi>([basicCatalog, myCatalog]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you add a "4." illustrating how the "processor" is used? I think that's the final piece of the puzzle.


### Lit v0.9 (recommended)

With `@a2ui/lit/v0_9`, catalog registration is handled at the protocol level. Define a `Catalog` object with your components and pass it to the `MessageProcessor`. When the agent sends a `createSurface` message with a matching `catalogId`, the processor automatically resolves and binds your catalog — no client-side flags required.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

... no client-side flags required.

I think that bit was referencing the v0.8 "enableCustomElement", but now that this shows up earlier in the document I think it doesn't make sense.


The `A2uiSurface` element in v0.9 receives a fully-resolved `SurfaceModel` (with catalog already bound), so custom components render automatically alongside standard ones.

### Lit v0.8 (legacy)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm tempted to use the "tabs" widget that we have to hide the Lit v0.8 behind a tab, like we do here:

## Message Types
=== "v0.8 (Stable)"
Version 0.8 uses the following message types:
- **`surfaceUpdate`**: Define or update UI components
- **`dataModelUpdate`**: Update application state
- **`beginRendering`**: Signal the client to render
- **`deleteSurface`**: Remove a UI surface
=== "v0.9 (Draft)"
Version 0.9 uses the following message types:
- **`createSurface`**: Create a new surface and specify its catalog
- **`updateComponents`**: Add or update UI components in a surface
- **`updateDataModel`**: Update application state
- **`deleteSurface`**: Remove a UI surface
v0.9 separates surface creation from rendering — `createSurface` replaces both `beginRendering` and the implicit surface creation in `surfaceUpdate`. All messages include a `version` field.
(looks like this)

That way the page doesn't grow too tall, and you only see the things about the framework you care about; what do you think?

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