Settings module: Session, Desktop and Panel tabs; the module manager moves in
CI / test (push) Failing after 15s

- The settings popup gets a tab bar, split by where things live: Session (the switches), Desktop
  (what is drawn on the desktop: the wallpaper list under a "Wallpaper" heading) and Panel (what
  the module manager showed: modules in the panel to remove, modules to add, Browse...).
  Left/Right or 1/2/3 switch tabs; it reopens on the tab it was left on. Modules can't be placed
  on the desktop yet (every wasm module lives in the panel; the desktop card is built in), so
  the Desktop tab has no module section until they can.
- The standalone module-manager module and its world are removed; the settings module imports
  `modules`. Saved panels listing "module-manager" get the settings module in its place.
- DesktopShell::open_settings(SettingsTab) opens the settings module on a tab (loading it into the
  panel if needed), for the panel menu and "System settings" entries; the wasm picker
  ("Modules..." in the panel menu) is open_settings(Panel).
- Tests: the native picker test drives the Panel tab, the wallpaper and switch tests go through
  the tabs, an open_settings test; the wasm and host-wasm module tests use the settings module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgxf6exeYrDGcy4WW3
This commit is contained in:
Claude committed 2026-11-25 18:50:57 +00:00
1 parent ee019ecbaa
commit 0e6a1257e1
20 files changed
+316 -917

No files matched your search

