Expand description
EditorActor — the editor runs on its own thread.
Phase 5.8.AF.5 / Slice 3c.0.
§Why this exists
Paramount goal #4 (CLAUDE.md): “Three-layer architecture (UI / Core / Plugins) communicating via typed message passing. Multi-threaded by construction. Nothing blocks the UI – enforced architecturally, not by discipline.”
After Slices 3a + 3b.* moved every per-buffer LSP cache off
the renderer thread via wait-free read primitives, the last
piece of architectural debt is Editor itself living on the
renderer thread. While the renderer holds &mut Editor, the
UI thread can (in principle) do editor work synchronously,
and any future feature that does so silently regresses the
architecture. The fix: relocate Editor to its own thread so
the renderer is physically incapable of touching it
directly.
§Shape
EditorActorHandle— what the renderer holds. Carries the command-send half (cmd_tx), the signal-receive half (signal_rx), and a clone of the editor’sArc<ArcSwap<RenderState>>. NotClonebecause it owns the unique receiver;send_action/send_commandgo through&self.EditorCommand— the typed mailbox payload. Renderer-to- editor messages. IncludesApply(Action),HandleEffect,DispatchBlocking { invocation, reply },Tick,Ping,Shutdown. Extensible: subsequent slices add variants.spawn_editor_actor(editor) -> EditorActorHandle— takes ownership of anEditor, spawns a dedicated thread with acurrent_threadtokio runtime, returns the handle. The thread name is"lattice-editor"for observability.
§Slice 3c.0 status
Everything in this module is dormant – no production call
site wires spawn_editor_actor yet. The follow-on sub-slices:
- 3c.1: populate
ActiveDocumentRenderState(the read contract for cursor/scroll/modal/etc.) so renderers can migrate off directeditor.Xreads. - 3c.2 / 3c.3: TUI / GPUI renderers switch their reads
to
RenderState. - 3c.4: renderers wire
EditorActorHandle;App::applybecomeshandle.send_action(action). - 3c.5: sever
Arc<Editor>from renderer entirely. - 3c.6 / 3c.7: polish + docs.
Tests in this file verify the substrate works end-to-end:
spawn the actor, send a Ping, await the reply.
Structs§
- Actor
Gone - Error returned by the synchronous handle methods when the
actor thread has shut down. Production code maps this to a
fatal condition: the editor thread dying is unrecoverable.
In tests, surfaces as a
panic!viaunwrap(acceptable — test fixtures keep the handle alive for their duration). - Editor
Actor Handle - Renderer-side handle to the editor actor.
Enums§
- Editor
Command - Renderer-to-editor mailbox payload. Each variant corresponds to a way the renderer (or another task) drives the editor’s state.
Functions§
- spawn_
editor_ actor - Spawn the editor actor on a dedicated thread with a
current_threadtokio runtime. Takes ownership ofeditor.