Skip to content
Sign in
DataAnalysis notebookMenu

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.

ProA refund spike traced to a new carrier: 1,204 new orders arrive, five cells go stale, Rerun brings them back in order.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/analysis-notebook

Usage

tsx
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

ProRunning in order with code hidden, a failed cell with its fix, empty, loading and error.

Props

PropTypeNotes
cellsAnalysisCell[]{ id, kind, text?, code?, language?, status?, output?, reads?, defines?, ranWith? }
sourcesAnalysisSource[]{ name, version, change?, meta? }
onRunCell, onRunAll, onRunStale, onInterruptcallbacksRun one, all, the stale ones, or stop
codeHidden, defaultCodeHidden, onCodeHiddenChangebooleanHide every code body
loading, error, onRetry, emptyText, disabledNotebook states

Keyboard

KeyAction
TabMoves through cell actions, code and outputs in order
Enter on a collapsed code lineShows 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.