Commit 81b73cf
authored
feat: unified frame pipe — single channel, WASM demux, shared frame type constants (#721)
* feat: unified frame pipe — single channel, single event, single command
Replaces the multi-channel relay architecture with one pipe:
Before: 2 channels (sync_tx, broadcast_tx), 2 relay tasks, 2 Tauri events
After: 1 channel (frame_tx), 1 relay task, 1 event (daemon:frame)
PipeChannel { frame_tx } replaces the old raw_sync_tx parameter.
All frame types (AutomergeSync, Broadcast, Presence) flow through
one channel preserving daemon-sent order. Response frames are still
consumed by the request/response cycle.
New send_frame Tauri command handles outgoing frames by type byte.
Old send_automerge_sync kept for backward compat during migration.
Frame type constants moved to notebook-doc::frame_types so all
consumers (daemon, WASM, Tauri, Python) share one source of truth.
WASM gains receive_frame() method that demuxes by frame type byte,
applies sync internally, and returns typed FrameEvent JSON for the
frontend — all protocol knowledge lives in Rust.
Pending frame buffering during request/response now prepends the
type byte so frames pipe correctly after the response arrives.
* feat(frontend): unified daemon:frame listener with WASM demux
Replaces the automerge:from-daemon listener with daemon:frame which
receives all frame types through the unified pipe. The WASM
handle.receive_frame() demuxes by frame type byte, applies sync
internally, and returns typed FrameEvent JSON.
Broadcasts are re-emitted as daemon:broadcast for backward compat
with useDaemonKernel and useEnvProgress. Presence events re-emitted
as daemon:presence for usePresence.
Sync replies from receive_frame (SyncReply events) are sent back
to the daemon via send_frame with the type byte prepended.
frame-types.ts provides shared constants matching
notebook_doc::frame_types in Rust.
WASM artifacts rebuilt with receive_frame() and presence exports.
* fix: address Copilot review — buffer all frame types, rename methods, update docs
- Buffer Broadcast and Presence frames during wait_for_response_with_broadcast
as typed frame bytes (type byte + payload) in pending_sync_frames, so they
reach the frontend via the unified pipe after the response arrives.
Previously only AutomergeSync was buffered; Broadcast went through a
separate broadcast_tx and Presence was dropped.
- Rename connect_split_with_raw_sync → connect_split_with_pipe (Unix + Windows)
- Update setup_sync_receivers doc comment to describe unified relay
- Update receive_frame doc comment to clarify SyncReply wire format
- Remove unnecessary braces around process_incoming_frame block
* fix: double type prefix bug + rename pending_sync_frames → pending_pipe_frames
pending_sync_frames now stores fully-typed frames (type byte + payload)
for AutomergeSync, Broadcast, and Presence. The drain loop was
prepending another AutomergeSync type byte, corrupting frames and
mislabeling non-sync frames.
Fix: drain loop forwards as-is. Rename to pending_pipe_frames to
reflect that it buffers all frame types, not just sync.
* build: rebuild WASM artifacts with receive_frame and presence exports
* feat(presence): add usePresence hook, remove send_automerge_sync
- Create usePresence.ts: listens for daemon:presence events, maintains
remote peer state (cursors/selections), exposes setCursor/setSelection
for outgoing presence via send_frame
- Migrate remaining send_automerge_sync calls to send_frame in save()
and notebook-metadata syncToRelay()
- Remove dead send_automerge_sync Tauri command (frontend fully migrated)
- Update doc comments to reference send_frame
* refactor: rename daemon:frame/broadcast/presence to notebook: prefix
Room-scoped events belong to the notebook: namespace. The daemon:
prefix is reserved for connection lifecycle events (daemon:ready,
daemon:disconnected).
- daemon:frame → notebook:frame
- daemon:broadcast → notebook:broadcast
- daemon:presence → notebook:presence
* fix: address copilot review — catch on unlisten, stale comment
- Add .catch(() => {}) to unlisten cleanup calls per repo pattern
- Update stale automerge:from-daemon reference to notebook:frame
- WASM artifacts still have daemon:frame in docs — will fix on next
wasm-pack rebuild
* build: rebuild WASM artifacts with notebook:frame doc comments1 parent 08dfcf5 commit 81b73cf
File tree
16 files changed
+970
-403
lines changed- apps/notebook/src
- hooks
- lib
- wasm/runtimed-wasm
- crates
- notebook-doc/src
- notebook/src
- runtimed-wasm/src
- runtimed/src
16 files changed
+970
-403
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
103 | | - | |
104 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
105 | 110 | | |
106 | 111 | | |
107 | 112 | | |
| |||
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
140 | | - | |
| 145 | + | |
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
| |||
205 | 210 | | |
206 | 211 | | |
207 | 212 | | |
208 | | - | |
209 | | - | |
210 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
211 | 223 | | |
212 | 224 | | |
213 | 225 | | |
214 | 226 | | |
215 | 227 | | |
216 | 228 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
232 | 286 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | 287 | | |
237 | | - | |
| 288 | + | |
238 | 289 | | |
239 | 290 | | |
240 | 291 | | |
| |||
257 | 308 | | |
258 | 309 | | |
259 | 310 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
264 | 315 | | |
265 | 316 | | |
266 | 317 | | |
267 | 318 | | |
268 | 319 | | |
269 | 320 | | |
270 | | - | |
| 321 | + | |
271 | 322 | | |
272 | 323 | | |
273 | 324 | | |
| |||
412 | 463 | | |
413 | 464 | | |
414 | 465 | | |
415 | | - | |
416 | | - | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
417 | 471 | | |
418 | 472 | | |
419 | 473 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
| 380 | + | |
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
410 | | - | |
| 410 | + | |
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| |||
0 commit comments