Files
chandra/wasmhost
Claude 1f4b686087
CI / test (push) Failing after 18s
Network module: Wi-Fi and wired status, connect to Wi-Fi networks, Wi-Fi and airplane switches
- New `network` panel module (in the default panel, before the battery and the clock): signal bars and the
  Wi-Fi network's name, a plug when wired, crossed-out bars offline or in airplane mode. Its
  popup shows the status and the last action's outcome ("Couldn't connect to X: wrong
  password?"), switches for Wi-Fi and airplane mode, and the networks in range (strongest
  access point per name, the one in use first). Click a saved or open network to connect, a new
  secured one to type its password in a field under it (Enter or Connect), the one in use to
  disconnect, or "Forget" on a saved one. Opening the popup asks for a scan.
- compositor/network: NetworkManager over D-Bus through a small D-Bus client of our own
  (wire format, EXTERNAL auth, async calls) on the existing @sys socket calls, so neither host
  needed new imports. One ObjectManager.GetManagedObjects + GetAll every 2 s; GetSettings once
  per saved connection; RequestScan, Device.Disconnect, WirelessEnabled / WwanEnabled,
  ActivateConnection (saved), AddAndActivateConnection (new: open, WPA/WPA2 PSK, WPA3 SAE) and
  Settings.Connection.Delete. Without NetworkManager it falls back to read-only status from
  /proc/net/dev, /proc/net/wireless and /sys/class/net (no network names there), and looks for
  NetworkManager again every 30 s.
- New `network` capability (wit/capabilities.wit): status, wifi-networks, scan, connect,
  disconnect, forget, set-wifi-enabled, set-airplane-mode. Served from host tables 8/9 and a
  `network(network-request)` request by the wasmer/wasmtime stub (compositor/wasm), host-wasm
  and the MoonBit wasmhost. The stub's build_list learned bool fields; request strings are
  wiped after use (Wi-Fi passwords).
- Running out of module instances now says "too many modules loaded".
- Deferred: VPN, hotspot, hidden networks, WEP and 802.1X (enterprise) networks, IP settings,
  mobile broadband beyond the airplane switch, D-Bus signals (state is polled).
- Tests: D-Bus wire format (incl. the well-known Hello bytes), NetworkManager objects -> status
  and list, security settings, /proc parsing; the module through the shell against a fake
  backend (list, connect/forget/disconnect, password entry, switches, read-only); a host-wasm
  test; and scripts/test-network-dbus.sh, which runs the backend against python-dbusmock's
  NetworkManager on a private bus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hizqNXcNDuef3gxa7D
2026-11-25 20:02:36 +00:00
..

wasmhost

The MoonBit host for the compositor component (build/compositor.wasm), replacing the Rust host-wasm/. It links wasmtime as the prebuilt C API library (libwasmtime.a from the upstream wasmtime-v$WASMTIME_VERSION-x86_64-linux-c-api release, fetched by scripts/setup-toolchain.sh into .tools/wasmtime-c-api) instead of compiling wasmtime, so a cold build takes about 4 s instead of about 2 minutes.

scripts/build-wasmhost.sh        # or: just wasmhost  ->  build/wasmhost
build/wasmhost build/compositor.wasm --socket PATH --gfx-out frame.png
  • wt/: the wasmtime C API (wt_stub.c) and the value encoding host calls cross as (val.mbt). wasmtime's C API has no bindgen: every call goes through one callback with dynamic values, so each import is a small handler from values to values. A list<u8> crosses as one dynamic value per byte and wasmtime caps how much one call may copy (about 2.7 MB of list<u8>), so large files are written as write-file plus append-file chunks.
  • bin/: the interfaces of wit/host. Most of it is the native compositor's own packages: sys is compositor/sys, glyphs come from compositor/font (stb_truetype). The rasteriser (raster.mbt, pixel work in raster_stub.c) is a port of host-wasm/src/raster.rs; SVG icons use nanosvg (third_party/nanosvg) where the Rust host used resvg.

Status: sys, font and raster work (--gfx-out frames match the Rust host's). Panel modules (plasmoids), the login-session display (--drm) and the nested window are still to come.

WASMHOST_TRACE=1 logs every host call.