Skip to main content

Module action_handler_registry

Module action_handler_registry 

Source
Expand description

Action-handler registry — mode-contributed closures per CommandId (M.10.1).

Per feedback_mode_owns_its_surface (CLAUDE.md standing rules, sharpened 2026-06-02) + mode-architecture.md §5.3, a mode owns BOTH the chord choice AND the action handler body. The keymap layer is contributed by Mode::keymap(); the handler closure is registered into this substrate from Mode::on_activate. The host’s chord-resolved-action dispatcher consults this registry; the handler returns an Effect the host applies through the existing pipeline.

Half-migration failure mode (the M.10 audit caught this): keymap layer in the mode but Editor::do_<provider>_action body in lattice-host::dispatch. This substrate exists so the handler body lives in the mode’s owning crate, not the host.

§Shape

Wait-free lookup via arc-swap. Register / unregister perform a copy-on-write via ArcSwap::rcu — O(N) per lifecycle event but registers are rare (per mode activation / deactivation, not per keystroke). Lookups happen per chord-dispatch — one Arc load + one HashMap::get.

§Lifecycle

register returns an ActionHandlerRegistration RAII token. The mode’s Guard carries one token per registered action; dropping the Guard drops the tokens, each of which unregisters its CommandId. Re-activation re-registers fresh closures.

Structs§

ActionContext
Read-only context handed to a mode-contributed action handler closure. Carries the bare minimum the host can supply on every invocation: the active buffer + cursor and shared subsystem registries the handler may need.
ActionHandlerContribution
A global (buffer-agnostic) action-handler contribution declared by a mode via Mode::action_handlers (SN.3c.0).
ActionHandlerRegistration
RAII registration token. Dropping it unregisters the handler. Modes typically aggregate these into their Mode::Guard; when the Guard drops on deactivation, every token drops, every handler unregisters.
ActionHandlerRegistry
Wait-free registry of mode-contributed action handlers.

Type Aliases§

ActionHandler
Action handler closure shape. Returns an [Effect] when the handler wants the host to apply state mutation (open a file, change selection, etc.); None for fire-and-forget handlers (logging, publishing an event).
ActionHandlerRegistryHandle
Typed handle for ServiceRegistry lookup. Boot registers a fresh ActionHandlerRegistry under this alias; modes pull it from on_activate via ctx.service::<ActionHandlerRegistryHandle>() (M.10.1.b, 2026-06-03).