Files
CatoandClaude Fable 5.1 b37c3d65ce feat(rich): chart blocks in answers, drawn by an injected renderer (0.15) (#28)
"Who produces gallium?" now carries a ranked bar chart, not a list. chatkit
stays dependency-free: it defines the data contract (`ChartBlock`, mirroring
@bitbaum/chartkit's props for line, bars, share, timeline, tiles) and a
renderer slot (`renderers={{ chart }}` on ChatScreen, ChatThread, ChatMessage,
Markdown and RichAnswerBlock); the app injects the drawing.

- Parser: each kind validated field by field (bounded lists, finite numbers,
  safe links). A malformed block is rejected by the parser and degrades to
  its caption and a table of the safe rows; without a renderer, or when one
  returns null, chatkit draws that table itself. A chart is never a blank.
- Instruction: when to draw (ranked 3+ rows -> bars, shares -> share, 3+
  points over time -> line, 3+ dated events -> timeline, 2-4 figures ->
  tiles), figures only from tool results, hrefs copied from the result.
- Copy and Listen read the figures as lines, never the wire JSON.
- Tests: node tests per kind, the fallback and the renderer paths; the
  browser test renders a bars block through a stub renderer and a line block
  through the fallback in demo/screen.html at 320/390/1280, with the
  broken-word scan and no horizontal overflow.


Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-23 11:09:15 +02:00

55 lines
1.5 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content"
/>
<title>chatkit — full screen</title>
<link rel="stylesheet" href="../node_modules/@bitbaum/design-tokens/tokens.css" />
<link rel="stylesheet" href="../styles.css" />
<style>
/* ChatScreen is the whole page: nothing else here on purpose. */
body {
margin: 0;
}
/* The demo's stand-in for an injected chart renderer (chartkit in
Substrata): a labelled bar per row, the highlighted one in the accent. */
.demo-bars {
display: grid;
gap: 0.5rem;
}
.demo-bar {
display: grid;
grid-template-columns: minmax(0, 7rem) 1fr auto;
align-items: center;
gap: 0.75rem;
font-size: 0.9375em;
}
.demo-bar-track {
height: 0.875rem;
border-radius: 999px;
background: var(--ck-raised);
overflow: hidden;
}
.demo-bar-fill {
display: block;
height: 100%;
background: var(--ck-fg-3);
}
.demo-bar-hi {
background: var(--ck-accent);
}
.demo-bar-value {
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
</style>
</head>
<body>
<div id="screen"></div>
<script src="./dist/demo.js"></script>
</body>
</html>