# dist-ui — on-device Rust UI driven by Gleam (erl_dist / ETF) ``` Gleam (host) ── cookie + epmd + ETF ──► Rust Android node dist_driver@127.0.0.1 ui@ model / dist_view ── {render, Tree} ──► registered name: gui ◄── {event, Id} ── button clicks ``` UI is **egui + vidya**. There is no desktop Plushie path. ## Run ```bash cd ~/code/global nix run .#global # or: just run ``` That single command: 1. `cargo apk build --target x86_64-linux-android --no-default-features` (in `dist-ui/`) 2. `adb install -r target/debug/apk/global-dist-ui.apk` 3. Starts Waydroid session + `show-full-ui`, launches the app, runs Gleam → `ui@` Requires: Waydroid, `cargo` + `cargo-apk`, NDK (`ANDROID_NDK_HOME`, default `~/.local/share/android-ndk-r29`), host Wayland session for the window. Skip rebuild: `GLOBAL_APK_SKIP_BUILD=1 nix run .#global` - Package: `uk.nandi.global.distui` - Node: **`ui@192.168.240.112`** (Waydroid eth0; auto-detected) - Cookie / register: **`global`** / **`gui`** ## Layout | Path | Role | |------|------| | `dist-ui/` | Thin Rust: `erl_dist` + `eetf` + **egui/eframe** + **vidya** | | flake input `vidya` | Theme crate ([nandi.uk/vidya](https://tangled.org/nandi.uk/vidya)), staged to `.flake/vidya` for cargo | | `dist_driver/` | Global Gleam shell over dist + `dist_driver_ffi.erl` | | `src/global_app/` | Domain model + `dist_view` Element tree | | `scripts/discover-peers` | Host peer discovery (Valent D-Bus/config, GSConnect, kdeconnect-cli, UDP) | ### Live devices and peer ops On start and on **Refresh**, Gleam runs `scripts/discover-peers` (via `peers` / `peer-ops list`). Pair / Unpair / Ring / clipboard / media go through `scripts/peer-ops` and only toast success when the host reports `ok: true` (offline peers get explicit errors). The local Valent host id is never listed as a remote peer. ## Protocol (ETF) **Gleam → UI** (`{gui, 'ui@…'} ! Term`): - `{hello, Pid}` - `ping` - `{render, Element}` where Element is `{window|v_box|h_box|label|button, …}` **UI → Gleam**: - `{ready, <<"ui@…">>}` - `{event, <<"…">>}` - `pong` / `window_closed`