Skip to content

feat: Theater route — A2UI message-stream playback (native @a2ui/angular) - #130

Closed
jerelvelarde wants to merge 12 commits into
a2ui-project:mainfrom
jerelvelarde:jerel/pr-theater
Closed

jerelvelarde wants to merge 12 commits into
a2ui-project:mainfrom
jerelvelarde:jerel/pr-theater

Conversation

@jerelvelarde

@jerelvelarde jerelvelarde commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

A "theater" that replays a recorded A2UI message stream into a live native surface, message by message — useful for demoing and debugging how a surface builds up over a generation.

Depends on #121 (Custom Catalog). This branch is stacked on #121, so the foundation commits appear in this diff until #121 merges. The Theater-specific changes are the last 4 commits: theater/** plus the /theater route + nav entry.

What

  • /theater route with a playback component and a generation-based playback engine.
  • Recordings derived from the flight and sales example surfaces.
  • Renders natively via @a2ui/angular (no iframe); replays the message prefix as a batch so the native surface renders correctly at each step.

Why

Makes the incremental, message-by-message nature of A2UI surfaces visible — a useful lens for demos and for debugging streamed generations.

Testing

ng build (lint + AOT) green on a clean build; theater + composer-shell unit tests pass (25 specs).


Contributed by CopilotKit.

Screenshots

/theater — A2UI message-stream playback:

Light Dark

@google-cla

google-cla Bot commented Jul 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a 'Custom Catalog' page and a 'Theater' playback route to the shell application, allowing users to render assembled components natively and replay recorded A2UI message streams. It adds several custom catalog components (such as charts, tables, and cards) along with their respective schemas, styles, and tests. The review feedback focuses on improving robustness against invalid or malformed user-provided JSON inputs. Specifically, the reviewer recommends adding type checks and optional chaining in the data table, pie chart, bar chart, catalog editor, and theater inspector to prevent potential runtime crashes and TypeErrors when parsing or binding dynamic data.

Comment thread shell/src/app/theater/theater.ts Resolved
@github-actions

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

Your automated preview is successfully live (commit d00bd0e):
👉 Launch PR Preview

Note: This environment will be wiped automatically when the PR is merged or closed.

@jerelvelarde

Copy link
Copy Markdown
Contributor Author

Addressed the Gemini review — the catalog is driven by user-editable JSON in the Monaco editor, so these harden against malformed input:

  • Chart computeds guard with Array.isArray plus optional-chaining / Number(d?.value) || 0, so a non-array or non-object payload can't throw.
  • onEdit wraps JSON.parse in try/catch and rejects non-object / array payloads.
  • theater's currentData uses a typed cast plus a 'value' in update guard before reading.

@jerelvelarde

Copy link
Copy Markdown
Contributor Author

Went back through the Gemini review comments on this PR and resolved them — all five were already addressed in the current code:

  • bar-chart.ts / pie-chart.ts — unguarded property access on user-supplied array elements. Both computeds now use optional chaining with fallbacks: Number(d?.value) || 0 and String(d?.label ?? "").
  • data-table.ts — columns/rows possibly containing null entries. Cell access is guarded: row ? String(row[key] ?? "") : "".
  • custom-catalog.ts — onEdit casting a bare JSON.parse result. There is now an explicit root-shape check before the cast: a non-object, array, or null payload is ignored rather than passed to the binder.
  • theater.ts — unchecked cast of messages[i]["updateDataModel"]. Typed as optional and guarded with if (update && "value" in update).

One thing worth flagging that the bot did not catch here: bar-chart.ts on this branch lacks the negative-value clamp that the same component has in #129 (Math.max(0, ...)), so a negative value would still yield a negative bar height. I will reconcile the two when this branch is rebuilt on the renderer-served demo pattern.

Holding off on rebasing until the refactor stack lands, per our chat.