+45 -29
View File
@@ -393,27 +393,29 @@ test "the panel is saved to panel.edn and restored" {
}
///|
test "the wasm picker opens the module manager, which loads and unloads modules" {
test "the wasm picker opens the settings module's Panel tab, which loads and unloads modules" {
let comp = new_comp("manager")
// The manager is not in the default panel: the picker loads it on demand.
// The settings module is in the default panel; the standalone module manager is gone.
assert_eq(comp.shell.slot_of("module-manager"), "")
let mgr = comp.shell.slot_of("session-settings")
assert_true(mgr != "")
let n0 = comp.shell.slots().length()
// Right-click empty panel space (the margin): the menu offers the module manager.
// Right-click empty panel space (the margin): the menu offers the module list.
let panel = comp.shell.panel_rect
click_at(comp, 1, panel.y + 5, 1U, btn=273U)
assert_true(comp.shell.menu_open)
assert_eq(comp.shell.menu_rows[0].label, "Module manager...")
assert_eq(comp.shell.menu_rows[0].label, "Modules...")
let m = comp.shell.menu_rect
click_at(comp, m.x + m.w / 2, m.y + 26 + 14, 10U)
assert_eq(comp.shell.slots().length(), n0 + 1)
let mgr = comp.shell.slot_of("module-manager")
assert_true(mgr != "")
assert_eq(comp.shell.slots().length(), n0) // nothing new was loaded for it
ignore(comp.compose_frame())
let pr = comp.shell.slot_popup_rect(mgr)
assert_true(pr.w > 0) // the picker opened the app's popup
// Rows: header(24), one per loaded module (28), header(24), one per available module (28), browse.
assert_true(pr.w > 0) // the picker opened the popup
// Rows below the tab bar (40): heading, one per loaded module, heading, one per available
// module, browse; 28 each.
let loaded = comp.shell.slots().length()
let avail_y = fn(k : Int) { pr.y + 4 + 24 + loaded * 28 + 24 + k * 28 + 14 }
assert_true(pr.h >= 40 + (loaded + 3) * 28)
let avail_y = fn(pr : @scene.Rect, k : Int) { pr.y + 40 + (loaded + 2 + k) * 28 + 13 }
let mut k_bin = -1
for k = 0; k < comp.shell.catalog.length(); k = k + 1 {
if comp.shell.catalog[k].id == "clock-binary" {
@@ -422,10 +424,11 @@ test "the wasm picker opens the module manager, which loads and unloads modules"
}
assert_true(k_bin >= 0)
assert_eq(comp.shell.slot_of("clock-binary"), "")
click_at(comp, pr.x + 40, avail_y(k_bin), 20U) // select it: it is loaded into the panel
click_at(comp, pr.x + 40, avail_y(pr, k_bin), 20U) // select it: it is loaded into the panel
assert_true(comp.shell.slot_of("clock-binary") != "")
assert_eq(comp.shell.slots().length(), loaded + 1)
// The popup stays open; click the loaded module's row to unload it again.
// The popup stays open (it grew a row); click the loaded module's row to unload it again.
ignore(comp.compose_frame())
let pr2 = comp.shell.slot_popup_rect(mgr)
assert_true(pr2.w > 0)
let slots = comp.shell.slots()
@@ -435,14 +438,15 @@ test "the wasm picker opens the module manager, which loads and unloads modules"
idx = i
}
}
click_at(comp, pr2.x + 40, pr2.y + 4 + 24 + idx * 28 + 14, 30U)
click_at(comp, pr2.x + 40, pr2.y + 40 + (1 + idx) * 28 + 13, 30U)
assert_eq(comp.shell.slot_of("clock-binary"), "")
assert_eq(comp.shell.slots().length(), loaded)
// The manager is just another module: it can be removed too, and the picker brings it back.
// The settings module is just another module: it can be removed too, and the picker brings it
// back.
assert_true(comp.shell.unload_slot(mgr))
assert_eq(comp.shell.slot_of("module-manager"), "")
assert_eq(comp.shell.slot_of("session-settings"), "")
assert_true(comp.shell.open_module_manager())
assert_true(comp.shell.slot_of("module-manager") != "")
assert_true(comp.shell.slot_of("session-settings") != "")
}
///|
@@ -1140,22 +1144,21 @@ test "the settings module lists the wallpapers and switches the desktop to the o
assert_true(comp.shell.slot_rect(slot).w > 0) // it is in the default panel
assert_eq(comp.shell.slot_of("wallpaper"), "") // the standalone chooser is gone
assert_eq(comp.shell.wallpaper_sel, 0)
// A click opens the list; nothing changes yet. The wallpapers follow the three settings and a
// "Wallpaper" heading, so the first is row 4.
// A click opens the popup on its Session tab; the Desktop tab (the second of three 96 px
// tabs) lists the wallpapers below a heading. Nothing changes yet.
click_module(comp, "session-settings", 1U)
let p0 = comp.shell.slot_popup_rect(slot)
click_at(comp, p0.x + 6 + 96 + 48, p0.y + 6 + 14, 3U)
let pr = comp.shell.slot_popup_rect(slot)
assert_true(pr.h >= 6 * 2 + (4 + 5) * 30) // one row per setting and wallpaper, and the heading
assert_eq(comp.shell.wallpaper_sel, 0)
// The heading does nothing.
click_at(comp, pr.x + 40, pr.y + 6 + 3 * 30 + 5, 3U)
assert_true(pr.h >= 40 + 6 * 28) // heading and one row per wallpaper below the tab bar
assert_eq(comp.shell.wallpaper_sel, 0)
// Third wallpaper: Starfield. The list stays open and the backdrop is drawn anew.
let star = click_wallpaper_ops(comp, pr.x + 40, pr.y + 6 + (4 + 2) * 30 + 5, 5U)
let star = click_wallpaper_ops(comp, pr.x + 40, pr.y + 40 + 3 * 28 + 13, 5U)
assert_eq(comp.shell.wallpaper_sel, 2)
assert_true(star > 0)
assert_true(comp.shell.slot_popup_rect(slot).w > 0)
// Last row: Solid, a single fill. Escape then closes the list.
assert_eq(click_wallpaper_ops(comp, pr.x + 40, pr.y + 6 + (4 + 4) * 30 + 5, 10U), 1)
assert_eq(click_wallpaper_ops(comp, pr.x + 40, pr.y + 40 + 5 * 28 + 13, 10U), 1)
assert_eq(comp.shell.wallpaper_sel, 4)
comp.shell.key_down("Escape")
ignore(comp.compose_frame())
@@ -1269,17 +1272,17 @@ test "the settings module flips the session settings from its popup" {
// A click opens the list of switches; nothing changes yet.
click_module(comp, "session-settings", 1U)
let pr = comp.shell.slot_popup_rect(slot)
assert_true(pr.h >= 6 * 2 + 3 * 30) // one row per setting
assert_true(pr.h >= 40 + 3 * 28) // one row per setting below the tab bar
assert_true(comp.shell.restore_session)
// First row: "Reopen windows at login" goes off, and on again with a second click.
click_at(comp, pr.x + 40, pr.y + 6 + 5, 5U)
click_at(comp, pr.x + 40, pr.y + 40 + 13, 5U)
assert_false(comp.shell.restore_session)
assert_true(comp.shell.remember_windows)
assert_true(comp.shell.slot_popup_rect(slot).w > 0) // the list stays open
click_at(comp, pr.x + 40, pr.y + 6 + 5, 10U)
click_at(comp, pr.x + 40, pr.y + 40 + 13, 10U)
assert_true(comp.shell.restore_session)
// Second row: "Remember window positions"; then Down and Enter flip it back from the keyboard.
click_at(comp, pr.x + 40, pr.y + 6 + 30 + 5, 15U)
click_at(comp, pr.x + 40, pr.y + 40 + 28 + 13, 15U)
assert_false(comp.shell.remember_windows)
comp.shell.key_down("Enter")
ignore(comp.compose_frame())
@@ -1287,7 +1290,7 @@ test "the settings module flips the session settings from its popup" {
assert_true(comp.shell.restore_session)
// Third row: Dark mode. Off switches the shell, panel and decorations to the light theme.
assert_eq(comp.theme.name, "Moon Night")
click_at(comp, pr.x + 40, pr.y + 6 + 2 * 30 + 5, 20U)
click_at(comp, pr.x + 40, pr.y + 40 + 2 * 28 + 13, 20U)
assert_false(comp.shell.dark_mode)
assert_eq(comp.theme.name, "Moon Day")
assert_eq(comp.shell.tokens.name, "Moon Day")
@@ -1351,3 +1354,16 @@ test "session settings are saved to state.edn and restored, and take effect" {
assert_false(read_state_edn().contains(":theme"))
}
}
///|
test "open_settings opens the settings module on the tab asked for" {
let comp = new_comp("opensettings")
let slot = comp.shell.slot_of("session-settings")
assert_true(comp.shell.open_settings(Desktop))
ignore(comp.compose_frame())
let pr = comp.shell.slot_popup_rect(slot)
assert_eq(pr.h, 40 + 6 * 28 + 6) // the Wallpaper heading and the five wallpapers
assert_true(comp.shell.open_settings(Session))
ignore(comp.compose_frame())
assert_eq(comp.shell.slot_popup_rect(slot).h, 40 + 3 * 28 + 6) // the three settings
}
+39 -14
View File
@@ -5,17 +5,18 @@
/// A module is a wasm plasmoid component (`chandra:desktop/plasmoid`). Its imports
/// are the capabilities it was granted: `theme` and `clock` always, `app-catalog` /
/// `app-launch` for the application menu, `windows` for the task list, `layout-control`
/// for the layout switcher, `inspector` for the Interface Explorer button and `modules`
/// for the module manager. The manager is itself just a module: the wasm picker
/// ("Module manager..." in the panel menu) loads it on demand and opens it.
/// for the layout switcher, `inspector` for the Interface Explorer button, and
/// `session-settings`, `wallpaper` and `modules` for the settings module. Managing modules is a
/// tab of that module: the wasm picker ("Modules..." in the panel menu) loads it on demand and
/// opens that tab.
///| Modules loaded into a fresh panel, in order. `tasks` stretches, so what follows it packs right.
let default_panel : Array[String] = [
"launcher", "inspector", "layout", "tasks", "moon-disc", "clock-digital12", "session-settings", "logout",
]
///| The module whose popup is the wasm picker.
let manager_module : String = "module-manager"
///| The module whose popup holds the wasm picker (its Modules tab).
let manager_module : String = "session-settings"
///| Directories searched for `*.wasm` modules, highest priority first.
fn module_dirs() -> Array[String] {
@@ -171,13 +172,14 @@ fn wall_secs() -> Int {
@sys.wall_time_field(3) * 3600 + @sys.wall_time_field(4) * 60 + @sys.wall_time_field(5)
}
///| Panels saved before the wallpaper chooser moved into the settings module list "wallpaper":
/// the settings module takes its place (once; a panel that already has it just drops it).
///| Panels saved before the wallpaper chooser and the module manager moved into the settings
/// module list "wallpaper" or "module-manager": the settings module takes the first one's place
/// (a panel that already has it just drops them).
fn migrate_panel(entries : Array[String]) -> Array[String] {
let has_settings = entries.contains("session-settings")
let out : Array[String] = []
for e in entries {
if e == "wallpaper" {
if e == "wallpaper" || e == "module-manager" {
if !has_settings && !out.contains("session-settings") {
out.push("session-settings")
}
@@ -192,6 +194,7 @@ fn migrate_panel(entries : Array[String]) -> Array[String] {
test "a saved panel's wallpaper button becomes the settings module" {
assert_eq(migrate_panel(["launcher", "wallpaper", "logout"]), ["launcher", "session-settings", "logout"])
assert_eq(migrate_panel(["wallpaper", "session-settings"]), ["session-settings"])
assert_eq(migrate_panel(["module-manager", "clock", "wallpaper"]), ["session-settings", "clock"])
assert_eq(migrate_panel(["clock"]), ["clock"])
}
@@ -586,9 +589,19 @@ fn DesktopShell::poll_picker(self : DesktopShell) -> Unit {
}
}
///| The wasm picker: open the module manager app to choose what to load, loading the
/// manager itself first if it is not in the panel.
pub fn DesktopShell::open_module_manager(self : DesktopShell) -> Bool {
///| Tabs of the settings module's popup, for `open_settings`.
pub(all) enum SettingsTab {
/// The session switches.
Session
/// What is on the desktop: the wallpaper (modules can't be placed on the desktop yet).
Desktop
/// The panel's modules: remove, add, browse.
Panel
} derive(Eq, Debug)
///| Open the settings module ("System settings") on `tab`, loading it into the panel first if it
/// isn't there. False when it can't be found or loaded.
pub fn DesktopShell::open_settings(self : DesktopShell, tab : SettingsTab) -> Bool {
self.ensure_booted()
let mut mgr : Widget? = None
for w in self.widgets {
@@ -599,7 +612,7 @@ pub fn DesktopShell::open_module_manager(self : DesktopShell) -> Bool {
if mgr is None {
match self.find_module(manager_module) {
None => {
self.say("Module manager not found (build it with scripts/build-modules.sh)")
self.say("Settings module not found (build it with scripts/build-modules.sh)")
return false
}
Some(c) => mgr = self.load_path(c.path)
@@ -612,12 +625,24 @@ pub fn DesktopShell::open_module_manager(self : DesktopShell) -> Bool {
if w.popup_rect.w == 0 {
ignore(self.deliver(w, false, PointerDown(0, 0)))
}
// The module's keys 1, 2, 3 pick its tabs.
let key = match tab {
Session => "1"
Desktop => "2"
Panel => "3"
}
ignore(self.deliver(w, true, KeyDown(key)))
self.save_panel_config()
true
}
}
}
///| The wasm picker: open the settings module on its Panel tab to choose what to load.
pub fn DesktopShell::open_module_manager(self : DesktopShell) -> Bool {
self.open_settings(Panel)
}
// ---------------------------------------------------------------- right-click menu
///| Title row height and item row height of the menu.
@@ -658,13 +683,13 @@ pub fn DesktopShell::right_click(self : DesktopShell, x : Int, y : Int) -> Bool
}
}
rows.push({ label: "Remove widget", kind: 1, arg: "" })
rows.push({ label: "Module manager...", kind: 2, arg: "" })
rows.push({ label: "Modules...", kind: 2, arg: "" })
self.open_menu(w.pl.name, rows, w.slot, x)
true
}
None =>
if inside(self.panel_rect, x, y) {
self.open_menu("Add widget", [{ label: "Module manager...", kind: 2, arg: "" }], "", x)
self.open_menu("Add widget", [{ label: "Modules...", kind: 2, arg: "" }], "", x)
true
} else {
was_open
+7 -6
View File
@@ -177,8 +177,8 @@ test "launcher module reads the host catalog, filters on typed keys and launches
}
///|
test "module manager lists host modules and asks to load, unload and browse" {
let p = load_module("module-manager")
test "the settings module's Panel tab lists host modules and asks to load, unload and browse" {
let p = load_module("session-settings")
assert_true(p.imports().contains("modules"))
let av = Table::new()
av.str("moon-disc")
@@ -194,6 +194,7 @@ test "module manager lists host modules and asks to load, unload and browse" {
li.end_row()
publish(Instances, li)
assert_true(p.on_event(false, PointerDown(1, 1)))
assert_true(p.on_event(true, KeyDown("3"))) // the Panel tab
match p.popup() {
None => fail("popup should be open")
Some(ps) => {
@@ -202,10 +203,10 @@ test "module manager lists host modules and asks to load, unload and browse" {
assert_true(ts.contains("Moon Phase (disc)"))
}
}
// rows: header(24) loaded(28) header(24) available(28) browse(28)
ignore(p.on_event(true, PointerDown(20, 4 + 24 + 3)))
ignore(p.on_event(true, PointerDown(20, 4 + 24 + 28 + 24 + 3)))
ignore(p.on_event(true, PointerDown(20, 4 + 24 + 28 + 24 + 28 + 3)))
// Below the tab bar (40), rows of 28: heading, loaded, heading, available, browse.
ignore(p.on_event(true, PointerDown(20, 40 + 28 + 3)))
ignore(p.on_event(true, PointerDown(20, 40 + 3 * 28 + 3)))
ignore(p.on_event(true, PointerDown(20, 40 + 4 * 28 + 3)))
assert_eq(drain(), [UnloadInstance("w1"), LoadModule("/m/moon-disc.wasm"), Browse])
p.unload()
}