Document the two UI crates, the adapter boundary and the controllers still to split

docs/ui.md: the structure of voelin-ui-vm and voelin-ui, a "Two crates"
section (values, lists, conversion, state, logic/bind) and the written list
of the controllers that still interleave logic with Bridge writes, with
their .set_ counts, for the next round; the pointers to the moved files
(Twemoji archive, BBCode reader, settings pages, studio) are corrected.
docs/architecture.md: the crate table has voelin-ui-vm. README.md and
CHANGELOG.md name the new crate. Module comments that pointed at studio.rs
and vm/ point at studio/ and the crate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-20 16:06:29 +03:00
1 parent ce0e6e1f62
commit 767a9dad46
7 files changed
+135 -33

No files matched your search

+7
View File
@@ -69,6 +69,13 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows
### Changed
- The view models, the app's state and the decisions of the settings pages and
of the Stream Studio moved out of `voelin-ui` into a new crate,
`voelin-ui-vm`, which depends on no UI toolkit (a second front end can use
it); `voelin-ui` converts its plain rows into Slint's and keeps the window,
the Bridge writes and the engine's tasks. The chat formatting reader and the
Twemoji archive moved with them. Nothing changes on screen. See
docs/ui.md, "Two crates".
- The identity store keeps identities of more than one kind (TeamSpeak, a Voelin
key, the signed-in account) with the account each belongs to, as a
`voelin-identity` key store, in two database migrations. Existing
+3
View File
@@ -45,6 +45,9 @@ Done so far (milestones M0–M4 and the first part of M5 of [the plan](docs/arch
(in the window and as a global hotkey), audio settings with a level meter, per-client volume, and on
TeamSpeak 6 streams: watch in a viewer, share the screen with sound. Desktop and phone layouts
from one design system, dark and light themes, text size, emoji ([docs/ui.md](docs/ui.md))
- `crates/voelin-ui-vm`: the view models and the app's state behind the UI, with no UI toolkit: engine state
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-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
+6 -4
View File
@@ -3,8 +3,10 @@
//!
//! The screens' logic is elsewhere: servers and the channel tree in
//! `servers.rs`, chat in `chat.rs`, streams in `streams.rs`, the settings
//! page in `settings_page.rs` and `appearance.rs`, the view models in `vm/`,
//! callbacks in `bind/`, development switches in `dev.rs`.
//! page in `settings_page.rs` and `appearance.rs`, the settings pages in
//! `settings_pages/`, the Stream Studio in `studio/`, the view models in the
//! `voelin-ui-vm` crate (`vm`), callbacks in `bind/`, development switches in
//! `dev.rs`.
use std::cell::RefCell;
use std::path::{Path, PathBuf};
@@ -241,7 +243,7 @@ pub(crate) struct App {
pub social: crate::social::Social,
/// The settings pages of the new design.
pub pages: crate::settings_pages::Pages,
/// The Stream Studio (studio.rs).
/// The Stream Studio (studio/).
pub studio: crate::studio::StudioState,
/// The stream's own window (popout.rs).
pub popout: crate::popout::Popout,
@@ -872,7 +874,7 @@ impl App {
Event::SettingRejected { key, message } => {
self.set_status(format!("Setting {key}: {message}"));
}
// The Stream Studio's stream (studio.rs).
// The Stream Studio's stream (studio/).
Event::StreamState { session, state } if self.studio_streams_to(session as i64) => {
self.studio_stream_state(state);
}
+1 -1
View File
@@ -305,7 +305,7 @@ impl App {
/// The lines of a tab's messages (`main`) or of its open topic, grouped
/// and with everything the row shows (also the stream chat of the
/// Stream Studio, studio.rs). The server chat starts with what the
/// Stream Studio, studio/). The server chat starts with what the
/// server says to everyone who connects ([`Self::server_lines`]).
pub(crate) fn lines_of(&self, view: &SessionView, tab: &Tab, main: bool) -> Vec<ChatLine> {
let messages = if main { &tab.messages } else { &tab.topic_messages };
+2 -2
View File
@@ -543,7 +543,7 @@ impl App {
if self.share.is_some() {
self.refresh_streams();
}
// The share dialog's audio mixer (studio.rs).
// The share dialog's audio mixer (studio/).
self.mixer_tick();
if self.watch.is_some() {
self.refresh_viewer();
@@ -755,7 +755,7 @@ impl App {
}
}
/// The running share's streamer (the mixer's rows, studio.rs).
/// The running share's streamer (the mixer's rows, studio/).
pub(crate) fn share_streamer(&self) -> Option<&Streamer> {
self.share.as_ref().map(|s| s.capture.streamer())
}
+2 -1
View File
@@ -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 |
+114 -25
View File
@@ -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)).
![Server page](screenshots/desktop-server.png)
## 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,96 @@ 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 49 bridge structs
(`bridge.rs`, `studio_bridge.rs`) are plain `Clone + PartialEq + Debug`
structs with the field names of the Slint structs in `bridge.slint`.
- **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 +360,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 +485,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 +505,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 +542,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 +560,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