Official

visuals

HTML pages (html_preview, html_render) and native inline charts, positioned diagrams and sortable tables in agent replies.

The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install convergence/visuals@0.2.1

Visuals — official plugin

convergence/visuals provides publish_visual for interactive, native visual replies. It ships enabled on a fresh install; an existing install keeps the choice it has, and users can turn it off or on in Settings → Plugins. It starts only when a reply first contains one of its fences and loads Pele only on the first Mermaid fence, so a chat without fences pays nothing. Its only requested permission is tools.provide.

HTML pages (T3 Code's html_preview and html_render)

html.ts holds T3's contract (pingdotgg/t3code b24f0fbb): the tool names, descriptions, limits (HTML 1–512000 UTF-16 units, title 1–200, preview width 240–1600 with 728 by default, frame height 80–2000), the result shapes and messages, the frame-height rule, and the theme bootstrap with Divergence's colours. Both tools are direct, so in code mode they stay tools of their own and the preview's PNG reaches the agent as an MCP image part.

  • html_preview sends the themed page to host/web.preview. With a web view it answers T3's metadata as text and structured content plus the PNG. Without one it is an error, HtmlBackendUnavailable: <raw reason>, with no image, and no screenshot is made up.
  • html_render saves the agent's page unchanged as a html v1 transcript artifact (the host stamps the owner) and answers T3's htmlRender reference and message. Measured heights are not supplied.
  • Inline (html-view.ts) the page is live (ui.webDocument): borderless in the reply, as wide as the column and as tall as the page up to the agent's height, with one small glass Open in panel control. The panel is a detail-pane tab (the convergence/tabs service): the page live again, its Source, Copy and Save (kernel/copy_text, kernel/save_text, both after a click).

The renderer is the system's WKWebView on macOS (crates/host/src/web), so a page behaves as it would in Safari, with the Mac's fonts, the GPU, text input, the clipboard and native pickers. The difference from T3 is that pages are offline: remote URLs and local image paths never load (missingImages lists the paths a page names). On Linux and Windows, which have no web view in this version, the page says so and its source, copy and save still work.

Version 2 supports responsive multi-panel compositions: bar (grouped/stacked/ percent; horizontal/vertical), line, area, scatter/bubble, pie/donut, heatmap, histogram, range/timeline, waterfall and boxplot, plus metrics, text, typed tables and positioned diagrams. document.ts defines the strict, bounded JSON schema; rules.md is the agent-facing reference. Version 1 documents still replay.

Rendering and interaction

Rust/GPUI draws every shape, label, control and floating tooltip. A pinned, DOM-free D3 math subset computes scales, numeric/UTC ticks and paths inside QuickJS; there is no browser, JavaScript UI execution, graph auto-layout, network, file, process or plugin-storage access. math.LICENSES.txt includes provenance and licenses; scripts/bundle-visuals-math.mjs reproduces the readable bundle.

Charts use the native canvas's onResize({width,height}) logical-pixel measurement, not a scaled viewBox. Text remains readable as panels grow or wrap. Compact legends keep original domains, colors and percentage denominators when hidden. Null breaks paths and stays explicitly missing in shared bar inspection.

Hover opens a clamped floating tooltip; click pins/unpins. Arrow keys, Home/End traverse observations, Enter/Space pin, Escape clears inspection. In the expanded overlay Escape unpins first, then closes. Tables retain stable raw row identity, sort nulls last in either direction, paginate and expose full selected values. Diagram node details remain accessible through a native picker.

State and cached geometry belong to each artifact's ctx.state, with separate panels and inline/expanded inspection. Hover does not recompute paths. Native resize reports are change-only and coalesced off-paint. No JavaScript frame loop or render-time notification runs.

Persistence and compatibility

The host owns immutable transcript artifacts. ctx.artifacts.publish persists the complete document independently of the surrounding tool result, including discarded acknowledgements and later code-mode errors. The plugin registers removable visual renderers for versions 1 and 2; Source retains original input and Data retains all raw values, including hidden series and nulls.

This plugin requires the updated native host and canvas resize API. Older hosts without artifact support fail with an explicit update message. Invalid persisted documents keep their readable summary and expose a validation error.

Verification

node --import ./plugins/testing/register.mjs --test plugins/visuals/*.test.ts
pnpm -C plugins typecheck
pnpm -C plugins exec prettier --check 'visuals/**/*.{ts,json,md}'

Geometry tests use asymmetric data and independent numeric expectations; view tests exercise real native element factories and handlers. Native desktop checks and app-owned Metal captures supplement these tests; they do not use a browser.

Permissions in 0.2.1

  • Provide agent tools tools.provideMediumGives tools to agents.Let agents preview and publish HTML pages and bounded visual replies into the current chat

Files

fence.test.ts2.7 KB
// The chart fence the manifest declares: its schema file, and the example the
// rules teach agents, which must stay inside that schema.
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { test } from "node:test";
import { renderMermaid } from "./mermaid.ts";

const read = (name: string) => readFileSync(new URL(name, import.meta.url), "utf8");

test("the manifest declares the chart fence with a schema that reads, and the mermaid fence", () => {
  const manifest = JSON.parse(read("plugin.json"));
  assert.deepEqual(manifest.contributes.fences, [
    { lang: "chart", schema: "chart.schema.json", draws: "chart" },
    { lang: "mermaid", draws: "svg" },
  ]);
  const schema = JSON.parse(read("chart.schema.json"));
  assert.equal(schema.$schema, "https://json-schema.org/draft/2020-12/schema");
  assert.equal(schema.additionalProperties, false);
});

test("every chart fence in the rules uses only what the schema allows", () => {
  const schema = JSON.parse(read("chart.schema.json"));
  const fences = [...read("rules.md").matchAll(/```chart\n([\s\S]*?)```/g)].map((match) => JSON.parse(match[1]));
  assert.ok(fences.length > 0, "the rules show a chart fence");
  for (const fence of fences) {
    for (const key of Object.keys(fence)) assert.ok(key in schema.properties, `${key} is in the schema`);
    assert.equal(fence.version, schema.properties.version.const);
    assert.ok(schema.properties.kind.enum.includes(fence.kind));
    for (const series of fence.series ?? []) assert.equal(series.values.length, fence.labels.length);
  }
});

// Every character 0.5em wide, bold or not, so widths are easy to check.
const measurer = { width: (text: string, size: number) => [...text].length * size * 0.5 };

test("a mermaid fence renders as SVG laid out with the app's text widths", async () => {
  const svg = await renderMermaid("flowchart LR\n  A[Parse] --> B[Draw]", { fontSize: 13, measurer });
  assert.match(svg, /^<svg /);
  assert.match(svg, /<text[^>]*>Parse<\/text>/);
  // A wider measurer makes wider boxes: the layout follows the widths it is given.
  const wide = await renderMermaid("flowchart LR\n  A[Parse] --> B[Draw]", {
    fontSize: 13,
    measurer: { width: (text: string, size: number) => [...text].length * size },
  });
  const width = (svg: string) => Number(/viewBox="0 0 ([\d.]+)/.exec(svg)?.[1]);
  assert.ok(width(wide) > width(svg), `${width(wide)} > ${width(svg)}`);
});

test("a malformed mermaid fence throws the error the fence shows", async () => {
  await assert.rejects(async () => renderMermaid("flowchart LR\n  A[Parse --> B", { fontSize: 13, measurer }), /./);
  await assert.rejects(async () => renderMermaid("not a diagram at all", { fontSize: 13, measurer }), /./);
});

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.2latestNov 21, 2026>=2 <4349.5 KB1 permissionListed
0.2.1Oct 25, 2026>=2 <4349.2 KB1 permissionListed
0.2.0Oct 23, 2026>=2 <4349.3 KB1 permissionListed

Reviews and comments

0 threads · 0 reviews

No comments yet.