Wasm panel modules, widget host, merged plasmoid host design, and shell/UI work

Panel and wasm host
- The panel is built from wasm plasmoid modules (compositor/wasm: wasmer-backed host).
  Modules get capabilities by importing host interfaces; the host publishes data tables
  and serves a request queue (launch, focus window, set layout, inspector, load/unload
  modules). New WIT: windows, layout-control, inspector, modules, system.
- Merged two competing host designs: generic tables + requests are the base; the
  `system` snapshot and the id-stable `windows.all/focus` (Desktop Pulse) run on top of it.
- Panel widgets: load a .wasm from a path or file chooser, reorder by dragging,
  right-click replace/remove/add, saved to panel.edn.
- Desktop widget, system sampler (sysinfo), app catalog/humanised names, Interface
  Explorer (inspector), real font rendering (compositor/font, assets/fonts).

Compositor
- Drag the divider between tiled windows; lower tiled rows leave room for the title bar.
- Title-bar buttons, 12-hour clock, truncated titles, task-list/layout menus.
- DRM/KMS session, tcc debug builds (vendored tinycc incl. conftest.c), justfile
  recipes (modules, run, test), pixi.toml.

Known gaps
- The sources for the pulse, tasks, layout, inspector, module-manager, moon-* and
  clock-digital12 modules are not in the tree yet, so `just modules` stops at pulse and
  the host tests that load those modules fail until they land.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-24 23:38:05 -08:00
1 parent 080377fd79
commit 0145981c6a
57 files changed
+11461 -221

No files matched your search

