diff --git a/README.md b/README.md index d14f312..2ad5787 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,10 @@ Done so far (milestones M0–M4 and the first part of M5 of [the plan](docs/arch as plain rows and forms, chat formatting, the Twemoji archive, and what the settings pages and the Stream Studio decide; `voelin-ui` puts them on Slint windows ([docs/ui.md](docs/ui.md)) - `crates/voelin-gpui` (`voelin-gpui`): the GPUI front end, under construction, on the same engine and - view models as the Slint one, which stays the app until it reaches parity (a window that opens and - closes so far; [docs/ui.md](docs/ui.md)) + view models as the Slint one, which stays the app until it reaches parity: a window with the engine's + state in one line, the Voelin theme (every token of the Slint one's `theme.slint`, light and dark, in + Inter with the same Lucide icons; `VOELIN_OPEN=swatch` shows them) and a cost meter (`VOELIN_METER=1`) + ([docs/ui.md](docs/ui.md), "The GPUI front end") - `crates/voelin-stream`: TeamSpeak 6 streams: stream commands and notifications, JSON signalling, WebRTC peers (str0m) with host and STUN candidates. A live test streams VP8 + Opus between two clients through a TS6 server diff --git a/docs/design/gpui-spikes.md b/docs/design/gpui-spikes.md index c396c2c..c0037ea 100644 --- a/docs/design/gpui-spikes.md +++ b/docs/design/gpui-spikes.md @@ -18,7 +18,12 @@ exception is explained (a counter window longer than the case). Step 3 (2026-10-27) rebuilt the three spikes on `gpui-kit` 0.8.1 of 2026-10-26 and ran each README's measurement command once: they build, every check passes and the per-frame cost is 0.8.0's, so the pin is 0.8.1 ("The version to -pin"); the figures on this page are still 0.8.0's. +pin"); the figures on this page are still 0.8.0's. The same day the +foundation of step 3 landed on `phase5/gpui-foundation` (items 1 to 4 and 6 +of "What step 3's first slice must contain": Rust 1.95, ashpd on `async-io`, +the `voelin-gpui` crate with its root entity, the theme with Inter and Lucide, +the cost meter; item 5, the shell, is next): what exists, how to run it and +the slices that follow are in [docs/ui.md](../ui.md), "The GPUI front end". | Spike | The plan's no-go | Seen (software rendering, see Setup) | Verdict | |---|---|---|---| @@ -28,7 +33,8 @@ pin"); the figures on this page are still 0.8.0's. Before step 3 can start: Rust 1.95 for the client (no `gpui-kit` builds on 1.94) and the client's ashpd on `async-io` (GPUI's and the client's ashpd -features cannot be built together); both are under "Settled for step 3". +features cannot be built together); both are under "Settled for step 3", and +both are done (the first two commits of `phase5/gpui-foundation`). ## Setup @@ -457,8 +463,24 @@ the raw source's `for n in 0u64..` in `spikes/gpui/video/src/main.rs`, now (X11 capture and hotkeys only). **Step 3 must move the client's ashpd use to `async-io`** before `voelin-ui` can depend on gpui-kit with PipeWire capture and the portal hotkey; zbus with `async-io` runs its own I/O - thread, so it does not need GPUI's executor. -- **Size and compile time.** The spikes' lock has 1,069 packages; the + thread, so it does not need GPUI's executor. *Done:* voelin-media's + `pipewire` and voelin-platform's `portal` features ask ashpd for `async-io`, + and `voelin-gpui` holds both (it depends on `voelin-core` with + `media-desktop`, which brings PipeWire, and on `voelin-platform` with its + portal feature). What zbus 5.19 does with the features (read in its + source): with `async-io` and `tokio` both compiled in it picks per + connection, tokio when a tokio runtime is current on the calling thread and + `async-io` with an I/O thread of its own otherwise. The workspace has both + on already (notify-rust asks for `tokio`, others for the defaults), so the + engine's portal calls inside its runtime still run on tokio and a caller + with no runtime (a GPUI foreground task) gets the thread; a test in + voelin-platform (`tests/proxy.rs`) calls ashpd from a thread with no tokio + runtime and gets the answer. +- **Size and compile time.** In the root workspace, which already carries + Slint's and the codecs' dependencies, gpui-kit adds 279 entries to + `Cargo.lock` (208 new names; about 195 packages on Linux), and cargo deny + needed two licences it had not allowed, 0BSD and CC0-1.0. The spikes' lock + has 1,069 packages; the release binaries are 390 to 480 MB with line tables. A full debug build of the workspace with a toolchain it had not built with before (nightly) took 3 min 14 s on the 32 threads at a load average around 90. @@ -577,6 +599,19 @@ and size tokens. Not in it: video (slice 6) needs the decision of spike 1's "What a real GPU changes"; emoji need the patch above before the chat slice (4). +Items 1, 2, 3, 4 and 6 are done on `phase5/gpui-foundation` (2026-10-27), a +commit each (item 1 as two, item 2 as two: the spikes rebuilt on 0.8.1, then +the crate; item 4 with one small follow-up): Rust 1.95.0 and the seven lints +it adds; ashpd on `async-io`; `crates/voelin-gpui` +on `gpui-kit = "=0.8.1"`; the root `Entity` with the engine's events, +the one-second tick and `Later`; `VoelinTheme`, Inter and the client's Lucide +set; the meter as `VOELIN_METER=1`. The crate is named `voelin-gpui` (binary +`voelin-gpui`), the choices below stayed as the report leaves them except +those named in docs/ui.md ("The GPUI front end"): the theme's second layer is +written as a `ThemeColor` mapping (a table there), and the client's Lucide set +is served under gpui-component's `icons/` paths. Item 5, the shell, is the +next task. + ### The risks of plan section 6, against what was seen | Risk (plan) | Seen | diff --git a/docs/ui.md b/docs/ui.md index 909be8b..4f1133f 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -49,7 +49,9 @@ crates/voelin-ui-vm/ view models and state, no UI toolkit talk), the crash notice and the volume dialog of a client bbcode.rs emoji.rs chat formatting; the Twemoji archive, text → runs of text and emoji crates/voelin-gpui/ the GPUI front end, under construction (binary voelin-gpui; gpui-kit - pinned exactly); it uses voelin-ui-vm and the engine, not voelin-ui + pinned exactly); it uses voelin-ui-vm and the engine, not voelin-ui: + the root state, the theme, Inter and Lucide, the swatch page, the + cost meter ([The GPUI front end](#the-gpui-front-end)) crates/voelin-ui/ the Slint front end ui/ app.slint MainWindow: picks the shell, puts the page's screens in it, dialogs @@ -947,6 +949,185 @@ renderer; the phone layouts are desktop renders, not Android device tests. | ![Light chat and channel banners](screenshots/banners-desktop-light.png) | ![Light server list](screenshots/banners-mobile-servers.png) | | ![Banner in the desktop voice header](screenshots/banners-desktop-voice.png) | ![Banner in the mobile voice header](screenshots/banners-mobile-voice.png) | +## The GPUI front end + +`crates/voelin-gpui` (binary `voelin-gpui`) is the second front end, on GPUI +(`gpui-kit`, pinned exactly at `=0.8.1`: GPUI, gpui-component and their assets +behind one pre-1.0 dependency). Plan section 6 step 3 builds it slice by +slice next to the Slint front end, which stays the app: both are `[[bin]]`s of +one workspace on the same engine and the same `voelin-ui-vm` state until the +GPUI one reaches parity. It does not depend on `voelin-ui` (that would bring +Slint in), so the few lines of the Slint crate's `HostedEngine` are repeated +in `engine.rs`. The measured case for the migration, and the versions and +conditions it settled, are in [design/gpui-spikes.md](design/gpui-spikes.md). + +### What exists + +``` +crates/voelin-gpui/ + build.rs the client's 147 Lucide icons as a table of include_bytes! + src/ + main.rs lib.rs `run()`: logging, the engine's runtime, the window; closing it + tells the engine to close the sessions and ends the app + engine.rs HostedEngine: Engine::start on a tokio runtime, its events + forwarded into a channel the window reads + app.rs AppState, the root Entity: the voelin-ui-vm state and Social, + the three loops (events, tick, Later), the one line of state + view.rs MainView: the status line, the shell's page (empty), the swatch + swatch.rs the swatch page (every token, widgets, icons) + theme/ VoelinTheme: tokens.rs, components.rs, slint_parity.rs (test) + fonts.rs Inter, from crates/voelin-ui/ui/assets/fonts + assets.rs icons/.svg: the client's set before gpui-kit-assets' + dev.rs the development switches + meter.rs the cost meter +``` + +- **The root state.** `AppState` (an `Entity`) holds `voelin_ui_vm::state::AppState>` + and `Social`; `events::handle` is its one dispatch, as in the Slint front end, + and the `Update` it returns is carried out as far as this front end has the + parts: the engine's commands go out, the warnings are logged, the rest + (what to redraw, what to keep, the streams' capture and decoder) is for the + slices that have those parts. Three loops start with it and end when the + entity is released: **the engine's events** (a foreground task awaits the + tokio receiver, `this.update(cx, ...)`, `cx.notify()`; a tokio channel needs + no reactor, so GPUI's executor polls it); **the tick**, once a second, a loop + of `background_executor().timer`; and **`Later`**: GPUI's `AsyncApp` is not + `Send`, so a hotkey, camera or decoder thread holds a `Later` and calls + `later.run(|app, cx| ...)`, a queue a third foreground task drains with the + entity, as `later(|app| ...)` does in Slint. The window shows one line: + the version, the voice connections up, the engine events handled, the seconds + up; each part moves by one of the loops. The window's start shows no store: + the shell slice opens it with the settings and the bookmarks. +- **Tests** need no display (GPUI's test platform, `#[gpui::test]`, with + `gpui-pre`'s `test-support` as a dev-dependency beside gpui-kit's own pin: its + `test-support` feature would make Cargo lock the unused `gpui-fast` backend and + pin taffy 0.15.0): an injected engine event, a real engine's event, the tick + and a job from another thread reach the entity; the theme reaches + gpui-component, follows the window's appearance and the text size; the + Slint file's tokens equal the Rust ones (below); the icons and fonts load. + `cargo test -p voelin-gpui`. + +### Running it + +```sh +cargo run -p voelin-gpui --release # the window and its one line of state +VOELIN_OPEN=swatch VOELIN_DEV_THEME=light cargo run -p voelin-gpui --release +``` + +GPUI draws through wgpu: it needs a Vulkan driver (Mesa's RADV, ANV or NVK, +NVIDIA's) or OpenGL at run time; in a virtual machine, a remote desktop or +CI, Mesa's lavapipe (`mesa-vulkan-drivers`) draws in software. Which device a +run took is in the log ("Selected GPU adapter: ..."; the default filter shows +GPUI's adapter lines: `VOELIN_LOG` or `RUST_LOG` change it). On Wayland and +on X11 (a window manager is needed there for fullscreen and close requests). + +| Switch | Does | +|---|---| +| `VOELIN_OPEN=swatch` | the swatch page in place of the shell; the Slint front end's other pages are not here yet and are named in a warning | +| `VOELIN_DEV_THEME=dark\|light\|system` | the theme mode (the settings' `ui.theme` will give it) | +| `VOELIN_FONT_SCALE=1.25` | the text size factor (`ui.font_scale`) | +| `VOELIN_WINDOW_SIZE=1440x960` | the window's size | +| `VOELIN_METER=1` | the cost meter: once a second a log line (`voelin_gpui::meter`) with the process's CPU, the CPU of each group of threads (`llvmpipe` is the software renderer, work a GPU takes over; `voelin-gpui` is GPUI's thread), the resident memory, the app's own counters per second (engine events, ticks, renders, `Later` jobs) and the voice connections up | + +Screenshots are made headless, the way `scripts/shots.sh` makes the Slint +ones: `scripts/gpui-shot.sh out.png swatch 1440x960` runs the binary under +`xvfb-run`, takes the window with `xwd`, closes it with Alt+F4 when a window +manager is there (else TERM) and says how the app ended. On NixOS, with the +spikes' environment (a headless X display with openbox, lavapipe as the only +Vulkan driver, the XDG directories and the D-Bus bus private): + +```sh +GPUI_SHOT_HEADLESS=1 DELAY=4 VOELIN_DEV_THEME=dark spikes/gpui/shell.sh \ + spikes/gpui/headless.sh -- scripts/gpui-shot.sh docs/ui/gpui-swatch-dark.png swatch 1440x960 +``` + +Wayland, the desktop's session bus and its portals are out of the environment, +and the state directories are temporary ones: a run never touches the desktop +or `~/.local/state/voelin`. `docs/ui/gpui-swatch-dark.png` and +`gpui-swatch-light.png` are two such pictures (truecolour: a reduction to 256 +colours would change the tokens' values). + +![The swatch page, dark](ui/gpui-swatch-dark.png) +![The swatch page, light](ui/gpui-swatch-light.png) + +### The theme + +Two layers (docs/design/gpui-spikes.md, "The theme against Theme tokens"): + +1. **`VoelinTheme`**, a GPUI global with every token of + `crates/voelin-ui/ui/theme.slint` (the source of truth while Slint lives): + the 43 colours for light and dark, the backdrop gradient, the radii, the + spacing, the eight type sizes and four weights, the control, row and shell + sizes (the sidebar's `264 * max(1, scale)`, the top bar's `max(44, control + + 8)`), the two durations, at the text size factor. The shell's own elements + (the server rail, presence, meters) read it. `theme/slint_parity.rs` reads + `theme.slint` at test time and compares every declaration of its `Theme` + global with `theme/tokens.rs` by name, with the file's own arithmetic, at + four text sizes; a token on one side only, a changed value or a kind of + declaration it does not know fails the test. +2. **gpui-component's `ThemeColor`**, which its widgets read, written from the + first on every change (`theme/components.rs`): the registered theme of the + mode first, then the mapped colours over it, the font (Inter, `font-body`), + the radii and the base size. + +| Voelin token | gpui-component (`ThemeColor` field) | +|---|---| +| `bg-app`, `text` | `background`, `foreground`; `caret`; `window_border` is `border` | +| `surface` | `sidebar`, `title_bar`, `status_bar`, `list`, `list_even`, `table`, `table_even`, `tab_bar` | +| `surface-2` | `secondary`, `muted`, `group_box`, `list_head`, `table_head`, `tab_active`, `accordion` | +| `surface-3` | `accent` (gpui-component's "accent" is a hover background, not the brand colour), `popover`, `list_hover`, `table_hover`, `secondary_hover`, `skeleton` | +| `surface-4` | `secondary_active`, `switch` | +| `scrim` | `overlay` | +| `border`, `border-strong` | `border`, `sidebar_border`, `title_bar_border`; `input`, `scrollbar_thumb` | +| `glow` | `ring` | +| `accent`, `accent-hover`, `accent-pressed`, `on-accent` | `primary`, `primary_hover`, `primary_active`, `primary_foreground` (`accent` also `sidebar_primary`, `slider_bar`, `progress_bar`, `drag_border`, `list_active_border`; `on-accent` also `slider_thumb`, `switch_thumb`) | +| `accent-soft` | `list_active`, `table_active`, `selection`, `drop_target` | +| `accent-text` | `link`, `link_hover`, `link_active` (one colour for the three) | +| `danger`, `success`, `warning`, `info` | the same names with `_hover` and `_active` (mixed 14 % toward white in dark, black in light; 18 % toward black) and `_foreground`: white or the window's ink, whichever contrasts more | +| `text-secondary`, `text-muted` | `table_head_foreground`, `tab_foreground`; `muted_foreground`, `scrollbar_thumb_hover` | +| `danger`, `success`, `warning`, `info` with `danger-soft`, `success-soft`, `warning-soft`, `accent-soft` | also the base palette `red`, `green`, `yellow`, `blue` and their `_light` variants; `chart_1` to `chart_5` are `accent`, `success`, `warning`, `danger`, `info` | +| the `button_*` fields | written from `secondary`, `primary`, `danger`, `success`, `warning` and `info` (a theme file leaves them to fall back to these; without it they would keep the default theme's blue) | +| not mapped | `bg-rail`, the backdrop gradient, `scrim-light`, `border-popup`, `live`, `live-soft`, `idle`, `dnd`, `offline`, `gold`, `meter-*`, `text-disabled`, `icon`, `name-text`: read from `VoelinTheme` by the shell. GPUI's gradient has two colour stops and the Slint backdrop three, so `Backdrop::to_gpui` draws the first and the last | + +The mode (`Choice`) is `ui.theme`: `system` follows the window's appearance +and its changes (`observe_window_appearance`), `light` and `dark` do not. +Where the platform draws the window's frame (macOS) the mode sets its +appearance; elsewhere that is a no-op. **Inter** (the five files the Slint +front end bundles) goes into GPUI's text system with `add_fonts` and is used by +family name. **Lucide:** `build.rs` embeds the client's 147 icons (Lucide +1.48) and `assets.rs` serves them as gpui-component's `icons/.svg` paths +before gpui-kit-assets' Lucide 1.43 catalogue (1,830 icons), so every widget +draws the icons the client draws and the rest of the catalogue still answers. + +### What is next + +The slices of plan section 6 step 3, in order, with what each takes from the +Slint `Bridge` (`ui/bridge.slint:801-1206`; properties / callbacks): + +1. the **desktop shell**: the server rail, the sidebar, the top bar, the empty + main area, window state (about 13 / 11, `bind/servers.rs`), the store and the + settings opened as in Slint's `run()`; +2. the channel tree and the members (about 13 / 6); +3. the voice page and the call bar (6 / 6); +4. chat, the composer and emoji (about 19 / 18, and the `Emoji` global 3 / 3): + needs the one-line `gpui-pre-wgpu` patch for colour emoji and Noto Color Emoji + bundled (design/gpui-spikes.md, "Emoji"), and a check of Wayland's preedit; +5. the settings pages (about 62 / 53), page by page; +6. the stream viewer and the share dialog (30 / 13): its first step is a run on + a GPU (design/gpui-spikes.md, "What a real GPU changes"), which decides `img()` + against a persistent texture; +7. home, friends, messages, events, the bell and the search (25 / 32, + `bind/social.rs`); +8. the Stream Studio (19 / 36) and its second window; +9. dialogs and overlays. + +Phone layouts are dropped (decision 2). Around the slices: system-font emoji +and the removal of `twemoji.bin`; `tr!()` over the gettext catalogue (1,255 +entries); the in-window keys as GPUI key bindings and the global ones through +`voelin-platform`, which now holds the portals and GPUI in one binary (ashpd on +`async-io`); and last the removal of Slint (`build.rs`, `ui/`, +`voelin-android`, `LicenseRef-Slint` of `deny.toml` and `about.toml`). + ## Limits - No drop shadows or blur (the software renderer draws none): glows are