Repository navigation
Draw React components as images among native Slack blocks - #275
jerelvelarde wants to merge 40 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new React Slack Catalog Renderer workspace (samples/react-slack-catalog) to preview A2UI surfaces as Slack message Block Kit. It also updates the preview bridge to handle catalog requests across renderer lifecycles and enhances the shell's chat coordinator to support programmatic renderer switching via a model tool call. The review feedback correctly identifies a potential runtime issue in lowerButton where props.child is accessed without a strict type guard, and suggests adding a validation check to prevent unexpected behavior.
| function lowerButton( | ||
| props: Readonly<Record<string, unknown>>, | ||
| context: LowerComponentContext, | ||
| ): Renderable { | ||
| const label = collectText(renderToIR(context.children(String(props.child)))); | ||
| return ChannelButton({ | ||
| children: label || 'Action', | ||
| style: props.variant === 'primary' ? 'primary' : undefined, | ||
| onClick: slackActionHandler(context.dispatch(context.rawProps.action)), | ||
| }); | ||
| } |
There was a problem hiding this comment.
In lowerButton, props is an untyped record (Record<string, unknown>). If props.child is not a string (or is undefined), attempting to resolve it can lead to runtime issues or unexpected behavior (like looking up a component with ID "undefined" or "[object Object]"). Please use a strict type guard typeof props.child === 'string' to safely validate and resolve the child component ID before passing it to context.children.
function lowerButton(
props: Readonly<Record<string, unknown>>,
context: LowerComponentContext,
): Renderable {
const label = typeof props.child === 'string'
? collectText(renderToIR(context.children(props.child)))
: '';
return ChannelButton({
children: label || 'Action',
style: props.variant === 'primary' ? 'primary' : undefined,
onClick: slackActionHandler(context.dispatch(context.rawProps.action)),
});
}References
- When validating properties from untyped or external records, use a strict type guard like typeof value === 'string' before processing them as strings to avoid runtime errors with non-string truthy objects.
26f3020 to
267a880
Compare
Replaces the CHART_TYPES tuple and its string-union type with a ChartType enum, and checks that the published catalog still lists the five chart types in order.
Slack does have a native chart block, data_visualization, which @copilotkit/channels-slack exposes as Slack.Block.DataVisualization. It draws only pie, bar, area, or line charts, limits titles to 50 characters and labels to 20, requires pie values above 0, and allows 2 per message. The catalog also allows donut and horizontal bar, and Channels' renderBlockKit skips the cross-platform chart node, so the sample draws every Chart as an image on purpose. Reword the catalog descriptions the model reads, the comments in lower-chart.ts, and the README Charts section to say that, and update the spec and e2e assertions that pinned the old sentence. Also correct the exportBlocks doc comment: it is set on every ready snapshot, not only when it differs from blocks.
Moves the image store out of chart-image.tsx into drawn-image-store.ts, as DrawnImageStore and createBlobImageStore, and the font, neutral colors and text clipping into drawn-image-style.ts, so a second component drawn as an image can use them. Lowering keeps the drawn image URLs in its state. A new drawn-image-blocks.ts holds placeDrawnImage, which serves a drawing, records its URL for the export swap, and raises SLACK_IMAGE_RENDERED_AT_SEND naming the component's type and id, and exportDrawnImages, which does that swap. Charts are still drawn from the Channels UI Chart node just before renderBlockKit, and the chart output and diagnostics are unchanged. Adds JSDoc to the exported chart types and functions, and stops exporting formatChartValue, which only chart-image.tsx uses.
Adds scorecard-image.tsx, a React SVG component that draws a match result as a 560x200 card: the competition, both teams with their scores, and the status. It uses the font and neutral colors that charts use. Long team names shrink or wrap to two lines, and text that still doesn't fit is cut short with an ellipsis and clipped to its column. scorecardAltText describes the card for Slack alt text, e.g. "Scorecard: Argentina 2, Mexico 0. Full time. World Cup, Group C."
Scorecard shows one match result: a home and an away team, each with a name and a score, plus an optional status and competition. Names are DynamicStrings; a score is a number or anything a DynamicString accepts, so "3 (4)" and bindings work too. The component and catalog descriptions tell the model to use it for a single result and Table for several, and that Slack has no block for a scorecard, so the renderer draws it and sends it as an uploaded image. Adds an Argentina 2, Mexico 0 Gallery example, and lists Scorecard in the catalog test and the Gallery e2e component list.
Lowers a Scorecard by drawing it while lowering and placing it in the message as a Channels UI Image. Unlike Chart, Scorecard is not a Channels UI component, so there is no Channels UI node to keep until renderBlockKit. Its URL joins the drawn-image set, so the export marks it with slack_file RENDERED_AT_SEND, and it raises the same SLACK_IMAGE_RENDERED_AT_SEND info diagnostic, naming Scorecard and the component id. Names, scores, status and competition resolve through the binder like other components' bound values. A team whose name or score is empty or missing leaves the scorecard out with a SLACK_SCORECARD_INVALID warning that names the team and field, and the rest of the message still renders. An accessibility label replaces the generated alt text. The lowering lives in lower-scorecard.ts, next to lower-chart.ts. Moves warnChart, renamed skipWithWarning, and optionalText out of lower-chart.ts into drawn-component-props.ts, since scorecards use them too.
scorecard-image.spec.tsx checks the drawing: both teams, scores, status and competition, escaped team names and scores, long names shrinking, wrapping and being cut short, and the alt text. lower-surface.scorecard.spec.ts lowers a match report with a Header, a Scorecard, a Table, a Chart and a button. The scorecard image sits between the header and table blocks, the export swaps both drawn images for slack_file while the native blocks stay as they are, and each drawn component raises one SLACK_IMAGE_RENDERED_AT_SEND. It also covers bound names and scores, the accessibility label, and the SLACK_SCORECARD_INVALID warning for an empty name or a missing score. catalog.spec.ts checks the Scorecard guidance and the shapes the schema accepts and rejects. The chart and scorecard specs share one fake drawn image store.
Pastes a match report into the JSON editor: a Header, a Scorecard, a Table, a Chart and a button. The journey checks that the header, both images, the table and the button appear in message order, that each drawn component raises SLACK_IMAGE_RENDERED_AT_SEND, and that "Generated Block Kit" has the header, table and actions blocks with two slack_file RENDERED_AT_SEND images between them and no blob URLs.
Turns the Charts section into "React components drawn as images", which covers both components. It defines Channels, Channels UI, renderBlockKit and your Channels app once, says how the preview draws each image and how the export marks it as an uploaded file, and then covers what is particular to Chart and to Scorecard, including their warnings. Adds a Scorecard row to the mappings table.
createSlackPreviewSession took a drawnImages option, and createBlobImageStore took the object that makes and frees URLs, only so specs could pass fakes; App.tsx passes neither. The fake store also lived in src/ next to the code it stood in for and imported vitest. Remove the option, the parameter and fake-drawn-image-store.ts. The store calls URL.createObjectURL and URL.revokeObjectURL directly, and the specs stub those with vi.spyOn and read each drawing back from the Blob it was served from. The session spec that only checked the fake's release arguments now checks what actually happens: a chart's URL is revoked once two renders in a row leave it out, and every shown URL is revoked on dispose.
exportBlocks was optional, and blocksForExport fell back to blocks when it was missing. lowerSurface sets it on every ready snapshot, so the fallback only kept specs that built snapshots by hand passing. Make exportBlocks a required field that, like blocks, is empty unless the snapshot is ready, drop blocksForExport, and have BlockKitExport read exportBlocks directly. The specs that build snapshots now set it: to their blocks when ready, since they draw no images, and to [] for the other statuses.
Charts and scorecards reached the same image block by two paths. Scorecards were drawn inline with placeDrawnImage. Charts were lowered to a keyed Channels UI Chart node, recorded with registerChart in state.charts, and swapped for a drawing by drawCharts after the whole tree was lowered. Nothing read the Chart node in between, so the second path only added a key built from state.revision that lived for one pass, and it pushed every chart's diagnostic after all the others, although lowering keeps diagnostics in document order. Draw a chart in lowerChart with placeDrawnImage, as lowerScorecard does, and remove LoweredChart, registerChart, state.charts and drawCharts. The reason charts are drawn at all moves to lowerChart's JSDoc. A new spec checks that a chart's diagnostic comes before those of the components after it. Update the README, which said the chart stays a Channels UI Chart until just before renderBlockKit runs.
chart-image.tsx declared its own ChartPoint and ChartImageProps, field
for field the same as ChartDataPoint and ChartProps that
@copilotkit/channels-ui exports, and its ChartType enum repeated
Channels UI's ChartType union with nothing to keep the two in step.
Keep the enum, and add two compile-time checks that `${ChartType}` and
Channels UI's ChartType are each assignable to the other, so a chart
kind added to or removed from either list fails the build. Build
ChartImageProps on ChartProps with the type required, and use
ChartDataPoint for the points instead of ChartPoint.
Also say in lowerChart why casting props.type to ChartType is safe:
lowerComponent validated the props against the Chart schema, and type
accepts no binding.
chart-image.tsx and scorecard-image.tsx each had the same round(), and they estimated text widths two ways: the chart allowed one character per 7 units of band width, and the scorecard used a CHARACTER_WIDTH of 0.6 times the font size. Move round() and the 0.6 estimate into drawn-image-style.ts, with the reason SVG text needs an estimate at all, and add estimateTextWidth and charactersThatFit on top of it. The chart's category labels now use charactersThatFit at their 12-unit font size, which is 7.2 units a character instead of 7, and the scorecard's name, score and status layouts use the shared helpers.
The drawings used bare numbers for their layout: a title band of 52 or a margin of 20, a pie radius of at most 130, a donut hole of 0.56, a label cut at 18 characters, a 1.2 line height, a status pill centered at 162, and many more. Readers had no way to tell what each one was. Give each one a named constant with a comment saying what it is, and use a FontWeight enum for the 600 and 700 weights. Document niceDomain's step count and floating-point cleanup, niceStep's round numbers, and slicePath's arc flags. The scorecard's four `* 0.35` offsets and the chart's `+ 4`, `+ 11`, `+ 14`, `+ 16` and `+ 18` baselines all placed text by its baseline. They now come from baselineCenteredOn and baselineBelow in drawn-image-style.ts, which use one documented cap height of 0.7 of the font size. Some chart labels move by up to 2 units as a result.
The chart and scorecard drawings set class names such as slice, bar, team-name and status. The preview shows a drawing through an <img>, so no stylesheet ever applies to it, and only the specs read the classes. Remove them. The specs now parse the markup and select what they count by its structure: slices are paths, bars are the rounded rectangles, a donut's hole is a circle in the background color, and team names are the text clipped to a column. The scorecard specs compare the full list of drawn text, which also shows the status and competition are left out when missing.
lowerChart and lowerScorecard each cut a component's accessibility label to Slack's alt text limit with slice, which drops the end silently, while the generated descriptions were cut with clipText, which ends them with an ellipsis. So the same image's alt text was cut two ways depending on where it came from. Add drawnImageAltText to drawn-component-props.ts. It picks the label or the description and cuts either with clipText, and both lowerings use it. chartAltText and scorecardAltText no longer cut, so they become describeChart and describeScorecard and lose their maxLength parameters. The cut is now tested once, in drawn-component-props.spec.
"Your Channels app" appeared in comments and in the SLACK_IMAGE_RENDERED_AT_SEND diagnostic, which users read, but someone previewing a Slack message may not use Channels at all. Say "the app that sends the message" instead, and have the diagnostic name the placeholder file ID, RENDERED_AT_SEND, that the app replaces. drawn-image-store.ts said a URL lives until it is missing from "two releases in a row" without saying what a release is. Say that the session calls release with the URLs of each snapshot it publishes, and rename the spec to match. Also say which export "the export" is (Generated Block Kit), what Slack's uploaded-file form is, what the chart's plot and bands are, that LoweringState also collects drawn images, and where the README explains the Tightknit renderer it names.
The README said Scorecard shows that any React component can be sent as an image. Only one that renders to static SVG markup with renderToStaticMarkup can: the markup is made once and is the image, so state, effects and event handlers never run, and HTML elements can't appear in it. Say so where the section introduces drawn components, and point the Scorecard section at that. Also say in the Generated Block Kit section that drawn images appear there in Slack's uploaded-file form, which it did not mention.
Many of the Chart and Scorecard tests checked several things at once, so a failure did not say which behavior broke. Split them so each test checks one thing and its name says what: the drawing specs (markup, title, slices, legend, bars, labels, axis titles, negative values, each step of fitting a team name), the image store, the lowering specs (draw, export, diagnostic, and leaving a component out apart from saying why), the catalog specs (one test per accepted or rejected shape), and the e2e journeys, which now share helpers that generate the chart or paste the match report. Remove the tests that only checked React's escaping of text in the SVG markup, and the one that checked exportBlocks is frozen: the session spec already checks that a published snapshot is frozen all the way down.
The rest of the Slack catalog declares string props with dynamicString, which publishes a reference to common_types.json's DynamicString. Chart and Scorecard still used their own string and number unions, which main no longer has. Chart's title, axis titles and labels, and Scorecard's names, status and competition now use dynamicString. Chart values use a new dynamicNumber, which publishes a reference to DynamicNumber. A number function call is published like a string one, so it must name one of the catalog's functions. A score takes a number or a string. Its union lists the members of DynamicNumber and DynamicString directly: web_core resolves a binding only in a union that holds the binding itself, so a union of the two left a bound score unresolved, and the scorecard was skipped. The chart test that sends 21 points now expects A2UI_PROCESS_MESSAGE_ERROR, which main reports for a schema rejection.
Opening the example JSON switches the Gallery's playground to its Edit JSON tab, which hides the preview. Check the drawn chart first, then the JSON, as the MarketSnapshot journey does.
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 Scorecard lowering spec and the drawn-images e2e journey each wrote out the same match report. Serve it as public/examples/match-report.json, which the spec imports and the journey reads with readSlackExample, as they do the data-bound action example, and list it in the README with the other served examples. The Chart and Scorecard lowering specs each built their own createSurface, updateComponents and updateData messages, and they and the image store spec each stubbed URL.createObjectURL the same way. They now share surfaceMessages and stubBlobUrls from drawn-images.helpers.ts.
DiagnosticCode says A2UI_ codes are problems with the A2UI messages and SLACK_ codes are places Slack can't show the surface. A chart value that isn't a number, a pie with only zeros, and a scorecard team with no name or score are problems with the messages, so rename SLACK_CHART_INVALID_DATA, SLACK_CHART_EMPTY and SLACK_SCORECARD_INVALID to A2UI_INVALID_CHART_DATA, A2UI_EMPTY_CHART and A2UI_INVALID_SCORECARD. The DiagnosticLevel docs no longer fit every code at their level: INFO said the preview reports progress, which the note about uploading drawn images doesn't, and WARNING said Slack can't show part of the surface, which a left-out chart isn't. Reword both to cover every code that uses them. Say why a drawn component that can't be drawn is left out with a warning while a Table throws: the drawn image is an addition the rest of the message is complete without, and a native block carries the message's own text.
The chart cut its text to fixed lengths that don't fit the 600-wide image: a 60-character title at size 18 is about 648 wide, an 18-character horizontal bar label about 130 where the plot leaves 116, a 28-character legend label runs past the edge once its value and share follow it, and a 40-character y-axis title can be taller than the plot. Derive each length with charactersThatFit from the room the text has, as the vertical chart's category labels and the scorecard already do: the title gets the width between two side margins, each axis title the side of the plot it runs along, a horizontal bar label the room left of the plot, and a legend label what its value and share leave on the line. The scorecard's status was cut to 40 characters and its label then clamped to the card. Derive the status length from the card's width instead, which makes the clamp unreachable, so drop it. Scores keep their 8-character cut: a longer score is drawn smaller to fit. Also use DrawnImageColor directly in the chart, as the scorecard does, instead of the INK, MUTED, GRID and BACKGROUND aliases.
Lowering left out every chart whose values were all zero, but only a pie or donut has nothing to draw then; a bar or line chart still has its axes and labels. Limit A2UI_EMPTY_CHART to pie and donut charts. niceDomain's guard for an empty value range is now reachable, so say when it applies, and drop the pie's guards against a zero total, which lowering keeps from ever reaching the drawing. A pie or donut drew its slices in the 8 colors of PALETTE, repeating them past the eighth, while the schema allows 20 points. Leave out a pie or donut with more slices than colors, with an A2UI_INVALID_CHART_DATA warning that names the limit, which is now PIE_CHART_MAX_SLICES. The Chart type and data descriptions and the README say so. Name the 20-point limit CHART_MAX_POINTS, beside the Chart schema, and build the data description from it. It is this catalog's limit, not Slack's. Also read the chart's points with arrayField, as lowerTable reads its rows.
drawnImageAltText cut a Chart's or Scorecard's accessibility label to Slack's 2,000-character alt text limit without saying so, while an Image whose description is too long fails with SLACK_IMAGE_ALT_TEXT_LIMIT_EXCEEDED. That code fails the render, which a cut label doesn't, so add SLACK_IMAGE_ALT_TEXT_TRUNCATED, a warning like the other _TRUNCATED codes, and report it when the author's label is cut. A generated description is still cut silently: it only repeats what the image shows. The README now says where a drawn image's alt text comes from.
Every drawn image raised its own SLACK_IMAGE_RENDERED_AT_SEND note of about 300 characters, so a message with three charts showed the same paragraph three times. Raise one note per render that names every drawn component by type and ID, after the components' own diagnostics. lowerChart and lowerScorecard passed their own component type and ID to placeDrawnImage, which lowerComponent already has. It now fills them in, and a lowering passes only the drawing and its alt text. LoweringState kept the URLs of drawn images in drawnImageUrls, beside the image store that hands those URLs out, and the export and the session each had their own test for an image block with an image_url. The store now answers has(url), which the export asks instead of the set, and both use one isUrlImageBlock test; the session frees URLs with the new imageUrls. Also check that a regular Image beside a drawn chart keeps its image_url in the export, and that three charts in one message are all drawn, in order, and named in one note.
The README's sentences on pinning slack-blocks-to-jsx sat in the Actions paragraph about buttons. Move them to "React components drawn as images", next to the Tightknit renderer's buttons, and say what would let the pin go: slack-blocks-to-jsx 1.4.1's <Message> takes a urlTransform prop, but the Tightknit addon's Renderer (0.1.1) doesn't pass one through. BlockKitExport's JSDoc said its JSON is ready to paste into Block Kit Builder or an app. With a drawn image it holds the RENDERED_AT_SEND placeholder that the app sending the message replaces, so say so.
STRING_PROPS, which checks that each string prop takes only calls to catalog functions returning a string, now covers Chart's title, axis titles and labels, and Scorecard's team names, status and competition. A new NUMBER_PROPS does the same for Chart values and Scorecard scores with a call returning a number. The published catalog rejects a call to openUrl or to a function the catalog lacks; the runtime schema takes any function name, as it does for string props. A string result is rejected for a Chart value in both schemas and accepted for a score, which can be text. The Chart accept and reject cases checked only the runtime schema; they now check the published one too, as the Scorecard cases do. Drop the Chart and Scorecard "accepts the Gallery example" tests, which repeat the loop over every SLACK_COMPONENT_USAGES example.
- A chart test named for a value that isn't a number bound a missing path. Name it for the missing path, and add a value bound to "seventy", which leaves the chart out, and to "70", which is drawn as 70. - The tests named "skips" checked only the warning. They now also check that the component's block is gone and nothing was drawn for it. - The negative bar test only counted bars. It now checks that the Loss bar starts at the zero line and reaches below it; its value label is a test of its own. - The bound scorecard test said in a comment that the unchanged chart kept its image. A separate test now checks it, and the bound messages are built fresh for each test, since the data model keeps and changes the objects it is given. - The drawn-images journey checked the JSON editor's validation in the ordering test; it is now a test of its own. - The assistant journeys that noted the upload and exported the chart repeated the drawn-images journeys once the messages arrive, so drop them. The assistant's chart is now possession-chart, not share. - Rename the BlockKitExport test that reads exportBlocks to what it checks: it shows the export blocks, not the preview blocks.
The README says the slack-blocks-to-jsx pin can go once the Tightknit renderer passes urlTransform through. Link the issue that asks for it, so anyone revisiting the pin can check its status.
c1cf9d4 to
e213523
Compare
Watch or download the video. Recorded on Nov 10 at
267a880. The assistant's reply is scripted, because the recording uses the e2e tests' Gemini stand-in.The problem
The Slack sample in #216 turns every A2UI component into a native Block Kit block. That covers
headers, tables, buttons and form inputs, but a real Slack app also sends things Slack has no block
for. A results card or a chart has to reach Slack as an image. Composer couldn't show such a message,
so an author couldn't see how an image sits among the native blocks around it.
Charts are the clearest case. Slack's
data_visualizationblock draws only pie, bar, area and linecharts. It allows two charts per message and 20-character labels. The Channels Slack renderer skips
chart nodes entirely. (Channels is CopilotKit's channel SDK, which the sample exports for; the README
defines its terms.) In #216's own recording, the pie chart is an image URL the model linked to,
because the catalog had no chart.
The approach
The Slack catalog gains two components that a React component draws as an image. Every other
component stays a native block, so one message carries both kinds, the way a real app sends it.
Chart draws vertical bar, horizontal bar, line, pie and donut charts from 1 to 20 labeled values,
literal or bound. Its props build on Channels UI's
ChartPropsandChartDataPoint. ItsChartTypeenum is checked against Channels UI's
ChartTypeat compile time, so the two can't drift. Everychart is drawn, including the types Slack's own block supports, so a message can have more than two
charts, and donut and horizontal bar charts work.
Scorecard shows one match result: home and away teams with names and scores, plus an optional
status and competition. Channels UI has no such component. It's here to show that the path works
for any component that renders to static SVG, not only for charts.
Props like the rest of the catalog. Chart and Scorecard declare their string props with
dynamicStringand Chart's values with a newdynamicNumber, so the published catalog refers tocommon_types.json'sDynamicStringandDynamicNumberfor them, the way the other components'bound text props already do.
A score takes a number or text, such as "3 (4)". Its union lists the members of both types directly,
because web_core resolves a binding only in a union that holds the binding itself.
One path for both. Each component is drawn while its A2UI component is lowered, so its
diagnostics stay in document order with the rest.
renderToStaticMarkuprenders the component onceto SVG markup, which becomes the image. So a drawn component can't use state, effects or HTML, and
the README says so.
drawn-image-blocks.tsplaces and exports both kinds of image, anddrawn-image-style.tsholds their shared font, colours, rounding and one text-width estimate.Preview and export differ on purpose. The preview serves each drawing from a
blob:URL as aSlack image block. The
Generated Block Kitexport writes the same block in Slack's uploaded-fileform,
{"type": "image", "slack_file": {"id": "RENDERED_AT_SEND"}}. One info diagnostic per render,SLACK_IMAGE_RENDERED_AT_SEND, names the drawn components and says the app that sends the messagerenders and uploads each file.
Exporting a hosted image URL instead would need a server that receives the message's data. A
placeholder keeps preview and export free of credentials and network calls.
That has a cost. An exported message can't be sent as it is: the sending app has to render each
drawn component to a PNG and upload it first. The Tightknit renderer's own
Copy JSONbutton copiesthe preview blocks, whose
blob:URLs load only inside the preview, and the README says to copy fromGenerated Block Kitinstead.One version of the Slack drawing library. The Tightknit renderer draws the preview with
slack-blocks-to-jsx. Since #216 landed, main's lockfile gives it 1.4.1, while the sample itselfdepends on 1.1.2. 1.4 allowlists URL schemes for every image
srcand dropsblob:, so the drawnimages showed no picture. 1.4's
<Message>takes aurlTransformthat would letblob:through,but the Tightknit
Rendererdoesn't pass one on(TightknitAI/storybook-addon-slack-block-kit#94). So this PR pins the library to 1.1.2 through the
root
resolutions, the version the sample was built against, and the README says why and when thepin can go. The cost is 1.4's URL checks in the preview. React already blocks
javascript:links,and lowering accepts only HTTP(S) image and source URLs. Passing the drawings as
data:URLs insteadwould keep 1.4, but a chart's SVG is several KB, over Slack's 3,000-character
image_urllimit thatthe preview checks.
Data that the schema accepts but that can't be drawn leaves out only that component, with an
A2UI_INVALID_CHART_DATA,A2UI_EMPTY_CHARTorA2UI_INVALID_SCORECARDwarning, and the rest of themessage still renders. Examples are a bound value that isn't a number, a negative pie slice, a pie
or donut with more slices than its 8 colours, or a pie or donut whose values are all zero. An
all-zero bar or line chart is still drawn. The code says why these are warnings when a Table cell
that can't be lowered fails the render: the drawn image is an addition the rest of the message is
complete without. Data the schema rejects, such as more than 20 points, puts the preview in its
error state, as it does for any other component. An accessibility label longer than Slack's alt
text limit is cut with a
SLACK_IMAGE_ALT_TEXT_TRUNCATEDwarning. A blob URL is freed only after twosnapshots in a row have left it out, so an image the preview still shows while React commits the
next snapshot never breaks.
What is not covered
a working image.
measure text. A long team name is shrunk, then wrapped, then cut, so it never overlaps the score,
but the estimate can cut a name that would have fit. Chart titles and labels are cut to the room
they have, by the same estimate.
are fixed, and there's no per-series styling.
scorecards.
Verification
On
267a880, which is main (fb0a428) plus 39 commits, with Node 24. The head,c1cf9d4, only addsthe issue link to the README:
yarn build,yarn lint,yarn tsc,yarn prettier:checkandyarn generate:demos:checkpass.scripts 36.
CI=1, one worker): 225 of 225 passed, none flaky. The new journeys are:cut to the room they have, the scorecard's lines, long names and a "3 (4)" score, alt text cut
with a warning, blob URLs freed only when two snapshots leave them out, a regular Image's URL kept
beside drawn images, three charts in one message, diagnostics in document order, and the
uploaded-file export. The catalog spec checks function calls in Chart and Scorecard props against
the published schema, as it does for the other components' props.
Merge notes
#216 merged, so this branch is now rebased onto main and shows only its own commits. One commit from
the earlier stack, which shared code between string and number props, was dropped because main
replaced the helpers it changed. #320 also edits the root
resolutions(web_core 0.15.0); whicheverlands second keeps both entries.