-
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 B of #761: Frontend and Python read widget state from CRDT
After Phase A (#808) dual-writes widget state to both CommState and doc.comms, this phase switches the frontend and Python clients to read widget state from the Automerge document instead of the CommSync broadcast.
Frontend changes
crates/runtimed-wasm/:
- Add
get_comms_json() -> String(orget_comms() -> JsValueviaserde_wasm_bindgen) - Return comms sorted by
seqfor dependency-correct widget instantiation
apps/notebook/src/:
- Add a
useWidgetDochook (or modifyuseAutomergeNotebook) that watchesdoc.commschanges after eachsync_appliedevent - On doc change: diff comms map against
WidgetStore, create/update/delete models - Handle
CommSyncbroadcast as a fallback during transition (ifdoc.commsis empty butCommSyncarrives, use it) -
WidgetStore.createModel/updateModel/deleteModeldriven by doc state, not broadcast
Key insight: The current materializeCells() pattern — read from WASM after sync, update React state — extends naturally to comms. After sync_applied, the frontend reads both cells and comms from the WASM handle.
Python changes
crates/notebook-sync/ (DocHandle):
- Add
get_comms() -> Vec<CommSnapshot>convenience method onDocHandle(callswith_doc)
crates/runtimed-py/:
- Add
session.get_widgets()/async_session.get_widgets()that reads from the doc - After
confirm_sync(), widget state is available directly — no broadcast accumulation needed
What stays (for now)
CommSyncbroadcast still sent by daemon (removed in Phase C)CommStatestill maintained in daemon (removed in Phase C)NotebookBroadcast::Commforcomm_open/comm_msg(update)/comm_closestill sent (removed in Phase C)- Frontend still listens for
comm_custombroadcasts (these are irreducible events, never move to CRDT)
Testing
- Open notebook with widgets → widgets render from doc state (not CommSync)
- Second window opens → widgets appear via Automerge sync (no CommSync needed, but it's still sent as backup)
- Python
get_widgets()returns current widget state afterconfirm_sync() - Widget state update from kernel → appears in both frontend and Python via doc sync
Size
Medium-Large — frontend hook changes + WASM bindings + Python bindings.
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