crates/voelin-gpui/src/app.rs holds the root entity: the toolkit-free voelin_ui_vm state (`AppState<Vec<ChatLine>>`) and `Social`, with `events::handle` as the one dispatch of an engine event (the entry point both front ends use; its Update's engine commands are sent, its warnings logged, the rest belongs to the slices that draw it). Three loops, spawned by `AppState::new` and ended when the entity is released: - the engine's events: a foreground task awaits the tokio receiver of the hosted engine (no reactor needed, as the plan says), `this.update` and `cx.notify()`: spike 3's hotkey task; - the tick: a loop of `background_executor().timer(1 s)`; - `Later`, for other threads: GPUI's `AsyncApp` holds an Rc-based weak handle and is not Send (read in gpui-pre's async_context.rs), so a thread that wants to touch the entity holds a Send handle that queues a boxed closure; a third foreground task, which owns the cloned AsyncApp, runs it with the entity. This is the Slint front end's `later(|app| ...)`. engine.rs repeats the ~25 lines of voelin-ui's `HostedEngine::start` (the engine on a tokio runtime, its events forwarded into an unbounded channel): that type lives in the Slint crate (crates/voelin-ui/src/app.rs), which this crate cannot depend on and this task does not touch. dev.rs reads VOELIN_WINDOW_SIZE. lib.rs `run()` logs through tracing (`VOELIN_LOG`, else `RUST_LOG`, else a filter that shows GPUI's adapter line), starts the engine's runtime, opens the window on the entity and, on close, tells the engine to close the sessions and ends the app. view.rs shows the one line of state the task asked for: version, voice connections up, engine events handled, seconds up; each part moves by one of the loops. Seven tests, none needing a display (GPUI's test platform): an injected engine event (a voice state) reaches the entity and its status line, the entity notifies its observers, the tick runs once per advanced second, a job from another thread runs on the entity, and a real engine (HostedEngine on a tokio runtime) delivers a real event (a setting changed by a command) to the entity through the same task; the window-size switch parses and refuses nonsense. The real-engine test calls `allow_parking`, as GPUI's test scheduler calls a wake from a tokio thread a non-deterministic test otherwise. The tests use `gpui-pre` (renamed `gpui`) with its `test-support` as a dev-dependency, pinned `=0.3.10` beside gpui-kit's own pin: gpui-kit's `test-support` feature names the optional `gpui-fast` backend in weak features, which makes cargo lock gpui-fast and its tree and pins taffy to 0.15.0 for every build (reproduced in a scratch project: 793 packages without the feature, 820 with it). The lock gains only gpui-pre's own test-support crates (proptest and its few, futures-concurrency, postage); THIRD_PARTY_NOTICES.md does not move (dev-dependencies are out of it) and cargo deny passes. Run on Xvfb :97 (headless.sh) with the debug binary: the window opens in 0.1 s, shows "Voelin 0.0.1-alpha · 0 connections · 1 engine event · 2 s up" and, four seconds later, "... · 6 s up" (the one engine event is the real engine's own at start); Alt+F4 ends the app with exit code 0 in 132 ms. Checked on Rust 1.95.0: fmt and clippy -D warnings (all targets, --no-deps), `cargo test -p voelin-gpui` (3 runs, 7 tests each), cargo deny. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
50 lines
2.0 KiB
TOML
50 lines
2.0 KiB
TOML
[package]
|
|
name = "voelin-gpui"
|
|
version = "0.0.1-alpha"
|
|
description = "The GPUI front end of the desktop app, under construction: it runs on the same engine as the Slint front end (voelin-ui) until it reaches parity."
|
|
edition.workspace = true
|
|
rust-version.workspace = true
|
|
license.workspace = true
|
|
repository.workspace = true
|
|
publish.workspace = true
|
|
|
|
[lib]
|
|
name = "voelin_gpui"
|
|
path = "src/lib.rs"
|
|
|
|
[[bin]]
|
|
name = "voelin-gpui"
|
|
path = "src/main.rs"
|
|
|
|
[dependencies]
|
|
anyhow = "1.0.104"
|
|
# GPUI, gpui-component and gpui-kit-assets behind one pinned dependency.
|
|
gpui-kit = { workspace = true }
|
|
# The engine's runtime and the channel of its events (a tokio receiver needs no
|
|
# reactor, so GPUI's executor can await it).
|
|
tokio = { version = "1.53.1", features = ["rt-multi-thread", "sync", "time"] }
|
|
tracing = "0.1.44"
|
|
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
|
|
# The engine, with the desktop's capture and codecs: ashpd on async-io (the
|
|
# commit that moved voelin-media and voelin-platform to it) lets this binary
|
|
# hold both the portals and gpui-kit.
|
|
voelin-core = { path = "../voelin-core", default-features = false, features = ["audio-device", "media-desktop"] }
|
|
# The app's name and id, the hotkeys and portals of the slices to come.
|
|
voelin-platform = { path = "../voelin-platform" }
|
|
# The Host trait's types (what the store knows of a chat's read marker).
|
|
voelin-store = { path = "../voelin-store" }
|
|
# The view models and the state, shared with the Slint front end.
|
|
voelin-ui-vm = { path = "../voelin-ui-vm" }
|
|
|
|
[dev-dependencies]
|
|
# GPUI's test platform (`#[gpui::test]`, `TestAppContext`): the front end's tests
|
|
# need no display. gpui-kit's own `test-support` feature is not used: it names
|
|
# the optional `gpui-fast` backend in weak features, which puts gpui-fast and
|
|
# its tree into Cargo.lock and pins taffy to 0.15.0 for every build. gpui-kit
|
|
# pins `gpui-pre` exactly, so this line moves with its `=` pin (a mismatch does
|
|
# not resolve).
|
|
gpui = { package = "gpui-pre", version = "=0.3.10", features = ["test-support"] }
|
|
|
|
[lints]
|
|
workspace = true
|