Skip to content

fix(shell): register active A2UI_CATALOG schema for catalog.json in MonacoEditor - #290

Merged
wrenj merged 1 commit into
mainfrom
fix/monaco-active-catalog-functions
Oct 22, 2026
Merged

wrenj merged 1 commit into
mainfrom
fix/monaco-active-catalog-functions

Conversation

@wrenj

@wrenj wrenj commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

MonacoEditor.buildValidationSchemas previously registered BASIC_CATALOG_SCHEMA under file:///catalog.json instead of the active A2UI_CATALOG JSON schema (this.catalogManagement.activeCatalog()). Because common_types.json#/$defs/FunctionCall resolves function calls via catalog.json#/$defs/anyFunction, any function defined on the active catalog (such as MCP catalog functions like callMcpTool and updateDataModel on the Material catalog) was rejected by the JSON editor validator.

Solution

  • Remove BASIC_CATALOG_SCHEMA from MonacoEditor and register structuredClone(catalog) (the active A2UI_CATALOG JSON schema from this.catalogManagement.activeCatalog()) for file:///catalog.json and https://a2ui.org/specification/v0_9/catalog.json, alongside COMMON_TYPES_SCHEMA for common_types.json.
  • Add unit test in monaco-editor.spec.ts verifying that buildValidationSchemas registers the active catalog schema under file:///catalog.json and https://a2ui.org/specification/v0_9/catalog.json.

@wrenj
wrenj requested a review from jgindin October 22, 2026 14:05

@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 updates the MonacoEditor component to resolve catalog.json function references against the active catalog when it declares functions, falling back to the basic catalog otherwise. It also adds corresponding unit tests. The feedback suggests simplifying the resolveFunctionCatalogSchema method by removing redundant nullish or undefined guard clauses on the catalog parameter, as it is already guaranteed to be non-nullish by the upstream caller, and updating the unit tests accordingly.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

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

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

@wrenj
wrenj force-pushed the fix/monaco-active-catalog-functions branch from ac5a75b to 5e78c87 Compare October 22, 2026 15:38
@wrenj
wrenj force-pushed the fix/monaco-active-catalog-functions branch from 5e78c87 to fb0e7e7 Compare October 22, 2026 16:04
@wrenj wrenj changed the title fix(shell): validate function calls against the active catalog's functions in the JSON editor fix(shell): register active A2UI_CATALOG schema for catalog.json in MonacoEditor Oct 22, 2026
@wrenj
wrenj merged commit 4da7969 into main Oct 22, 2026
15 checks passed
jerelvelarde added a commit to jerelvelarde/a2ui-composer that referenced this pull request Oct 30, 2026
Since a2ui-project#290, Composer validates the JSON editor against the active
renderer's catalog as `catalog.json`, and `common_types.json` refers to
`catalog.json#/$defs/anyFunction` for function calls. The Slack catalog
had no `$defs`, so the editor reported "$ref '/$defs/anyFunction' in
'file:///catalog.json' can not be resolved" on every Slack draft that the
JSON worker checked.

The catalog now defines `$defs.anyComponent`, referencing each component,
and `$defs.anyFunction`, a call to each of its functions shaped like the
basic catalog's entries. Its `functions` stays the inline catalog's list
that web_core's client capabilities produce, which a `$ref` can't address
by name, so `anyFunction` inlines the call schemas. A call to `openUrl`,
which the Slack catalog leaves out, no longer validates.
jgindin pushed a commit that referenced this pull request Nov 6, 2026
* Add Slack Block Kit authoring to Composer

Composer previews A2UI only in renderers that draw a web page, so an
author can't see what a surface becomes as a Slack message, or get the
Block Kit to send, until a Slack app posts it. This adds a Slack
renderer and the shared changes it needs.

- samples/react-slack-catalog is a renderer like the other samples. It
  sends a Slack catalog of 11 components over the bridge, lowers each
  A2UI surface to Channels UI nodes and draws them with renderBlockKit
  from @copilotkit/channels-slack. The preview draws the blocks the way
  Slack would, and Generated Block Kit exports the same blocks after
  validation. TextField and date-only DateTimeInput become native Slack
  inputs with writable bindings, and buttons dispatch their actions
  with the current values. Where Slack can't match A2UI, the preview
  approximates it and reports a diagnostic. The renderer runs on port
  3460, is built into the shell's samples and the GitHub Pages and PR
  preview deployments, and is configured as the "slack" profile.
- The assistant can switch renderers with a switchRenderer model tool
  that calls RendererSelection. A prompt makes at most two model
  requests, so the model can't keep cycling between renderers. Stopping
  the turn cancels a pending switch: it closes an open origin
  confirmation without allowing the origin and never commits the
  selection.
- The prompt's examples use the active catalog's ID, which the Slack
  renderer needs because it rejects any other catalogId. One
  getCatalogId() helper replaces the copies of that lookup. Icon
  guidance in the multimodal guidelines comes from the catalog's
  schema, so custom SVG is suggested only when Icon declares svgPath. A
  catalog whose Image.url pattern rejects data URLs gets an allowlist
  rule, in every prompt, limiting Image URLs to that pattern.
- The bridge asks again for the current renderer's catalog when the
  renderer is replaced while its catalog loads, unless a newer request
  is already answering the host.
- A renderer switch no longer resolves with the previous page's
  catalog: the catalog wait asks again only if the page was already
  showing the renderer when the switch began.
