Module settings in each module's right-click menu, and System settings
CI / test (push) Failing after 15s
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:
37 files changed
+1285
-128
No files matched your search
@@ -93,6 +93,33 @@ fn drain() -> Array[HostRequest] {
|
||||
out
|
||||
}
|
||||
|
||||
///|
|
||||
test "a module's own settings (module-config) are listed and set through wasmer" {
|
||||
let p = load_module("clock-digital")
|
||||
let items = p.config_items()
|
||||
assert_eq(items.length(), 2)
|
||||
assert_eq(items[0], { key: "format", label: "Time format", choices: ["24-hour", "12-hour"], value: "24-hour" })
|
||||
assert_eq(items[1].choices.length(), 0) // an on/off switch
|
||||
assert_true(p.set_config("format", "12-hour"))
|
||||
assert_false(p.set_config("format", "12-hour")) // unchanged
|
||||
assert_false(p.set_config("bogus", "x"))
|
||||
assert_eq(p.config_items()[0].value, "12-hour")
|
||||
let mut ampm = false
|
||||
for op in p.render(p.pref_w, p.pref_h, test_tokens()) {
|
||||
match op {
|
||||
Text(t) => if t.text.has_suffix("AM") || t.text.has_suffix("PM") { ampm = true }
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
assert_true(ampm)
|
||||
p.unload()
|
||||
// Modules without the export have no settings, and setting one is a no-op.
|
||||
let l = load_module("layout")
|
||||
assert_eq(l.config_items().length(), 0)
|
||||
assert_false(l.set_config("format", "12-hour"))
|
||||
l.unload()
|
||||
}
|
||||
|
||||
///|
|
||||
test "task list module draws the host's windows and asks to focus one" {
|
||||
let p = load_module("tasks")
|
||||
|
||||
Reference in new issue
Block a user