Module Quill.Session
Interactive notebook sessions.
A session manages document state with undo/redo history and transient cell execution statuses. It is purely functional: all operations return a new session value.
Sessions do not own a kernel. The caller is responsible for driving kernel execution and feeding results back via apply_output and finish_execution.
Cell status
Sessions
create ?history_capacity doc creates a session from doc. history_capacity defaults to 100.
Accessors
val cell_status : Cell.id -> t -> cell_statuscell_status id s is the execution status of cell id in s.
val can_undo : t -> boolcan_undo s is true if an undo operation is available.
val can_redo : t -> boolcan_redo s is true if a redo operation is available.
Document operations
Structural operations (insert_cell, remove_cell, move_cell, set_cell_kind) record undo history automatically. Source edits via update_source do not -- call checkpoint when the edit sequence is complete.
update_source id source s updates the source of cell id. Does not record undo history. Call checkpoint when the edit sequence ends.
checkpoint s saves the current document to the undo history. Call this at natural boundaries: before execution, before save, on cell focus change. No-op if the document hasn't changed since the last checkpoint.
set_cell_kind id kind s changes cell id to the given kind.
Execution state
Update transient cell status. These do not touch the kernel -- the caller is responsible for driving kernel execution.
val apply_output : Cell.id -> Cell.output -> t -> tapply_output id output s appends output to cell id in the document. The output is visible immediately via doc.
finish_execution id ~success s marks cell id as idle and increments its execution count.
History
undo s restores the previous document state. Returns s unchanged if no undo is available.
redo s restores the next document state. Returns s unchanged if no redo is available.