jerelvelarde and others added 12 commits August 28, 2026 05:15
Enables in-app (no-iframe) rendering of custom catalogs. Pin shell zod to
3.25.76 so app-authored catalog schemas share the exact zod instance the
@a2ui/web_core binder introspects (Angular's own zod 4 stays nested/isolated).
Validated end-to-end: a shell-authored custom Title resolves a {path} binding
via <a2ui-v09-surface>.
Port of the react-flight-catalog dashboard catalog to native @a2ui/angular
renderers (Row/Column/Title/Badge/Metric/DashboardCard/FlightCard/DataTable/
Button + hand-rolled SVG PieChart/BarChart), themed via --cpk-* tokens.
buildDashboardCatalog() registers all 11 into an AngularCatalog. Surface-render
tests green (children, chart shapes, path bindings, action dispatch).
Native /custom-catalog page: renders the Flight Card + Sales Dashboard trees
via <a2ui-v09-surface> (no iframe) from the 11-component dashboard catalog,
with an editable Monaco data-model panel. Example toggle + data-state tabs
(Morning/Afternoon, Q1-Q4); editing the JSON live-updates the surface via
updateDataModel. Surfaces are built once per example (createSurface+
updateComponents), so data changes push updateDataModel only. Nav item added
to Google's list; shell spec nav counts updated for the new route.
Transport (reset/step/play-pause), clickable message timeline, and an
Events/Data/Config inspector over a native @a2ui/angular surface.
The native renderer.processMessages needs createSurface + updateComponents in
one call (as the Assembled/Reference pages send); applying them incrementally
left the surface root empty. Each seek now replays [0,target) as one batch on
a fresh generation, creating the surface in the same tick the template switches
to its id (no mount-before-create gap). Also drops the v0.9 envelope's
top-level version field, which the native processor does not consume.
The composer-shell spec asserts a hardcoded number of aria-hidden
MatIcon elements. This branch adds two nav items and raised the count
from 5 to 7; main independently raised it from 5 to 6. The rebase kept
one increment, so bump it to 8 to match what renders.

Also runs prettier over sources that had never been formatted.
These pages are authored against the shell's --cpk-* design tokens, which
are introduced by a separate PR. On their own none of the tokens resolve,
so every padding, radius, font and colour collapsed and the page rendered
unstyled.

Add a small styles/_cpk-fallbacks.scss partial supplying light and dark
defaults under --cpk-fb-* names, and reference each token as
var(--cpk-x, var(--cpk-fb-x)). The real token always wins where it exists,
so nothing here shadows or overrides the theme; the fallbacks apply only
in its absence. Dark values are keyed off the existing .dark-theme class
via :host-context, so the standalone page themes correctly too.
@jerelvelarde

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and pushed. Verified locally: tsc, prettier, lint clean, full suite green, clean build.

Three things changed beyond the rebase:

  1. Decorative-icon count. composer-shell.spec.ts asserts a hardcoded number of aria-hidden mat-icon elements. main raised it for its new nav item and this branch had raised it for its own, so the rebase collapsed the two identical edits into one and the spec asserted fewer icons than actually render. Corrected. Worth deriving that count from the template at some point — it will catch anyone who adds a nav item on a branch.

  2. Formatting. Several files here had never been through prettier. yarn prettier over them, no logic touched.

  3. Standalone theming. This page is authored against the shell's --cpk-* design tokens, which the theme PR introduces. On its own none of them resolved, so every padding, radius and colour collapsed and the page rendered unstyled. Added styles/_cpk-fallbacks.scss with light and dark defaults under --cpk-fb-*, and each usage is now var(--cpk-x, var(--cpk-fb-x)). The real token always wins where it exists, so nothing shadows or overrides the theme.

Screenshots in the description have been retaken against this branch.

Note on ordering: this still looks best merged after the theme layer. The fallbacks are there so it reviews correctly on its own, not to replace the theme.

The screenshots here previously showed an un-played surface ("Press play…"). Retaken with the stream replayed to 6/6 so the description actually shows what Theater builds.

@jerelvelarde

Copy link
Copy Markdown
Contributor Author

Parking Theater until Composer has real session capture and an agreed playback workflow. The branch is preserved for reference. The current implementation replays bundled examples and carries the earlier native custom-catalog implementation; a future proposal should use captured sessions and the selected renderer/catalog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant