Skip to main content

Module virtual_rows_worker

Module virtual_rows_worker 

Source
Expand description

D.0a.1 (2026-05-29) — Virtual-rows worker.

Sibling of cells_worker. Owns the rebuild path for the displacing-virtual-row primitive landed in D.0a (lattice_cells::VirtualRowMatrix) and publishes the result via the shared virtual_rows_matrix_cell: Arc<ArcSwap<VirtualRowMatrix>> on Editor.

§Why this exists

Per paramount goal #1 (CLAUDE.md): UI thread does no I/O, no parsing, no shaping. Virtual rows are the renderer’s input for inline diff deletion blocks (D.3), multibuffer excerpt headers (M.2), and future inlay-hint / signature-preview consumers. Each consumer registers a VirtualRowProvider; the worker polls them off-thread and publishes a fresh VirtualRowMatrix via RCU.

§D.0a.1 scope — minimal

  • VirtualRowProviderRegistry — BufferId-keyed (as of D.4.d.2.1.a). Each visible buffer owns its own ProviderId → provider map so baseline + current panes’ filler providers (D.4.c) coexist without colliding on ProviderId, and the worker (post-D.4.d.2.1.b) can iterate panes and poll each one’s scope independently. This slice keeps the worker single-pane: recompute reads active_document.document_buffer_id and snapshots only that buffer’s providers. Today’s sole producer (the D.3.a inline diff overlay) registers against the same buffer the worker reads, so behaviour is identical for single-pane flows.
  • recompute — sync decision function. Tests call this directly to assert each branch.
  • run — async loop. wake.notified().awaits the VirtualRowsWake signal, then calls recompute.
  • Cache-hit fingerprinting via a stable hash of [(provider_id, provider_version)] + source_line_count. The worker holds its own monotonic publish counter; the matrix’s version only bumps when the fingerprint changes, so downstream consumers compare versions to invalidate their derived state cheaply.

§What this slice does NOT do

  • No production provider yet. The first one lands with D.3 (inline diff overlay’s deletion-block provider) or M.2 (multibuffer excerpt-header provider), whichever ships first.
  • No per-pane matrices. v1 uses one global matrix tied to the active document. Multi-pane diff (D.4) and project-wide diff (multibuffer M.6) will introduce per-pane or per-document indexing then.
  • No paint-debounce inside the worker. Notify-permit coalescing (mirrors cells_worker) handles bursts — the worker rebuilds once per quiescent burst regardless of how many wakes arrived.

Structs§

VirtualRowProviderRegistry
Process-wide registry of VirtualRowProvider instances, scoped per BufferId (D.4.d.2.1.a).
VirtualRowsWorkerState
Worker-local state held across recompute calls.

Enums§

WorkerDecision
Recompute decision the worker takes on a wake. Visible for testing; the production loop calls recompute directly.

Functions§

recompute
Pure sync recompute. Iterates rs.cells.panes, dispatches each to recompute_pane, and aggregates the per-pane decisions into a single one for the async loop. Returns the aggregate so tests can assert behaviour without driving run.
recompute_pane
D.4.d.2.1.c (2026-05-30): per-pane recompute. Same shape as cells_worker::recompute_pane. Visible for tests that want to assert per-pane decisions without driving the aggregate.
run
Worker entry point spawned at boot. Loops forever, awaiting the wake Notify. Each wake re-reads the latest RenderState + provider registry and calls recompute.