Repository navigation
Add Slack Block Kit authoring to Composer - #216
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new workspace package, react-slack-catalog, which serves as a credential-free React sample renderer for previewing A2UI surfaces as Slack Block Kit messages. It includes the core rendering and lowering logic, extensive unit and E2E tests, and integration into the main monorepo. The review feedback highlights several robustness improvements: adding defensive type guards in collectText to prevent runtime crashes on raw child nodes, using ActionSchema.safeParse in registerAction to gracefully handle incomplete actions during live editing, refactoring dispatchCurrentAction to safely catch synchronous errors, and appending the array index to React keys in SlackPreviewState to avoid key collisions.
| function collectText(nodes: ChannelNode[]): string { | ||
| return nodes | ||
| .flatMap(node => { | ||
| if (node.type === 'text' && typeof node.props.value === 'string') return [node.props.value]; | ||
| if (typeof node.props.children === 'string' || typeof node.props.children === 'number') { | ||
| return [String(node.props.children)]; | ||
| } | ||
| return Array.isArray(node.props.children) | ||
| ? [collectText(node.props.children as ChannelNode[])] | ||
| : []; | ||
| }) | ||
| .filter(Boolean) | ||
| .join(' '); | ||
| } |
There was a problem hiding this comment.
The collectText function recursively traverses node.props.children. However, if node.props.children contains raw strings or numbers, node in the recursive call will be a string or number. Accessing node.props or node.type on a non-object will throw a TypeError. Adding a defensive type guard to ensure node and node.props are valid objects before accessing their properties prevents runtime crashes.
function collectText(nodes: ChannelNode[]): string {
return nodes
.flatMap(node => {
if (!node || typeof node !== 'object') return [];
const props = node.props;
if (!props || typeof props !== 'object') return [];
if (node.type === 'text' && typeof props.value === 'string') return [props.value];
if (typeof props.children === 'string' || typeof props.children === 'number') {
return [String(props.children)];
}
return Array.isArray(props.children)
? [collectText(props.children as ChannelNode[])]
: [];
})
.filter(Boolean)
.join(' ');
}References
- When validating properties from untyped or external records, use a strict type guard before calling methods or accessing properties.
There was a problem hiding this comment.
Added the guard in 113b372, reusing the existing isChannelNode helper rather than inline checks, so collectText matches channelChildNodes a few lines up in the same file.
For accuracy: this is not reachable today. collectText only ever runs on renderToIR output, and expand() normalizes every child — raw strings and numbers become {type: "text", props: {value}} nodes before collectText sees them. The one path that preserves raw scalars is expandNativeValue, and the sample's only native node (createNativeNode('slack', 'raw', ...)) carries a value prop with no children.
Taking it as defense-in-depth: the parameter type is only as good as the as ChannelNode[] cast that feeds the recursion, so the guard is worth having. No test, since there is no way to reach it through the public API.
| function registerAction( | ||
| state: LoweringState, | ||
| surface: SurfaceModel, | ||
| componentId: string, | ||
| basePath: string, | ||
| rawAction: unknown, | ||
| ): string { | ||
| const parsedAction = ActionSchema.parse(rawAction) as Action; | ||
| const actionId = `a2ui-${state.revision}-${state.nextActionOrdinal}`; | ||
| state.nextActionOrdinal += 1; | ||
|
|
||
| const eventEntry = createEventActionDispatchEntry({ | ||
| actionId, | ||
| revision: state.revision, | ||
| surface, | ||
| sourceComponentId: componentId, | ||
| basePath, | ||
| action: parsedAction, | ||
| }); | ||
|
|
||
| state.actions.set( | ||
| actionId, | ||
| eventEntry ?? { | ||
| actionId, | ||
| revision: state.revision, | ||
| surface, | ||
| surfaceId: surface.id, | ||
| sourceComponentId: componentId, | ||
| basePath, | ||
| action: parsedAction, | ||
| }, | ||
| ); | ||
| return actionId; | ||
| } |
There was a problem hiding this comment.
During live editing, components might have incomplete action properties. Calling ActionSchema.parse(rawAction) directly will throw a ZodError and crash the preview. Using ActionSchema.safeParse allows the preview to degrade gracefully and ignore incomplete actions instead of crashing.
function registerAction(
state: LoweringState,
surface: SurfaceModel,
componentId: string,
basePath: string,
rawAction: unknown,
): string {
if (!rawAction) return '';
const parsedAction = ActionSchema.safeParse(rawAction);
if (!parsedAction.success) return '';
const actionId = `a2ui-${state.revision}-${state.nextActionOrdinal}`;
state.nextActionOrdinal += 1;
const eventEntry = createEventActionDispatchEntry({
actionId,
revision: state.revision,
surface,
sourceComponentId: componentId,
basePath,
action: parsedAction.data,
});
state.actions.set(
actionId,
eventEntry ?? {
actionId,
revision: state.revision,
surface,
surfaceId: surface.id,
sourceComponentId: componentId,
basePath,
action: parsedAction.data,
},
);
return actionId;
}References
- When validating properties from untyped or external records, use a strict type guard or safe parsing before proceeding.
There was a problem hiding this comment.
I switched to safeParse in 113b372, but not with this suggestion — two things in the premise do not hold here.
It does not crash the preview. rerender() already wraps the whole lowering pass in try/catch and converts any throw into an error diagnostic with status: 'error'. A ZodError is caught there today.
It cannot be reached. lowerComponent runs api.schema.safeParse(model.properties) before lowering, and ButtonApi.schema has action as a required union. A malformed action is rejected there first. Verified with a throwaway test — {action: {event: 42}} on a Button produces:
[{"level":"error","code":"A2UI_INVALID_PROPS",
"message":"Invalid props for A2UI component \"root\": ...",
"componentId":"root"}]
So registerAction never sees invalid input, and returning '' would not degrade gracefully — it would render a button wired to a dead action id with no diagnostic at all, which is the opposite of what the rest of this file does. Every other bad-input path here throws LoweringError(code, message, componentId).
What I did take is the underlying point that .parse is the wrong call. If the catalog schema and ActionSchema ever diverge, the old code surfaced an opaque ZodError as a generic A2UI_LOWERING_ERROR with no componentId. Now:
const parsed = ActionSchema.safeParse(rawAction);
if (!parsed.success) {
throw new LoweringError('A2UI_INVALID_ACTION', `...${issues}`, componentId);
}Same fail-loud behavior as the rest of the file, but the diagnostic names the component. No test, since the branch is unreachable behind A2UI_INVALID_PROPS.
| const dispatchCurrentAction = useCallback( | ||
| (actionId: string | undefined) => { | ||
| if (!actionId || !actionIds.has(actionId)) return; | ||
|
|
||
| setDispatchError(undefined); | ||
| void Promise.resolve(dispatch(actionId)).catch(error => { | ||
| setDispatchError({ | ||
| level: 'error', | ||
| code: 'SLACK_ACTION_DISPATCH_FAILED', | ||
| message: error instanceof Error ? error.message : String(error), | ||
| }); | ||
| }); | ||
| }, | ||
| [actionIds, dispatch], |
There was a problem hiding this comment.
In dispatchCurrentAction, Promise.resolve(dispatch(actionId)) is used to catch errors. However, if dispatch throws a synchronous error, it will execute before Promise.resolve wraps it, causing an unhandled exception. Refactoring dispatchCurrentAction to be an async function with a standard try/catch block ensures both synchronous and asynchronous errors are caught safely.
const dispatchCurrentAction = useCallback(
async (actionId: string | undefined) => {
if (!actionId || !actionIds.has(actionId)) return;
setDispatchError(undefined);
try {
await dispatch(actionId);
} catch (error) {
setDispatchError({
level: 'error',
code: 'SLACK_ACTION_DISPATCH_FAILED',
message: error instanceof Error ? error.message : String(error),
});
}
},
[actionIds, dispatch],
);
There was a problem hiding this comment.
Confirmed and fixed in 113b372. This one was a live bug: dispatch(actionId) is evaluated as the argument before Promise.resolve wraps it, so a synchronous throw escaped the React event handler entirely and never reached the diagnostics list.
I kept the callback synchronous instead of making it async, so the two call sites (handleNativeClick, handleInteraction) do not need void and the signature stays unchanged:
const reportDispatchFailure = (error: unknown) => { /* set diagnostic */ };
try {
void Promise.resolve(dispatch(actionId)).catch(reportDispatchFailure);
} catch (error) {
reportDispatchFailure(error);
}Covered by a new regression test, renders diagnostics when action dispatch throws synchronously. Verified red before the fix (the error escaped as unhandled and the diagnostics element was absent) and green after.
| {snapshot.diagnostics.map(diagnostic => ( | ||
| <li | ||
| key={`${snapshot.revision}-${diagnostic.level}-${diagnostic.code}-${ | ||
| diagnostic.componentId ?? '' | ||
| }`} | ||
| > | ||
| <strong>{diagnostic.level}</strong> <code>{diagnostic.code}</code>{' '} | ||
| {diagnostic.componentId ? <span>{diagnostic.componentId} </span> : null} | ||
| <span>{diagnostic.message}</span> | ||
| </li> | ||
| ))} |
There was a problem hiding this comment.
Using only the revision, level, code, and componentId as the React key can lead to key collisions if multiple diagnostics share the same properties within the same revision. Appending the array index to the key ensures uniqueness and prevents potential React rendering bugs.
| {snapshot.diagnostics.map(diagnostic => ( | |
| <li | |
| key={`${snapshot.revision}-${diagnostic.level}-${diagnostic.code}-${ | |
| diagnostic.componentId ?? '' | |
| }`} | |
| > | |
| <strong>{diagnostic.level}</strong> <code>{diagnostic.code}</code>{' '} | |
| {diagnostic.componentId ? <span>{diagnostic.componentId} </span> : null} | |
| <span>{diagnostic.message}</span> | |
| </li> | |
| ))} | |
| {snapshot.diagnostics.map((diagnostic, index) => ( | |
| <li | |
| key={`${snapshot.revision}-${diagnostic.level}-${diagnostic.code}-${ | |
| diagnostic.componentId ?? '' | |
| }-${index}`} | |
| > | |
| <strong>{diagnostic.level}</strong> <code>{diagnostic.code}</code>{' '} | |
| {diagnostic.componentId ? <span>{diagnostic.componentId} </span> : null} | |
| <span>{diagnostic.message}</span> | |
| </li> | |
| ))} |
There was a problem hiding this comment.
Added the index to the key in 113b372.
Worth noting it is not currently reachable: pushDiagnostic dedupes by code, and the direct diagnostics.push sites either carry a distinct componentId (SLACK_LAYOUT_FLATTENED) or run once per revision (SLACK_ACTION_REGISTRY_FILTERED). Taking it anyway — the key is a hand-rolled identity for a list with no natural id, and the index makes it correct by construction at zero cost.
0c750d1 to
113b372
Compare
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
8d68ee6 to
ee34f3c
Compare
ee34f3c to
b9a75e0
Compare
b9a75e0 to
dda6178
Compare
feebd24 to
82bccaf
Compare
|
Synced with main through the whole stack. Head is now
On this head, the full e2e suite passes all 17 Slack journeys. The only failures are the data-model test that also fails on unchanged main, and main's React shrink test, which is flaky there too. |
|
Synced with the latest main (
Full e2e on this head: 103 of 103, with no flaky retries. Formatting, lint, typechecks, the production build, and 2,041 unit tests pass. |
|
Synced with main ( I also fixed two more parallel-load races in the Slack journeys:
Full e2e: 103 pass. The one failure is main's custom-instructions journey, which fails the same way on unchanged main. |
5763306 to
5089b0f
Compare
|
Rebuilt on the independent #215, so the merge order is now just #215 → #216, with no dependency on #129. The branch is #215's commit plus one commit for this PR on |
|
|
||
| protected readonly rendererSelection = inject(RendererSelection); | ||
|
|
||
| protected readonly rendererLabel = computed(() => { |
There was a problem hiding this comment.
How can we abstract this such that we're not encoding any particular renderers?
We have others (there's an outstanding PR to add a renderer from TickTock) and also there are Google internal renderers. Having to maintain this list seems pretty fragile.
There was a problem hiding this comment.
Nothing encodes a particular renderer anymore:
- The pill labels each renderer with its configured
displayName, so there's no list of renderer IDs to maintain. That code lives in feat: pair Gemini + CopilotKit in the Composer assistant #215, so the change is there (1ac6882), and this PR builds on it. - The assistant's
switchRenderertool builds its choices and description from the configured renderers, and no longer names Slack (8594f3b).
TikTok's renderer or Google's internal renderers show up in the pill and the tool with no code change. The tool also no longer uses CopilotKit: it calls the renderer selection service directly, so the shared coordinator stays CopilotKit-free, matching the DI split in #215.
8594f3b to
9c2c694
Compare
a0000b6 to
1181af9
Compare
Nothing in this PR passed the optional AbortSignal that RendererSelection, SettingsService and StartupResolution accepted; only tests did. Its caller is a2ui-project#216's assistant tool, which cancels a pending switch when the user stops the turn, so the signal moves to a2ui-project#216 with it. The rest stays: a selection is committed only once its origin is allowed, a stale approval is rejected, and the renderer menu stays locked while an approval is open, now covered by a timeout test instead of a cancellation test.
fcc1912 to
cd09e21
Compare
Nothing in this PR passed the optional AbortSignal that RendererSelection, SettingsService and StartupResolution accepted; only tests did. Its caller is a2ui-project#216's assistant tool, which cancels a pending switch when the user stops the turn, so the signal moves to a2ui-project#216 with it. Without it, nothing produces a DOMException, so a failed switch's message is read from a plain Error. The rest stays: a selection is committed only once its origin is allowed, a stale approval is rejected, and the renderer menu stays locked while an approval is open, now covered by a timeout test instead of a cancellation test.
a2ui-project#216 renamed the chat panel tab to "Assistant" and rewrote the title in saved layouts. Nothing in the Slack work depends on the name, so the rename, its unit test and the matching e2e locator are reverted. A product-neutral title can be proposed on its own.
a2ui-project#216 quoted the existing --base-href and --base arguments while adding the Slack sample's build. The paths contain no spaces, so the quotes changed nothing; the existing lines are restored and the new line follows their style.
084d018 to
ac5178e
Compare
|
Rebuilt on the updated #244 and #269 (head |
* feat(chat): switch renderers from the chat panel's prompt pill The CopilotKit panel's prompt pill gets a renderer menu, so switching renderers doesn't need a trip to Settings. The menu lists every configured renderer by its display name, keeps the typed prompt, and holds Send until the selected renderer's catalog is active. - RendererSelection switches the preview and waits for the new renderer's handshake and catalog. The wait is its own small class with a method per step. If Settings declines the renderer, the message says why and what to do, and the panel shows it under the menu. - StartupResolution commits a selection only after its origin is allowed, cancels a pending confirmation when asked, and refuses non-HTTP(S) URLs. A selection that was overtaken while its confirmation was open is rejected by comparing the selection before and after. * test(visual): update the CopilotKit panel baseline for the renderer menu * refactor(chat): list the preview's URL parameters once and clarify docs Addresses review feedback on the renderer menu: - The preview's query parameters (origin, theme) live in one PreviewUrlParam enum, used where the preview adds them and where RendererSelection removes them before comparing URLs. A new test fails if the preview adds a parameter the enum doesn't list. - submitPrompt's doc said it waited for a renderer switch, but it skips sending: the Send button is disabled during a switch, Enter repeats that check, and the prompt stays in the input. - RendererSelection's doc says where to use it, and why the Settings page calls SettingsService.selectRenderer directly. - The rendererSelection field uses a JSDoc comment. * refactor(chat): leave renderer-switch cancellation to its first caller Nothing in this PR passed the optional AbortSignal that RendererSelection, SettingsService and StartupResolution accepted; only tests did. Its caller is #216's assistant tool, which cancels a pending switch when the user stops the turn, so the signal moves to #216 with it. Without it, nothing produces a DOMException, so a failed switch's message is read from a plain Error. The rest stays: a selection is committed only once its origin is allowed, a stale approval is rejected, and the renderer menu stays locked while an approval is open, now covered by a timeout test instead of a cancellation test.
…ject#269 follow-up, snapshot-once Recorded 2026-10-18 on each PR's branch with the e2e Gemini fixture (browser recordings) or vhs (the a2ui-project#269 follow-up's test run).
a2ui-project#216 renamed the chat panel tab to "Assistant" and rewrote the title in saved layouts. Nothing in the Slack work depends on the name, so the rename, its unit test and the matching e2e locator are reverted. A product-neutral title can be proposed on its own.
a2ui-project#216 quoted the existing --base-href and --base arguments while adding the Slack sample's build. The paths contain no spaces, so the quotes changed nothing; the existing lines are restored and the new line follows their style.
ac5178e to
2ad2bbe
Compare
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.
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.
2ad2bbe to
6337c12
Compare
- 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.
- 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.
- ?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.
- 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.
- 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 '*'.
|
@jgindin, here are answers to the review you emailed, in its order. The fixes are in five commits on top of a merge of main ( Watch or download the video (31s). The assistant's replies are scripted, because the recording uses the e2e tests' Gemini stand-in. What's the stuff at the bottom?The Data Model / Events / Errors / Raw Messages panel is main's inspector. This PR adds two things at the bottom of the Slack preview itself:
The two overlap: Copy JSON and Copy Block Kit both copy the message's blocks, and Simulate repeats a click on the real button. If you'd rather the preview showed only the message and one export, I can draw it with BlockerB1. A canvas reset during a renderer switch went into the conversation. Fixed. While a response streams, StateSync no longer adds a canvas change to the conversation. The editor and preview are locked then, so the only change possible is a reset to the renderer's sample, and the response replaces it. The model turn stays last, so the CopilotKit panel keeps showing it as streaming, and the next prompt doesn't send the sample as the current canvas. Your other suggestions are in too:
MajorM1. Raw vs. resolved renderer URLs. Fixed. M2. M3. Catalog
M4. M5. "Cancelled" stays under the chat bar after Stop. Fixed. M6. M7. Array-shaped M8. Slack catalog schema gaps. Fixed, both parts.
M9.
M10. Vite host, settle helper, dependencies.
Minor
VerificationAll of this ran on
|
The Tightknit renderer resolved its own slack-blocks-to-jsx range to 1.4.1 when a2ui-project#216's lockfile was rebuilt on main. 1.4 allowlists URL schemes for every image src and drops blob: URLs, so the images drawn for Chart and Scorecard showed no picture in the preview. Pin it through resolutions to 1.1.2, the version the sample already depends on, so both use one copy. The lockfile loses only the 1.4.1 entry and its react-markdown 10 dependency.
The Tightknit renderer resolved its own slack-blocks-to-jsx range to 1.4.1 when a2ui-project#216's lockfile was rebuilt on main. 1.4 allowlists URL schemes for every image src and drops blob: URLs, so the images drawn for Chart and Scorecard showed no picture in the preview. Pin it through resolutions to 1.1.2, the version the sample already depends on, so both use one copy. The lockfile loses only the 1.4.1 entry and its react-markdown 10 dependency.

Watch or download the video. Recorded on Nov 2 at
592836d. The assistant's replies are scripted, because the recording uses the e2e tests' Gemini stand-in.The problem
Composer previews A2UI in the Angular, Lit and React renderers, which all draw into a web page. An
agent that answers in Slack can't use any of them. A Slack message is a list of Block Kit blocks, with
its own limits: no nested layouts, at most 50 blocks, length caps on every text field, and only a few
input types. An author can't see what an A2UI surface turns into in Slack, or get the Block Kit to
send, until a real Slack app posts it.
The approach
A renderer, not a shell feature.
samples/react-slack-catalogis a renderer like the othersamples. It owns a Slack catalog of 11 components, sends that catalog to Composer over the bridge,
and draws the preview. The shell has no Slack code: the renderer menu labels every renderer with its
configured
displayName, and the Gallery reads the Slack examples over the bridge like any otherrenderer's.
One message, drawn and exported. The renderer lowers each A2UI surface to Channels UI
components and renders them with
renderBlockKitfrom@copilotkit/channels-slack. Channels isCopilotKit's channel SDK, and the sample README defines its terms. The Tightknit renderer draws the
blocks the way Slack would, and Generated Block Kit exports those same blocks after validation.
TextFieldand date-onlyDateTimeInputbecome native Slack inputs with writable bindings, andbuttons dispatch their actions with the current values. Where Slack can't match A2UI, for example a
Row of mixed content, the preview approximates it and reports a diagnostic.
The assistant can switch renderers. The
switchRenderermodel tool lists the configuredrenderers by ID and origin and calls Composer's renderer selection service directly, so the
coordinator doesn't need CopilotKit. Stopping the turn cancels the switch. If the origin
confirmation is still open, Stop closes it without allowing the origin, and nothing is selected. If
Settings has already committed the selection while the new renderer loads, the preview stays on the
new renderer and the conversation is kept. An edited canvas survives the switch, as it does when you
pick a renderer yourself.
Why each shared-code change is in this PR. Some changes outside the sample look general, so here
is what Slack needs from each:
catalog: web_core throws "Catalog not found" for any other
catalogId. Main's condensed examples(Prompt reduction #270) now carry the active catalog's ID, and one
getCatalogId()helper replaces every copy of thatlookup, including the one the Gallery playground (feat(gallery): Add interactive playground to Component Gallery #265) added.
image is attached, through an Icon
svgPathor an Imagedata:image/svg+xmlURL. The Slack catalog has no Icon,and Slack images take only HTTP(S) URLs, so that advice produced payloads Slack rejects. The Slack
catalog now publishes a JSON-Schema
pattern(^https?://) on Image.url. The prompt suggests SVGonly when the Icon schema has
svgPath, and limits Image URLs to the declared pattern when itrejects a data URL. It no longer matches words in a description.
sends its catalog inline and attaches in a React StrictMode effect. In development, which is what
the e2e journeys run, that effect attaches, detaches and attaches again. A reply for the first
attachment was dropped without a log, and the host then waited for its watchdog. The bridge now
asks again for the current renderer's catalog, unless a newer request is already answering. This
also hardens main's React sample, which uses StrictMode too.
the iframe already points at the new renderer, but the old page is still loaded and the host still
reports it ready. The catalog wait from Switch renderers from the chat prompt, without a trip to Settings #244 then asked that page for its catalog again, and the old
renderer's answer resolved the switch. A person rarely sends a prompt in that gap. The
switchRenderertool generates straight away, so its next request carried the previous catalog. Thewait now asks again only if the page was already showing the renderer when the switch began.
samples/react-slack-catalog/,so it works at
/composer/on GitHub Pages and at/composer/pr/<n>/in PR previews. Relative URLsresolve in one place,
EnvironmentContextService.resolveRendererUrl(), whichbuildRendererUrl(theiframe URL for
RenderedFrameand demo cards, through Extract a shared GuestFrame for RenderedFrame and DemoCard #294'sGuestFrame),StartupResolution,RendererSelection,QueryParser(?renderer=links) andHostCommunication's origin checks all use.which is built from main. These journeys would otherwise test main's bridge against this branch's
shell.
Moved out of this PR: hiding a repeated canvas card in the CopilotKit panel. The repeat came from
shared code, and #276 fixes it for both panels. Also removed: the
slack-devprofile,which loaded the same copy as
slackand carried a second inline payload, and the unused@copilotkit/channelsdependency.What is not covered
delivery wasn't tested.
config.json, and as the sample'scar-booking.json, whichbooking-example.spec.tschecks it against. One copy would need arenderer to provide its starter content, either over the bridge or through a payload URL in the
renderer config. That's a change for every renderer, so it should be its own PR.
useSlackInputBridge.ts), which ignoresmultiline, shows an Enter hint our inputs don't use, and labels every input "Select an item".Upstream issue feat: native @a2ui/angular rendering — custom catalog #121 covers the first two; an issue for the labels is drafted, not filed.
preview messages. Handshakes repeat a render, and no bridge message marks the last render. The
helper's comment names each source.
buildRendererUrlkeeps main's fallback for a missinglocation, because main's SSR test needs it.the pill, with or without the theme toggle and with no Slack code (several failures in 8 runs).
Both renderer-menu journeys here wait for focus to move into the menu before pressing Escape,
which avoids it. The fix for the app belongs on main.
Rebased on main (Oct 29)
Main moved underneath this PR after #269 and #193 merged, so it's rebuilt on main
4a98989as one commit,32f767a, plus one fix,6337c12. A commit-by-commit rebase stopped on 11 of the 46 commits, withchat-coordinator.ts,yarn.lock, the prompt factory and the preview frame conflicting again and again, so the rebuild applies this PR's whole diff once and resolves it there. The PR's review history is in the threads and the sections above.GuestFrame: main moved the iframe URL out ofRenderedFrameintobuildRendererUrl(). Page-relative renderer URLs are resolved there now, against the document base URI fromEnvironmentContextService, and the base-path tests moved torenderer-url.spec.ts.systemPrompt(), so it gets the image guidelines when the conversation has images. The Icon and SVG guidance sits in main's image-only section, and the Image URL rule is an allowlist rule in every prompt, which the Slack journeys check.@a2ui/web_core0.10.7, which main'sresolutionsalready pinned, and main's Vite. Since 0.10.6, web_core validates component props itself and reportsA2UI_PROCESS_MESSAGE_ERROR, so the sample's own invalid-props check could no longer fire and is removed. Row and Columnchildrenare now published as a reference toChildList.catalog.json, andcommon_types.jsonrefers tocatalog.json#/$defs/anyFunction. The Slack catalog had no$defs, so every Slack draft showed an unresolved reference.6337c12definesanyComponentandanyFunction; a call toopenUrl, which the Slack catalog leaves out, no longer validates.gallery.e2e.tsdoes.RENDERER_URLSmoved topreview/testing/renderer-urls.ts, which now lists the Slack renderer, and the Slack journeys use main's preview frame selectors.Review round (Nov 2)
Your emailed review is answered finding by finding in a PR comment. Main was merged in at
6ad0013(#311), and the fixes are five commits on top:@slack/types.Verification
On
592836d, on main6ad0013, with Node 24:yarn build,yarn lint,yarn tsc,yarn prettier:checkand the demo data check pass.CI=1, one worker): 218 of 218 passed.6ad0013, same settings: 166 passed, with one failure (gallery.e2e.ts:361) and two flaky tests (demo-card-commit-accuracy.e2e.ts:421anddemos.e2e.ts:247).lower-surface.tsis split by concern into nine modules, andsubmitPromptinto its phases.host-render-messages.spec.tsxmounts the sample on the real bridge and posts RENDER_A2UI from the host window.QueryParser,StartupResolution,HostCommunicationandbuildRendererUrltests cover page-relative URLs.$defsresolve, andanyFunctionaccepts a Slack function and rejectsopenUrl.Merge notes
#269 and #193 have merged. This PR is its original commit, the catalog fix, a merge of main, and the five review commits. This PR and #274, the #269 follow-up, both change the guard at the top of
ChatCoordinator.cancelStream. This PR adds|| this.cancelReason !== null, and #274 adds that check plus one that a response is streaming, so whichever lands second keeps #274's condition. #275, the React components PR, is stacked on an earlier head of this branch and needs a rebase onto592836d.