README: describe Chandra as it is now
CI / test (push) Failing after 17s

Rewrite the M0-era README for the current project: the rename from
moon-plasma, the MoonBit wasmhost as the default host (Rust host-wasm as
fallback), the just recipes, shortcuts (Super+D, screenshots, recording),
panel modules and Settings, config/state paths, CHANDRA_* variables, and
known gaps. Add a headless desktop frame (docs/screenshots/desktop.png).
TOOLCHAIN.md and ARCHITECTURE.md get notes that they describe M0 and point
to the README for the current state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhZBVRuyDznwycdo4s
This commit is contained in:
Claude committed 2026-11-25 20:31:19 +00:00
1 parent 005e11e7bf
commit c1936299cb
4 files changed
+178 -62

No files matched your search

+163 -62
View File
@@ -1,93 +1,194 @@
# chandra # Chandra
A modular, KDE-Plasma-inspired desktop environment where **every part is a A modular, KDE-Plasma-inspired Wayland desktop where **every part is a WebAssembly component**
WebAssembly component** (Component Model, WIT interfaces) written in (Component Model, WIT interfaces) written in [MoonBit](https://www.moonbitlang.com), on top of a
[MoonBit](https://www.moonbitlang.com), on top of a deliberately tiny trusted host. deliberately small host. The compositor itself (Wayland server, window manager, scene, shell) is a
component, and so is every panel module: the clock, the task manager, the launcher, the settings.
![launcher open](docs/screenshots/m0-2-launcher-open.png) Chandra was called moon-plasma until 2026-11-25. The code, the WIT packages (`chandra:*`), the
session (`chandra-session`) and the paths (`~/.config/chandra`) all use the new name; an old
`~/.config/moon-plasma/panel.edn` and `state.edn` are still read when the new ones don't exist yet.
*Headless-Chromium capture of the M0 browser host: the shell, the launcher and the clock Repository: <https://git.site.latha.org/experiments/chandra>
are three separate MoonBit components.*
![Chandra desktop](docs/screenshots/desktop.png)
*A frame rendered headless by `build/wasmhost --gfx-out`: the wallpaper, the desktop card and every
panel button are drawn by wasm components.*
## Vision ## Vision
Plasma's strength is its decomposition (shell, widgets, window manager, runner, Plasma's strength is its decomposition (shell, widgets, window manager, runner, settings modules,
settings modules, notifications, tray). chandra keeps that decomposition and notifications, tray). Chandra keeps that decomposition and makes each seam a **typed WIT
makes each seam a **typed WIT interface** with **deny-by-default capabilities**: interface** with **deny-by-default capabilities**:
* the **host** only owns engine/lifecycle, devices, the capability broker and the * the **host** only owns the wasm engine, devices (sockets, files, DRM/KMS, libinput), the
render-list rasteriser; capability broker and the rasteriser;
* **everything else is a component**: swap the clock for another implementation, * **everything else is a component**: swap the clock for another implementation, swap the shell,
swap the whole shell, change the theme, without rebuilding the rest; change the theme, without rebuilding the rest;
* components draw by returning a **render-list** (`list<draw-op>`), never pixels; * components draw by returning a **render list** (`list<draw-op>`), never pixels;
* components can't touch anything their imports + the desktop config don't grant. * components can't touch anything their imports and the desktop config don't grant.
Read [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) (Plasma→component mapping, host Design: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) (Plasma to component mapping, permissions,
decision, rendering, input, permissions, versioning, roadmap M0–M8) and versioning) and [docs/compositor-design.md](docs/compositor-design.md) (the compositor and its
[docs/TOOLCHAIN.md](docs/TOOLCHAIN.md) (what works today, exact versions). hosts). Toolchain notes: [docs/TOOLCHAIN.md](docs/TOOLCHAIN.md). Dark mode and the portal: [docs/dark-mode.md](docs/dark-mode.md). Running as root and run0:
[docs/run0.md](docs/run0.md).
## Status: M0 (proof of concept) ## How it runs
Works today: ```
build/compositor.wasm the compositor, a wasm component (components/compositor, code in compositor/)
build/wasmhost the host that runs it: MoonBit, linked to the prebuilt wasmtime C API (default)
host-wasm/ the same host in Rust on the wasmtime crate (fallback)
build/components/*.wasm panel modules, loaded by the host and drawn by the compositor
```
* WIT package `chandra:desktop@0.1.0` (`wit/`): worlds `widget`, `clock-widget`, The **MoonBit host** ([wasmhost/](wasmhost/README.md)) is the default. It links
`launcher-widget`, `panel`, `shell`. `libwasmtime` from the upstream C API release instead of compiling wasmtime, so a cold build takes
* Four MoonBit components, each an independently built `.wasm` component of 24–33 KB: about 4 seconds (the Rust host takes about 2 minutes). The **Rust host**
`clock-digital` (12-hour with AM/PM by default, 24-hour in its right-click settings), ([host-wasm/](host-wasm/README.md)) serves the same `wit/host` interfaces and is kept as a
`clock-binary` (drop-in replacement), `launcher` (kickoff-like with fallback until it is removed; any host change goes into both. A **native build** of the same
keyboard search), `shell` (desktop background + bottom panel layout + theme tokens). compositor code (no wasm, `just run-native`) is used by the test suite.
* Host (`host/`): Node + browser, jco-transpiled components, capability grants,
popup/focus input routing, hot-swap, fault isolation, Canvas2D + ASCII renderers.
* Tests: 16 MoonBit unit tests (pure logic), 13 host integration tests that
instantiate the real components, WIT conformance (`wasm-tools component targets`),
generated-bindings freshness check, `wasmtime compile` of every component.
Stubbed / not done (see ARCHITECTURE §10): no window manager/compositor, search runner, The compositor runs either **nested**, as a window on your current Wayland session, or as a
notifications, settings, tray, session, shortcuts, clipboard, files; `launch` only logs; **login session** on DRM/KMS with libinput (`--drm`, through libseat/logind).
host does input hit-testing; fixed-advance text metrics, no real fonts/icons; native
wasmtime host is M3; no CPU/fuel limits under jco.
## Quickstart ## Quickstart
Requirements: Linux x86_64, Node ≥ 20, [MoonBit](https://www.moonbitlang.com/download). Requirements: Linux x86_64, [MoonBit](https://www.moonbitlang.com/download),
[pixi](https://pixi.sh) (it provides `just`, tcc and seatd/libseat), and the dev headers for
libdrm, libinput, libudev and libxkbcommon (on Debian/Ubuntu:
`apt install libdrm-dev libinput-dev libudev-dev libxkbcommon-dev libseat-dev`).
Screen recording needs `ffmpeg` on `PATH`.
```bash ```bash
export PATH="$HOME/.moon/bin:$PATH" export PATH="$HOME/.moon/bin:$PATH"
scripts/setup-toolchain.sh # wasm-tools, wit-bindgen, wasmtime -> ./.tools (no root) moon update # fetch mooncakes dependencies
(cd host && npm ci) # jco scripts/setup-toolchain.sh # wasm-tools, wit-bindgen, wasmtime + its C API -> ./.tools (no root)
scripts/build.sh # MoonBit -> components -> build/components, build/jco
scripts/test.sh # everything CI runs
node host/src/cli.mjs --time 2026-11-24T14:07:00 --click-launcher # terminal render just run # build compositor.wasm, wasmhost and the modules; open in a window
node host/serve.mjs 8080 # browser host: http://127.0.0.1:8080/ just client # start foot inside it (or: just client konsole)
node host/serve.mjs & # then try ?config=desktop.binary-clock.json or ?theme=moon-day
``` ```
Swap the clock **without rebuilding anything else**: | Recipe | What it does |
|---|---|
| `just run` | Nested in a window on your Wayland session, MoonBit host |
| `just run-drm` | As a login session on the real screen (from a text console, as yourself) |
| `just install-session` | Install the "Chandra" display-manager session (asks for root once) |
| `just install-session-dev` | Same, but symlinked into this checkout: later just rebuild |
| `just run-rust`, `run-drm-rust`, `install-session-rust` | The same with the Rust host |
| `just run-native`, `run-drm-native`, `install-session-native` | The native (non-wasm) build |
| `just compositor-wasm`, `wasmhost`, `host-wasm`, `modules` | Build one piece |
| `just test` | Native compositor tests and lib tests |
| `just frame` | Render one composed frame to `_build/e2e_frame.png` |
| `just remote-build` | Build on a sprites.dev sprite (`CHANDRA_SPRITE`) and pull the artifacts back |
```bash `build/wasmhost build/compositor.wasm --socket PATH` takes `--window` (nested), `--drm` (login
node host/src/cli.mjs --config config/desktop.binary-clock.json session), `--theme PATH`, `--no-restore`, `--profile`, `--size WxH` and `--gfx-out frame.png`
scripts/build.sh clock-binary # builds just that component (render to a PNG, headless; add `--serve` to keep refreshing it). `WASMHOST_PROFILE=1` prints the
# in the browser console: await chandra.swap('clock', 'clock-binary') time spent in each host function every 5 seconds; `WASMHOST_TRACE=1` logs every host call.
```
Screenshots: see the end of [docs/TOOLCHAIN.md](docs/TOOLCHAIN.md). The installed session logs to `~/.local/state/chandra/session.log`. Start it as yourself, never
as root: `chandra-session` refuses to run as root (`CHANDRA_ALLOW_ROOT=1` overrides). Installing
Installing the login session (`just install-session`) asks for root through run0, else sudo/doas/pkexec; goes through `scripts/as-root`, which prefers run0 and falls back to sudo, doas or pkexec
for starting the desktop from a TTY and running apps as root inside it (`chandra-root`), see (`CHANDRA_AS_ROOT` picks one). To run a graphical app as root inside Chandra, use
`chandra-root gparted`. Details, including polkit agents (`CHANDRA_POLKIT_AGENT`), are in
[docs/run0.md](docs/run0.md). [docs/run0.md](docs/run0.md).
## What works
**Windows**
* Wayland clients (xdg-shell, wl_shm buffers, clipboard), tiling or floating (the Tile | Float
panel toggle).
* Drag a window by its title bar, resize floating windows from corners and edges, double-click
the title bar to maximize or restore. Clicking a window raises it.
* App right-click menus (xdg_popup) stay open and on screen; apps that draw with Vulkan on wl_shm
(Zed, Delta) show every frame; buffers stay valid after their pool is destroyed.
* The mouse wheel scrolls windows.
* Window positions are remembered per app, and on login the session reopens the windows the last
one ended with (switch it off in Settings, or start with `--no-restore`).
**Shortcuts**
| Keys | Action |
|---|---|
| Super (tap) | Open the application launcher |
| Alt+Tab | Window switcher, with a live preview of each window |
| Super+D | Show the desktop (minimize every window); again to bring them back |
| Super+Shift+S | Screenshot: select a region or click a window (F full screen, W active window) |
| Print / Super+Print / Super+Ctrl+Print | Screenshot of the full screen / active window / window under the pointer |
| Super+Shift+R | Record a region or window (Enter starts) |
| Super+Alt+R / Super+Ctrl+R | Record the whole screen / the window under the pointer |
Screenshots go to `~/Pictures/Screenshots/` and the clipboard; recordings (H.264 MP4, via
`ffmpeg`) go to `~/Videos/Screencasts/`. A red REC pill shows while recording; click it or press
a recording shortcut again to stop.
**Panel modules** (each one a separate `.wasm` component in `components/`)
* **Launcher** (application menu with search) and **Dock**.
* **Task manager**: a pill per window with the app's real icon from its `.desktop` file;
right-click a pill for Minimize, Maximize and Quit.
* **Network**: Wi-Fi and wired status, connect to Wi-Fi networks (with passwords), Wi-Fi and
airplane switches, through NetworkManager over D-Bus (read-only sysfs status without it).
* **Battery**: charge, charging state, time left, low-battery warning (only added on machines
with a battery).
* **Clocks**: the Digital Clock (12-hour with AM/PM by default, 24-hour in its Module settings)
and a binary clock.
* **Screenshot**, **Layout** (Tile | Float), **Inspector** (interface explorer), **Log out**.
* **Settings**: tabs for Session (reopen windows at login, remember window positions, dark
mode), Desktop (wallpapers), Panel (add, remove and replace modules) and Power (screen off and
suspend when idle, battery, suspend / restart / power off). Dark mode also sets the system
preference for apps: GTK, Qt and KDE settings, and in the login session Chandra serves
xdg-desktop-portal's Settings color-scheme itself, so Chrome, Firefox and Electron apps follow
the switch live (see [docs/dark-mode.md](docs/dark-mode.md)).
Right-click any module for **Module settings** (its own options, such as the clock's format,
saved in `state.edn`), **System settings**, Replace with and Remove widget. Right-clicking empty
panel space opens System settings on the Panel tab.
**Performance**: an idle desktop sleeps instead of redrawing (about 0.35 % CPU, down from about
9 %), only changed parts of the screen are redrawn, and screenshots, recording and `--gfx-out`
keep pixels on the host rather than copying them through the component.
## Configuration and state
* `~/.config/chandra/panel.edn`: the panel's modules, in order.
* `~/.config/chandra/state.edn`: layout mode, recent apps, window positions, the windows to
reopen, wallpaper, theme, power timeouts, per-module settings (`:module-config`), and the
Settings switches (`:restore-session false`, `:remember-windows false`, `:theme :light`).
* Themes: `config/themes/moon-night.json` (default) and `moon-day.json`.
## Known gaps
* 5 to 6 compositor tests fail on main in a cloud container and are not regressions
(`input_test`, plus `screenshot_test` when the screenshot module isn't built). Build the panel
modules first and run with `CHANDRA_TEST_CONFIG=1`, or more tests fail.
* The DRM/KMS login session and real-hardware paths (power actions, battery, NetworkManager on a
real machine) are not exercised by CI; they have been built and unit-tested, not run on
hardware in automation.
* Not done yet: lock screen, notifications daemon, system tray, virtual desktops, multi-monitor
configuration, idle-inhibit (a playing video doesn't keep the screen on), lid and power-button
actions (logind's defaults apply), VPN and enterprise Wi-Fi.
* Desktop Pulse (`compositor/wasm/testdata/pulse.component.wasm`) and the `moon-disc` panel
module have no source in the tree, so `scripts/build-modules.sh` skips moon-disc and a fresh
panel shows a "Module 'moon-disc' not found" notice (remove it in Settings, Panel tab).
## Layout ## Layout
``` ```
wit/ the WIT package (host-agnostic API) wit/ WIT packages: chandra:desktop (components) and chandra:host (wit/host, what hosts serve)
interface/ world/ generated shared MoonBit bindings (wit-bindgen; committed) compositor/ the compositor in MoonBit: wayland/, shell/, scene/, raster/, kms/, network/, portal/, host/, ...
components/<n>/gen/ generated export bindings + hand-written thin stub.mbt components/<n>/ one wasm component each: compositor, shell, panel modules (gen/ bindings + thin stub.mbt)
lib/ pure, unit-tested logic (ui helpers, panel layout, launcher state machine, ...) lib/ pure, unit-tested logic (panel layout, clock, launcher, battery, task pills, ...)
host/ JS host: src/desktop.mjs (core), loaders, renderers, tests, web/ (browser) wasmhost/ the default host (MoonBit + wasmtime C API)
config/ desktop configs (grants!), themes, static app list host-wasm/ the fallback host (Rust + wasmtime)
scripts/ setup-toolchain, gen-bindings, build, test, screenshot host/ the original M0 browser/Node host (jco), kept for the component demos
docs/ ARCHITECTURE, TOOLCHAIN, screenshots session/ chandra-session, chandra-root, chandra.desktop, chandra.portal, install.py
config/ desktop configs, themes, app list
scripts/ setup-toolchain, build-*, gen-bindings, as-root, remote-build, test
docs/ ARCHITECTURE, compositor-design, TOOLCHAIN, run0, dark-mode, screenshots
``` ```
## License ## License
+9
View File
@@ -242,6 +242,10 @@ Designed next (no WIT yet): `window-registry`/`wm-policy`/`decoration`, `search-
## 10. What is a PoC stub today ## 10. What is a PoC stub today
> Written at M0. Much of this list is done now: a real Wayland compositor and window manager,
> real fonts and icons, settings, session restore, clipboard, shortcuts and a DRM/KMS login
> session. See the README's "What works" and "Known gaps" for the current state.
* Host does hit-testing/routing (see §5), time and app list are host-provided statics. * Host does hit-testing/routing (see §5), time and app list are host-provided statics.
* `app-launch.launch` records the id and logs; it does not start anything. * `app-launch.launch` records the id and logs; it does not start anything.
* Text uses a fixed-advance contract; no font/shaping/icon interfaces (glyph letters stand in for icons). * Text uses a fixed-advance contract; no font/shaping/icon interfaces (glyph letters stand in for icons).
@@ -251,6 +255,11 @@ Designed next (no WIT yet): `window-registry`/`wm-policy`/`decoration`, `search-
## 11. Roadmap ## 11. Roadmap
> Status as of 2026-11-25: M0 is done; the native host (M3) exists as the MoonBit wasmhost
> (default) and the Rust host-wasm; the compositor hosts real Wayland clients (M5, in MoonBit
> rather than smithay) and runs as a DRM/KMS + libinput login session (M8). Settings, power and
> clipboard from M6 are in; notifications, tray, vfs and packaging are not.
| M | Goal | Status | | M | Goal | Status |
|---|---|---| |---|---|---|
| **M0** | Toolchain proof, WIT v0.1 (`widget`/`panel`/`shell`), host (Node+browser), 4 components, tests, CI, swap/theme/permission demos | **done (this PR)** | | **M0** | Toolchain proof, WIT v0.1 (`widget`/`panel`/`shell`), host (Node+browser), 4 components, tests, CI, swap/theme/permission demos | **done (this PR)** |
+6
View File
@@ -1,5 +1,11 @@
# Toolchain: what works today (verified 2026-11-24) # Toolchain: what works today (verified 2026-11-24)
> This page records the M0 toolchain proof (browser/Node host via jco). Since then the
> components also run natively under wasmtime: the default host is the MoonBit
> [wasmhost](../wasmhost/README.md) on the wasmtime C API, with the Rust
> [host-wasm](../host-wasm/README.md) as a fallback. For the current build see the
> [README](../README.md). Pinned versions live in `scripts/versions.env`.
Everything here was run on x86_64 Linux (glibc 2.43 locally; CI uses Everything here was run on x86_64 Linux (glibc 2.43 locally; CI uses
`node:20-bookworm`, glibc 2.36), without root. `node:20-bookworm`, glibc 2.36), without root.
Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB