Skip to content

feat(notebook): make addCell and deleteCell optimistic#542

Merged
rgbkrk merged 1 commit intomainfrom
feat/optimistic-cell-mutations
Mar 5, 2026
Merged

feat(notebook): make addCell and deleteCell optimistic#542
rgbkrk merged 1 commit intomainfrom
feat/optimistic-cell-mutations

Conversation

@rgbkrk
Copy link
Member

@rgbkrk rgbkrk commented Mar 5, 2026

Phase 0 of the local-first Automerge migration: eliminate user-visible latency for cell mutations.

addCell and deleteCell now update React state immediately and fire-and-forget the backend sync. The existing notebook:updated Automerge broadcast acts as the convergence backstop.

Changes

addCell — UUID generated on frontend via crypto.randomUUID(), cell constructed locally, invoke is fire-and-forget. Backend add_cell command accepts an optional cell_id parameter.

deleteCell — last-cell guard moved to frontend, invoke is fire-and-forget. Backend delete_cell returns Ok(()) instead of Err when the cell can't be deleted.

Testing

  • Rapid add/delete feels instant
  • Last-cell guard prevents deleting the only cell
  • Frontend-generated UUIDs flow through to Automerge doc
  • Second window sees cells appear/disappear via sync
  • No console or daemon errors under normal operation

Move cell mutations to fire-and-forget: React state updates before
invoke(), eliminating user-visible IPC latency.

addCell: generate UUID via crypto.randomUUID() on the frontend,
construct NotebookCell locally, pass cellId to backend. Backend
add_cell command accepts optional cell_id parameter.

deleteCell: move last-cell guard to frontend, fire-and-forget the
backend sync. Backend delete_cell returns Ok(()) instead of Err
when the cell is last or not found.

Convergence is maintained by the existing notebook:updated listener
which does a full setCells() from the Automerge doc on every sync
broadcast.
@rgbkrk rgbkrk merged commit ccb6ae8 into main Mar 5, 2026
10 checks passed
@rgbkrk rgbkrk deleted the feat/optimistic-cell-mutations branch March 5, 2026 19:53
rgbkrk added a commit that referenced this pull request Mar 5, 2026
@rgbkrk rgbkrk mentioned this pull request Mar 5, 2026
45 tasks
rgbkrk added a commit that referenced this pull request Mar 6, 2026
rgbkrk added a commit that referenced this pull request Mar 6, 2026
…e architecture

Update 12 files across AGENTS.md, README, contributing/, and docs/ to
reflect the local-first Automerge migration (PRs #542-#554):

- AGENTS.md: add Notebook Document Architecture section (WASM peers,
  mutation flow, sync flow), update key files table, add runtimed-wasm
  build note
- README.md: add runtimed-wasm to project structure
- contributing/architecture.md: conformance table now fully Conformant
- contributing/build-dependencies.md: add runtimed-wasm to all three
  Mermaid diagrams and key points table
- contributing/development.md: add wasm-pack manual build note
- contributing/runtimed.md: cross-reference runtimed-wasm shared code
- docs/runtimed.md: rewrite Phase 5 for actual local-first architecture,
  fix stale Known Limitations, update summary table
- docs/python-bindings.md + python/runtimed/README.md: add session.save()
- docs/logging.md: fix stale log prefixes
- useDaemonKernel.ts: fix stale comment (notebook:updated → automerge:from-daemon)
rgbkrk added a commit that referenced this pull request Mar 6, 2026
…e architecture (#560)

Update 12 files across AGENTS.md, README, contributing/, and docs/ to
reflect the local-first Automerge migration (PRs #542-#554):

- AGENTS.md: add Notebook Document Architecture section (WASM peers,
  mutation flow, sync flow), update key files table, add runtimed-wasm
  build note
- README.md: add runtimed-wasm to project structure
- contributing/architecture.md: conformance table now fully Conformant
- contributing/build-dependencies.md: add runtimed-wasm to all three
  Mermaid diagrams and key points table
- contributing/development.md: add wasm-pack manual build note
- contributing/runtimed.md: cross-reference runtimed-wasm shared code
- docs/runtimed.md: rewrite Phase 5 for actual local-first architecture,
  fix stale Known Limitations, update summary table
- docs/python-bindings.md + python/runtimed/README.md: add session.save()
- docs/logging.md: fix stale log prefixes
- useDaemonKernel.ts: fix stale comment (notebook:updated → automerge:from-daemon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant