Skip to content

refactor(notebook): remove dead commands#554

Merged
rgbkrk merged 1 commit intomainfrom
540/phase-2d-cleanup-v2
Mar 6, 2026
Merged

refactor(notebook): remove dead commands#554
rgbkrk merged 1 commit intomainfrom
540/phase-2d-cleanup-v2

Conversation

@rgbkrk
Copy link
Member

@rgbkrk rgbkrk commented Mar 6, 2026

Phase 2D cleanup after the Automerge migration (#553).

Dead code removal (−216 lines Rust)

These Tauri commands are no longer called by the frontend — all cell mutations go through the WASM NotebookHandle + Automerge sync relay:

Removed command Replacement
load_notebook get_automerge_doc_bytes + WASM NotebookHandle.load()
update_cell_source WASM handle.update_source() + sync
add_cell WASM handle.add_cell() + sync
delete_cell WASM handle.delete_cell() + sync
refresh_from_automerge get_automerge_doc_bytes bootstrap

Also removed:

  • cell_snapshot_to_frontend helper (only used by dead commands)
  • notebook:updated cell emissions from init and receiver loop (frontend uses automerge:from-daemon)

Kept:

  • notebook:metadata_updated emission — 3 active frontend listeners (useDependencies, useCondaDependencies, useDenoDependencies)
  • cell:source_updated emission — active listener in useAutomergeNotebook for format feedback
  • onOutput: () => {} — wiring appendOutput causes duplicate outputs (broadcast appends, then Automerge sync replaces with doc state; if React batches both setCells, the functional update runs against the already-replaced state → double output). Sync latency is imperceptible. Future fix: dedup via header.msg_id.

Also gitignores apps/notebook/package-lock.json (project uses pnpm).

@rgbkrk rgbkrk force-pushed the 540/phase-2d-cleanup-v2 branch from 66a2177 to 10fd534 Compare March 6, 2026 07:33
…ming

Phase 2D cleanup after Automerge migration.

Frontend:
- Wire onOutput: appendOutput in App.tsx — broadcast outputs give instant
  feedback, Automerge sync is the eventual-consistency backstop. Fixes
  output streaming latency regression.

Rust dead code removal (-217 lines):
- Remove cell_snapshot_to_frontend helper (only caller was dead commands)
- Remove load_notebook command (frontend bootstraps via WASM)
- Remove update_cell_source command (WASM handle.update_source + sync)
- Remove add_cell command (WASM handle.add_cell + sync)
- Remove delete_cell command (WASM handle.delete_cell + sync)
- Remove refresh_from_automerge command (frontend uses get_automerge_doc_bytes)
- Remove notebook:updated cell emissions (frontend uses automerge:from-daemon)
- Keep notebook:metadata_updated emission (3 active listeners)
@rgbkrk rgbkrk force-pushed the 540/phase-2d-cleanup-v2 branch from 10fd534 to 9dc881c Compare March 6, 2026 07:40
@rgbkrk rgbkrk enabled auto-merge (squash) March 6, 2026 07:42
@rgbkrk rgbkrk mentioned this pull request Mar 6, 2026
45 tasks
@rgbkrk rgbkrk merged commit a3e9f04 into main Mar 6, 2026
19 of 20 checks passed
@rgbkrk rgbkrk deleted the 540/phase-2d-cleanup-v2 branch March 6, 2026 08:10
@rgbkrk rgbkrk changed the title refactor(notebook): remove dead commands, wire real-time output streaming refactor(notebook): remove dead commands 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)
rgbkrk added a commit that referenced this pull request Mar 6, 2026
After PR #554 (dead command removal) and #566 (metadata fallback migration),
NotebookState is only used in 4 functions. This PR removes those usages by:

1. Add dirty flag to WindowNotebookContext - tracks unsaved changes in context
   instead of NotebookState
2. Migrate clone_notebook_to_path to daemon - daemon reads from Automerge,
   clears outputs, generates fresh env_id
3. Decouple initialize_notebook_sync from NotebookState - daemon is source of
   truth; pass explicit notebook_id and cells rather than NotebookState

Step 4 (removing notebook_state field from WindowNotebookContext) is deferred
because fallback usages (get_kernelspec, get_dependencies, etc.) read from
NotebookState when daemon isn't connected. Removing these requires either
removing fallbacks or finding alternative sources.

The daemon now owns notebook content via Automerge; NotebookState remains only
as a local window cache and for fallback cases.
rgbkrk added a commit that referenced this pull request Mar 6, 2026
* refactor: eliminate NotebookState from save, clone, and reconnect

After PR #554 (dead command removal) and #566 (metadata fallback migration),
NotebookState is only used in 4 functions. This PR removes those usages by:

1. Add dirty flag to WindowNotebookContext - tracks unsaved changes in context
   instead of NotebookState
2. Migrate clone_notebook_to_path to daemon - daemon reads from Automerge,
   clears outputs, generates fresh env_id
3. Decouple initialize_notebook_sync from NotebookState - daemon is source of
   truth; pass explicit notebook_id and cells rather than NotebookState

Step 4 (removing notebook_state field from WindowNotebookContext) is deferred
because fallback usages (get_kernelspec, get_dependencies, etc.) read from
NotebookState when daemon isn't connected. Removing these requires either
removing fallbacks or finding alternative sources.

The daemon now owns notebook content via Automerge; NotebookState remains only
as a local window cache and for fallback cases.

* fix: address reviewer feedback on save-as and clone

1. Fix save_notebook_as data loss risk: Read cells and metadata from the
   old room BEFORE disconnecting. The new room won't have them since it's
   a different notebook_id, so we need to carry them across to populate
   the new room if it's empty.

2. Fix clone_notebook_to_disk dropping metadata: Read existing notebook
   to preserve cell metadata, attachments, and non-snapshot notebook
   metadata fields. Use split_inclusive for cleaner source line splitting.
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