Merge phase5/ui-vm: the toolkit-free voelin-ui-vm crate (plan section 6 step 2)
CI / Linux checks (push) Failing after 1m7s
CI / Linux checks (push) Failing after 1m7s
Shared view-model types (ImageSource, Rgb, list diffing), the view models, the BBCode reader and the Twemoji archive, SessionView/Tab/Msg and the App state moved out of the Slint crate into voelin-ui-vm; the Slint crate keeps adapters and bindings (studio and settings split into logic and bind). Opus gate accepted with five minors left as follow-ups (server_tint falls back to black, ImageSource::size reads headers only, convert::image does not check the RGBA length, docs/ui.md metric wording, field docs on the mirrored bridge structs). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
commit
ad2097963e
73 files changed
+11836
-5281
No files matched your search
@@ -73,7 +73,8 @@ fuzz/ cargo-fuzz targets
|
||||
| `voelin-audio` | Capture/playback, Opus, echo cancellation, resampling, jitter buffer, mixer, VAD/push-to-talk; the voice packet types (`TalkerId`, `VoicePacket`, `EncodedVoice`), so it depends on no voice transport | v0 (no AEC yet) |
|
||||
| `voelin-stream` | TS6 stream commands, JSON signalling, str0m peer connections, host/STUN candidates, streamer/viewer sessions, frame-source seam; its frame and simulcast layer types are `voelin-media`'s | sessions + transport |
|
||||
| `voelin-core` | Engine: runtime, per-server sessions, merge of voice/gateway/query sources, the `ServerLink` seam the voice source sits behind (`link.rs`; `TsLink` is the TeamSpeak implementation, for now in this crate), event bus, command API, chat history, the gateway's features, audio settings and volumes, streams on TS6, files, avatar and icon cache, pokes, offline messages, contacts; `media` module (capture → encoder → stream, stream → decoder); the stream types of its API are its own (`stream_types`, see Streams) | done |
|
||||
| `voelin-ui` | Slint UI and the desktop binary: streams panel, viewer, share dialog, audio / hotkey / codec settings | done (desktop) |
|
||||
| `voelin-ui-vm` | The view models, toolkit-free: engine state turned into plain rows and forms (servers, channel tree, chat with its BBCode reader, social, streams, the Stream Studio, the settings pages), the app's state (`AppState`, sessions and chat tabs), `ImageRef`/`Rgb`/`list::diff`, the Twemoji archive. Depends on `voelin-core`, `voelin-model`, `voelin-store`, `voelin-gateway-proto` and `voelin-audio`, on no UI toolkit; a front end converts its rows | done |
|
||||
| `voelin-ui` | Slint UI and the desktop binary: streams panel, viewer, share dialog, audio / hotkey / codec settings; the Slint side of what `voelin-ui-vm` decides (the Bridge and model writes, windows, the engine's tasks) and the conversion of its rows into Slint values (see [ui.md](ui.md), "Two crates") | done (desktop) |
|
||||
| `voelin-media` | Screen and system-audio capture backends (PipeWire portal, X11, Windows Graphics Capture, Android MediaProjection), video codecs; the frame and simulcast layer types of a stream (`stream::EncodedFrame`, `LayerSpec`, `LayerId`, `LayerSet`) | done (desktop hardware encoders through FFmpeg loaded at runtime, not run on a GPU yet; MediaCodec not run on a device yet) |
|
||||
| `voelin-platform` | Global hotkeys, notifications, paths, crash reports, notices | done |
|
||||
| `voelin-android` + `android/` | Android library + Gradle/Kotlin app (foreground services for voice and screen capture); see [android.md](android.md) | builds, not yet run on a device |
|
||||
|
||||
+116
-25
@@ -4,14 +4,31 @@
|
||||
(`crates/voelin-android` runs the same window). It uses Slint's software
|
||||
renderer, the Inter font, Lucide icons and Twemoji; the look follows the
|
||||
design mockups (deep navy panels, a blue accent, a server rail, a top bar, a
|
||||
sidebar with the user card, an optional right panel).
|
||||
sidebar with the user card, an optional right panel). What its screens show
|
||||
is made by `crates/voelin-ui-vm`, which knows no UI toolkit ([Two
|
||||
crates](#two-crates)).
|
||||
|
||||

|
||||
|
||||
## Structure
|
||||
|
||||
```
|
||||
crates/voelin-ui/
|
||||
crates/voelin-ui-vm/ view models and state, no UI toolkit
|
||||
assets/twemoji.bin the Twemoji SVGs packed by scripts/pack-twemoji.py
|
||||
src/
|
||||
image.rs color.rs ImageRef (a picture by where it comes from), Rgb
|
||||
list.rs list::diff(old, new) → Changes (update, remove, insert by index)
|
||||
bridge.rs the bridge structs as plain values (Arc<str>, ImageRef, Rgb, Vec)
|
||||
studio_bridge.rs the same for the Stream Studio
|
||||
state.rs AppState, SessionView, Tab, Msg: what the client knows apart from
|
||||
the window, generic over the list type of a chat tab's lines
|
||||
servers.rs tree.rs chat.rs social.rs home.rs streams.rs avatar.rs studio/mod.rs
|
||||
pure view models (engine state → bridge structs), unit-tested
|
||||
settings.rs the UI's settings keys, the audio form
|
||||
settings_pages/logic.rs, studio/logic.rs
|
||||
the decisions of the settings pages and of the Stream Studio
|
||||
bbcode.rs emoji.rs chat formatting; the Twemoji archive, text → runs of text and emoji
|
||||
crates/voelin-ui/ the Slint front end
|
||||
ui/
|
||||
app.slint MainWindow: picks the shell, puts the page's screens in it, dialogs
|
||||
theme.slint Theme global: design tokens (colours, radii, spacing, type)
|
||||
@@ -35,28 +52,98 @@ crates/voelin-ui/
|
||||
studio-parts (the studio's pieces), studio (its page, its
|
||||
phone layout)
|
||||
assets/ fonts/ (Inter, OFL), icons/ (Lucide, ISC), logo.svg
|
||||
assets/twemoji.bin the Twemoji SVGs packed by scripts/pack-twemoji.py
|
||||
src/
|
||||
app.rs setup, App state, event dispatch
|
||||
app.rs setup, the Slint models (`Models`), event dispatch; `App` holds
|
||||
a `voelin_ui_vm::state::AppState` and the window
|
||||
servers.rs chat.rs members.rs streams.rs settings_page.rs appearance.rs
|
||||
home.rs social.rs messages.rs events.rs settings_pages.rs previews.rs
|
||||
studio.rs popout.rs the logic of each area (social.rs: contacts, the bell and the
|
||||
search; previews.rs: pictures in chat; studio.rs: the Stream
|
||||
Studio's controller; popout.rs: the stream's own window)
|
||||
vm/ pure view models (engine state → Slint structs), unit-tested
|
||||
bind/ callbacks of each area, wired once
|
||||
home.rs social.rs messages.rs events.rs previews.rs popout.rs
|
||||
the Slint side of each area (social.rs: contacts, the bell and the
|
||||
search; previews.rs: pictures in chat; popout.rs: the stream's own
|
||||
window)
|
||||
settings_pages/ mod.rs (Pages), bind.rs: the settings pages on the Bridge
|
||||
studio/ mod.rs (StudioState), bind.rs: the Stream Studio's windows and engine
|
||||
bind/ callbacks of each area, wired once; convert.rs, convert/items.rs
|
||||
(plain values → Slint values), rows.rs (a Slint model kept in step
|
||||
with a plain list)
|
||||
images.rs the image cache (LRU, bounded by `ui.image_cache_mb`)
|
||||
emoji.rs the Twemoji archive, text → runs of text and emoji
|
||||
dev.rs development switches (screenshots, sample data)
|
||||
```
|
||||
|
||||
Models are created once (`app::Models`) and updated row by row with
|
||||
`vm::list::sync`, which keeps the rows shared at both ends and changes,
|
||||
`bind::rows::Rows::sync`, which finds what changed with
|
||||
`voelin_ui_vm::list::diff`, keeps the rows shared at both ends and changes,
|
||||
inserts or removes the rest: a client that starts talking changes one row of
|
||||
the tree. Every chat tab owns a `VecModel` of its lines; the chat view shows
|
||||
the selected tab's model, so a new message is one `push` and switching tabs
|
||||
swaps the model. Lists that can grow (channels, messages, notices, the emoji
|
||||
grid) use `ListView`, which builds only the visible rows.
|
||||
the tree. Every chat tab owns a `Rows` of its lines (`app::ChatRows`); the
|
||||
chat view shows the selected tab's model, so a new message is one `push` and
|
||||
switching tabs swaps the model. Lists that can grow (channels, messages,
|
||||
notices, the emoji grid) use `ListView`, which builds only the visible rows.
|
||||
|
||||
## Two crates
|
||||
|
||||
`voelin-ui-vm` turns engine state into rows and decides what the controls
|
||||
change; it has no `slint` and no `gpui` in its dependency tree, and the
|
||||
Slint crate imports it as `vm` (`use voelin_ui_vm as vm`), so `vm::chat` in
|
||||
this file is `voelin_ui_vm::chat`. The boundary:
|
||||
|
||||
- **Values.** A picture is an `ImageRef` (`Arc<ImageSource>`: a file of the
|
||||
engine's cache with its stamp, decoded RGBA pixels, SVG or memory bytes,
|
||||
or none; `size()` reads a file's header). A colour is an `Rgb(u32)`, a
|
||||
shared string an `Arc<str>`, a list a `Vec`. The bridge structs (51 in
|
||||
`bridge.rs`, 10 in `studio_bridge.rs`) are plain `Clone + PartialEq + Debug`
|
||||
structs with the field names of the Slint structs in `bridge.slint` and
|
||||
`studio-bridge.slint`; `MytsBadge` and `MytsForm`, which have no data source
|
||||
in this build, stay Slint-only.
|
||||
- **Lists.** `list::diff(old, new)` gives `Changes`: updates, removals and
|
||||
insertions by index, in the order to apply them. `bind/rows.rs` applies
|
||||
them to a `VecModel` and converts only the changed rows; a GPUI view
|
||||
re-renders from the list and needs no `Changes`.
|
||||
- **Conversion.** The Slint crate owns the temporary `From` impls from the
|
||||
plain structs to the Slint ones (`bind/convert/items.rs`), the colour,
|
||||
picture and model helpers (`bind/convert.rs`) and the decoded-picture cache
|
||||
(`images.rs`).
|
||||
- **State.** `AppState<L>` (the servers, their sessions, the settings the
|
||||
screens show, the dialogs' targets), `SessionView<L>` and `Tab<L>` live in
|
||||
`voelin_ui_vm::state`, generic over the list type `L` of a chat tab's
|
||||
lines: the Slint app plugs in `Rows<ChatLine>` (`app::ChatRows`), a front
|
||||
end that re-renders can use a `Vec`. `App.state` is the one `AppState`.
|
||||
- **Logic and bind.** An area that interleaves decisions with Bridge writes
|
||||
is split into `<area>/logic.rs` in `voelin-ui-vm` (functions over the
|
||||
settings service, the `AppState` and plain rows; they return rows,
|
||||
commands or messages for the status line, and write no Bridge) and
|
||||
`<area>/bind.rs` in `voelin-ui` (the Bridge and model writes, windows,
|
||||
timers, threads, engine commands). Done: `settings_pages` and `studio`.
|
||||
|
||||
The pure code is tested in `voelin-ui-vm` (`cargo test -p voelin-ui-vm`,
|
||||
no display); the Slint crate's tests are what needs the window types.
|
||||
|
||||
### Controllers still to split
|
||||
|
||||
Counted as `.set_` calls per file (`grep -c '\.set_'`, the status line's
|
||||
`set_status` included) before this round's splits; Bridge writes alone are
|
||||
about four fifths of each. Each one is a slice of the same shape as
|
||||
`settings_pages` and `studio`: move the decisions into
|
||||
`voelin-ui-vm/src/<area>/logic.rs`, keep the writes in
|
||||
`voelin-ui/src/<area>/bind.rs`.
|
||||
|
||||
| File | `.set_` calls | What it mixes |
|
||||
|---|---|---|
|
||||
| `streams.rs` | 45 | the streams panel, viewer and share dialog: what the voice card, the viewer header and the share form say, with the watch and share bookkeeping |
|
||||
| `chat.rs` | 38 | the chat view: lines, the unread divider, pins, topics and downloads, with the engine's history batches |
|
||||
| `app.rs` | 38 | event dispatch and the status line, the toolbar and tree refreshes |
|
||||
| `servers.rs` | 37 | the rail, the server dialog and the channel tree's refresh |
|
||||
| `settings_page.rs` | 26 | the audio settings page and the devices |
|
||||
| `social.rs` | 23 | home's contacts, the bell and the search |
|
||||
| `dev.rs` | 23 | development switches and the sample data (the switches stay with the window; the sample rows can move) |
|
||||
| `images.rs` | 13 | the decoded-picture cache |
|
||||
| `messages.rs` | 12 | direct messages |
|
||||
| `appearance.rs` | 11 | theme, font scale and breakpoints |
|
||||
| `popout.rs` | 8 | the viewer's own window |
|
||||
| `members.rs`, `links.rs`, `inbox.rs`, `home.rs`, `events.rs` | 6, 5, 5, 5, 4 | small; split with their neighbours |
|
||||
|
||||
Before this round: `studio.rs` had 62 and `settings_pages.rs` 52 (the two
|
||||
with the most). Their `bind.rs` files still show 58 and 51 `.set_` calls: the
|
||||
Bridge and model writes stay where the toolkit is, and what each write says
|
||||
now comes from `logic.rs`, which has tests of its own.
|
||||
|
||||
## Theme tokens
|
||||
|
||||
@@ -275,7 +362,7 @@ The studio (mockups 09, 10 and the phone's 04) is a page of the main window
|
||||
window, "Stream Studio" for the studio; while a share runs the button opens
|
||||
its dialog), a window of its own (the button in its
|
||||
header; closing that window brings it back) and a phone page. Its controller
|
||||
is `src/studio.rs` on the engine's studio ([studio.md](studio.md)): the
|
||||
is `src/studio/` on the engine's studio ([studio.md](studio.md)), its decisions in `voelin-ui-vm`'s `studio/logic.rs`: the
|
||||
studio runs while it is shown, live or recording, and a `Streamer` started
|
||||
for it encodes the composite from the start, so Record Clip and recordings
|
||||
work before going live.
|
||||
@@ -400,7 +487,7 @@ without joining; there is no Observe button. Without a gateway, observing
|
||||
starts once one is found.
|
||||
|
||||
Settings → Profiles (`ProfilesSection` in `screens/settings-pages.slint`;
|
||||
`settings_pages.rs`, and `identities.rs` for the default and the import
|
||||
`settings_pages/`, and `identities.rs` for the default and the import
|
||||
switch) lists the stored identities with where they came from, marks the
|
||||
store's default and has "Use as default" for the others, plus the switch
|
||||
for importing the official clients' identities on start
|
||||
@@ -420,10 +507,14 @@ for importing the official clients' identities on start
|
||||
`ui/app.slint` put its sidebar and main parts into `DesktopShell` under
|
||||
`if Nav.page == Page.<name>:` (and a case in `MobileShell`). Dialogs go at
|
||||
the end of `MainWindow` with an `*-open` flag in `Nav`.
|
||||
4. Rust: a pure view model in `src/vm/<name>.rs` (with tests) that turns
|
||||
engine state into the structs; a model in `app::Models` set on the Bridge
|
||||
once and updated with `vm::list::sync`; callbacks in `src/bind/<name>.rs`
|
||||
(call it from `bind::wire`); the logic as `impl App` in `src/<name>.rs`.
|
||||
4. Rust: a pure view model in `voelin-ui-vm/src/<name>.rs` (with tests) that
|
||||
turns engine state into the plain bridge structs (`bridge.rs`, with a
|
||||
`From` impl for the Slint struct in `bind/convert/items.rs`); a model in
|
||||
`app::Models` set on the Bridge once and updated with `Rows::sync`;
|
||||
callbacks in `voelin-ui/src/bind/<name>.rs` (call it from `bind::wire`);
|
||||
the Slint side as `impl App` in `voelin-ui/src/<name>.rs`, with the
|
||||
decisions in the view-model crate (`<name>/logic.rs`, [Two
|
||||
crates](#two-crates)).
|
||||
5. A development switch to open it (`dev.rs`, `VOELIN_OPEN=<name>`), a
|
||||
screenshot (below) and a line in this file.
|
||||
|
||||
@@ -453,8 +544,8 @@ In a config file write them as dotted keys at the top level
|
||||
|
||||
The software renderer has no colour glyphs, so emoji are images. The 3720
|
||||
Twemoji SVGs are packed by `scripts/pack-twemoji.py` into
|
||||
`assets/twemoji.bin` (64 KiB blocks of raw deflate, an index sorted by key,
|
||||
picker names and categories; 1.9 MB) and embedded in the binary. `emoji.rs`
|
||||
`crates/voelin-ui-vm/assets/twemoji.bin` (64 KiB blocks of raw deflate, an index sorted by key,
|
||||
picker names and categories; 1.9 MB) and embedded in the binary. `voelin-ui-vm`'s `emoji.rs`
|
||||
splits chat text into grapheme clusters, maps emoji to Twemoji keys (code
|
||||
points in hex; U+FE0F dropped outside ZWJ sequences, as Twemoji names its
|
||||
files; text-default symbols such as © or digits only with U+FE0F) and makes
|
||||
@@ -471,7 +562,7 @@ code-point ranges) and searches Unicode names. There are no shortcodes yet.
|
||||
|
||||
## Formatting
|
||||
|
||||
TeamSpeak clients format chat with BBCode. `vm/bbcode.rs` reads a message
|
||||
TeamSpeak clients format chat with BBCode. `voelin-ui-vm/src/bbcode.rs` reads a message
|
||||
into a `Doc`: blocks (lines, quote lines, code, list items, rules) of spans
|
||||
with a style (bold, italic, underline, strike, code, colour, link) or a
|
||||
picture. The Doc does not depend on BBCode, so Markdown (TeamSpeak 6) can be
|
||||
|
||||
Reference in new issue
Block a user