Split the streams controller: the state, the events and the rows into voelin-ui-vm

What we share and what we watch are in the AppState now (Sharing, Watching),
with the transitions of the engine's stream events (apply handles them, the
Stream Studio's stream excepted), the user's choices (watch, leave, volume,
quality, the share dialog's plan, the capture that started) and the rows and
texts of the streams panel, the share card and the viewer, as plain data in
streams/logic.rs with tests of their own. The Slint side (streams/bind.rs)
writes the Bridge, owns the capture and the decoder, and attaches or drops
them as an update says (StreamEffects).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-21 06:48:18 +03:00
1 parent 03d1c3bd07
commit 0d2ad3f250
17 files changed
+2125 -1143

No files matched your search

+23 -17
View File
@@ -27,9 +27,12 @@ crates/voelin-ui-vm/ view models and state, no UI toolkit
events/ events::apply: what an engine event does to the AppState
(mod.rs; gateway.rs: the gateway's events and directory)
previews.rs pictures linked in chat: which to fetch, the transfers
servers.rs tree.rs chat/mod.rs social.rs home.rs streams.rs avatar.rs studio/mod.rs
servers.rs tree.rs chat/mod.rs social.rs home.rs streams/mod.rs avatar.rs studio/mod.rs
pure view models (engine state → bridge structs), unit-tested
chat/logic.rs chat tabs, messages and what is read, pins and topics, files
streams/logic.rs the streams we share and watch: their state, the events and the
user's choices, the streams panel's, the share card's and the
viewer's rows and texts
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
@@ -63,12 +66,14 @@ crates/voelin-ui/ the Slint front end
a `voelin_ui_vm::state::AppState` and the window
host.rs SlintHost (the answers the transitions ask for), `App::apply_event`,
`transition` and `perform`: doing what an `Update` says
servers.rs chat.rs members.rs streams.rs settings_page.rs appearance.rs
servers.rs chat.rs members.rs settings_page.rs appearance.rs
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
streams/ mod.rs (Share: the capture), bind.rs: the streams panel, the share
dialog and the viewer on the Bridge, the capture and the decoder
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
@@ -128,22 +133,22 @@ this file is `voelin_ui_vm::chat`. The boundary:
update out in `host.rs`) and `social_refresh`; a GPUI client calls `apply`
and draws what `Update::refresh` names. The vm tests replay tapes of events
against a fake `Host` (`events/tests.rs`). `Update::rest` hands back the
events whose state is not in the `AppState` yet: the stream we share and
watch and the studio's (`StreamState`, `StreamViewerRequest`,
`StreamViewers`, `WatchState`, `WatchLayers`, `StreamKeyframeRequest`,
`StreamLayerBitrate`), `SettingChanged`, and the rest that no screen looks
at. The friends, pokes, offline messages and notices that `social.rs` keeps
events whose state is not in the `AppState`: the Stream Studio's stream
(`StreamState` and `StreamViewers` while `Host::studio_streams_to`),
`SettingChanged`, and the rest that no screen looks at. The streams we
share and watch are in the `AppState` (`share`, `watch`; the capture and
the decoder are the front end's, and an update says when to attach or drop
them). The friends, pokes, offline messages and notices that `social.rs` keeps
(`Poke`, `FriendPresence`, `OfflineMessages`, `OfflineMessage`,
`RequestDone`, and the notices of `Chat`, `ChatHistory`, `Presence`,
`State`, `ServerInfo`, `ContactsChanged`, `AvatarReady`) are looked at by
`social.rs` before and after `apply`. They move with `streams.rs` and
`social.rs`.
`social.rs` before and after `apply`. They move with `social.rs`.
- **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`.
timers, threads, engine commands). Done: `settings_pages`, `studio` and `streams`.
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.
@@ -164,7 +169,6 @@ the same shape as `settings_pages` and `studio`: move the decisions into
| 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` | 33 | the chat view: lines, the unread divider, pins, topics and downloads (the engine's history batches, the reads and the gateway's pins and topics are in `chat/logic.rs`) |
| `app.rs` | 31 | setup, the status line, the toolbar and tree refreshes (the event dispatch is `vm::events::apply`) |
| `servers.rs` | 32 | the rail, the server dialog and the channel tree's refresh (the server's name, icon and gateway, joining again and the password are in `events`) |
@@ -180,17 +184,19 @@ the same shape as `settings_pages` and `studio`: move the decisions into
Before the work on `voelin-ui-vm` began, `studio.rs` had 64 `.set_` calls
and `settings_pages.rs` 52 (the two with the most, then `streams.rs` with 45;
62 was `studio.rs` once the view models had moved, two setters having
gone with them). Their `bind.rs` files still show 58 and 51: 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.
gone with them). Their `bind.rs` files still show 58 and 51 (and
`streams/bind.rs`, split from the 45 of `streams.rs`, 38): 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.
Why the studio went before `streams.rs`: it had the most calls, and it is
self-contained. It has its own state (`StudioState`), windows and bridge
(`studio-bridge.slint`), so its decisions moved without touching the event
dispatch of `app.rs`. `streams.rs`, `chat.rs` and the rest of the list are
driven by that dispatch (the watch, share and history events of `events.rs`
and `app.rs`), so they follow it: the state transition of every engine event
comes first, then the controllers that show the result.
driven by that dispatch (the watch, share and history events), so they
followed it: the state transition of every engine event came first
(`events::apply`), then the controllers that show the result, `streams` first
as the one whose events were still the front end's.
## Theme tokens