Skip to content

Runtime data model

These TypeScript contracts describe in-memory state in v0.2.7. Persistence stores only a subset.

export type CellState = "idle" | "running" | "error" | "success";
Value Meaning
idle The cell is not executing and has no current success/error transition.
running The frontend has started an execution request and exposes the interrupt control.
success The last request returned without an error field.
error Kernel startup, invoke, transport, or Python execution produced an error.

Cell state is not persisted.

export type KernelState = "starting" | "idle" | "busy" | "stopped" | "error";
Value Meaning
starting Frontend is ensuring or restarting a process.
idle Backend process is available.
busy The frontend coordinator has reserved the tab for an execution sequence.
stopped No usable process is available, or a stopped sentinel was installed.
error Process or communication failure.
export interface CellOutput {
outputType: "stream" | "error" | "image/png";
streamName?: "stdout" | "stderr";
text?: string;
imageData?: string;
}
  • stream uses streamName to distinguish stdout and stderr.
  • error uses text for the traceback or transport error.
  • image/png and imageData are reserved. The current renderer returns null for this type, and the Python server never emits it.
export interface Cell {
id: string;
type: "code" | "markdown";
source: string;
executionCount: number | null;
outputs: CellOutput[];
state: CellState;
}
Field Durable? Notes
id Yes Generated with crypto.randomUUID() for new cells.
type Yes New cells are code; markdown is reserved.
source Yes Raw editor text.
executionCount No Assigned optimistically before invoking Rust.
outputs No Replaced on every run and cleared on restart.
state No Session-only UI state.
export interface Notebook {
tabIndex: number;
cells: Cell[];
kernelState: KernelState;
executionCounter: number;
}

The store initializes notebook indices 0 through 3. Only cell identity, type, source, order, and the tab index are serialized.

export type KernelResponse = {
id: string;
type: string;
stdout: string;
stderr: string;
error: string | null;
output_type: string;
};

The response uses snake case for output_type because it mirrors the Python JSON protocol. The frontend currently ignores that field when creating output records and derives streams from stdout, stderr, and error.

The Zustand store also holds:

Field Type Meaning
notebooks Notebook[] Four notebook states.
activeTab number Current zero-based tab index; begins at 0.
focusedCellId string | null Temporary request to focus a newly created or advanced-to cell.
isCommandMode boolean Intended command-mode flag set by Escape.

Neither active-tab nor focus state is persisted.