An analytics assistant’s thread: the queries it ran, sources with previews, an annotated chart of what dropped and when, and a composer with @table mentions.
select step, platform, count(*) from events where ts >= 'Oct 6' group by 1, 242 rows · 820 ms
select day, platform, avg(verified_at is not null) from signups group by 1, 242 rows · 310 ms
select version, shipped_at, notes from release_log where shipped_at >= 'Oct 1'1 row · 90 ms
Activation fell from 41% to 33%. Nearly all of the loss is at email verification, and it is all in Android sign-ups since the 2.14 release.
Email verified, by platform
Line chart of the share of sign-ups who verified their email, by day from October 6 to 19. Web holds near 90% and iOS near 85%. Android holds near 79% until release 2.14 ships on October 13, then falls to 44% by October 19, 35 points under its expected level.
Daily, Oct 6 – 19 · dashed = expectedActivated 33% · was 41%
Since 2.14, Android opens the verification link in an in-app browser that drops the session, and a third of those users never return to the app. Sending the link back to the system browser, as 2.13 did, should win back most of the drop.
The live component, numbered part by part. Every measurement is read from it as it is drawn. Point at a row to outline its part, or at a part to find its row.
A panel or page of its own, one thread at a time. The window grows to 760 px wide and centres itself in what is left.
Its layout answers to its container, not the screen: at 560 px and under, the range shows its icon only and the gap label drops “vs expected”; at 400 px and under, the title gets a row of its own, with the picker and Share under it.
maxHeight (560 px by default) is how tall the thread gets before it scrolls inside its own box, keeping its end in view. Set it to the room the panel has.
answer comes first: what changed, by how much and where, in a sentence or two.
Then chart or table, never both: the table takes the chart’s place. Past one chart, a thread is hard to scan.
Mark the change on the chart: anomaly turns a series red from the day it left its expected level and hatches the gap; marker names what happened that day.
followUp goes under the chart with the why and what to do; suggestion is the next question, asked when pressed.
List in sources every table or doc the answer read, and in thought the queries it ran, so the answer can be checked.
onAsk hears every question sent, with the tables it mentions and the format, range, comparison and model it was sent with. Run the question from there.
The answers the thread writes back to new questions come from its own sample tables. Wire it to your data before it shows real figures.
tables lists what “@” offers, with row counts; models fills the picker, the first one chosen.
Every piece of a thread is written to be read in order: the finding, the proof, then what to do.
The title: the finding as a noun phrase, sentence case, no full stop: Refund spike on Tuesday.
The question: as someone would ask it, with the metric and the time: Why did activation drop last week?
The answer: the figures first, with the before and after: Activation fell from 41% to 33%.
The chart: a title naming what is measured and how it is split (Email verified, by platform), a caption with the range, and a headline with the figure.
The marker: what happened, in two or three words (2.14 shipped), with its date under it.
describe: the chart in sentences for screen readers, with the figures a sighted reader would take from it.
The suggestion: the next question, short enough for a chip: Compare 2.13 vs 2.14.
Sources: the table or doc names as they are in your warehouse, so people can find them.
Either way it needs React 19 and a bundler that supports CSS Modules, such as Next.js or Vite. It has a dark colour scheme: it follows your page’s color-scheme, light unless the page sets one, or its colorScheme prop, with nothing to configure. Browsers without light-dark() show it light.
One question about the data and its answer, laid out so the work shows. “Thought for 12 s · ran 3 queries” opens to the queries; the sources are chips that preview their columns; the chart draws each platform, the one that fell in red from the day a release shipped, its expected level dashed and the gap hatched with its size. The composer turns “@” into a menu of tables and the one picked into a token, picks the answer’s format, range and comparison, and streams the answer back with a small chart or table. Light and dark.
The chart is SVG drawn in real px: a ResizeObserver reads its box, so the text never stretches and the labels are HTML over it. Each line is a run of cubic curves whose handles follow the neighbouring days. A series with an anomaly turns red from its first day off, a dashed line holds its expected level, and the gap between them is filled with a hatch pattern and labelled with its size in points.
The values at the right end are sorted by height and pushed apart so none overlap. The release marker’s label goes under the lines, or over them when the lines run low, as in the refund spike.
The crosshair follows the pointer (or the arrow keys, Home and End) to the nearest day: a dot on each series and a tooltip with the values, highest first, that flips to the left past the middle. The legend’s buttons turn series off, and the gap goes with its series.
The composer is a line of parts: text, @table tokens, and the field being typed. A space or the start followed by “@” and letters opens the Tables menu, filtered by those letters; Enter or a press turns the match into a token. Backspace in the empty field takes back the last part whole.
A question is answered from its words and the tables it mentions: a breakdown by channel, a comparison of versions, or activation by platform. The format picks bars, a table or text alone; the range dilutes the drop over a longer window; the comparison adds last week as ticks on the bars or a change column.
The answer thinks for a moment, then streams two words at a time; Send turns into Stop meanwhile. Under reduced motion it comes all at once. The thread scrolls inside its own box and keeps its end in view.
The model picker sets how long the next answer thinks and how many queries it runs. Share and Copy write to the clipboard; the thumbs up is a toggle.
While on screen and untouched, a demo pointer opens the queries, reads the chart a day at a time, types “Break it down by @”, picks signups, types “channel” and sends. Any real input hands it over; it comes back after 9 s of quiet.
The conversation it opens on: title, question, the queries behind it, the answer, sources, a line chart or a table, the follow-up and a suggestion. null opens on the composer alone. ACTIVATION, REFUNDS and CHURN are exported.
assistant
string
'Wren'
The assistant’s name, in the composer’s placeholder and what it announces.
models
Model[]
three
The header’s model picker: name, a note and how long it thinks. The first is chosen.
tables
{ name: string; rows: string }[]
four
The tables “@” lists, with their row counts.
defaultFormat
'text' | 'chart' | 'table'
'chart'
How new answers come back at first.
defaultRange
'7d' | '30d' | '90d'
'30d'
The range new answers cover at first.
onAsk
(question: string, options) => void
—
Called with each question sent, its mentioned tables, and the format, range, comparison and model it was sent with.
maxHeight
number
560
The thread’s height before it scrolls on its own, in px.
autoplay
boolean
true
While on screen and untouched, a demo pointer shows the main interactions. Any real input stops it.
defaultState
InsightThreadState
—
Opens held in a moment (queries open, a day read, a menu open, a question half answered), with the demo off.
colorScheme
'light' | 'dark' | 'system'
—
Light or dark colours, or the reader’s; without it, the page’s color-scheme.
The thread is a section named by its title; each question and answer is an article named by its question, marked busy while its answer streams.
A polite live region announces the answer once it is complete, not word by word, and says when a table is added to the question.
The chart
The chart says in words what it shows: its describe text is tied to the plot by aria-describedby.
The plot takes the focus: the Left and Right arrows, Home and End read a day at a time into a live region, and Escape clears it. The legend’s buttons are aria-pressed.
Colour is never the only sign of the change: the expected level is dashed, the gap is hatched and labelled with its size in points (WCAG 1.4.1, A).
Every word, figure and end label is at least 4.5:1 against its surface in both schemes (WCAG 1.4.3, AA), and the lines, marks and switch track at least 3:1 (WCAG 1.4.11, AA).
Keyboard
The composer’s field is a combobox: “@” opens a listbox of tables, the arrows move through it, Enter or Tab picks and Escape closes. Enter sends; Backspace in an empty field takes back the last part whole. The model and range menus move with the arrows, Home and End, and Escape closes them with the focus back on their button. The format is a radiogroup moved with the arrows; the comparison is a switch.
Motion
Under reduced motion nothing slides, blinks or streams: an answer comes all at once, and the demo never plays. Otherwise the pointer over it holds the demo, and the first press, key or wheel stops it for good (WCAG 2.2.2, A).
In this build
The thread is a section named by its title; each question and answer is an article named by its question, busy while its answer streams. The answer is announced in a polite live region once it is complete, not word by word.
The chart says in words what it shows. Its plot takes the focus: the arrow keys, Home and End read a day at a time into a live region, and Escape clears it. The legend’s buttons are aria-pressed.
The source chips are buttons whose preview is a tooltip linked by aria-describedby, shown on hover and on focus and closed by Escape.
The composer’s field is a combobox: “@” opens a listbox of tables, the arrows move aria-activedescendant, Enter or Tab picks and Escape closes. The model and range are menu buttons whose menus move with the arrows and close on Escape with the focus back on their button.
The format is a radiogroup moved with the arrow keys; the comparison is a switch; dictation is a toggle button. Send is aria-disabled until there is a question, and becomes Stop while an answer streams.
Under reduced motion nothing slides, blinks or streams and the demo never plays. The demo pointer is decorative.
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import { useEffect, useId, useRef, useState,typeCSSProperties,typeKeyboardEventasReactKeyboardEvent,typePointerEventasReactPointerEvent,} from'react';importtype { BarSpec, LineChartSpec, TableSpec } from'./data';import styles from'./insight-thread.module.css';/* * The charts in the thread, hand-drawn: * * - LineChart, the annotated one: a line per series, the dropping (or jumping) one red from the * day it leaves its expected level, a dashed line where it was expected and the gap hatched * between them with its size, a marker on the day something shipped, values at the ends, and a * crosshair with the day's values under the pointer or the arrow keys. It is drawn in real px * (its width read by a ResizeObserver), so the text never stretches; labels and the tooltip are
insight-thread.module.css
/* Insight thread (insight-thread.tsx): an analytics assistant's window on a grey stage, near-black by night and white by day. The header, the thread in an inset panel that scrolls on its own, and the composer with its tools under it. The charts (charts.tsx) use the same tokens. Colours are the tokens below, light-dark(light, dark) where the two differ: the component takes the color-scheme it inherits from the page, or the one its colorScheme prop sets (data-color-scheme). */.root {--stage: #e9e9ec;--window: #ffffff;--panel: #f7f7f8;--line: #e7e7ea;--line-2: #dcdce1;--ink: #18181b;--ink-2: #66666e;--ink-3: #6d6d73;--bubble: #ededf0;--chip: #ffffff;--hover: #f1f1f3;--card: #ffffff;--grid: #d9d9de;--menu: #ffffff;--menu-active: #f0f0f3;
data.ts
// Copyright (c) 2026 Bruno Delorence. MIT License./* * The insight thread's content: the thread it opens on (a question, the queries the assistant * ran, its answer, the sources and an annotated chart), the tables the composer can mention, and * the answers it writes for new questions. Answers are read from the question's words, the * tables it mentions, the format, the range and the comparison, so every option changes them. */exporttypeTone = 'green' | 'violet' | 'amber' | 'red' | 'blue';/** One line of the annotated chart. */exporttypeSeries = { id: string; name: string; tone: Tone;/** One value a day, in percent. */ values: number[];/** From this day on the line runs off the level it was expected at: drawn red, the gap hatched. */ anomaly?: { from: number; expected: number };};exporttypeLineChartSpec = { title: string;
menu.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import { useEffect, useLayoutEffect, useRef, useState,typeKeyboardEventasReactKeyboardEvent,typeReactNode,} from'react';import { Icon } from'./glyphs';import styles from'./insight-thread.module.css';/* * The menus: placed on the stage under their trigger (over it when there is no room below), in * the stage's own px, since a gallery card may scale the whole stage. The arrows, Home and End * move between items; Escape closes and gives the focus back; a press elsewhere closes. */constITEMS = '[role="menuitem"], [role="menuitemradio"]';exportfunctionMenu({
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';importtype { CSSProperties, Ref } from'react';/* * The demo's pointer, and the steps that move it. A demo is a script of awaited steps: wait, or * glide the pointer somewhere. Stopping the demo (the reader takes over, or it scrolls away) ends * the step in progress at once: its promise rejects, which ends the script right there, and the * pointer fades out. * * Each glide is a curved flight played by the Web Animations API, so nothing runs frame by frame. * The points of the flight are handed to whoever wants to move along with it. The arrow and the * hand are HTML boxes * that swap by their visibility: a change of style inside an SVG would lay the SVG out again. */exporttypePoint = { x: number; y: number };/** A glide's path and timing, for an animation that plays along with it. */exporttypeFlight = { points: Point[]; timing: KeyframeAnimationOptions };exporttypeDemo = {
use-autoplay.ts
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import { useCallback, useEffect, useRef, useState } from'react';/* * When a demo may play on its own: while part of it is on screen and the tab is visible, never * under reduced motion, and never again once the reader has used it. `take()` (a press, a key or * the wheel) hands it to the reader for good, until the component remounts. `pause()` (the * pointer moving over it) only holds it, and it carries on `idle` ms after the pointer stops. */exportfunction useAutoplay<TextendsHTMLElement>(idle = 6000) {const ref = useRef<T>(null);const [visible, setVisible] = useState(false);const [reduced, setReduced] = useState(true);const [taken, setTaken] = useState(false);const [paused, setPaused] = useState(false);const timer = useRef(0);useEffect(() => {const element = ref.current;if (!element) return;let onScreen = false;