Reload panel modules from outside the session: control socket, chandra-ctl, SIGUSR1
CI / test (push) Failing after 16s

Until now a module reload was only reachable by clicking Settings > Panel inside the session.
Now:

- The compositor listens on $XDG_RUNTIME_DIR/chandra/<wayland socket name>.sock (the login
  session's is wayland-moon-0.sock) with a line protocol: ping, list, reload [NAME], help.
  Replies end with an "ok ..." or "error ..." line. It lives in compositor/host/control.mbt,
  runs from ChandraCompositor::step, and its fds join the idle loop's wait set, so an idle
  desktop still sleeps (measured ~0.4% CPU on wasmhost, ~0.1% on host-wasm) and wakes for a
  command. A path another live compositor answers on is left alone.
- DesktopShell::reload_modules(name) reloads every loaded module (or those whose module id,
  stem, slot or path is NAME) in place via replace_slot: same panel position, saved
  :module-config applied, a module that fails to load stays as it was and the error is
  reported to the caller and shown as a notice. The catalog is rescanned.
- SIGUSR1 to the host reloads every module (result in the log and the notice): new WIT
  function sys.take-sigusr1, implemented in compositor/sys (native build and wasmhost) and
  host-wasm; the handler has no SA_RESTART so it interrupts the idle poll.
- session/chandra-ctl (installed to /usr/local/bin), `just reload [NAME]`, docs/reloading.md,
  README.
- Tests: compositor/host/control_test.mbt (protocol, reload all / by name / by slot, order
  and settings kept, failing module kept, busy socket). Checked headless on both hosts with
  chandra-ctl and kill -USR1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hjLJtvYcgW48okL6qQ
This commit is contained in:
Claude committed 2026-11-25 20:57:40 +00:00
1 parent 0fc2598d27
commit 68164ff75e
21 files changed
+844 -31

No files matched your search

+3
View File
@@ -84,6 +84,9 @@ fn wasmImportHasExe(p0 : Int, p1 : Int) -> Int = "chandra:host/sys@0.1.0" "has-e
///|
fn wasmImportSpawn(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int = "chandra:host/sys@0.1.0" "spawn"
///|
fn wasmImportTakeSigusr1() -> Int = "chandra:host/sys@0.1.0" "take-sigusr1"
///|
extern "wasm" fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] =
#|(func (param i32) (param i32) (result i32)
@@ -140,6 +140,11 @@ fn wasmImportSpawn(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportTakeSigusr1() -> Int {
abort("wasm-only host import")
}
///|
fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] {
abort("wasm-only")
@@ -44,6 +44,8 @@ pub fn spawn(String, String) -> Bool
pub fn take_fd(Int32) -> Int32
pub fn take_sigusr1() -> Bool
pub fn unix_accept(Int32) -> Int32
pub fn unix_connect(String) -> Int32
+10
View File
@@ -326,4 +326,14 @@ pub fn spawn(cmd : String, display : String) -> Bool {
return ret
}
///|
/// True once after the host process got SIGUSR1 (a request to reload the panel modules from
/// disk; see docs/reloading.md). The first call installs the handler; until then SIGUSR1 keeps
/// its default action. A signal interrupts `wait-readable`, so an idle loop wakes for it.
pub fn take_sigusr1() -> Bool {
let result : Int = wasmImportTakeSigusr1();
let ret = (result != 0)
return ret
}