- Page-relative renderer URLs resolve against the document's base URI
  in one place, EnvironmentContextService.resolveRendererUrl(). The
  iframe URL (buildRendererUrl), StartupResolution, RendererSelection,
  QueryParser (?renderer= links) and HostCommunication's origin checks
  all use it, so the Slack profile's relative URL works at /composer/
  and in PR previews.
- The settings journeys serve this branch's Angular renderer rather
  than the GitHub Pages copy, which is built from main.

The sample uses @a2ui/web_core 0.10.7 like the other workspaces. Its
message processor checks component props against the catalog, so the
Slack lowering no longer repeats that check.

* fix(slack): define the catalog's anyComponent and anyFunction

Since #290, Composer validates the JSON editor against the active
renderer's catalog as `catalog.json`, and `common_types.json` refers to
`catalog.json#/$defs/anyFunction` for function calls. The Slack catalog
had no `$defs`, so the editor reported "$ref '/$defs/anyFunction' in
'file:///catalog.json' can not be resolved" on every Slack draft that the
JSON worker checked.

The catalog now defines `$defs.anyComponent`, referencing each component,
and `$defs.anyFunction`, a call to each of its functions shaped like the
basic catalog's entries. Its `functions` stays the inline catalog's list
that web_core's client capabilities produce, which a `$ref` can't address
by name, so `anyFunction` inlines the call schemas. A call to `openUrl`,
which the Slack catalog leaves out, no longer validates.

* Trim the Slack sample's dependencies

- Stop installing Storybook. The preview uses only the Renderer
  component of @tightknitai/storybook-addon-slack-block-kit, which
  doesn't import Storybook; .yarnrc.yml marks the addon's Storybook
  peer as optional instead. The lockfile loses about 1,000 lines.
- Pin @slack/types to 2.22.0, the version @copilotkit/channels-slack
  resolves, so the lockfile holds one copy.
- Run the sample with plain `vite`; its config already sets port 3460.
- Add re2js 2.8.7, the bridge's version, to the shell for checking
  catalog patterns.
- Say in tsconfig.json why the sample keeps skipLibCheck: two
  dependencies' typings don't compile in a browser-only project.

* Keep the conversation intact when the assistant switches renderers

- While a response streams, StateSync no longer adds a canvas change to
  the conversation. The only change possible then is a reset to the
  renderer's sample, which used to land after the model turn: the
  CopilotKit panel stopped showing the turn as streaming, and the next
  prompt sent the sample as the current canvas.
- A renderer switch the model asks for keeps an edited canvas, as a
  switch the user makes does, so a second request that fails or is
  stopped doesn't lose it. An unedited sample is replaced, and the
  second request is sent without the previous renderer's sample.
- Renderer URLs are compared after resolving them, so a switch to the
  renderer a ?renderer= link already loaded isn't counted as a change.
  The expected URL stays set until the coordinator sees the preview
  switch to it.
- The renderer tool isn't offered when there's no other renderer, and
  names the renderer the preview shows.
- A switch cancelled by Stop no longer leaves "Cancelled" under the
  renderer menu.
- The model turn is cleared after a switch, so a failed second request
  doesn't leave the first request's text showing.
- Remove five tests that repeated main's.

* Harden renderer links, catalog prompts and catalog replies

- ?renderer= accepts a URL with a scheme or a path containing "/". An
  empty value or a single word is rejected, with a hint to use
  rendererId, instead of becoming a same-origin custom renderer.
- A catalog's Image.url pattern is checked with re2js, capped at 256
  characters and one line. The pattern and the catalog ID enter the
  system prompt as JSON strings, with backticks escaped.
- findPropertySchema searches only schema keywords that declare
  properties and follows local $defs refs. An Icon that takes only
  listed names is told to use them and not to draw SVG.
- Catalog.functions may be a list, as v0.9 inline catalogs send it;
  catalogDeclaresFunction reads both shapes.
- The bridge answers a GET_CATALOG left unanswered when a renderer
  detached before its replacement attached, instead of waiting for the
  host's watchdog.
- LlmToolDefinition's JSDoc says what the type is.

* Tighten the Slack catalog, inputs and diagnostics

- String props publish common_types.json's DynamicString, so a function
  call must name a catalog function that returns a string. anyFunction
  now accepts bound and computed arguments.
- Button is a SlackButtonApi: action is required, the Checkable fields
  are gone, and variant is default or primary.
- One HTTP(S) rule (http-url.ts) serves Image and MarketSnapshot.
  MarketSnapshot sources are checked when drawn, with their own codes,
  and written as Slack <url|text> links.
- A single-line input turns pasted line breaks into spaces.
- Input lowering throws LoweringError with the component ID and a
  specific code. LoweringError takes an options object.
- Action failures are session diagnostics, so the preview shows one
  diagnostics list, and repeated failures aren't duplicated.
- The Vite server listens on localhost, as the other samples do.
- Add useSlackInputBridge tests; catalog tests load web_core's
  common_types.json.

* Wait for the render an edit causes in Slack journeys

- replaceMonacoJson waits for a render reported after the paste, and
  opening Generated Block Kit waits for the resize it causes, before
  waiting for a quiet preview.
- The renderer-menu journeys wait for focus inside the menu before
  pressing Escape, and both check focus returns to the pill.
- Restore two SettingsService tests this branch had dropped.
- Use the full license header, collect unexpected errors in the cursor
  journey, and post to the preview's origin instead of '*'.
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.

2 participants