Analysis notebookPro
Analysis as question, code, output and note cells on one spine. Cells run in order, turn stale when a source gets new data, rerun in one action and collapse their code.
On this page
Installation
Usage
import { AnalysisNotebook } from "@/components/ui/chatcn/pro/analysis-notebook"
<AnalysisNotebook
title="Refund spike, October"
cells={cells}
sources={[{ name: "orders", version: 42, change: "1,204 new rows" }]}
onRunStale={rerun}
onRunAll={runAll}
/>Staleness is computed for you. Give each cell the sources and variables it reads and defines, and the source versions its last run saw in ranWith. When a source's version moves, every cell that read it turns stale, and so does everything downstream through variables, notes included. Outputs are tables, charts (drawn by the free chart), metrics, text and errors with a fix. staleCells in chatcn-pro-data-a does the same in your backend.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
cells | AnalysisCell[] | { id, kind, text?, code?, language?, status?, output?, reads?, defines?, ranWith? } |
sources | AnalysisSource[] | { name, version, change?, meta? } |
onRunCell, onRunAll, onRunStale, onInterrupt | callbacks | Run one, all, the stale ones, or stop |
codeHidden, defaultCodeHidden, onCodeHiddenChange | boolean | Hide every code body |
loading, error, onRetry, emptyText, disabled | Notebook states |
Keyboard
| Key | Action |
|---|---|
| Tab | Moves through cell actions, code and outputs in order |
| Enter on a collapsed code line | Shows the code |
Accessibility
- Each code cell is a labelled region named by its number and language.
- Stale is said in words with its reason, not only by the amber rule on the spine.
- A run finishing is announced once; progress inside a run is not.
Motion
Stale outputs fade to 45% over 150 ms and come back when they rerun. Notes rewrite as plain streamed text. Nothing moves; reduced motion keeps the fades.