Skip to content

feat(runtimed): format-on-execute, remove Tauri format_cell command#563

Merged
rgbkrk merged 1 commit intomainfrom
540/format-on-execute
Mar 6, 2026
Merged

feat(runtimed): format-on-execute, remove Tauri format_cell command#563
rgbkrk merged 1 commit intomainfrom
540/format-on-execute

Conversation

@rgbkrk
Copy link
Member

@rgbkrk rgbkrk commented Mar 6, 2026

The daemon now formats cell source before execution, replacing the Tauri-mediated format_cell command. Formatting ownership is fully daemon-side.

How it works

Format-on-execute: When a cell is executed (Shift+Enter), the daemon formats the source with ruff (Python) or deno fmt (Deno) before queuing it for the kernel. The formatted source is written back to the Automerge doc and syncs to all peers. Best-effort — if formatting fails (syntax error, formatter unavailable), the original source executes unchanged.

Format-on-save: Already daemon-owned since PR #545. No change here.

QA

  • Python: x=1+2 → Shift+Enter → source reformats to x = 1 + 2
  • Deno: verified formatting via deno fmt

What was removed

Tauri commands (−111 lines Rust):

Removed Reason
format_cell command Last consumer of handle.get_cells() + handle.update_source() — blocking relay simplification (#556)
check_formatter_available command Zero frontend callers
cell:source_updated event emission Only emitter was format_cell

Frontend (−25 lines TS):

Removed Reason
⌘⇧F / Ctrl+Shift+F keybinding Vestigial — no UI affordance, format-on-execute covers the use case
onFormat prop chain useCellKeyboardNavigationCodeCellNotebookViewApp.tsx
formatCell callback in useAutomergeNotebook Was a no-op after command removal
cell:source_updated listener Only consumer of the removed event

Daemon changes

  • Extract format_source() helper from format_notebook_cells() — reusable for single-cell formatting
  • Extract detect_room_runtime() helper — shared between format-on-execute and format-on-save
  • Add format step in ExecuteCell handler before kernel queue

−164 net lines. Unblocks relay simplification by removing the last handle.get_cells() consumer in Tauri.

The daemon now formats cell source before execution (best-effort,
non-blocking on failure). This replaces the Tauri-mediated format_cell
command and moves formatting ownership fully to the daemon.

Daemon changes:
- Extract format_source() helper from format_notebook_cells()
- Add format-on-execute in ExecuteCell handler: format source, write
  back to Automerge doc, then queue for kernel execution
- format_notebook_cells() refactored to use format_source() (format-on-save
  was already daemon-owned)

Tauri removals (-111 lines):
- format_cell command (was last consumer of handle.get_cells() +
  handle.update_source(), blocking relay simplification)
- check_formatter_available command (zero frontend callers)
- Both invoke_handler registrations

Frontend changes:
- Remove cell:source_updated listener (only emitter was format_cell)
- formatCell callback becomes no-op (⌘⇧F keybinding is vestigial,
  formatted source arrives via Automerge sync after execution)
@rgbkrk rgbkrk force-pushed the 540/format-on-execute branch from 278e7a5 to f4f54a0 Compare March 6, 2026 15:39
@rgbkrk rgbkrk merged commit 9f2fa1e into main Mar 6, 2026
14 checks passed
@rgbkrk rgbkrk deleted the 540/format-on-execute branch March 6, 2026 16:11
rgbkrk added a commit that referenced this pull request Mar 8, 2026
Addresses #596:
- Delete get_preferred_kernelspec Tauri command (zero frontend callers)
- Delete format module (202 lines, zero callers after #563)

Frontend reads kernelspec from WASM doc via useSyncExternalStore.
Formatting now lives in daemon (format-on-execute).
rgbkrk added a commit that referenced this pull request Mar 8, 2026
* refactor(notebook): remove fallback branches, keep mutation-based initialization

This PR simplifies the Tauri relay architecture (issue #556):

Task 1: Remove NotebookState fallback branches
- Remove fallback in get_preferred_kernelspec() - now requires daemon
- Remove fallback in verify_notebook_trust() - now requires daemon

Keeps mutation-based cell initialization:
- The initial_cells via handshake approach was reverted because:
  1. Handshake has 64 KiB frame limit - large notebooks would fail
  2. Architecturally wrong - daemon should determine cell seeding
- Mutations (add_cell, update_source, set_metadata) remain for now
- NotebookState.path sync restored for session restore compatibility

* chore(notebook): remove dead get_preferred_kernelspec and format module

Addresses #596:
- Delete get_preferred_kernelspec Tauri command (zero frontend callers)
- Delete format module (202 lines, zero callers after #563)

Frontend reads kernelspec from WASM doc via useSyncExternalStore.
Formatting now lives in daemon (format-on-execute).
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