Expand description
PL8.D.4 — auto-reload the user’s init.rs config when its compiled artifact
changes on disk.
The edit→rebuild→reload loop shouldn’t need a manual :reload-config. This
watches <config>/lattice/init/ with the notify crate and calls
[PluginLoader::sync_init] (load-or-reload) whenever the directory changes —
so after you cargo build a new init.wasm, the editor picks it up.
Why the artifact, not the source. init.rs is Rust source; the editor
loads the compiled init.wasm. Saving the source doesn’t change the artifact,
so the watch is on the directory holding the .wasm and fires on the write a
build produces. To compile source → artifact without an external cargo
step, use [PluginLoader::reload_config] (the :reload-config command) or
the plugins view’s b on the init row — both recompile in place, then
reload; a full source-watching auto-rebuild loop is future work.
Debounce. A build rewrites the file in a burst (truncate, write, rename);
the watcher coalesces events, waiting for [SETTLE] of quiet before it
reloads once, so a single rebuild triggers a single reload.
Broken build heals. sync_init reloads when init is loaded and loads
when it isn’t; a rebuild that produces a bad component leaves init unloaded
(logged), and the next good build’s write fires this again and loads it. No
restart needed either way.
Functions§
- spawn_
init_ watcher - Spawn the init-artifact auto-reload watcher on
runtime. Watchesinit_dir(non-recursively) andsync_inits the loader on every settled change. A watcher that can’t be created / can’t watch the dir is a logged warning that disables auto-reload (manual:reload-configstill works), never a failure. No-op ifinit_dirdoesn’t exist (nothing to watch until the user creates a config; a restart picks it up).