Repository navigation
Add show_visual: Claude draws SVG charts and stats, shown sandboxed - #66
Merged
Merged
Conversation
Cue's screen leaned on words (#61). Bars, a big number with an icon, a timeline read across a Meet tile where bullets don't, and Mermaid can't draw them. So Claude can now write an SVG (or a small HTML/CSS block). Model output can be steered by pages it read (#14), so the markup gets two layers: sanitize.js keeps an allowlist of drawing and text elements and drops handlers, external URLs, url() other than #id, @import and CSS escapes; then it renders in an iframe with an empty sandbox (no scripts, opaque origin) under a CSP that loads only the brand's Google Fonts. The page never inserts model markup into its own DOM. scripts/sanitize-check.mjs runs the hostile cases in npm run check under linkedom. Prompt: one new tool line and two new rule lines (colours, viewBox, type sizes); no existing rule reworded, since #58 owns that wording. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A viewBox comes only from a plain width and height: width="100%" gave "0 0 100 100" and zoomed into the drawing's corner. - An svg beside a <style> or inside a <div> gets the viewBox too, and shrinks to fit there instead of clipping. - The title stays on one line, so the frame stays 470 tall and 22px text stays 22px; the schema asks for under 40 characters. - HTML taller than the frame keeps its top (safe center). - At most 40 <use> copies and 3000 elements: nested <use> can ask for millions of copies in a few kilobytes and stall the 15 fps page. - data: in a harmless attribute (aria-label="Revenue data: Q3") stays; URL attributes still must start with #. - Prompt: when show_visual wins over a stat slide, a Mermaid timeline or two_columns; markup under 4,000 characters (it's the slowest tool to write); font fallbacks so text never flashes in serif. The "one visual per turn" list itself (line 34) is #58's wording, so the new tool stays a line of its own for now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es, for #65 inland-ocelot's restyle (#73) changes every brand value while keeping the token names. Hex values in the prompt would leave drawings in the old palette, so the iframe now gets the page's computed --cue-* values and font stylesheet, and Claude colours with classes (accent, ink, muted, line, paper, hl, display). Whichever palette is live, drawings match. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #65
Why
Tyler (#61): Cue's screen "is lacking in visuals and relies too much on words". A bar chart of numbers just said, or one big number with an icon, reads across a Meet tile; bullets don't, and Mermaid can't draw either.
Change
show_visualtool (agent.js): Claude writes one SVG (viewBox="0 0 1136 470", which fills the frame) or a small HTML/CSS block. Prompt: one new tool line and two new rule lines (it counts as a visual; brand colours, fonts, type ≥22px, ≤~25 words, no invented data). No existing rule reworded (Make Cue act unprompted, as the intern running the projector #58 owns that wording).public/views/sanitize.js: allowlist of drawing and text elements; dropson*handlers,<script>,<foreignObject>,<image>,<a>,<meta>/<base>/<link>/forms, any URL attribute that isn't#id,url()other thanurl(#id),data:/javascript:,@import,image-set(), CSS escapes,<animate>/<set>onhref, and<in style text (so</style>can't break out on reparse).public/views/visual.js: renders in an<iframe sandbox="">viasrcdoc(no scripts, opaque origin, no navigation) under a CSP ofdefault-src 'none', allowing only Google Fonts for the brand faces. Model markup never enters the page's own DOM.scripts/sanitize-check.mjsruns 14 hostile cases under linkedom as part ofnpm run check.public/app.js,evals/replay.mjs: one dispatch case each.Screenshots
What Claude itself drew in the replay (claude-haiku-5-5, low) when Maya read out four quarterly numbers, after 3788eeb (colour classes, no hex values), rendered by this view:
Two hand-written mocks: A bar chart of numbers just said (title above), and a stat with an icon (no title; this one's mock also carried the hostile markup, all stripped):
Verified
npm run checkpasses (including the 14 sanitizer cases)./api/thinkmocked: the chart and the stat render with the brand fonts. The stat's mock carriedonload="alert(1)", a<script>callingfetch('https://evil.example/x'), an external<image>and aurl(https://evil.example/…)fill: no dialog, no request to any host but the server and Google Fonts, and none of them in the iframe'ssrcdoc.Review
Opus review of e289337: no way found for markup to run script, make a request, navigate, read the token or leave the frame. Its rendering and prompt findings are fixed in fea2a1a: viewBox from
100%, a two-line title shrinking text below 22px, tall HTML losing its top, svg-inside-HTML sizing, serif flash,data:in harmless attributes, nested<use>blow-up (capped), and the overlap with stat slides, Mermaid timelines and two_columns. Not taken: putting show_visual into the "one visual per turn" list on line 34, which is #58's wording, so it stays a line of its own. 3788eeb (colours from the page's live tokens, for #73's restyle) came after the review and is page and prompt only.🤖 Generated with Claude Code