Persistence model
Molt persists a small notebook document, not a running notebook session.
Durable state
Section titled “Durable state”The version 1 persistence snapshot contains:
- Four tab entries.
- Each tab’s numeric index.
- Each cell’s UUID.
- Each cell’s reserved type value.
- Each cell’s Python source.
- Cell order through array order.
This is enough to reconstruct the visible editing surface.
Transient state
Section titled “Transient state”The following fields are deliberately excluded:
- Cell outputs.
- Execution counts.
- Idle, running, success, or error states.
- Notebook execution counters.
- Toolbar kernel state.
- Python globals, imports, objects, open files, or package state.
- Active tab and editor focus.
On load, persisted cells receive fresh transient defaults. Every kernel begins as a new Python process when ensured.
Debounced writes
Section titled “Debounced writes”The React persistence hook subscribes to the Zustand store after the initial load completes. It waits 1.5 seconds after the latest change, extracts only persistable fields, and compares the serialized snapshot with the last saved snapshot.
A write is skipped when only transient state changed. Running a cell therefore does not write merely because outputs or execution labels changed. Editing source, inserting a cell, deleting a cell, moving a cell, or clearing a tab changes the persisted snapshot and triggers a write.
Saves are serialized, so an older write cannot finish after a newer snapshot. A failure remains pending and appears in a warning banner; a later durable change or the best-effort unmount flush can retry it.
Initial-load safety
Section titled “Initial-load safety”The UI does not render the notebook until the load attempt finishes. The save subscription also stays disabled during that phase, preventing blank initial state from overwriting existing data before it has been read.
If no file exists, Molt keeps its default four one-cell notebooks.
If loading or validation fails, Molt shows a warning, continues with defaults, and disables autosave for that session so it cannot overwrite the invalid file. There is no in-app repair interface.
File-level consequences
Section titled “File-level consequences”Persistence atomically replaces one JSON file rather than using a database or one file per tab. This makes backups and manual inspection simple, but it also means:
- Clear can quickly replace an entire tab’s source in the next autosave.
- Manual edits should be performed only while Molt is quit.
- A malformed file can prevent source restoration.
- There is no built-in history, versioning, conflict resolution, or cloud synchronization.
Use Manage saved work for safe backup and recovery procedures.
Configuration is separate
Section titled “Configuration is separate”config.toml and notebooks.json share the Molt Application Support directory but have separate lifecycles:
- Configuration is loaded synchronously by the Rust backend and rewritten when Settings is saved.
- Notebook data is loaded and saved through Tauri commands called by the React persistence hook.
Changing a configuration field does not modify notebook source. Resetting notebooks.json does not reset the interpreter or appearance setting.