+227
View File
@@ -0,0 +1,227 @@
///|
fn test_tokens() -> @theme.Tokens {
let c = fn(r : Int, g : Int, b : Int) -> @types.Color { { r: r.to_byte(), g: g.to_byte(), b: b.to_byte(), a: b'\xff' } }
{
name: "t",
palette: {
desktop_top: c(1, 2, 3),
desktop_bottom: c(4, 5, 6),
surface: c(30, 30, 40),
surface_hover: c(50, 50, 60),
surface_popup: c(20, 20, 30),
foreground: c(250, 250, 250),
foreground_muted: c(150, 150, 150),
accent: c(80, 120, 255),
accent_foreground: c(255, 255, 255),
border: c(90, 90, 90),
},
font_size: 14U,
radius: 6U,
spacing: 6U,
panel_height: 40U,
}
}
///|
fn load_fixture(name : String) -> Result[Plasmoid, String] {
match load("compositor/wasm/testdata/" + name, test_tokens()) {
Ok(p) => Ok(p)
Err(_) => load("testdata/" + name, test_tokens())
}
}
///|
test "a plasmoid component loads and renders through wasmer" {
let p = load_fixture("clock-digital.component.wasm").unwrap()
assert_eq(p.id, "org.moonplasma.clock.digital")
assert_true(p.pref_w > 0 && p.pref_h > 0)
let ops = p.render(p.pref_w, p.pref_h, test_tokens())
assert_true(ops.length() > 0)
// The digital clock draws its time as text, in the theme's foreground colour.
let mut texts = 0
for op in ops {
match op {
Text(t) => {
texts = texts + 1
assert_true(t.text.length() >= 4)
assert_true(t.style.color.r == b'\xfa' || t.style.color.r == b'\x96') // theme foreground / muted
}
_ => ()
}
}
assert_true(texts >= 1)
p.unload()
}
///|
test "a bare core module loads too, and junk is rejected" {
let p = load_fixture("clock-digital.core.wasm").unwrap()
assert_eq(p.id, "org.moonplasma.clock.digital")
p.unload()
assert_true(load("/nonexistent.wasm", test_tokens()) is Err(_))
}
///| Load a panel module built by scripts/build-modules.sh.
fn load_module(name : String) -> Plasmoid {
match load("build/components/" + name + ".wasm", test_tokens()) {
Ok(p) => p
Err(_) => load("../../build/components/" + name + ".wasm", test_tokens()).unwrap()
}
}
///|
fn texts_of(ops : Array[@types.DrawOp]) -> Array[String] {
let out : Array[String] = []
for op in ops {
match op {
Text(t) => out.push(t.text)
_ => ()
}
}
out
}
///|
fn drain() -> Array[HostRequest] {
let out : Array[HostRequest] = []
while true {
match next_request() {
Some(r) => out.push(r)
None => break
}
}
out
}
///|
test "task list module draws the host's windows and asks to focus one" {
let p = load_module("tasks")
assert_true(p.stretch)
assert_true(p.imports().contains("windows") && p.imports().contains("theme"))
let t = Table::new()
t.int(7)
t.str("Kate — notes")
t.int(1)
t.int(0)
t.end_row()
t.int(9)
t.str("foot")
t.int(0)
t.int(1)
t.end_row()
publish(Windows, t)
let ops = p.render(400, 36, test_tokens())
assert_eq(texts_of(ops), ["Kate — notes", "foot"])
assert_true(p.on_event(false, PointerDown(146 + 10, 10)) || true)
assert_eq(drain(), [FocusWindow(9)])
p.unload()
}
///|
test "layout module shows the current mode, opens a popup and sets the layout" {
let p = load_module("layout")
let t = Table::new()
for name in ["Tiling (BSP)", "Monocle", "Floating"] {
t.str(name)
t.end_row()
}
publish(Layouts, t)
publish_state(1, false)
assert_true(texts_of(p.render(130, 36, test_tokens())).contains("Monocle"))
assert_true(p.popup() is None)
assert_true(p.on_event(false, PointerDown(5, 5)))
match p.popup() {
None => fail("popup should be open")
Some(ps) => {
assert_true(ps.w > 100 && ps.h > 80)
assert_true(texts_of(ps.ops).contains(" Floating"))
}
}
assert_true(p.on_event(true, PointerDown(20, 4 + 28 * 2 + 3)))
assert_eq(drain(), [SetLayout(2)])
assert_true(p.popup() is None)
p.unload()
}
///|
test "launcher module reads the host catalog, filters on typed keys and launches" {
let p = load_module("launcher")
let t = Table::new()
for a in [("a.term", "Terminal"), ("b.files", "Files")] {
t.str(a.0)
t.str(a.1)
t.str("comment")
t.str("System")
t.str("T")
t.end_row()
}
publish(Apps, t)
assert_true(p.on_event(false, PointerDown(1, 1)))
assert_true(p.popup() is Some(_))
for k in ["f", "i", "l", "e", "s"] {
ignore(p.on_event(true, KeyDown(k)))
}
match p.popup() {
Some(ps) => assert_true(texts_of(ps.ops).contains("Files"))
None => fail("popup closed early")
}
assert_true(p.on_event(true, KeyDown("Enter")))
assert_eq(drain(), [Launch("b.files")])
assert_true(p.popup() is None)
p.unload()
}
///|
test "module manager lists host modules and asks to load, unload and browse" {
let p = load_module("module-manager")
assert_true(p.imports().contains("modules"))
let av = Table::new()
av.str("moon-disc")
av.str("Moon Phase (disc)")
av.str("/m/moon-disc.wasm")
av.int(0)
av.end_row()
publish(Modules, av)
let li = Table::new()
li.str("w1")
li.str("clock-digital")
li.str("Digital Clock")
li.end_row()
publish(Instances, li)
assert_true(p.on_event(false, PointerDown(1, 1)))
match p.popup() {
None => fail("popup should be open")
Some(ps) => {
let ts = texts_of(ps.ops)
assert_true(ts.contains("Digital Clock"))
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)))
assert_eq(drain(), [UnloadInstance("w1"), LoadModule("/m/moon-disc.wasm"), Browse])
p.unload()
}
///|
test "interface explorer module toggles through the inspector capability" {
let p = load_module("inspector")
assert_true(p.imports().contains("inspector"))
publish_state(0, false)
assert_true(p.on_event(false, PointerDown(3, 3)))
assert_eq(drain(), [SetInspector(true)])
p.unload()
}
///|
test "moon and 12-hour clock modules render from the clock capability" {
let m = load_module("moon-disc")
assert_true(m.render(36, 36, test_tokens()).length() > 3)
m.unload()
let c = load_module("clock-digital12")
let ts = texts_of(c.render(120, 36, test_tokens()))
assert_true(ts[0].has_suffix("AM") || ts[0].has_suffix("PM"))
c.unload()
}