Repository navigation
feat(canvas): one rich block vocabulary for the agent and its voice mode (abilityai/trinity-enterprise#536) - #2562
Merged
Merged
Conversation
…ode (abilityai/trinity-enterprise#536)
Widen the agent canvas so the text agent and its voice mode write the same
blocks onto the same default canvas, rendered by the same component wherever a
canvas is shown.
Vocabulary: `image` (https URL · inline data:image raster under 64 KiB ·
workspace path through the authenticated preview route, one confinement gate
for both writers) and `diagram` (mermaid loaded lazily, strict + htmlLabels
off, SVG through the one DOMPurify policy, renders serialised) join the kinds;
`chart` widens to line/area/bar/stacked_bar/pie/donut on the metric series
shape `series[{label, unit, points[{ts, value}]}]` (a projection of the
#478 store so #538 becomes a resolver, not a schema; the ent#438 shape stays
accepted). A `markdown` block may carry ```chart/```kpi/```table/```mermaid
fences rendered through the same leaves. Every stored block carries an id
(b1..bN assigned); `patch_canvas` / PATCH replaces named blocks in place and
refuses unknown ids by name — still no append.
One write path: `canvas_service.write_canvas` (audience REQUIRED) is the only
writer; the router and the voice panel tools both call it. `main` is the
default canvas for the MCP tools and the voice panel — no `voice` silo, no
in-memory `panel_state`; the panel poll returns the row. Voice verbs are block
edits on the `voice*` ids so the agent's own board survives a call, and a
canvas stored wider than the session's audience is refused with a spoken
reason. `### Your Canvas` teaches the text agent, CI-pinned against the MCP
enum and the frontend rules like the report block.
Security: the pre-existing trend-chart tooltip built innerHTML over
agent-authored labels/colours (roster-visible) — rebuilt with DOM APIs and
hex-only colours. CSP `img-src` gains `https:` in both mirrors so a web image
can load at all (never worked since #190); every sanitised <img> now carries
no-referrer and url()-bearing inline styles are stripped app-wide.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_013CgzGLnmPrQk6q5LqZCRru
…3 internals `canvas.test.ts` reached the block-kind enum through `_def.type.shape` and `_def.values`, which are zod v3 internals; the lockfile pins zod 4.5.4, where `_def.type` is the literal string "array". The suite failed and `tsc --noEmit` errored on a fresh `npm ci`. Use `.element` / `.options`, the public v4 API. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UFvKUcog6RtvSD7nVBhiaQ
…s-vocabulary # Conflicts: # docs/memory/learnings.md
vybe
approved these changes
Sep 7, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
Validated via /validate-pr: docs, security scans, packaging all clean. Fixed on-branch: canvas.test.ts used zod v3 internals against the zod 4.5.4 lockfile (MCP suite + tsc red on a fresh npm ci); merged dev resolving the learnings.md conflict. Local evidence on merged tree: pytest 273 passed, vitest 2085 passed, mcp-server 314 passed + tsc clean. CI: 26 pass.
5 tasks
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.
Summary
image(https URL · inlinedata:imageraster ≤ 64 KiB · a workspace file through the authenticated preview route — one confinement gate for both writers),diagram(mermaid loaded lazily,strictwithhtmlLabels:falseso DOMPurify does not blank every node, renders serialised), andcharton six types over the metric series shapeseries[{label, unit, points[{ts, value}]}]— a projection of the fix(SUB-003): rate-limit events age correctly; max_retries default → 0 (#476) #478 store so fix(deploy): align scripts, configs, and docs with production patterns (#504) #538 becomes a resolver, not a new kind. The ent#438{labels, series[{data}]}shape still renders.markdownblock may carrychart /kpi /table /mermaid fences rendered by the same leaves (only an exact column-0 three-backtick fence with a usable body is extracted; everything else stays prose). Every stored block carries an id (b1..bNassigned);patch_canvas/PATCH …/canvas/{id}replaces named blocks in place, refuses unknown ids by name, and there is still no append.mainis what the MCP tools default to and what the voice panel draws on — novoicesilo, no in-memorypanel_state(the panel poll returns the row).canvas_service.write_canvas(audience=REQUIRED)is the only writer. Voice verbs are block edits on thevoice*ids, so the agent's own board survives a call; a canvas stored wider thanVoiceSession.canvas_audience(defaultoperator; ent#534 setsroster) is refused with a spoken reason — never widens, never silently narrows. Both independent plan reviewers hit "voice replaces the whole canvas at an inherited audience" as the regret; this is the resolution.### Your Canvasin the platform prompt (tool guidance, MINIMAL-droppable), CI-pinned against the MCPBLOCK_KINDSenum and the frontend rules exactly astest_1535pins the report block.Security notes (read these)
TrendLineChart's hover tooltip concatenated agent-authoredlabel/colorintoinnerHTMLand the canvas mounted it on the roster-visible Workspace. Rebuilt withcreateElement/textContent; colours hex-or-palette; labels plain text. (/cso --diffF2.)img-srcgainshttps:in both mirrors (vite.config.js,security-headers.conf). A web-URL image has been blocked by the browser since SEC: Missing Security Headers (CSP, X-Frame-Options, HSTS, etc.) #190 — feat: Voice Workspace canvas enrichment (Mermaid, images, panel history) + orb polish #979's "web URLs render directly" never held in production. Because the directive is page-global, the mitigation is too:utils/sanitizeHooks.jsruns inside the app's one DOMPurify hook and gives every sanitised<img>referrerpolicy="no-referrer"and stripsurl()-bearing inline styles; the write gate admitshttps:only. Residual (documented): an https host of the agent's choosing sees a viewer's IP and view time. (/cso --diffF1, verifier-widened.) A Settings-surfaced host allowlist is a possible follow-up, not filed.docs/security-reports/cso-diff-2026-09-07-ent536-canvas-vocabulary.md.Changes
models.py(kinds,id,CanvasPatch, caps,DEFAULT_CANVAS_ID),services/canvas_blocks.py(new pure leaf: image gate, ids, merges, voice verb mapper),services/canvas_service.py(write_canvas,patch_canvas,audience_within),routers/canvas.py(PATCH,# mcp:header),services/gemini_voice.py(panel tools → canvas,canvas_audience),routers/voice.py(panel returns the row),services/platform_prompt_service.py(### Your Canvas).tools/canvas.ts(patch_canvas, default id, kind guide),client.ts.components/canvas/{canvasUtils.js, CanvasBlock, CanvasChart, CanvasPieChart, CanvasDiagram, CanvasImage, CanvasMarkdown, CanvasPanel}.vue,utils/{canvasPalette,sanitizeHooks,markdown}.js,TrendLineChart.vue+StackedBarChart.vue(labelFormatprop; index keys), the two CSP mirrors.feature-flows/agent-canvas.md,requirements/core-agent.md§5.18 (FR-9..13),architecture/observability.md, flows index,learnings.md(two entries).blocksJSON).Test Plan
pytest tests/unit/test_ent536_canvas_vocabulary.py tests/unit/test_ent536_canvas_prompt_guidance.py tests/unit/test_ent438_agent_canvas.py tests/unit/test_voice_tools.py tests/unit/test_voice_auth.py— green; every unit file touching the changed modules (25 files): 713 passed, 2 skippedsrc/frontend:npx vitest run— 2062 passed (incl.canvasUtils.spec.js,sanitizeHooks.spec.js);npm run check:tokensOK; raw-color ratchet did not grow;vite buildOK (mermaid in its own chunk)src/mcp-server:npm test— 314 passed;tsc --noEmitcleancanvas_updatedWS trigger lands with ent#534's canvas column.Fixes abilityai/trinity-enterprise#536
🤖 Generated with Claude Code
https://claude.ai/code/session_013CgzGLnmPrQk6q5LqZCRru