Module settings in each module's right-click menu, and System settings
CI / test (push) Failing after 15s

- New optional WIT export `chandra:desktop/module-config` (wit/plasmoid.wit): config-items (key,
  label, choices, current value; no choices = an on/off switch) and set-config. Hosts look it up
  by name, so modules without it (or prebuilt ones like Pulse) load as before.
- Right-click a panel module: "Module settings..." (or a greyed "No module settings"), then
  "System settings..." (the settings module, Session tab), then Replace with... and Remove widget.
  The "Modules..." row is gone; right-clicking empty panel space offers "System settings..." on the
  Panel tab instead. Module settings open in the same menu: on/off rows with a check box, choices
  under a heading with the current one ticked; clicking applies at once and the menu stays open.
- Choices are saved per module id in state.edn as :module-config {"clock-digital" {"format"
  "12-hour"}} (module_config.mbt; not an owned key, so save_state keeps it) and handed back through
  set-config whenever the module is loaded. Other instances of the module follow a change.
- Both hosts: wasmer stub (optional exports 8-10, canonical-ABI decoding in wasm_native.mbt) and
  host-wasm (chandra:host/plasmoids config-items/set-config, bound with a separate `configurable`
  world so the export stays optional).
- Adopted by the digital clock (Time format 24-hour/12-hour, Show date) and the binary clock (Show
  seconds); clock-widget now exports module-config.
- Tests: native menu end-to-end (open, pick 12-hour, heading inert, reload keeps it), state.edn
  round trip, EDN unit test, wasmer and host-wasm module-config tests, lib/clock settings test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hjuApkJR4sVRYDpDLy
This commit is contained in:
Claude committed 2026-11-25 18:58:43 +00:00
1 parent a7909014b8
commit 4fc4a963b4
37 files changed
+1285 -128

No files matched your search

+13
View File
@@ -35,6 +35,19 @@ interface plasmoids {
/// Deliver an event to the module (`on-popup`: to its popup surface). True when it wants a redraw.
on-event: func(handle: u32, on-popup: bool, event: input-event) -> bool;
/// One of a module's own settings (chandra:desktop/module-config `config-item`): `choices`
/// empty means an on/off switch whose value is "on" or "off".
record config-item {
key: string,
label: string,
choices: list<string>,
value: string,
}
/// The module's settings for its right-click menu; empty when it doesn't export module-config.
config-items: func(handle: u32) -> list<config-item>;
/// Set one of them. True when the module wants a redraw (false without module-config).
set-config: func(handle: u32, key: string, value: string) -> bool;
// ---- host data modules read through their capabilities ----
/// Row tables, as built by compositor/wasm: a LE u32 row count, then per row each field as a LE
+22
View File
@@ -29,3 +29,25 @@ interface plasmoid {
/// Returns true when the widget's visuals changed and a redraw is needed.
on-event: func(target: surface, event: input-event) -> bool;
}
/// Optional: a module's own settings. A module that exports this gets a "Module settings" entry in
/// its right-click menu, listing the items below; the shell draws the menu (the same for every
/// module), remembers each choice per module in state.edn (`:module-config`), and hands the saved
/// values back through `set-config` right after the module is loaded. A module without it simply
/// has no settings: the export is looked up by name, so older modules keep loading.
interface module-config {
record config-item {
/// Stable key, saved in state.edn, e.g. "format".
key: string,
/// What the menu shows, e.g. "Time format".
label: string,
/// The values to choose from, shown as one row each (the current one ticked). Empty: an on/off
/// switch, whose value is "on" or "off".
choices: list<string>,
/// The current value.
value: string,
}
config-items: func() -> list<config-item>;
/// Set `key` to `value` (unknown keys and values are ignored). True when the widget should redraw.
set-config: func(key: string, value: string) -> bool;
}
+7
View File
@@ -9,6 +9,13 @@ world widget {
world clock-widget {
include widget;
import clock;
export module-config;
}
/// The optional `module-config` export on its own. A module of any world may add it to get its own
/// settings in its right-click menu; hosts look it up separately (host-wasm binds it with this world).
world configurable {
export module-config;
}
world launcher-widget {