-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
architectureArchitecture proposals and structural changesArchitecture proposals and structural changesenhancementNew feature or requestNew feature or requestipywidgetsWidget rendering, comm protocol, Output widgetsWidget rendering, comm protocol, Output widgetssyncAutomerge CRDT sync protocolAutomerge CRDT sync protocol
Milestone
Description
Phase A of #761: Schema + dual-write
Add a comms/ top-level map to the notebook Automerge document so widget state is replicated via the same CRDT sync that handles cells and metadata. This is a pure addition — no behavior changes, existing CommState + CommSync continue to work as fallback.
Schema change
ROOT/
schema_version: u64 ← bump to 3
...existing cells/, metadata/...
comms/ ← Map keyed by comm_id (NEW)
{comm_id}/
target_name: Str
model_module: Str ← e.g. "@jupyter-widgets/controls"
model_name: Str ← e.g. "IntSliderModel"
state: Str ← JSON-encoded widget state
outputs/ ← List<Str> (OutputModel only: manifest hashes)
seq: u64 ← Insertion order counter
Precedent
This follows the same pattern as the native metadata migration (#791):
- Add new structured data to the doc
- Dual-write (new + old) during transition
- Remove old path in a later phase
Implementation
crates/notebook-doc/:
- Add
commsmap creation inNotebookDoc::new() - Add
migrate_v2_to_v3()— adds emptycommsmap, bumpsschema_versionto 3 - Add methods:
put_comm(comm_id, target_name, model_module, model_name, state_json, seq),update_comm_state(comm_id, state_json),remove_comm(comm_id),get_comms() -> Vec<CommSnapshot>,clear_comms() - For OutputModel:
append_comm_output(comm_id, manifest_hash),clear_comm_outputs(comm_id) - Tests for all operations
crates/runtimed/ (daemon):
- In the IOPub handler (
kernel_manager.rs), aftercomm_state.on_comm_open(), also write todoc.comms - After
comm_state.on_comm_update(), also updatedoc.comms[comm_id].state - After
comm_state.on_comm_close(), also removedoc.comms[comm_id] - On kernel shutdown (
comm_state.clear()), also calldoc.clear_comms() - Continue sending
CommSyncbroadcast (old path still active)
crates/notebook-protocol/:
- No changes needed —
CommSnapshotstruct already exists and can be reused
What this does NOT change
- Frontend still reads widgets from
CommSyncbroadcast →WidgetStore CommStatestill exists and is kept in sync- Binary buffers still inline (blob store migration is Phase D)
- No new frame types or protocol changes
Testing
- Unit tests: add/update/remove comms in
NotebookDoc, verify withget_comms() - Integration test: daemon writes comm to doc, second client syncs and sees it
- Migration test: v2 doc loads, migration runs,
commsmap exists - Verify existing widget tests still pass (CommSync path unchanged)
Size
Medium — mostly notebook-doc schema work + daemon dual-write wiring.
Part of #761.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
architectureArchitecture proposals and structural changesArchitecture proposals and structural changesenhancementNew feature or requestNew feature or requestipywidgetsWidget rendering, comm protocol, Output widgetsWidget rendering, comm protocol, Output widgetssyncAutomerge CRDT sync protocolAutomerge CRDT sync protocol