Skip to content

Lit Renderer v0.9#885

Open
ditman wants to merge 29 commits intogoogle:mainfrom
ditman:lit-renderer
Open

Lit Renderer v0.9#885
ditman wants to merge 29 commits intogoogle:mainfrom
ditman:lit-renderer

Conversation

@ditman
Copy link
Collaborator

@ditman ditman commented Mar 18, 2026

Description

Adds a Lit renderer for the v0.9 version of the protocol.

I cloned @jacobsimionato's #869 and polished it a little!

This iteration of the renderer is missing two big features compared to v0.8 (that will work on as fast-follows):

  • Proper Markdown rendering (integrate @a2ui/markdown-it)
  • CSS styling/theming

(And probably some proper formatting and better tooling).

Anyway, this should suffice as a starting point. Check out the demo:gallery09 Lit sample app to get this renderer to run. Other examples will be ported later.

Pre-launch Checklist

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

@gemini-code-assist

This comment was marked as outdated.

@ditman
Copy link
Collaborator Author

ditman commented Mar 21, 2026

OK, there's a version of the renderer that uses LitElements. Some things that I still obviously need:

  • Add tests
  • Move code around so imports from v0_9 make sense (and ensure that everything is imported consistently internally)
  • (Later) Integrate with @a2ui/markdown-it package
  • (Later) Add some configurable styling (CSS variables? classnames?)
  • (Even later) migrate some Lit samples to v0_9
  • ... And probably more stuff that I'm not aware of yet :)

/cc @jacobsimionato

Copy link
Collaborator

@jacobsimionato jacobsimionato left a comment

Choose a reason for hiding this comment

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

This looks great to me. I'm in favor of merging this soon and then iterating.

@jacobsimionato
Copy link
Collaborator

  • ... And probably more stuff that I'm not aware of yet :)

What about also deferring the markdown integration to later? Having this merged would mean that we can then make changes to the web core API without breaking your pending PR.

@ditman
Copy link
Collaborator Author

ditman commented Mar 23, 2026

  • ... And probably more stuff that I'm not aware of yet :)

What about also deferring the markdown integration to later? Having this merged would mean that we can then make changes to the web core API without breaking your pending PR.

Absolutely agree, the markdown integration should be super easy to add to the Text widget later.

render() {
if (!this.surface) return nothing;
if (!this._hasRoot) {
return html`<slot name="loading"><div>Loading surface...</div></slot>`;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are we using the "loading" slot elsewhere? Why is this a slot, but the error isn't?

jacobsimionato and others added 10 commits March 25, 2026 13:40
This prevents the DOM of the app to look like:

```
<a2ui-surface>
  <a2ui-node>
    <a2ui-column>
        <a2ui-node>
           <a2ui-row>
               <a2ui-node>
                   <a2ui-text>
                   ...
```
Use the stricter types in web_core to allow "props" type to be inferred. This enables  component programmers to have better type safety when accessing its component's controller.props (in the initial implementation this was always typed as "any")
ditman added 14 commits March 25, 2026 13:43
Now that Elements are real LitElements and we don't need to carry over the ChildBuilder functions around, we can simplify the LitComponentImplementation to only hold what we care about of a Lit component: its tag name!
This is the model to make every other element a true LitElement:

* Creates its own correctly typed controller (this allows strongly typed access to props)
* Exports a correct element definition (with tagName)
* Uses renderA2uiNode to render its children
* Recreates the controller when the context changes
Each component is refactored as a LitElement, following the same changes that were done to the Tabs component.
This method is used to hide all the complexity of rendering child items
in A2UI Lit elements from the catalog; it should make it much easier to
end users to create their own.
* Renamed catalog component files to match the class they contain.
* Made the v0_9/index.ts export *explicitly* what we want to be part of
  the public API.
* Updated catalog implementation with the latest imports, and format the
  files.
@ditman ditman requested a review from ava-cassiopeia March 26, 2026 03:04
@ditman ditman marked this pull request as ready for review March 26, 2026 03:08
@ditman
Copy link
Collaborator Author

ditman commented Mar 26, 2026

OK, this is it! PTAL @jacobsimionato, @ava-cassiopeia (anybody else who may want to look at this?)

Copy link
Collaborator

@jacobsimionato jacobsimionato left a comment

Choose a reason for hiding this comment

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

Looks great to me!

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