Merge phase5/gpui-foundation: the foundation of the GPUI front end (Rust 1.95, ashpd on async-io with zbus on one executor, crates/voelin-gpui on gpui-kit 0.8.1, the root entity and the engine's event loop, VoelinTheme with Inter and Lucide, the meter)
CI / Linux checks (push) Successful in 1h10m33s
CI / Linux checks (push) Successful in 1h10m33s
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
commit
ba224e1dff
52 files changed
+11062
-400
No files matched your search
@@ -16,7 +16,8 @@ runs:
|
||||
- name: apt packages
|
||||
if: runner.os == 'Linux'
|
||||
shell: bash
|
||||
# ALSA (audio devices), fontconfig + xkbcommon (UI), libvpx + dav1d
|
||||
# ALSA (audio devices), fontconfig + xkbcommon (UI), xkbcommon-x11 + xcb (linked
|
||||
# by the GPUI front end), libvpx + dav1d
|
||||
# (video codecs), PipeWire + SPA (screen and audio capture), libclang
|
||||
# (bindgen), Xvfb (X11 tests).
|
||||
run: |
|
||||
@@ -27,7 +28,7 @@ runs:
|
||||
"${sudo[@]}" apt-get update
|
||||
"${sudo[@]}" apt-get install -y --no-install-recommends \
|
||||
build-essential ca-certificates cmake curl git jq pkg-config python3 \
|
||||
libasound2-dev libfontconfig1-dev libxkbcommon-dev \
|
||||
libasound2-dev libfontconfig1-dev libxkbcommon-dev libxkbcommon-x11-dev libxcb1-dev \
|
||||
libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev \
|
||||
xvfb xauth
|
||||
|
||||
|
||||
@@ -8,6 +8,24 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows
|
||||
|
||||
### Added
|
||||
|
||||
- `voelin-gpui`, the GPUI front end of the desktop app, in its first form: a
|
||||
window titled Voelin with one line of the app's state in it (the version,
|
||||
the voice connections that are up, the engine events handled, the seconds
|
||||
up), fed by the same engine and the same view models as the Slint app
|
||||
(`cargo run -p voelin-gpui --release`), in the Voelin theme: every colour,
|
||||
radius, size and type token of the Slint app's `theme.slint`, light and dark
|
||||
(a test reads the Slint file and fails when the two differ), written into
|
||||
the widget library's theme too, in Inter, with the Slint app's Lucide icons.
|
||||
`system` mode follows the window's appearance. `VOELIN_OPEN=swatch` shows
|
||||
every token, a few widgets and the icons (`VOELIN_DEV_THEME`,
|
||||
`VOELIN_FONT_SCALE`, `VOELIN_WINDOW_SIZE`; screenshots with
|
||||
`scripts/gpui-shot.sh`, docs/ui/). `VOELIN_METER=1` logs what it costs once a
|
||||
second: the CPU by group of threads, the memory and its own counters. A
|
||||
window that cannot open (no driver, no display server) ends the app with
|
||||
the reason and exit status 1. The Slint app (`voelin`) is unchanged and
|
||||
stays the app; both run on one engine until the GPUI one reaches parity
|
||||
(docs/ui.md). It needs Vulkan or OpenGL at run time (Mesa's lavapipe renders
|
||||
in software); no package ships it yet.
|
||||
- Log files: each run logs to `<state>/voelin/logs/voelin.log`, the previous
|
||||
four runs are kept; `VOELIN_LOG` sets what is logged. Settings → Advanced
|
||||
opens the folder.
|
||||
@@ -69,6 +87,18 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows
|
||||
|
||||
### Changed
|
||||
|
||||
- The desktop portals (screen capture and camera through PipeWire, the push to
|
||||
talk shortcut, the file chooser and the proxy settings) talk to D-Bus through
|
||||
ashpd on `async-io` instead of `tokio`. Nothing changes on screen; the GPUI
|
||||
front end, which is being built, enables ashpd's `async-io` and ashpd cannot
|
||||
have both. Every D-Bus connection of the apps, the desktop notifications'
|
||||
included, now runs on an I/O thread of its own, whichever part of the app
|
||||
asks first.
|
||||
- The build needs Rust 1.95 (`rust-toolchain.toml` and the workspace's
|
||||
`rust-version`; 1.95.0 was used to check it), up from 1.94: the GPUI
|
||||
front end, which is being built, depends on a library that calls a function
|
||||
stable since 1.95. Nothing changes in the apps; the gateway's Docker image
|
||||
builds from `rust:1.95-bookworm`.
|
||||
- The key store now keeps the device key when signing out of an account,
|
||||
unbound, whether it was in use before the account or was made for it; "Forget
|
||||
this device's identity" is the only way a key is deleted. The identity store
|
||||
|
||||
@@ -8,6 +8,12 @@ org `Voelin`; the current plan lives in the approved plan file referenced in
|
||||
`cargo fmt` (hard tabs, `rustfmt.toml`) and `cargo clippy -D warnings` on the
|
||||
project's own crates (`scripts/own-crates.sh`) green.
|
||||
|
||||
Two front ends run on one engine until the second reaches parity:
|
||||
`crates/voelin-ui` (Slint, the `voelin` binary, the app today) and
|
||||
`crates/voelin-gpui` (GPUI on an exactly pinned `gpui-kit`, the `voelin-gpui`
|
||||
binary, under construction); `crates/voelin-ui-vm` holds what they share, the
|
||||
view models and the state, with no UI toolkit (`docs/ui.md`).
|
||||
|
||||
## Hosting: Gitea, not GitHub
|
||||
|
||||
- The source of truth is **https://git.faumaray.com** (Gitea). Pull requests,
|
||||
|
||||
Generated
+3668
-131
File diff suppressed because it is too large.
Load diff
+8
-1
@@ -15,6 +15,7 @@ members = [
|
||||
"crates/voelin-core",
|
||||
"crates/voelin-gateway",
|
||||
"crates/voelin-gateway-proto",
|
||||
"crates/voelin-gpui",
|
||||
"crates/voelin-media",
|
||||
"crates/voelin-observer",
|
||||
"crates/voelin-platform",
|
||||
@@ -36,6 +37,7 @@ default-members = [
|
||||
"crates/voelin-core",
|
||||
"crates/voelin-gateway",
|
||||
"crates/voelin-gateway-proto",
|
||||
"crates/voelin-gpui",
|
||||
"crates/voelin-observer",
|
||||
"crates/voelin-platform",
|
||||
"crates/voelin-query",
|
||||
@@ -48,7 +50,7 @@ default-members = [
|
||||
|
||||
[workspace.package]
|
||||
edition = "2024"
|
||||
rust-version = "1.94"
|
||||
rust-version = "1.95"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/Faumaray/Voelin"
|
||||
publish = false
|
||||
@@ -66,6 +68,11 @@ voelin-identity = { git = "ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.gi
|
||||
voelin-proto = { git = "ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git", rev = "c5bb6b914bdab86eb36f6e32a1a5bc9ac4785562" }
|
||||
# The UI-facing domain model and the client's replica of v1 entities.
|
||||
voelin-model = { git = "ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git", rev = "c5bb6b914bdab86eb36f6e32a1a5bc9ac4785562" }
|
||||
# GPUI, gpui-component and their assets for the GPUI front end (voelin-gpui). Pre-1.0:
|
||||
# pinned exactly (it pins its `gpui-pre` snapshot exactly too), upgraded in commits of
|
||||
# their own after rebuilding spikes/gpui on the new release (docs/design/gpui-spikes.md,
|
||||
# "The version to pin").
|
||||
gpui-kit = "=0.8.1"
|
||||
|
||||
[workspace.lints.rust]
|
||||
# deny, not forbid: generated code (Slint) needs a local allow.
|
||||
|
||||
@@ -48,6 +48,11 @@ Done so far (milestones M0–M4 and the first part of M5 of [the plan](docs/arch
|
||||
- `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-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 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
|
||||
@@ -79,6 +84,8 @@ The UI (design system, desktop and phone layouts, emoji, how to add a screen) is
|
||||
```sh
|
||||
# Desktop app
|
||||
cargo run -p voelin-ui --bin voelin
|
||||
# The GPUI front end, under construction (Vulkan or OpenGL at run time)
|
||||
cargo run -p voelin-gpui --release
|
||||
|
||||
# Local servers (use REGISTRY=mirror.gcr.io if Docker Hub rate-limits you)
|
||||
docker compose -f dev/docker-compose.yml up -d
|
||||
|
||||
+3253
-44
File diff suppressed because it is too large.
Load diff
@@ -11,6 +11,13 @@ archive in crates/voelin-ui-vm):
|
||||
- Lucide icons (lucide-static 1.48.0), Copyright (c) Lucide Icons and
|
||||
Contributors, under the ISC License; the icons derived from Feather are
|
||||
Copyright (c) 2013-present Cole Bemis, under the MIT License (texts below).
|
||||
- Lucide icons 1.43.0 (the 1,818 icons of the catalogue of gpui-kit-assets
|
||||
0.8.1, embedded in the GPUI front end, crates/voelin-gpui, behind the
|
||||
client's own set above), Copyright (c) Lucide Icons and Contributors, under
|
||||
the ISC License; the icons derived from Feather are Copyright (c) 2013-present
|
||||
Cole Bemis, under the MIT License (the same texts, below). The catalogue's
|
||||
12 other icons are the crate's own, under its Apache-2.0 licence (listed with
|
||||
the crates).
|
||||
- Twemoji 15.0 (the emoji images): Twemoji graphics by Twitter, Inc and other
|
||||
contributors, licensed under CC-BY 4.0
|
||||
(https://creativecommons.org/licenses/by/4.0/). The SVG files are packed
|
||||
|
||||
@@ -23,6 +23,10 @@ accepted = [
|
||||
"LicenseRef-Slint-Royalty-free-2.0",
|
||||
# libbz2-rs-sys (unpacks Cisco's OpenH264 download in voelin-media).
|
||||
"bzip2-1.0.6",
|
||||
# The GPUI front end: 0BSD (enum-iterator, enum-iterator-derive) and CC0-1.0
|
||||
# (notify 8, tiny-keccak); see deny.toml.
|
||||
"0BSD",
|
||||
"CC0-1.0",
|
||||
]
|
||||
|
||||
# What the apps ship on: the desktop app on Linux (x86_64, and aarch64 for
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# -e TSGW_QUERY_PASSWORD=… -p 7788:7788 tsgw
|
||||
# Logs: docker logs -f tsgw (more: -e TSGW_LOG_LEVEL=debug; also to a file in
|
||||
# the volume: -e TSGW_LOG_FILE=logs/tsgw.log). See docs/gateway-admin.md.
|
||||
FROM rust:1.94-bookworm AS build
|
||||
FROM rust:1.95-bookworm AS build
|
||||
WORKDIR /src
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cmake git libasound2-dev openssh-client && rm -rf /var/lib/apt/lists/*
|
||||
# voelin-identity comes from the private VoelinProtocol repository, fetched
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
[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" }
|
||||
|
||||
# The meter reads /proc/self (CPU ticks per second, the page size).
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
rustix = { version = "1.1.5", features = ["param"] }
|
||||
|
||||
[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
|
||||
@@ -0,0 +1,34 @@
|
||||
//! Embeds the client's Lucide icons: `crates/voelin-ui/ui/assets/icons/*.svg`
|
||||
//! (Lucide 1.48, the set the Slint front end draws) become a sorted table of
|
||||
//! `include_bytes!` in `$OUT_DIR/icons.rs`, which `assets.rs` serves as
|
||||
//! gpui-component's `icons/<name>.svg` paths before gpui-kit-assets' own
|
||||
//! (Lucide 1.43) catalogue. No dependency: the directory is read and the
|
||||
//! table written with `std`.
|
||||
|
||||
use std::fmt::Write as _;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
let manifest =
|
||||
PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR"));
|
||||
let dir = manifest.join("../voelin-ui/ui/assets/icons");
|
||||
println!("cargo:rerun-if-changed={}", dir.display());
|
||||
let mut names: Vec<String> = std::fs::read_dir(&dir)
|
||||
.unwrap_or_else(|e| panic!("the client's icons are at {}: {e}", dir.display()))
|
||||
.filter_map(|entry| entry.ok()?.file_name().into_string().ok())
|
||||
.filter(|name| name.ends_with(".svg"))
|
||||
.collect();
|
||||
names.sort();
|
||||
assert!(!names.is_empty(), "no icons in {}", dir.display());
|
||||
let mut table = String::from(
|
||||
"/// The client's icons by file name, sorted.\npub static ICONS: &[(&str, &[u8])] = &[\n",
|
||||
);
|
||||
for name in &names {
|
||||
let path = dir.join(name);
|
||||
let path = path.canonicalize().unwrap_or(path);
|
||||
let _ = writeln!(table, "\t({name:?}, include_bytes!({:?})),", path.display().to_string());
|
||||
}
|
||||
table.push_str("];\n");
|
||||
let out = PathBuf::from(std::env::var_os("OUT_DIR").expect("OUT_DIR")).join("icons.rs");
|
||||
std::fs::write(out, table).expect("write icons.rs");
|
||||
}
|
||||
@@ -0,0 +1,453 @@
|
||||
//! The root state of the window, `Entity<AppState>`: everything the client
|
||||
//! knows (the toolkit-free [`voelin_ui_vm`] state and the friends and pokes
|
||||
//! beside it) and the three loops that keep it current on GPUI's thread:
|
||||
//!
|
||||
//! - the **engine's events**: a foreground task awaits the receiver of
|
||||
//! [`crate::engine::HostedEngine`] (a tokio channel needs no reactor, so
|
||||
//! GPUI's executor can poll it), hands every event to
|
||||
//! [`events::handle`] and tells the entity to redraw (`cx.notify()`), the
|
||||
//! pattern of spike 3's hotkey task;
|
||||
//! - the **tick**, once a second, a loop of `background_executor().timer`
|
||||
//! (the Slint front end's `slint::Timer` calling `App::tick`);
|
||||
//! - **later**: other threads (a hotkey, a camera, a decoder) cannot touch the
|
||||
//! entity, and GPUI's `AsyncApp` is not `Send`, so they hold a [`Later`], a
|
||||
//! channel of jobs a third foreground task runs on GPUI's thread, as
|
||||
//! `later(|app| ...)` does in the Slint front end.
|
||||
//!
|
||||
//! What a transition asks for besides the state (`Update`: which parts to
|
||||
//! draw again, what to keep, the streams' capture and decoder) belongs to
|
||||
//! the slices that have those parts; today only the engine commands go out
|
||||
//! and the warnings are logged.
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use gpui_kit::Context;
|
||||
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
|
||||
use voelin_core::{AudioSettings, Command, Engine, Event, VoiceState};
|
||||
use voelin_store::{ChatRead, ChatTarget as StoredTarget};
|
||||
use voelin_ui_vm::bridge::ChatLine;
|
||||
use voelin_ui_vm::events;
|
||||
use voelin_ui_vm::host::{Host, Update};
|
||||
use voelin_ui_vm::settings::UiSettings;
|
||||
use voelin_ui_vm::social::logic::Social;
|
||||
|
||||
use crate::meter::Counters;
|
||||
|
||||
/// The toolkit-free state of the client, with the chat lines of a tab as plain
|
||||
/// rows (what a front end that draws again from the list needs).
|
||||
pub type VmState = voelin_ui_vm::state::AppState<Vec<ChatLine>>;
|
||||
|
||||
/// A job for GPUI's thread, from any thread.
|
||||
type Job = Box<dyn FnOnce(&mut AppState, &mut Context<AppState>) + Send>;
|
||||
|
||||
/// How other threads reach the root state: `later.run(|app, cx| ...)` runs
|
||||
/// the closure on GPUI's thread with the entity (the Slint front end's
|
||||
/// `later`). Cloneable and `Send`; the closure must be `Send` too.
|
||||
#[derive(Clone)]
|
||||
pub struct Later(UnboundedSender<Job>);
|
||||
|
||||
impl Later {
|
||||
/// Run `job` on GPUI's thread soon. `false` once a job has found the
|
||||
/// window gone (the entity released): the loop that runs the jobs notices
|
||||
/// that only when a job reaches it, ends and drops the channel, so the
|
||||
/// first job sent after the window went answers `true` and is never run.
|
||||
/// `true` is a promise of nothing more than that the job was queued.
|
||||
pub fn run(
|
||||
&self,
|
||||
job: impl FnOnce(&mut AppState, &mut Context<AppState>) + Send + 'static,
|
||||
) -> bool {
|
||||
self.0.send(Box::new(job)).is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
/// What the transitions of the state ask of this front end while they run.
|
||||
/// There is no store yet (the shell slice opens it): nothing was read, and
|
||||
/// nothing is kept.
|
||||
#[derive(Debug, Default)]
|
||||
struct ShellHost;
|
||||
|
||||
impl Host for ShellHost {
|
||||
fn demo_ui(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn chat_shown(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn watching(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn autowatch(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn studio_streams_to(&self, _session: i64) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn preview_limit(&self) -> u64 {
|
||||
0
|
||||
}
|
||||
|
||||
fn fetch_images(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn dm_shown(&self, _session: i64, _uid: &str) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn chat_reads(&self, _server_uid: &str) -> Result<Vec<(StoredTarget, ChatRead)>, String> {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
fn set_chat_read(
|
||||
&self,
|
||||
_server_uid: &str,
|
||||
_target: &StoredTarget,
|
||||
_read: &ChatRead,
|
||||
) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// The root entity.
|
||||
pub struct AppState {
|
||||
/// What the client knows apart from the window.
|
||||
pub vm: VmState,
|
||||
/// The friends, pokes and notices the social screens keep.
|
||||
pub social: Social<()>,
|
||||
/// Engine events handled since the window opened.
|
||||
pub events_handled: u64,
|
||||
/// One-second ticks since the window opened.
|
||||
pub ticks: u64,
|
||||
engine: Option<Engine>,
|
||||
host: ShellHost,
|
||||
started: Instant,
|
||||
counters: Counters,
|
||||
later: Later,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
/// The state at start, with its three loops running: the engine's
|
||||
/// `events` (the engine is `None` in tests that need none), the tick and
|
||||
/// the jobs of [`Later`]. They end when the entity is released.
|
||||
pub fn new(
|
||||
engine: Option<Engine>,
|
||||
events: UnboundedReceiver<Event>,
|
||||
counters: Counters,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
let (later, mut jobs) = mpsc::unbounded_channel::<Job>();
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
let mut events = events;
|
||||
while let Some(event) = events.recv().await {
|
||||
if this.update(cx, |state, cx| state.handle_event(event, cx)).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
loop {
|
||||
cx.background_executor().timer(Duration::from_secs(1)).await;
|
||||
if this.update(cx, |state, cx| state.tick(cx)).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
while let Some(job) = jobs.recv().await {
|
||||
if this
|
||||
.update(cx, |state, cx| {
|
||||
state.counters.later_jobs.incr();
|
||||
job(state, cx);
|
||||
cx.notify();
|
||||
})
|
||||
.is_err()
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
Self {
|
||||
vm: VmState::new(
|
||||
Vec::new(),
|
||||
UiSettings::default(),
|
||||
AudioSettings::default(),
|
||||
Default::default(),
|
||||
),
|
||||
social: Social::default(),
|
||||
events_handled: 0,
|
||||
ticks: 0,
|
||||
engine,
|
||||
host: ShellHost,
|
||||
started: Instant::now(),
|
||||
counters,
|
||||
later: Later(later),
|
||||
}
|
||||
}
|
||||
|
||||
/// The handle other threads use to run something on GPUI's thread.
|
||||
pub fn later(&self) -> Later {
|
||||
self.later.clone()
|
||||
}
|
||||
|
||||
/// What an engine event does to the state ([`events::handle`], the one
|
||||
/// dispatch of both front ends), and what comes of it for the engine.
|
||||
pub fn handle_event(&mut self, event: Event, cx: &mut Context<Self>) {
|
||||
self.events_handled += 1;
|
||||
self.counters.engine_events.incr();
|
||||
let update = events::handle(&mut self.vm, &mut self.social, &self.host, event);
|
||||
self.perform(update);
|
||||
self.counters.connections.set(self.connections() as u64);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// Do what an update asks that this front end has the parts for: the
|
||||
/// engine's commands go out, the warnings are logged.
|
||||
fn perform(&mut self, update: Update) {
|
||||
if let Some(engine) = &self.engine {
|
||||
for command in update.commands {
|
||||
engine.send(command);
|
||||
}
|
||||
}
|
||||
for warning in update.warnings {
|
||||
tracing::warn!("{warning}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The once-a-second work: what the Slint front end's `App::tick` will be
|
||||
/// here (stream statistics, stored settings); today it counts.
|
||||
pub fn tick(&mut self, cx: &mut Context<Self>) {
|
||||
self.ticks += 1;
|
||||
self.counters.ticks.incr();
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// Voice connections that are up.
|
||||
pub fn connections(&self) -> usize {
|
||||
self.vm.sessions.values().filter(|view| view.state.voice == VoiceState::Connected).count()
|
||||
}
|
||||
|
||||
/// Seconds since the window opened.
|
||||
pub fn uptime(&self) -> Duration {
|
||||
self.started.elapsed()
|
||||
}
|
||||
|
||||
/// The one line of state the window shows: the version, how many voice
|
||||
/// connections are up, how many engine events came and how long the
|
||||
/// window has run. Each part moves by a loop above, so a line that
|
||||
/// changes shows that the loop runs.
|
||||
pub fn state_line(&self) -> String {
|
||||
let connections = self.connections();
|
||||
format!(
|
||||
"{} {} · {} connection{} · {} engine event{} · {} s up",
|
||||
voelin_platform::APP_NAME,
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
connections,
|
||||
if connections == 1 { "" } else { "s" },
|
||||
self.events_handled,
|
||||
if self.events_handled == 1 { "" } else { "s" },
|
||||
self.ticks,
|
||||
)
|
||||
}
|
||||
|
||||
/// Leave the servers properly, so no ghost client stays behind until it
|
||||
/// times out (the window is closing): tell the engine to close every
|
||||
/// session. Returns how many it told, so that the caller can give the
|
||||
/// engine time to act on them before the runtime goes (none without an
|
||||
/// engine).
|
||||
pub fn shutdown(&self) -> usize {
|
||||
let Some(engine) = &self.engine else { return 0 };
|
||||
for id in self.vm.sessions.keys() {
|
||||
engine.send(Command::CloseSession { session: *id as u64 });
|
||||
}
|
||||
self.vm.sessions.len()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::time::Duration;
|
||||
|
||||
use gpui::TestAppContext;
|
||||
use gpui_kit::AppContext as _;
|
||||
use voelin_core::{Command, Event, SessionState, VoiceState};
|
||||
|
||||
use super::*;
|
||||
use crate::engine::HostedEngine;
|
||||
|
||||
fn voice(voice: VoiceState) -> Event {
|
||||
Event::State { session: 1, state: SessionState { voice, ..Default::default() } }
|
||||
}
|
||||
|
||||
/// The entity of a test with no engine behind it: `tx` stands in for the
|
||||
/// engine's events.
|
||||
fn entity(
|
||||
cx: &mut TestAppContext,
|
||||
) -> (gpui_kit::Entity<AppState>, UnboundedSender<Event>, Counters) {
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
let counters = Counters::default();
|
||||
let app = cx.new({
|
||||
let counters = counters.clone();
|
||||
move |cx| AppState::new(None, rx, counters, cx)
|
||||
});
|
||||
(app, tx, counters)
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn an_injected_engine_event_reaches_the_entity(cx: &mut TestAppContext) {
|
||||
let (app, tx, counters) = entity(cx);
|
||||
app.read_with(cx, |app, _| {
|
||||
assert_eq!(app.connections(), 0);
|
||||
assert!(app.state_line().contains("0 connections · 0 engine events"));
|
||||
});
|
||||
|
||||
tx.send(voice(VoiceState::Connected)).unwrap();
|
||||
cx.run_until_parked();
|
||||
app.read_with(cx, |app, _| {
|
||||
assert_eq!(app.events_handled, 1);
|
||||
assert_eq!(app.connections(), 1);
|
||||
assert_eq!(app.vm.status, "Connected", "the transition's status line");
|
||||
assert!(
|
||||
app.state_line().contains("1 connection · 1 engine event"),
|
||||
"{}",
|
||||
app.state_line()
|
||||
);
|
||||
});
|
||||
assert_eq!(counters.engine_events.get(), 1);
|
||||
assert_eq!(counters.connections.get(), 1);
|
||||
|
||||
tx.send(voice(VoiceState::Disconnected)).unwrap();
|
||||
cx.run_until_parked();
|
||||
app.read_with(cx, |app, _| {
|
||||
assert_eq!((app.events_handled, app.connections()), (2, 0));
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn the_entity_redraws_on_an_event(cx: &mut TestAppContext) {
|
||||
let (app, tx, _) = entity(cx);
|
||||
let notified = std::rc::Rc::new(std::cell::Cell::new(0));
|
||||
let _subscription = cx.update(|cx| {
|
||||
let notified = notified.clone();
|
||||
cx.observe(&app, move |_, _| notified.set(notified.get() + 1))
|
||||
});
|
||||
tx.send(voice(VoiceState::Connecting)).unwrap();
|
||||
cx.run_until_parked();
|
||||
assert_eq!(notified.get(), 1);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn the_tick_runs_once_a_second(cx: &mut TestAppContext) {
|
||||
let (app, _tx, counters) = entity(cx);
|
||||
cx.run_until_parked();
|
||||
assert_eq!(app.read_with(cx, |app, _| app.ticks), 0);
|
||||
for second in 1..=3 {
|
||||
cx.executor().advance_clock(Duration::from_secs(1));
|
||||
cx.run_until_parked();
|
||||
assert_eq!(app.read_with(cx, |app, _| app.ticks), second);
|
||||
}
|
||||
assert_eq!(counters.ticks.get(), 3);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn another_thread_runs_a_job_on_the_entity_through_later(cx: &mut TestAppContext) {
|
||||
let (app, _tx, counters) = entity(cx);
|
||||
let later = app.read_with(cx, |app, _| app.later());
|
||||
let sent = std::thread::spawn(move || {
|
||||
later.run(|app, _| app.vm.status = "from another thread".into())
|
||||
})
|
||||
.join()
|
||||
.unwrap();
|
||||
assert!(sent);
|
||||
cx.run_until_parked();
|
||||
assert_eq!(app.read_with(cx, |app, _| app.vm.status.clone()), "from another thread");
|
||||
assert_eq!(counters.later_jobs.get(), 1);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_job_sent_after_the_window_went_is_dropped_and_the_next_one_is_refused(
|
||||
cx: &mut TestAppContext,
|
||||
) {
|
||||
let (app, _tx, counters) = entity(cx);
|
||||
let later = app.read_with(cx, |app, _| app.later());
|
||||
drop(app);
|
||||
cx.update(|_| {});
|
||||
cx.run_until_parked();
|
||||
assert!(later.run(|_, _| {}), "queued: nothing has found the entity gone yet");
|
||||
cx.run_until_parked();
|
||||
assert_eq!(counters.later_jobs.get(), 0, "never run");
|
||||
assert!(!later.run(|_, _| {}), "the first job found the entity gone");
|
||||
}
|
||||
|
||||
/// What closing the window hands the runtime's shutdown: the number of
|
||||
/// sessions the engine was told to close, which `run` gives time to act
|
||||
/// on (the Slint front end does the same). The engine ignores a close for
|
||||
/// a session it never opened, so the sessions here are only the state's.
|
||||
#[gpui::test]
|
||||
fn closing_counts_the_sessions_the_engine_was_told_to_close(cx: &mut TestAppContext) {
|
||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||
.worker_threads(2)
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
let hosted = HostedEngine::start(&runtime);
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
let app =
|
||||
cx.new(|cx| AppState::new(Some(hosted.engine.clone()), rx, Counters::default(), cx));
|
||||
assert_eq!(app.read_with(cx, |app, _| app.shutdown()), 0, "no session open yet");
|
||||
tx.send(voice(VoiceState::Connected)).unwrap();
|
||||
cx.run_until_parked();
|
||||
assert_eq!(app.read_with(cx, |app, _| app.shutdown()), 1);
|
||||
runtime.shutdown_timeout(Duration::from_secs(2));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn closing_without_an_engine_tells_nothing(cx: &mut TestAppContext) {
|
||||
let (app, tx, _) = entity(cx);
|
||||
tx.send(voice(VoiceState::Connected)).unwrap();
|
||||
cx.run_until_parked();
|
||||
assert_eq!(app.read_with(cx, |app, _| (app.connections(), app.shutdown())), (1, 0));
|
||||
}
|
||||
|
||||
/// The whole path with a real engine: a command makes the engine report a
|
||||
/// setting change, which its forwarder hands to the window's channel and
|
||||
/// the foreground task to the entity. The engine's tasks run on tokio
|
||||
/// threads, so the test looks again until the event is in (no bound on
|
||||
/// how long the loaded machine takes, a generous one on the whole wait);
|
||||
/// the test scheduler is told that other threads wake it
|
||||
/// (`allow_parking`), which it otherwise reports as a test that is not
|
||||
/// deterministic.
|
||||
#[gpui::test]
|
||||
fn a_real_engine_event_reaches_the_entity(cx: &mut TestAppContext) {
|
||||
cx.executor().allow_parking();
|
||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||
.worker_threads(2)
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
let hosted = HostedEngine::start(&runtime);
|
||||
let engine = hosted.engine.clone();
|
||||
let counters = Counters::default();
|
||||
let app = cx.new(|cx| AppState::new(Some(engine.clone()), hosted.events, counters, cx));
|
||||
engine.send(Command::SetSetting { key: "stream.fps".into(), value: 144.into() });
|
||||
let deadline = Instant::now() + Duration::from_secs(120);
|
||||
while app.read_with(cx, |app, _| app.events_handled) == 0 {
|
||||
assert!(Instant::now() < deadline, "the engine's event never arrived");
|
||||
cx.run_until_parked();
|
||||
std::thread::sleep(Duration::from_millis(10));
|
||||
}
|
||||
assert!(app.read_with(cx, |app, _| app.events_handled) >= 1);
|
||||
runtime.shutdown_timeout(Duration::from_secs(2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//! What `svg()` and gpui-component's `Icon` load by path. The client's own
|
||||
//! Lucide 1.48 icons (the 147 SVGs of the Slint front end, embedded by
|
||||
//! `build.rs`) answer `icons/<name>.svg` first, so every widget draws the
|
||||
//! icons the client draws; anything else (the rest of gpui-kit-assets'
|
||||
//! Lucide 1.43 catalogue, which gpui-component's `IconName` names) comes from
|
||||
//! gpui-kit-assets.
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use gpui_kit::{AssetSource, Result, SharedString};
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/icons.rs"));
|
||||
|
||||
/// The client's icons first, then gpui-kit-assets'.
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
pub struct Assets;
|
||||
|
||||
/// The client's icon of a file name (`mic.svg`), if it has one.
|
||||
pub fn client_icon(name: &str) -> Option<&'static [u8]> {
|
||||
ICONS.binary_search_by_key(&name, |(n, _)| n).ok().map(|i| ICONS[i].1)
|
||||
}
|
||||
|
||||
/// The names of the client's icons, sorted.
|
||||
pub fn client_icon_names() -> impl Iterator<Item = &'static str> {
|
||||
ICONS.iter().map(|(name, _)| *name)
|
||||
}
|
||||
|
||||
impl AssetSource for Assets {
|
||||
fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
|
||||
if let Some(bytes) = path.strip_prefix("icons/").and_then(client_icon) {
|
||||
return Ok(Some(Cow::Borrowed(bytes)));
|
||||
}
|
||||
gpui_kit::assets::AllAssets.load(path)
|
||||
}
|
||||
|
||||
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
|
||||
gpui_kit::assets::AllAssets.list(path)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_client_set_is_embedded_and_sorted() {
|
||||
assert!(ICONS.len() >= 140, "{} icons", ICONS.len());
|
||||
assert!(ICONS.windows(2).all(|pair| pair[0].0 < pair[1].0));
|
||||
for (name, bytes) in ICONS {
|
||||
assert!(std::str::from_utf8(bytes).is_ok_and(|text| text.contains("<svg")), "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_client_icon_answers_before_gpui_kit_assets() {
|
||||
let name = client_icon_names().find(|n| *n == "mic.svg").expect("the client has a mic");
|
||||
let ours = client_icon(name).unwrap();
|
||||
let kit = gpui_kit::assets::AllAssets
|
||||
.load(&format!("icons/{name}"))
|
||||
.unwrap()
|
||||
.expect("gpui-kit-assets has a mic too");
|
||||
let served = Assets.load(&format!("icons/{name}")).unwrap().unwrap();
|
||||
assert_eq!(&*served, ours);
|
||||
assert_ne!(&*kit, ours, "Lucide 1.43 and 1.48 draw it differently, or this test is moot");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn other_icons_and_other_paths_fall_through_to_gpui_kit_assets() {
|
||||
let kit = gpui_kit::assets::AllAssets.list("icons/").unwrap();
|
||||
let only_in_kit = kit
|
||||
.iter()
|
||||
.find(|path| client_icon(path.trim_start_matches("icons/")).is_none())
|
||||
.expect("the catalogue has icons the client lacks");
|
||||
assert!(Assets.load(only_in_kit).unwrap().is_some(), "{only_in_kit}");
|
||||
// gpui-kit-assets answers a path it does not have with an error, so do we.
|
||||
assert!(Assets.load("icons/no-such-icon.svg").is_err());
|
||||
assert!(Assets.load("nothing/here").is_err());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
//! The development switches of the GPUI front end, read from the
|
||||
//! environment. They are the Slint front end's (docs/ui.md, "Development
|
||||
//! switches and screenshots") where the GPUI one has the same thing to
|
||||
//! switch, so that one recipe serves both; the rest are new.
|
||||
//!
|
||||
//! - `VOELIN_OPEN=swatch`: the swatch page (every theme token, a few
|
||||
//! components, the icons) in place of the shell. The Slint front end's
|
||||
//! other pages do not exist here yet; they are named in a warning and
|
||||
//! skipped.
|
||||
//! - `VOELIN_DEV_THEME=dark|light|system`: the theme mode, in place of the
|
||||
//! one the settings will give (`ui.theme` in the Slint front end).
|
||||
//! - `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, one log line a second
|
||||
//! ([`crate::meter`]).
|
||||
|
||||
use crate::theme::Choice;
|
||||
|
||||
/// A page the window can be opened on.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Page {
|
||||
/// The shell. Today an empty window with the state line.
|
||||
Shell,
|
||||
/// Every theme token, a few components and the icons.
|
||||
Swatch,
|
||||
}
|
||||
|
||||
/// What the environment switched.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Switches {
|
||||
/// The page to open on.
|
||||
pub open: Page,
|
||||
/// The theme mode, when the switch names one.
|
||||
pub theme: Option<Choice>,
|
||||
/// The text size factor, when the switch names one.
|
||||
pub font_scale: Option<f32>,
|
||||
/// The window's size in pixels, when the switch names one.
|
||||
pub window: Option<(f32, f32)>,
|
||||
/// Log the cost meter.
|
||||
pub meter: bool,
|
||||
}
|
||||
|
||||
impl Default for Switches {
|
||||
fn default() -> Self {
|
||||
Self { open: Page::Shell, theme: None, font_scale: None, window: None, meter: false }
|
||||
}
|
||||
}
|
||||
|
||||
impl Switches {
|
||||
/// The switches of this process's environment.
|
||||
pub fn from_env() -> Self {
|
||||
Self::parse(|name| std::env::var(name).ok())
|
||||
}
|
||||
|
||||
/// The switches `get` answers for; what it does not understand is logged
|
||||
/// and left out.
|
||||
pub fn parse(get: impl Fn(&str) -> Option<String>) -> Self {
|
||||
let mut switches = Self::default();
|
||||
if let Some(list) = get("VOELIN_OPEN") {
|
||||
for what in list.split(',').map(str::trim).filter(|w| !w.is_empty()) {
|
||||
match what {
|
||||
"swatch" => switches.open = Page::Swatch,
|
||||
other => tracing::warn!(
|
||||
"VOELIN_OPEN={other}: this page is not in the GPUI front end yet (swatch is)"
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(name) = get("VOELIN_DEV_THEME") {
|
||||
match Choice::parse(name.trim()) {
|
||||
Some(choice) => switches.theme = Some(choice),
|
||||
None => tracing::warn!("VOELIN_DEV_THEME={name}: dark, light or system"),
|
||||
}
|
||||
}
|
||||
if let Some(text) = get("VOELIN_FONT_SCALE") {
|
||||
match text.trim().parse::<f32>() {
|
||||
Ok(scale) if (0.5..=3.0).contains(&scale) => switches.font_scale = Some(scale),
|
||||
_ => tracing::warn!("VOELIN_FONT_SCALE={text}: a number from 0.5 to 3"),
|
||||
}
|
||||
}
|
||||
if let Some(text) = get("VOELIN_WINDOW_SIZE") {
|
||||
match parse_size(&text) {
|
||||
Some(size) => switches.window = Some(size),
|
||||
None => tracing::warn!("VOELIN_WINDOW_SIZE={text}: WIDTHxHEIGHT, such as 1440x960"),
|
||||
}
|
||||
}
|
||||
switches.meter = get("VOELIN_METER").is_some_and(|v| !matches!(v.trim(), "" | "0"));
|
||||
switches
|
||||
}
|
||||
}
|
||||
|
||||
/// `WIDTHxHEIGHT` in pixels, at least 320 by 240 and at most 16384 each way.
|
||||
fn parse_size(text: &str) -> Option<(f32, f32)> {
|
||||
let (w, h) = text.trim().split_once('x')?;
|
||||
let (w, h): (u32, u32) = (w.parse().ok()?, h.parse().ok()?);
|
||||
((320..=16384).contains(&w) && (240..=16384).contains(&h)).then_some((w as f32, h as f32))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn env(pairs: &[(&str, &str)]) -> Switches {
|
||||
let map: HashMap<String, String> =
|
||||
pairs.iter().map(|(k, v)| ((*k).to_owned(), (*v).to_owned())).collect();
|
||||
Switches::parse(|name| map.get(name).cloned())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nothing_switched_is_the_shell_in_the_settings_theme() {
|
||||
assert_eq!(env(&[]), Switches::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_switch_is_read() {
|
||||
let s = env(&[
|
||||
("VOELIN_OPEN", "swatch"),
|
||||
("VOELIN_DEV_THEME", "light"),
|
||||
("VOELIN_FONT_SCALE", "1.25"),
|
||||
("VOELIN_WINDOW_SIZE", "1440x960"),
|
||||
("VOELIN_METER", "1"),
|
||||
]);
|
||||
assert_eq!(s.open, Page::Swatch);
|
||||
assert_eq!(s.theme, Some(Choice::Light));
|
||||
assert_eq!(s.font_scale, Some(1.25));
|
||||
assert_eq!(s.window, Some((1440.0, 960.0)));
|
||||
assert!(s.meter);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn what_makes_no_sense_is_left_out() {
|
||||
let s = env(&[
|
||||
("VOELIN_OPEN", "settings:voice,home"),
|
||||
("VOELIN_DEV_THEME", "blue"),
|
||||
("VOELIN_FONT_SCALE", "9"),
|
||||
("VOELIN_WINDOW_SIZE", "10x10"),
|
||||
("VOELIN_METER", "0"),
|
||||
]);
|
||||
assert_eq!(s, Switches::default());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//! The engine this front end runs on, the same one the Slint front end
|
||||
//! hosts (`voelin_ui::HostedEngine`, `crates/voelin-ui/src/app.rs`): started
|
||||
//! on a tokio runtime, its events forwarded into a channel the window reads.
|
||||
//! The Slint crate cannot be a dependency here (it brings Slint in), so the
|
||||
//! few lines are repeated; both go into `voelin-ui-vm` when the Slint front
|
||||
//! end is retired.
|
||||
|
||||
use tokio::runtime::{Handle, Runtime};
|
||||
use tokio::sync::{broadcast, mpsc};
|
||||
use voelin_core::{Engine, Event};
|
||||
|
||||
/// An engine owned by the caller of [`crate::run`].
|
||||
pub struct HostedEngine {
|
||||
/// The handle: commands go in through it.
|
||||
pub engine: Engine,
|
||||
/// The runtime the engine runs on; the window's helpers run there too.
|
||||
pub runtime: Handle,
|
||||
/// The engine's events for the window: first those that rebuild the
|
||||
/// current state of every session, then new ones. Reading them needs no
|
||||
/// reactor, so the window's foreground executor can await it.
|
||||
pub events: mpsc::UnboundedReceiver<Event>,
|
||||
}
|
||||
|
||||
impl HostedEngine {
|
||||
/// A new engine on `runtime`, all of whose events go to the window.
|
||||
pub fn start(runtime: &Runtime) -> Self {
|
||||
let engine = runtime.block_on(async { Engine::start() });
|
||||
let (tx, events) = mpsc::unbounded_channel();
|
||||
let mut rx = engine.subscribe();
|
||||
runtime.spawn(async move {
|
||||
loop {
|
||||
match rx.recv().await {
|
||||
Ok(event) => {
|
||||
if tx.send(event).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Err(broadcast::error::RecvError::Lagged(_)) => continue,
|
||||
Err(_) => break,
|
||||
}
|
||||
}
|
||||
});
|
||||
Self { engine, runtime: runtime.handle().clone(), events }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//! Inter, the UI font, as the Slint front end bundles it
|
||||
//! (`crates/voelin-ui/ui/assets/fonts`, OFL): the five files go into GPUI's
|
||||
//! text system and are used by family name ([`crate::theme::FONT_FAMILY`]),
|
||||
//! so nothing depends on what fontconfig finds for Latin text. Colour emoji
|
||||
//! come later (the chat slice; docs/design/gpui-spikes.md, "Open choices for step 3").
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use gpui_kit::App;
|
||||
|
||||
/// The files of the family: regular, medium, semibold, bold, italic.
|
||||
const INTER: [&[u8]; 5] = [
|
||||
include_bytes!("../../voelin-ui/ui/assets/fonts/Inter-Regular.ttf"),
|
||||
include_bytes!("../../voelin-ui/ui/assets/fonts/Inter-Medium.ttf"),
|
||||
include_bytes!("../../voelin-ui/ui/assets/fonts/Inter-SemiBold.ttf"),
|
||||
include_bytes!("../../voelin-ui/ui/assets/fonts/Inter-Bold.ttf"),
|
||||
include_bytes!("../../voelin-ui/ui/assets/fonts/Inter-Italic.ttf"),
|
||||
];
|
||||
|
||||
/// Add Inter to GPUI's text system.
|
||||
pub fn load(cx: &mut App) {
|
||||
let fonts: Vec<Cow<'static, [u8]>> = INTER.iter().map(|bytes| Cow::Borrowed(*bytes)).collect();
|
||||
if let Err(error) = cx.text_system().add_fonts(fonts) {
|
||||
tracing::warn!(%error, "cannot add Inter to the text system");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_files_are_fonts() {
|
||||
for bytes in INTER {
|
||||
assert!(bytes.len() > 100_000, "a font file, not {} bytes", bytes.len());
|
||||
assert!(matches!(&bytes[..4], [0, 1, 0, 0] | b"OTTO" | b"true"), "an sfnt header");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
//! The GPUI front end of the desktop app, under construction (plan section 6
|
||||
//! of the migration from Slint; docs/ui.md, "The GPUI front end"). The Slint
|
||||
//! front end (`voelin-ui`, the `voelin` binary) stays the app until this one
|
||||
//! reaches parity; both run on the same engine.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
pub mod app;
|
||||
pub mod assets;
|
||||
pub mod dev;
|
||||
pub mod engine;
|
||||
pub mod fonts;
|
||||
pub mod meter;
|
||||
pub mod swatch;
|
||||
pub mod theme;
|
||||
pub mod view;
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{Context as _, Result};
|
||||
use gpui_kit::{App, AppContext as _, TitlebarOptions, WindowBounds, WindowOptions, px, size};
|
||||
use tracing_subscriber::{EnvFilter, fmt, prelude::*};
|
||||
|
||||
use crate::app::AppState;
|
||||
use crate::assets::Assets;
|
||||
use crate::dev::Switches;
|
||||
use crate::engine::HostedEngine;
|
||||
use crate::meter::Counters;
|
||||
use crate::theme::{Choice, VoelinTheme};
|
||||
use crate::view::MainView;
|
||||
|
||||
/// How long the engine gets, after the window closed, to act on the
|
||||
/// `CloseSession` commands the close sent (the Slint front end waits as long):
|
||||
/// its tasks run on the runtime, and shutting the runtime down drops them.
|
||||
const CLOSE_GRACE: Duration = Duration::from_millis(500);
|
||||
|
||||
/// What the log gets without `VOELIN_LOG` or `RUST_LOG`: warnings of every
|
||||
/// crate, this front end's information, and what GPUI says about the display
|
||||
/// and the GPU adapter it picked (which device a run used). Two warnings are
|
||||
/// left out because they are harmless: zbus's, as in the Slint front end (it
|
||||
/// warns when a desktop portal's request object is gone before it reads its
|
||||
/// properties), and GPUI's "failed to load font .SystemUIFont" (gpui-component
|
||||
/// asks for the platform's UI font, which Linux has no name for, before the
|
||||
/// theme names Inter; the text system falls back).
|
||||
const LOG_FILTER: &str =
|
||||
"warn,zbus=error,gpui::text_system=error,voelin_gpui=info,gpui_wgpu=info,gpui_linux=info";
|
||||
|
||||
/// Log to the terminal: `VOELIN_LOG`, else `RUST_LOG`, else [`LOG_FILTER`].
|
||||
/// GPUI logs through the `log` crate; the subscriber carries those records.
|
||||
pub fn init_logging() {
|
||||
let filter = EnvFilter::try_from_env("VOELIN_LOG")
|
||||
.or_else(|_| EnvFilter::try_from_default_env())
|
||||
.unwrap_or_else(|_| EnvFilter::new(LOG_FILTER));
|
||||
let _ = tracing_subscriber::registry()
|
||||
.with(fmt::layer().with_writer(std::io::stderr).with_filter(filter))
|
||||
.try_init();
|
||||
}
|
||||
|
||||
/// The main window's options: titled with the app's name, grouped by its id,
|
||||
/// centred, 1280 by 800 unless `VOELIN_WINDOW_SIZE` says otherwise.
|
||||
fn window_options(switches: &Switches, cx: &App) -> WindowOptions {
|
||||
let (width, height) = switches.window.unwrap_or((1280.0, 800.0));
|
||||
WindowOptions {
|
||||
titlebar: Some(TitlebarOptions {
|
||||
title: Some(voelin_platform::APP_NAME.into()),
|
||||
..Default::default()
|
||||
}),
|
||||
app_id: Some(voelin_platform::APP_ID.to_owned()),
|
||||
window_min_size: Some(size(px(640.0), px(480.0))),
|
||||
window_bounds: Some(WindowBounds::centered(size(px(width), px(height)), cx)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Open the main window on the root state; closing it leaves the servers and
|
||||
/// ends the app. `closed_sessions` is set to how many sessions the close told
|
||||
/// the engine to close, which [`run`] needs after GPUI's loop has ended.
|
||||
fn open_main_window(
|
||||
cx: &mut App,
|
||||
switches: &Switches,
|
||||
engine: HostedEngine,
|
||||
counters: Counters,
|
||||
closed_sessions: Rc<Cell<usize>>,
|
||||
) -> Result<()> {
|
||||
// Without a display server GPUI falls back to a headless platform, which
|
||||
// opens windows that draw nothing and runs until it is stopped.
|
||||
if cx.compositor_name() == "headless" {
|
||||
return Err(anyhow::anyhow!(
|
||||
"no display: neither DISPLAY nor WAYLAND_DISPLAY names a display server"
|
||||
))
|
||||
.context("cannot open the main window");
|
||||
}
|
||||
let HostedEngine { engine, events, .. } = engine;
|
||||
let app = cx.new({
|
||||
let counters = counters.clone();
|
||||
move |cx| AppState::new(Some(engine), events, counters, cx)
|
||||
});
|
||||
let options = window_options(switches, cx);
|
||||
let page = switches.open;
|
||||
gpui_kit::open_window(options, cx, {
|
||||
let app = app.clone();
|
||||
move |window, cx| {
|
||||
// The window's own appearance, which may differ from the system's before
|
||||
// the window exists.
|
||||
VoelinTheme::set_system_appearance(cx, window.appearance());
|
||||
window.on_window_should_close(cx, {
|
||||
let app = app.clone();
|
||||
move |_, cx| {
|
||||
closed_sessions.set(app.read(cx).shutdown());
|
||||
cx.quit();
|
||||
true
|
||||
}
|
||||
});
|
||||
cx.new(|cx| MainView::new(app, page, counters, window, cx))
|
||||
}
|
||||
})
|
||||
.context("cannot open the main window")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Run the app on the current thread until its window closes.
|
||||
pub fn run() -> Result<()> {
|
||||
init_logging();
|
||||
let switches = Switches::from_env();
|
||||
tracing::info!(
|
||||
version = env!("CARGO_PKG_VERSION"),
|
||||
os = std::env::consts::OS,
|
||||
"Voelin (GPUI) starting"
|
||||
);
|
||||
let counters = Counters::default();
|
||||
if switches.meter {
|
||||
meter::start(counters.clone());
|
||||
}
|
||||
// The engine runs on tokio threads of its own; the window is GPUI's.
|
||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.context("cannot start the engine's runtime")?;
|
||||
let hosted = HostedEngine::start(&runtime);
|
||||
let failure: Rc<RefCell<Option<anyhow::Error>>> = Rc::default();
|
||||
let closed_sessions: Rc<Cell<usize>> = Rc::default();
|
||||
gpui_kit::application().with_assets(Assets).run({
|
||||
let failure = failure.clone();
|
||||
let closed_sessions = closed_sessions.clone();
|
||||
move |cx| {
|
||||
gpui_kit::init(cx);
|
||||
fonts::load(cx);
|
||||
// Until the settings are read here (the shell slice), the mode and
|
||||
// the text size are the development switches' or the defaults.
|
||||
VoelinTheme::init(
|
||||
cx,
|
||||
switches.theme.unwrap_or(Choice::System),
|
||||
cx.window_appearance(),
|
||||
switches.font_scale.unwrap_or(1.0),
|
||||
);
|
||||
if let Err(e) = open_main_window(cx, &switches, hosted, counters, closed_sessions) {
|
||||
*failure.borrow_mut() = Some(e);
|
||||
// Not `cx.quit()` here: GPUI's Linux platform runs this callback
|
||||
// before it starts its event loop, and the loop forgets a stop
|
||||
// asked for earlier (calloop clears its stop signal when it
|
||||
// starts), so the process would stay with no window and no
|
||||
// message. A task runs inside the loop.
|
||||
cx.spawn(async move |cx| cx.update(|cx| cx.quit())).detach();
|
||||
}
|
||||
}
|
||||
});
|
||||
// The close told the engine to close the sessions; give its tasks time to
|
||||
// send that before the runtime drops them (`shutdown_timeout` waits for
|
||||
// blocking tasks only), as the Slint front end does, or ghost clients stay
|
||||
// on the servers until they time out. Any other way to end the app that
|
||||
// the slices add must call `AppState::shutdown` too.
|
||||
if closed_sessions.get() > 0 {
|
||||
runtime.block_on(tokio::time::sleep(CLOSE_GRACE));
|
||||
}
|
||||
runtime.shutdown_timeout(Duration::from_secs(2));
|
||||
match failure.take() {
|
||||
Some(e) => Err(e),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//! `voelin-gpui`: the GPUI front end of the desktop app (docs/ui.md, "The
|
||||
//! GPUI front end").
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
voelin_gpui::run()
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
//! What the app costs, once a second, in the log: the CPU of the process and
|
||||
//! of each group of threads, the resident memory, and the app's own counters
|
||||
//! (a development switch, `VOELIN_METER=1`, so that every slice can say what
|
||||
//! it costs). It is `spike_common::meter` of the GPUI spikes
|
||||
//! (`spikes/gpui/common/src/meter.rs`, docs/design/gpui-spikes.md) without the
|
||||
//! measuring run's summary and exit, writing log lines instead of JSON.
|
||||
//!
|
||||
//! CPU is in percent of one core (200 means two cores busy). Threads are
|
||||
//! grouped by name without a trailing number (`llvmpipe-12` becomes
|
||||
//! `llvmpipe`), which tells the software renderer's share (Mesa's `llvmpipe-*`
|
||||
//! threads, work a GPU would take over) from GPUI's thread, the engine's
|
||||
//! runtime and the codecs. The numbers come from `/proc/self`: on other
|
||||
//! systems the meter says it cannot read them and stops.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Write as _;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
/// A number the app counts up (events handled, frames drawn) or sets (open
|
||||
/// connections); the meter reports counters per second and gauges as they
|
||||
/// are.
|
||||
#[derive(Clone, Default, Debug)]
|
||||
pub struct Counter(Arc<AtomicU64>);
|
||||
|
||||
impl Counter {
|
||||
/// Add one.
|
||||
pub fn incr(&self) {
|
||||
self.0.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// Set (gauges).
|
||||
pub fn set(&self, value: u64) {
|
||||
self.0.store(value, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// The current value.
|
||||
pub fn get(&self) -> u64 {
|
||||
self.0.load(Ordering::Relaxed)
|
||||
}
|
||||
}
|
||||
|
||||
/// The app's own numbers the meter reports besides the process's.
|
||||
#[derive(Clone, Default, Debug)]
|
||||
pub struct Counters {
|
||||
/// Engine events handled by the root state (per second).
|
||||
pub engine_events: Counter,
|
||||
/// One-second ticks of the root state (per second: 1).
|
||||
pub ticks: Counter,
|
||||
/// Windows drawn (frames, per second).
|
||||
pub renders: Counter,
|
||||
/// Jobs other threads handed to the foreground through
|
||||
/// [`crate::app::Later`] (per second).
|
||||
pub later_jobs: Counter,
|
||||
/// Voice connections that are up (a gauge).
|
||||
pub connections: Counter,
|
||||
}
|
||||
|
||||
/// CPU ticks of the process and of each thread group, and the resident
|
||||
/// memory, at one moment.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Snapshot {
|
||||
at: Instant,
|
||||
process: u64,
|
||||
threads: BTreeMap<String, u64>,
|
||||
rss_bytes: u64,
|
||||
}
|
||||
|
||||
/// The size of a page of memory, for `statm`'s page counts.
|
||||
#[cfg(target_os = "linux")]
|
||||
fn page_size() -> u64 {
|
||||
rustix::param::page_size() as u64
|
||||
}
|
||||
|
||||
/// The size of a page of memory (Linux only matters: `/proc`).
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn page_size() -> u64 {
|
||||
4096
|
||||
}
|
||||
|
||||
/// The unit of the CPU times in `stat`.
|
||||
#[cfg(target_os = "linux")]
|
||||
fn clock_ticks_per_second() -> u64 {
|
||||
rustix::param::clock_ticks_per_second()
|
||||
}
|
||||
|
||||
/// The unit of the CPU times in `stat` (Linux only matters: `/proc`).
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn clock_ticks_per_second() -> u64 {
|
||||
100
|
||||
}
|
||||
|
||||
/// `utime + stime` and the name of a `/proc/.../stat` line.
|
||||
fn ticks_of(stat: &str) -> Option<(String, u64)> {
|
||||
let open = stat.find('(')?;
|
||||
let close = stat.rfind(')')?;
|
||||
let name = stat.get(open + 1..close)?.to_owned();
|
||||
let fields: Vec<&str> = stat.get(close + 1..)?.split_whitespace().collect();
|
||||
// Fields 14 and 15 of proc(5); the remainder starts at field 3.
|
||||
let utime: u64 = fields.get(11)?.parse().ok()?;
|
||||
let stime: u64 = fields.get(12)?.parse().ok()?;
|
||||
Some((name, utime + stime))
|
||||
}
|
||||
|
||||
/// A thread's group: its name without a trailing number or separator.
|
||||
pub fn group_of(name: &str) -> String {
|
||||
let trimmed = name.trim_end_matches(|c: char| c.is_ascii_digit());
|
||||
let trimmed = trimmed.trim_end_matches(['-', '_', ':', ' ', '#']);
|
||||
if trimmed.is_empty() { name.to_owned() } else { trimmed.to_owned() }
|
||||
}
|
||||
|
||||
impl Snapshot {
|
||||
/// Read `/proc/self` now; `None` where there is none.
|
||||
pub fn now() -> Option<Self> {
|
||||
let process = std::fs::read_to_string("/proc/self/stat").ok().and_then(|s| ticks_of(&s))?.1;
|
||||
let mut threads = BTreeMap::new();
|
||||
if let Ok(dir) = std::fs::read_dir("/proc/self/task") {
|
||||
for entry in dir.flatten() {
|
||||
let Ok(stat) = std::fs::read_to_string(entry.path().join("stat")) else { continue };
|
||||
if let Some((name, ticks)) = ticks_of(&stat) {
|
||||
*threads.entry(group_of(&name)).or_insert(0) += ticks;
|
||||
}
|
||||
}
|
||||
}
|
||||
let rss_bytes = std::fs::read_to_string("/proc/self/statm")
|
||||
.ok()
|
||||
.and_then(|s| s.split_whitespace().nth(1)?.parse::<u64>().ok())
|
||||
.map_or(0, |pages| pages * page_size());
|
||||
Some(Self { at: Instant::now(), process, threads, rss_bytes })
|
||||
}
|
||||
|
||||
/// Resident memory in MiB.
|
||||
pub fn rss_mib(&self) -> f64 {
|
||||
self.rss_bytes as f64 / (1024.0 * 1024.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// CPU in percent of one core between two snapshots: the process's and each
|
||||
/// thread group's that used any (groups that exited in between count from
|
||||
/// zero).
|
||||
pub fn cpu_between(a: &Snapshot, b: &Snapshot) -> (f64, BTreeMap<String, f64>) {
|
||||
let hz = clock_ticks_per_second() as f64;
|
||||
let secs = b.at.duration_since(a.at).as_secs_f64().max(1e-6);
|
||||
let pct = |ticks: u64| ticks as f64 / hz / secs * 100.0;
|
||||
let process = pct(b.process.saturating_sub(a.process));
|
||||
let threads = b
|
||||
.threads
|
||||
.iter()
|
||||
.map(|(name, &t)| (name.clone(), pct(t.saturating_sub(*a.threads.get(name).unwrap_or(&0)))))
|
||||
.filter(|(_, p)| *p > 0.0)
|
||||
.collect();
|
||||
(process, threads)
|
||||
}
|
||||
|
||||
/// One second of the meter as a log line: `cpu 42.0% rss 210.4 MiB threads
|
||||
/// llvmpipe 31.0 main 5.0 | engine_events 0.0/s ... | connections 1`.
|
||||
pub fn line(
|
||||
cpu: f64,
|
||||
rss_mib: f64,
|
||||
threads: &BTreeMap<String, f64>,
|
||||
rates: &[(&str, f64)],
|
||||
gauges: &[(&str, u64)],
|
||||
) -> String {
|
||||
let mut text = format!("cpu {cpu:.1}% rss {rss_mib:.1} MiB");
|
||||
// The busiest groups first; a thread group under 0.5 % is noise.
|
||||
let mut busy: Vec<(&String, &f64)> = threads.iter().filter(|(_, p)| **p >= 0.5).collect();
|
||||
busy.sort_by(|a, b| b.1.total_cmp(a.1).then_with(|| a.0.cmp(b.0)));
|
||||
if !busy.is_empty() {
|
||||
text.push_str(" | threads");
|
||||
for (name, pct) in busy {
|
||||
let _ = write!(text, " {name} {pct:.1}");
|
||||
}
|
||||
}
|
||||
text.push_str(" |");
|
||||
for (name, rate) in rates {
|
||||
let _ = write!(text, " {name} {rate:.1}/s");
|
||||
}
|
||||
if !gauges.is_empty() {
|
||||
text.push_str(" |");
|
||||
for (name, value) in gauges {
|
||||
let _ = write!(text, " {name} {value}");
|
||||
}
|
||||
}
|
||||
text
|
||||
}
|
||||
|
||||
/// Start the meter on a thread of its own: once a second, a log line (target
|
||||
/// `voelin_gpui::meter`, level info) with the process's CPU and memory and
|
||||
/// `counters`' rates. It ends with the process.
|
||||
pub fn start(counters: Counters) {
|
||||
let spawned = std::thread::Builder::new().name("voelin-meter".into()).spawn(move || {
|
||||
let Some(mut last) = Snapshot::now() else {
|
||||
tracing::warn!(target: "voelin_gpui::meter", "the meter reads /proc/self; there is none here");
|
||||
return;
|
||||
};
|
||||
let rated = [
|
||||
("engine_events", counters.engine_events.clone()),
|
||||
("ticks", counters.ticks.clone()),
|
||||
("renders", counters.renders.clone()),
|
||||
("later_jobs", counters.later_jobs.clone()),
|
||||
];
|
||||
let mut last_counts: Vec<u64> = rated.iter().map(|(_, c)| c.get()).collect();
|
||||
tracing::info!(target: "voelin_gpui::meter", "meter on: one line a second (VOELIN_METER)");
|
||||
loop {
|
||||
std::thread::sleep(Duration::from_secs(1));
|
||||
let Some(now) = Snapshot::now() else { return };
|
||||
let secs = now.at.duration_since(last.at).as_secs_f64().max(1e-6);
|
||||
let (cpu, threads) = cpu_between(&last, &now);
|
||||
let counts: Vec<u64> = rated.iter().map(|(_, c)| c.get()).collect();
|
||||
let rates: Vec<(&str, f64)> = rated
|
||||
.iter()
|
||||
.zip(counts.iter().zip(&last_counts))
|
||||
.map(|((name, _), (c, l))| (*name, c.saturating_sub(*l) as f64 / secs))
|
||||
.collect();
|
||||
let gauges = [("connections", counters.connections.get())];
|
||||
tracing::info!(
|
||||
target: "voelin_gpui::meter",
|
||||
"{}",
|
||||
line(cpu, now.rss_mib(), &threads, &rates, &gauges)
|
||||
);
|
||||
last = now;
|
||||
last_counts = counts;
|
||||
}
|
||||
});
|
||||
if let Err(error) = spawned {
|
||||
tracing::warn!(target: "voelin_gpui::meter", %error, "no meter thread");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn groups_drop_trailing_numbers() {
|
||||
assert_eq!(group_of("llvmpipe-12"), "llvmpipe");
|
||||
assert_eq!(group_of("tokio-runtime-w"), "tokio-runtime-w");
|
||||
assert_eq!(group_of("voelin-meter"), "voelin-meter");
|
||||
assert_eq!(group_of("1234"), "1234");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stat_lines_parse_with_spaces_in_names() {
|
||||
let line = "42 (a b) c) S 1 2 3 4 5 6 7 8 9 10 100 23 0 0 20 0 1 0 0";
|
||||
assert_eq!(ticks_of(line), Some(("a b) c".to_owned(), 123)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_line_names_the_busiest_threads_first_and_hides_the_idle_ones() {
|
||||
let threads = BTreeMap::from([
|
||||
("main".to_owned(), 5.04),
|
||||
("llvmpipe".to_owned(), 310.0),
|
||||
("idle".to_owned(), 0.2),
|
||||
]);
|
||||
let text = line(
|
||||
317.0,
|
||||
210.44,
|
||||
&threads,
|
||||
&[("engine_events", 0.0), ("renders", 59.96)],
|
||||
&[("connections", 1)],
|
||||
);
|
||||
assert_eq!(
|
||||
text,
|
||||
"cpu 317.0% rss 210.4 MiB | threads llvmpipe 310.0 main 5.0 | engine_events 0.0/s renders 60.0/s | connections 1"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn this_process_can_be_read_on_linux() {
|
||||
if !cfg!(target_os = "linux") {
|
||||
return;
|
||||
}
|
||||
let a = Snapshot::now().expect("/proc/self");
|
||||
// The kernel counts a process's CPU in ticks of 10 ms, and on a busy
|
||||
// machine this thread gets a tick's worth of CPU only after a long wall
|
||||
// time: burn CPU until a second reading shows the process's ticks above
|
||||
// the first, and in a thread group (the process's total and a thread's
|
||||
// own are rounded separately). The deadline only ends a hang
|
||||
// (docs/testing/load.md); it never decides the result.
|
||||
let deadline = Instant::now() + Duration::from_secs(30);
|
||||
let (b, cpu) = loop {
|
||||
let burn = Instant::now();
|
||||
let mut x = 0u64;
|
||||
while burn.elapsed() < Duration::from_millis(2) {
|
||||
x = x.wrapping_mul(31).wrapping_add(7);
|
||||
}
|
||||
std::hint::black_box(x);
|
||||
let b = Snapshot::now().expect("/proc/self");
|
||||
let (cpu, threads) = cpu_between(&a, &b);
|
||||
if b.process > a.process && !threads.is_empty() {
|
||||
break (b, cpu);
|
||||
}
|
||||
assert!(
|
||||
Instant::now() < deadline,
|
||||
"no CPU tick showed in 30 s: {} -> {}",
|
||||
a.process,
|
||||
b.process
|
||||
);
|
||||
};
|
||||
assert!(cpu > 0.0 && b.rss_mib() > 1.0, "{cpu} {}", b.rss_mib());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,389 @@
|
||||
//! The swatch page: every colour token of the theme with its name and value,
|
||||
//! the radii, the spacing, the type scale, a few gpui-component widgets (drawn
|
||||
//! from the second layer of the theme) and the client's icons, in the mode
|
||||
//! the theme is in. A development page (`VOELIN_OPEN=swatch`): the screenshots
|
||||
//! of a theme change, and what the screenshots in docs/ui/ show.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use gpui_kit::component::button::{Button, ButtonVariants as _};
|
||||
use gpui_kit::component::checkbox::Checkbox;
|
||||
use gpui_kit::component::switch::Switch;
|
||||
use gpui_kit::{
|
||||
FontWeight, InteractiveElement as _, IntoElement, ParentElement as _,
|
||||
StatefulInteractiveElement as _, Styled as _, div, px, svg,
|
||||
};
|
||||
|
||||
use crate::theme::{VoelinTheme, hsla, tokens::Rgba};
|
||||
|
||||
/// The colour tokens by the groups of docs/ui.md's "Theme tokens" table.
|
||||
pub const GROUPS: [(&str, &[&str]); 6] = [
|
||||
(
|
||||
"Backgrounds",
|
||||
&[
|
||||
"bg-app",
|
||||
"bg-rail",
|
||||
"surface",
|
||||
"surface-2",
|
||||
"surface-3",
|
||||
"surface-4",
|
||||
"scrim",
|
||||
"scrim-light",
|
||||
"overlay",
|
||||
],
|
||||
),
|
||||
("Lines", &["border", "border-strong", "border-popup", "glow"]),
|
||||
(
|
||||
"Accent",
|
||||
&[
|
||||
"accent",
|
||||
"accent-hover",
|
||||
"accent-pressed",
|
||||
"accent-soft",
|
||||
"accent-soft-hover",
|
||||
"accent-text",
|
||||
"name-text",
|
||||
"on-accent",
|
||||
],
|
||||
),
|
||||
(
|
||||
"States",
|
||||
&[
|
||||
"live",
|
||||
"live-soft",
|
||||
"danger",
|
||||
"danger-soft",
|
||||
"success",
|
||||
"success-soft",
|
||||
"warning",
|
||||
"warning-soft",
|
||||
"idle",
|
||||
"dnd",
|
||||
"offline",
|
||||
"gold",
|
||||
"info",
|
||||
],
|
||||
),
|
||||
("Text", &["text", "text-secondary", "text-muted", "text-disabled", "icon"]),
|
||||
("Meter", &["meter-low", "meter-mid", "meter-high", "meter-off"]),
|
||||
];
|
||||
|
||||
/// Icons shown, by the name of the client's file.
|
||||
const ICONS: [&str; 16] = [
|
||||
"mic.svg",
|
||||
"mic-off.svg",
|
||||
"headphones.svg",
|
||||
"volume-2.svg",
|
||||
"settings.svg",
|
||||
"search.svg",
|
||||
"bell.svg",
|
||||
"users.svg",
|
||||
"message-square.svg",
|
||||
"monitor-up.svg",
|
||||
"hash.svg",
|
||||
"lock.svg",
|
||||
"crown.svg",
|
||||
"plus.svg",
|
||||
"x.svg",
|
||||
"check.svg",
|
||||
];
|
||||
|
||||
fn heading(theme: &VoelinTheme, text: &str) -> impl IntoElement {
|
||||
let m = &theme.metrics;
|
||||
div()
|
||||
.text_size(px(m.font_md))
|
||||
.font_weight(FontWeight::SEMIBOLD)
|
||||
.text_color(hsla(theme.colors.text))
|
||||
.child(text.to_owned())
|
||||
}
|
||||
|
||||
fn chip(theme: &VoelinTheme, name: &str, color: Rgba) -> impl IntoElement {
|
||||
let (c, m) = (&theme.colors, &theme.metrics);
|
||||
div()
|
||||
.w(px(100.0))
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(2.0))
|
||||
.child(
|
||||
div()
|
||||
.h(px(24.0))
|
||||
.rounded(px(m.radius_xs))
|
||||
.border_1()
|
||||
.border_color(hsla(c.border_strong))
|
||||
.bg(hsla(color)),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.text_size(px(m.font_xs))
|
||||
.text_color(hsla(c.text_secondary))
|
||||
.child(name.to_owned()),
|
||||
)
|
||||
.child(
|
||||
div().text_size(px(m.font_xs)).text_color(hsla(c.text_muted)).child(color.to_string()),
|
||||
)
|
||||
}
|
||||
|
||||
fn colours(theme: &VoelinTheme) -> impl IntoElement {
|
||||
let (c, m) = (&theme.colors, &theme.metrics);
|
||||
let by_name: HashMap<&str, Rgba> = c.entries().into_iter().collect();
|
||||
let mut column = div().flex().flex_col().gap(px(m.space_4));
|
||||
for (group, names) in GROUPS {
|
||||
let mut row = div().flex().flex_row().flex_wrap().gap(px(m.space_3));
|
||||
for name in names {
|
||||
row = row.child(chip(theme, name, by_name[name]));
|
||||
}
|
||||
column = column.child(
|
||||
div().flex().flex_col().gap(px(m.space_2)).child(heading(theme, group)).child(row),
|
||||
);
|
||||
}
|
||||
column
|
||||
}
|
||||
|
||||
fn radii(theme: &VoelinTheme) -> impl IntoElement {
|
||||
let (c, m) = (&theme.colors, &theme.metrics);
|
||||
let mut row = div().flex().flex_row().gap(px(m.space_4));
|
||||
for (name, radius) in [
|
||||
("xs", m.radius_xs),
|
||||
("sm", m.radius_sm),
|
||||
("md", m.radius_md),
|
||||
("lg", m.radius_lg),
|
||||
("xl", m.radius_xl),
|
||||
("pill", m.radius_pill),
|
||||
] {
|
||||
row = row.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.items_center()
|
||||
.gap(px(m.space_2))
|
||||
.child(
|
||||
div()
|
||||
.size(px(40.0))
|
||||
.rounded(px(radius))
|
||||
.bg(hsla(c.surface_4))
|
||||
.border_1()
|
||||
.border_color(hsla(c.border_popup)),
|
||||
)
|
||||
.child(div().text_size(px(m.font_xs)).text_color(hsla(c.text_muted)).child(name)),
|
||||
);
|
||||
}
|
||||
div().flex().flex_col().gap(px(m.space_3)).child(heading(theme, "Radii")).child(row)
|
||||
}
|
||||
|
||||
fn spacing(theme: &VoelinTheme) -> impl IntoElement {
|
||||
let (c, m) = (&theme.colors, &theme.metrics);
|
||||
let mut rows = div().flex().flex_col().gap(px(m.space_1));
|
||||
for (name, space) in [
|
||||
("space-1", m.space_1),
|
||||
("space-2", m.space_2),
|
||||
("space-3", m.space_3),
|
||||
("space-4", m.space_4),
|
||||
("space-5", m.space_5),
|
||||
("space-6", m.space_6),
|
||||
("space-7", m.space_7),
|
||||
("space-8", m.space_8),
|
||||
] {
|
||||
rows = rows.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.items_center()
|
||||
.gap(px(m.space_3))
|
||||
.child(
|
||||
div()
|
||||
.w(px(56.0))
|
||||
.text_size(px(m.font_xs))
|
||||
.text_color(hsla(c.text_muted))
|
||||
.child(name),
|
||||
)
|
||||
.child(div().h(px(6.0)).w(px(space * 4.0)).rounded(px(2.0)).bg(hsla(c.accent)))
|
||||
.child(
|
||||
div()
|
||||
.text_size(px(m.font_xs))
|
||||
.text_color(hsla(c.text_muted))
|
||||
.child(format!("{space} px")),
|
||||
),
|
||||
);
|
||||
}
|
||||
div().flex().flex_col().gap(px(m.space_3)).child(heading(theme, "Spacing")).child(rows)
|
||||
}
|
||||
|
||||
fn type_scale(theme: &VoelinTheme) -> impl IntoElement {
|
||||
let (c, m) = (&theme.colors, &theme.metrics);
|
||||
let mut rows = div().flex().flex_col();
|
||||
for (name, size, weight) in [
|
||||
("font-3xl", m.font_3xl, FontWeight::BOLD),
|
||||
("font-2xl", m.font_2xl, FontWeight::SEMIBOLD),
|
||||
("font-xl", m.font_xl, FontWeight::SEMIBOLD),
|
||||
("font-lg", m.font_lg, FontWeight::MEDIUM),
|
||||
("font-md", m.font_md, FontWeight::MEDIUM),
|
||||
("font-body", m.font_body, FontWeight::NORMAL),
|
||||
("font-sm", m.font_sm, FontWeight::NORMAL),
|
||||
("font-xs", m.font_xs, FontWeight::NORMAL),
|
||||
] {
|
||||
rows = rows.child(
|
||||
div()
|
||||
.text_size(px(size))
|
||||
.font_weight(weight)
|
||||
.text_color(hsla(c.text))
|
||||
.child(format!("{name} {size}: Raid tonight at 21:00")),
|
||||
);
|
||||
}
|
||||
div().flex().flex_col().gap(px(m.space_3)).child(heading(theme, "Type")).child(rows)
|
||||
}
|
||||
|
||||
fn components(theme: &VoelinTheme) -> impl IntoElement {
|
||||
let m = &theme.metrics;
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(m.space_3))
|
||||
.child(heading(theme, "Components (gpui-component, through ThemeColor)"))
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.flex_wrap()
|
||||
.gap(px(m.space_3))
|
||||
.child(Button::new("primary").primary().label("Primary"))
|
||||
.child(Button::new("secondary").label("Secondary"))
|
||||
.child(Button::new("danger").danger().label("Danger"))
|
||||
.child(Button::new("success").success().label("Success"))
|
||||
.child(Button::new("warning").warning().label("Warning"))
|
||||
.child(Button::new("info").info().label("Info")),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.items_center()
|
||||
.gap(px(m.space_5))
|
||||
.child(Switch::new("on").checked(true))
|
||||
.child(Switch::new("off").checked(false))
|
||||
.child(Checkbox::new("checked").checked(true).label("Checked"))
|
||||
.child(Checkbox::new("unchecked").checked(false).label("Unchecked")),
|
||||
)
|
||||
}
|
||||
|
||||
fn backdrop(theme: &VoelinTheme) -> impl IntoElement {
|
||||
let (c, m, b) = (&theme.colors, &theme.metrics, &theme.backdrop);
|
||||
let [first, _, last] = b.stops;
|
||||
div().flex().flex_col().gap(px(m.space_3)).child(heading(theme, "Backdrop")).child(
|
||||
div()
|
||||
.h(px(36.0))
|
||||
.rounded(px(m.radius_md))
|
||||
.border_1()
|
||||
.border_color(hsla(c.border))
|
||||
.bg(b.to_gpui())
|
||||
.px(px(m.space_3))
|
||||
.py(px(m.space_2))
|
||||
.text_size(px(m.font_xs))
|
||||
.text_color(hsla(c.text_secondary))
|
||||
.child(format!(
|
||||
"{}deg: {} to {}; the middle stop, {} at {}%, is not drawn",
|
||||
b.angle,
|
||||
first.0,
|
||||
last.0,
|
||||
b.stops[1].0,
|
||||
(b.stops[1].1 * 100.0).round()
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
||||
fn icons(theme: &VoelinTheme) -> impl IntoElement {
|
||||
let (c, m) = (&theme.colors, &theme.metrics);
|
||||
let mut row = div().flex().flex_row().flex_wrap().gap(px(m.space_5));
|
||||
for name in ICONS {
|
||||
row = row.child(
|
||||
svg().path(format!("icons/{name}")).size(px(m.icon_lg)).text_color(hsla(c.icon)),
|
||||
);
|
||||
}
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(m.space_3))
|
||||
.child(heading(theme, "Icons (the client's Lucide 1.48, as gpui-component's icons/ paths)"))
|
||||
.child(row)
|
||||
}
|
||||
|
||||
/// The page: the colours on the left, the rest on the right; it scrolls when
|
||||
/// the window is smaller than it.
|
||||
pub fn swatch(theme: &VoelinTheme) -> impl IntoElement {
|
||||
let (c, m) = (&theme.colors, &theme.metrics);
|
||||
div()
|
||||
.id("swatch")
|
||||
.size_full()
|
||||
.overflow_y_scroll()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(m.space_4))
|
||||
.p(px(m.space_6))
|
||||
.bg(hsla(c.bg_app))
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.items_baseline()
|
||||
.gap(px(m.space_4))
|
||||
.child(
|
||||
div()
|
||||
.text_size(px(m.font_2xl))
|
||||
.font_weight(FontWeight::BOLD)
|
||||
.text_color(hsla(c.text))
|
||||
.child("Voelin theme"),
|
||||
)
|
||||
.child(div().text_size(px(m.font_sm)).text_color(hsla(c.text_muted)).child(
|
||||
format!(
|
||||
"{} (setting {}), text size {}",
|
||||
if theme.is_dark() { "dark" } else { "light" },
|
||||
theme.choice().name(),
|
||||
m.font_scale
|
||||
),
|
||||
)),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.gap(px(m.space_8))
|
||||
.child(div().w(px(752.0)).flex_none().child(colours(theme)))
|
||||
.child(
|
||||
div()
|
||||
.w(px(600.0))
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(m.space_4))
|
||||
.child(backdrop(theme))
|
||||
.child(radii(theme))
|
||||
.child(spacing(theme))
|
||||
.child(type_scale(theme))
|
||||
.child(components(theme))
|
||||
.child(icons(theme)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use super::*;
|
||||
use crate::assets::client_icon;
|
||||
use crate::theme::Palette;
|
||||
|
||||
#[test]
|
||||
fn every_colour_token_is_in_exactly_one_group() {
|
||||
let shown: Vec<&str> = GROUPS.iter().flat_map(|(_, names)| names.iter().copied()).collect();
|
||||
let unique: BTreeSet<&str> = shown.iter().copied().collect();
|
||||
assert_eq!(shown.len(), unique.len(), "a token in two groups");
|
||||
let tokens: BTreeSet<&str> = Palette::DARK.entries().into_iter().map(|(n, _)| n).collect();
|
||||
assert_eq!(unique, tokens);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_icons_shown_are_the_clients() {
|
||||
for name in ICONS {
|
||||
assert!(client_icon(name).is_some(), "{name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
//! The second layer of the theme: the colours gpui-component's widgets read,
|
||||
//! written from the Voelin palette. gpui-component's `ThemeColor` is shadcn's
|
||||
//! vocabulary (about 135 colours: a background, a primary, a muted, one set
|
||||
//! for the list, one for the table, one for each kind of button); the
|
||||
//! client's tokens map onto it as docs/ui.md ("The GPUI front end") lists.
|
||||
//! What has no counterpart stays as the registered theme of the mode has it
|
||||
//! (charts' bullish and bearish colours, the cyan and magenta of the base
|
||||
//! palette).
|
||||
//!
|
||||
//! gpui-component's "accent" is a hover background, not a brand colour: the
|
||||
//! client's `accent` is its `primary`.
|
||||
|
||||
use gpui_kit::Hsla;
|
||||
use gpui_kit::component::ThemeColor;
|
||||
|
||||
use super::tokens::{Palette, Rgba};
|
||||
|
||||
/// A palette colour as GPUI's.
|
||||
pub fn hsla(color: Rgba) -> Hsla {
|
||||
gpui_kit::rgba(color.0).into()
|
||||
}
|
||||
|
||||
/// Of `base`, the colours a status button needs: hover, active, and a text
|
||||
/// that reads on it (white or the window's ink, whichever contrasts more).
|
||||
struct Status {
|
||||
base: Hsla,
|
||||
hover: Hsla,
|
||||
active: Hsla,
|
||||
foreground: Hsla,
|
||||
}
|
||||
|
||||
fn status(base: Rgba, ink: Rgba, dark: bool) -> Status {
|
||||
let toward_hover = if dark { Rgba(0xffff_ffff) } else { Rgba(0x0000_00ff) };
|
||||
Status {
|
||||
base: hsla(base),
|
||||
hover: hsla(base.mix(toward_hover, 0.14)),
|
||||
active: hsla(base.mix(Rgba(0x0000_00ff), 0.18)),
|
||||
foreground: hsla(base.readable(ink)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Write the palette's colours into `colors`, over what the registered theme
|
||||
/// of the mode left there. Every field that gpui-component's themes derive
|
||||
/// from another (the buttons fall back to `primary`, `danger`, ...) is written
|
||||
/// too, so that none keeps the default theme's blue.
|
||||
pub fn write(p: &Palette, dark: bool, colors: &mut ThemeColor) {
|
||||
let c = colors;
|
||||
let h = hsla;
|
||||
let clear = Hsla::transparent_black();
|
||||
|
||||
// The window and its text.
|
||||
c.background = h(p.bg_app);
|
||||
c.foreground = h(p.text);
|
||||
c.border = h(p.border);
|
||||
c.input = h(p.border_strong);
|
||||
c.ring = h(p.glow);
|
||||
c.overlay = h(p.scrim);
|
||||
c.window_border = h(p.border);
|
||||
c.caret = h(p.text);
|
||||
c.selection = h(p.accent_soft);
|
||||
c.drag_border = h(p.accent);
|
||||
c.drop_target = h(p.accent_soft);
|
||||
|
||||
// Links: one colour for all three states, as the client has one.
|
||||
c.link = h(p.accent_text);
|
||||
c.link_hover = h(p.accent_text);
|
||||
c.link_active = h(p.accent_text);
|
||||
|
||||
// The brand colour, and gpui-component's hover "accent".
|
||||
c.primary = h(p.accent);
|
||||
c.primary_hover = h(p.accent_hover);
|
||||
c.primary_active = h(p.accent_pressed);
|
||||
c.primary_foreground = h(p.on_accent);
|
||||
c.accent = h(p.surface_3);
|
||||
c.accent_foreground = h(p.text);
|
||||
|
||||
// Cards, inputs, menus, popovers.
|
||||
c.secondary = h(p.surface_2);
|
||||
c.secondary_hover = h(p.surface_3);
|
||||
c.secondary_active = h(p.surface_4);
|
||||
c.secondary_foreground = h(p.text);
|
||||
c.muted = h(p.surface_2);
|
||||
c.muted_foreground = h(p.text_muted);
|
||||
c.popover = h(p.surface_3);
|
||||
c.popover_foreground = h(p.text);
|
||||
c.group_box = h(p.surface_2);
|
||||
c.group_box_foreground = h(p.text);
|
||||
c.accordion = h(p.surface_2);
|
||||
c.description_list_label = h(p.surface_2);
|
||||
c.description_list_label_foreground = h(p.text_secondary);
|
||||
|
||||
// The status colours, with the text that reads on each.
|
||||
let [danger, success, warning, info] =
|
||||
[p.danger, p.success, p.warning, p.info].map(|base| status(base, p.bg_app, dark));
|
||||
(c.danger, c.danger_hover, c.danger_active, c.danger_foreground) =
|
||||
(danger.base, danger.hover, danger.active, danger.foreground);
|
||||
(c.success, c.success_hover, c.success_active, c.success_foreground) =
|
||||
(success.base, success.hover, success.active, success.foreground);
|
||||
(c.warning, c.warning_hover, c.warning_active, c.warning_foreground) =
|
||||
(warning.base, warning.hover, warning.active, warning.foreground);
|
||||
(c.info, c.info_hover, c.info_active, c.info_foreground) =
|
||||
(info.base, info.hover, info.active, info.foreground);
|
||||
|
||||
// Lists and tables: rows on the panel, hovered rows raised, the selected
|
||||
// row the soft accent with the accent's edge.
|
||||
c.list = h(p.surface);
|
||||
c.list_hover = h(p.surface_3);
|
||||
c.list_active = h(p.accent_soft);
|
||||
c.list_active_border = h(p.accent);
|
||||
c.list_even = h(p.surface);
|
||||
c.list_head = h(p.surface_2);
|
||||
c.table = h(p.surface);
|
||||
c.table_hover = h(p.surface_3);
|
||||
c.table_active = h(p.accent_soft);
|
||||
c.table_active_border = h(p.accent);
|
||||
c.table_even = h(p.surface);
|
||||
c.table_head = h(p.surface_2);
|
||||
c.table_head_foreground = h(p.text_secondary);
|
||||
c.table_foot = h(p.surface_2);
|
||||
c.table_foot_foreground = h(p.text_secondary);
|
||||
c.table_row_border = h(p.border);
|
||||
|
||||
// The panels around the content: the sidebar, the title and status bars.
|
||||
c.sidebar = h(p.surface);
|
||||
c.sidebar_foreground = h(p.text);
|
||||
c.sidebar_border = h(p.border);
|
||||
c.sidebar_accent = h(p.surface_3);
|
||||
c.sidebar_accent_foreground = h(p.text);
|
||||
c.sidebar_primary = h(p.accent);
|
||||
c.sidebar_primary_foreground = h(p.on_accent);
|
||||
c.title_bar = h(p.surface);
|
||||
c.title_bar_border = h(p.border);
|
||||
c.status_bar = h(p.surface);
|
||||
c.status_bar_border = h(p.border);
|
||||
|
||||
// Small widgets.
|
||||
c.scrollbar = clear;
|
||||
c.scrollbar_thumb = h(p.border_strong);
|
||||
c.scrollbar_thumb_hover = h(p.text_muted);
|
||||
c.slider_bar = h(p.accent);
|
||||
c.slider_thumb = h(p.on_accent);
|
||||
c.switch = h(p.surface_4);
|
||||
c.switch_thumb = h(p.on_accent);
|
||||
c.progress_bar = h(p.accent);
|
||||
c.skeleton = h(p.surface_3);
|
||||
c.tab = clear;
|
||||
c.tab_active = h(p.surface_2);
|
||||
c.tab_active_foreground = h(p.text);
|
||||
c.tab_bar = h(p.surface);
|
||||
c.tab_bar_segmented = h(p.surface_2);
|
||||
c.tab_foreground = h(p.text_secondary);
|
||||
|
||||
// The base palette and the charts: the client's state colours.
|
||||
c.red = h(p.danger);
|
||||
c.red_light = h(p.danger_soft);
|
||||
c.green = h(p.success);
|
||||
c.green_light = h(p.success_soft);
|
||||
c.yellow = h(p.warning);
|
||||
c.yellow_light = h(p.warning_soft);
|
||||
c.blue = h(p.info);
|
||||
c.blue_light = h(p.accent_soft);
|
||||
c.chart_1 = h(p.accent);
|
||||
c.chart_2 = h(p.success);
|
||||
c.chart_3 = h(p.warning);
|
||||
c.chart_4 = h(p.danger);
|
||||
c.chart_5 = h(p.info);
|
||||
|
||||
// The buttons: what a theme file leaves out they take from the colours
|
||||
// above, so they are written from them here.
|
||||
c.button = c.secondary;
|
||||
c.button_hover = c.secondary_hover;
|
||||
c.button_active = c.secondary_active;
|
||||
c.button_foreground = c.secondary_foreground;
|
||||
c.button_primary = c.primary;
|
||||
c.button_primary_hover = c.primary_hover;
|
||||
c.button_primary_active = c.primary_active;
|
||||
c.button_primary_foreground = c.primary_foreground;
|
||||
c.button_secondary = c.secondary;
|
||||
c.button_secondary_hover = c.secondary_hover;
|
||||
c.button_secondary_active = c.secondary_active;
|
||||
c.button_secondary_foreground = c.secondary_foreground;
|
||||
c.button_danger = c.danger;
|
||||
c.button_danger_hover = c.danger_hover;
|
||||
c.button_danger_active = c.danger_active;
|
||||
c.button_danger_foreground = c.danger_foreground;
|
||||
c.button_success = c.success;
|
||||
c.button_success_hover = c.success_hover;
|
||||
c.button_success_active = c.success_active;
|
||||
c.button_success_foreground = c.success_foreground;
|
||||
c.button_warning = c.warning;
|
||||
c.button_warning_hover = c.warning_hover;
|
||||
c.button_warning_active = c.warning_active;
|
||||
c.button_warning_foreground = c.warning_foreground;
|
||||
c.button_info = c.info;
|
||||
c.button_info_hover = c.info_hover;
|
||||
c.button_info_active = c.info_active;
|
||||
c.button_info_foreground = c.info_foreground;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn written(dark: bool) -> (Palette, ThemeColor) {
|
||||
let palette = if dark { Palette::DARK } else { Palette::LIGHT };
|
||||
let mut colors = ThemeColor::default();
|
||||
write(&palette, dark, &mut colors);
|
||||
(palette, colors)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_client_tokens_land_where_the_table_says() {
|
||||
for dark in [true, false] {
|
||||
let (p, c) = written(dark);
|
||||
assert_eq!(c.background, hsla(p.bg_app));
|
||||
assert_eq!(c.foreground, hsla(p.text));
|
||||
assert_eq!(c.primary, hsla(p.accent));
|
||||
assert_eq!(c.primary_hover, hsla(p.accent_hover));
|
||||
assert_eq!(c.primary_active, hsla(p.accent_pressed));
|
||||
assert_eq!(c.primary_foreground, hsla(p.on_accent));
|
||||
assert_eq!(
|
||||
c.accent,
|
||||
hsla(p.surface_3),
|
||||
"gpui-component's accent is a hover background"
|
||||
);
|
||||
assert_eq!(c.secondary, hsla(p.surface_2));
|
||||
assert_eq!(c.secondary_active, hsla(p.surface_4));
|
||||
assert_eq!(c.border, hsla(p.border));
|
||||
assert_eq!(c.input, hsla(p.border_strong));
|
||||
assert_eq!(c.ring, hsla(p.glow));
|
||||
assert_eq!(c.overlay, hsla(p.scrim));
|
||||
assert_eq!(c.list_active, hsla(p.accent_soft));
|
||||
assert_eq!(c.link, hsla(p.accent_text));
|
||||
assert_eq!(c.muted_foreground, hsla(p.text_muted));
|
||||
assert_eq!(c.sidebar, hsla(p.surface));
|
||||
assert_eq!(c.danger, hsla(p.danger));
|
||||
assert_eq!(c.success, hsla(p.success));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_buttons_follow_the_colours_they_fall_back_to() {
|
||||
let (_, c) = written(true);
|
||||
assert_eq!(c.button_primary, c.primary);
|
||||
assert_eq!(c.button_primary_hover, c.primary_hover);
|
||||
assert_eq!(c.button_danger_foreground, c.danger_foreground);
|
||||
assert_eq!(c.button, c.secondary);
|
||||
assert_eq!(c.button_info_active, c.info_active);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_text_on_a_status_colour_is_the_one_that_reads_better() {
|
||||
for (p, dark) in [(Palette::DARK, true), (Palette::LIGHT, false)] {
|
||||
for base in [p.danger, p.success, p.warning, p.info] {
|
||||
let s = status(base, p.bg_app, dark);
|
||||
let chosen = base.readable(p.bg_app);
|
||||
let other = if chosen == Rgba(0xffff_ffff) { p.bg_app } else { Rgba(0xffff_ffff) };
|
||||
assert!(base.contrast(chosen) >= base.contrast(other), "{base} on {chosen}");
|
||||
assert_eq!(s.foreground, hsla(chosen));
|
||||
assert_ne!(s.hover, s.base);
|
||||
assert_ne!(s.active, s.base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mixing_and_contrast_do_what_they_say() {
|
||||
let (black, white) = (Rgba(0x0000_00ff), Rgba(0xffff_ffff));
|
||||
assert_eq!(black.mix(white, 0.0), black);
|
||||
assert_eq!(black.mix(white, 1.0), white);
|
||||
assert_eq!(Rgba(0x1020_30c0).mix(white, 0.0), Rgba(0x1020_30c0), "opacity stays");
|
||||
assert!((black.contrast(white) - 21.0).abs() < 0.01);
|
||||
assert_eq!(black.readable(black), white);
|
||||
assert_eq!(Rgba(0xf5b3_01ff).readable(Rgba(0x060a_18ff)), Rgba(0x060a_18ff));
|
||||
assert_eq!(Rgba(0x12ab_34ff).to_string(), "#12ab34");
|
||||
assert_eq!(Rgba(0x12ab_3480).to_string(), "#12ab3480");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
//! The Voelin theme, in two layers (docs/ui.md, "The GPUI front end"):
|
||||
//!
|
||||
//! 1. [`VoelinTheme`], a GPUI global with every token of
|
||||
//! `crates/voelin-ui/ui/theme.slint`, light and dark ([`tokens`]), which a
|
||||
//! test keeps equal to the Slint file ([`slint_parity`]). The shell's own
|
||||
//! elements (the server rail, presence dots, meters, the backdrop) read it.
|
||||
//! 2. gpui-component's `ThemeColor`, the colours its widgets (inputs, lists,
|
||||
//! menus, dialogs) read, written from the first on every change
|
||||
//! ([`components`]), so that they look like ours.
|
||||
//!
|
||||
//! The mode is the client's `ui.theme`: `system` follows the window's
|
||||
//! appearance (and its changes), `light` and `dark` do not.
|
||||
|
||||
mod components;
|
||||
#[cfg(test)]
|
||||
mod slint_parity;
|
||||
pub mod tokens;
|
||||
|
||||
pub use components::hsla;
|
||||
use gpui_kit::component::{Theme, ThemeMode};
|
||||
use gpui_kit::{App, Background, Global, WindowAppearance, linear_color_stop, linear_gradient, px};
|
||||
pub use tokens::{Backdrop, FONT_FAMILY, Metrics, Palette, Rgba};
|
||||
|
||||
impl Backdrop {
|
||||
/// What GPUI draws: its gradient has two colour stops, so the first and the
|
||||
/// last of the three; the middle one is not drawn.
|
||||
pub fn to_gpui(&self) -> Background {
|
||||
let [first, _, last] = self.stops;
|
||||
linear_gradient(
|
||||
self.angle,
|
||||
linear_color_stop(hsla(first.0), first.1),
|
||||
linear_color_stop(hsla(last.0), last.1),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// The theme mode setting (`ui.theme` of the Slint front end).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum Choice {
|
||||
/// Follow the window's appearance.
|
||||
System,
|
||||
/// Always light.
|
||||
Light,
|
||||
/// Always dark.
|
||||
Dark,
|
||||
}
|
||||
|
||||
impl Choice {
|
||||
/// `system`, `light` or `dark`.
|
||||
pub fn parse(text: &str) -> Option<Self> {
|
||||
match text {
|
||||
"system" => Some(Self::System),
|
||||
"light" => Some(Self::Light),
|
||||
"dark" => Some(Self::Dark),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The setting's value.
|
||||
pub fn name(self) -> &'static str {
|
||||
match self {
|
||||
Self::System => "system",
|
||||
Self::Light => "light",
|
||||
Self::Dark => "dark",
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the theme is dark, given whether the window's appearance is.
|
||||
pub fn resolve(self, system_dark: bool) -> bool {
|
||||
match self {
|
||||
Self::System => system_dark,
|
||||
Self::Light => false,
|
||||
Self::Dark => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a window's appearance is a dark one.
|
||||
pub fn is_dark(appearance: WindowAppearance) -> bool {
|
||||
matches!(appearance, WindowAppearance::Dark | WindowAppearance::VibrantDark)
|
||||
}
|
||||
|
||||
/// Every token of `theme.slint` for the resolved mode and text size; a GPUI
|
||||
/// global.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct VoelinTheme {
|
||||
choice: Choice,
|
||||
dark: bool,
|
||||
/// The colours of the resolved mode.
|
||||
pub colors: Palette,
|
||||
/// The window's backdrop gradient of the resolved mode.
|
||||
pub backdrop: Backdrop,
|
||||
/// The sizes, radii, type and durations at the text size factor.
|
||||
pub metrics: Metrics,
|
||||
}
|
||||
|
||||
impl Global for VoelinTheme {}
|
||||
|
||||
impl VoelinTheme {
|
||||
/// The tokens for a mode (resolved against `system_dark`) and a text size
|
||||
/// factor.
|
||||
pub fn new(choice: Choice, system_dark: bool, font_scale: f32) -> Self {
|
||||
let dark = choice.resolve(system_dark);
|
||||
Self {
|
||||
choice,
|
||||
dark,
|
||||
colors: if dark { Palette::DARK } else { Palette::LIGHT },
|
||||
backdrop: if dark { Backdrop::DARK } else { Backdrop::LIGHT },
|
||||
metrics: Metrics::new(font_scale),
|
||||
}
|
||||
}
|
||||
|
||||
/// The theme mode that was set.
|
||||
pub fn choice(&self) -> Choice {
|
||||
self.choice
|
||||
}
|
||||
|
||||
/// Whether the colours are the dark ones.
|
||||
pub fn is_dark(&self) -> bool {
|
||||
self.dark
|
||||
}
|
||||
|
||||
/// Install the theme as the global and write it into gpui-component, which
|
||||
/// `gpui_kit::init` must have set up. `appearance` is the window's (or
|
||||
/// the system's before there is a window).
|
||||
pub fn init(cx: &mut App, choice: Choice, appearance: WindowAppearance, font_scale: f32) {
|
||||
cx.set_global(Self::new(choice, is_dark(appearance), font_scale));
|
||||
Self::apply(cx);
|
||||
}
|
||||
|
||||
/// The theme global.
|
||||
pub fn global(cx: &App) -> &Self {
|
||||
cx.global::<Self>()
|
||||
}
|
||||
|
||||
/// Change the mode (a setting changed), given the window's appearance now.
|
||||
pub fn set_choice(cx: &mut App, choice: Choice, appearance: WindowAppearance) {
|
||||
let (scale, current) = {
|
||||
let this = Self::global(cx);
|
||||
(this.metrics.font_scale, this.choice)
|
||||
};
|
||||
if current == choice && Self::global(cx).dark == choice.resolve(is_dark(appearance)) {
|
||||
return;
|
||||
}
|
||||
cx.set_global(Self::new(choice, is_dark(appearance), scale));
|
||||
Self::apply(cx);
|
||||
}
|
||||
|
||||
/// The window's appearance changed; it matters only in `system` mode.
|
||||
pub fn set_system_appearance(cx: &mut App, appearance: WindowAppearance) {
|
||||
let this = Self::global(cx);
|
||||
if this.choice == Choice::System && this.dark != is_dark(appearance) {
|
||||
let (choice, scale) = (this.choice, this.metrics.font_scale);
|
||||
cx.set_global(Self::new(choice, is_dark(appearance), scale));
|
||||
Self::apply(cx);
|
||||
}
|
||||
}
|
||||
|
||||
/// The text size factor changed (`ui.font_scale`).
|
||||
pub fn set_font_scale(cx: &mut App, font_scale: f32) {
|
||||
let this = Self::global(cx);
|
||||
if (this.metrics.font_scale - font_scale).abs() < f32::EPSILON {
|
||||
return;
|
||||
}
|
||||
// `dark` is what the mode resolved to: for every mode, resolving it again
|
||||
// against it gives the same.
|
||||
let (choice, dark) = (this.choice, this.dark);
|
||||
cx.set_global(Self::new(choice, dark, font_scale));
|
||||
Self::apply(cx);
|
||||
}
|
||||
|
||||
/// Write the global into gpui-component's theme: the mode, the colours of
|
||||
/// the second layer, the font, the base size and the radii.
|
||||
fn apply(cx: &mut App) {
|
||||
let this = Self::global(cx).clone();
|
||||
// The registered theme of the mode first (it sets whatever the second
|
||||
// layer leaves alone), then our colours over it in a second update, as
|
||||
// `Theme::update` says a mode change must be.
|
||||
Theme::change(if this.dark { ThemeMode::Dark } else { ThemeMode::Light }, None, cx);
|
||||
Theme::update(cx, |theme| {
|
||||
components::write(&this.colors, this.dark, &mut theme.colors);
|
||||
theme.font_family = FONT_FAMILY.into();
|
||||
theme.font_size = px(this.metrics.font_body);
|
||||
theme.radius = px(this.metrics.radius_sm);
|
||||
theme.radius_lg = px(this.metrics.radius_lg);
|
||||
});
|
||||
// Where the platform draws the window's frame itself (macOS), it follows
|
||||
// the mode; elsewhere this does nothing.
|
||||
cx.set_window_appearance(match this.choice {
|
||||
Choice::System => None,
|
||||
Choice::Light => Some(WindowAppearance::Light),
|
||||
Choice::Dark => Some(WindowAppearance::Dark),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use gpui::TestAppContext;
|
||||
use gpui_kit::component::ActiveTheme as _;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn start(cx: &mut TestAppContext, choice: Choice, appearance: WindowAppearance) {
|
||||
cx.update(|cx| {
|
||||
gpui_kit::init(cx);
|
||||
VoelinTheme::init(cx, choice, appearance, 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_mode_resolves_against_the_window() {
|
||||
assert!(Choice::System.resolve(true) && !Choice::System.resolve(false));
|
||||
assert!(Choice::Dark.resolve(false) && !Choice::Light.resolve(true));
|
||||
for choice in [Choice::System, Choice::Light, Choice::Dark] {
|
||||
assert_eq!(Choice::parse(choice.name()), Some(choice));
|
||||
}
|
||||
assert_eq!(Choice::parse("blue"), None);
|
||||
assert!(is_dark(WindowAppearance::VibrantDark) && !is_dark(WindowAppearance::VibrantLight));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_backdrop_draws_the_first_and_the_last_of_its_three_stops() {
|
||||
let b = Backdrop::DARK;
|
||||
let [first, middle, last] = b.stops;
|
||||
assert_eq!(
|
||||
b.to_gpui(),
|
||||
linear_gradient(
|
||||
160.0,
|
||||
linear_color_stop(hsla(first.0), 0.0),
|
||||
linear_color_stop(hsla(last.0), 1.0)
|
||||
)
|
||||
);
|
||||
assert_ne!(
|
||||
b.to_gpui(),
|
||||
linear_gradient(
|
||||
160.0,
|
||||
linear_color_stop(hsla(first.0), 0.0),
|
||||
linear_color_stop(hsla(middle.0), 1.0)
|
||||
),
|
||||
"the middle stop is not the end one"
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn the_tokens_reach_gpui_component(cx: &mut TestAppContext) {
|
||||
start(cx, Choice::Dark, WindowAppearance::Light);
|
||||
cx.update(|cx| {
|
||||
let theme = cx.theme();
|
||||
assert!(theme.is_dark());
|
||||
assert_eq!(theme.colors.primary, hsla(Palette::DARK.accent));
|
||||
assert_eq!(theme.colors.background, hsla(Palette::DARK.bg_app));
|
||||
assert_eq!(theme.colors.button_primary, hsla(Palette::DARK.accent));
|
||||
assert_eq!(theme.font_family.as_ref(), "Inter");
|
||||
assert_eq!(theme.font_size, px(14.0));
|
||||
assert_eq!(theme.radius, px(6.0));
|
||||
assert_eq!(theme.radius_lg, px(12.0));
|
||||
assert_eq!(VoelinTheme::global(cx).colors, Palette::DARK);
|
||||
assert_eq!(VoelinTheme::global(cx).backdrop, Backdrop::DARK);
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn system_follows_the_window_appearance_and_light_and_dark_do_not(cx: &mut TestAppContext) {
|
||||
start(cx, Choice::System, WindowAppearance::Light);
|
||||
let primary = |cx: &mut TestAppContext| cx.update(|cx| cx.theme().colors.primary);
|
||||
assert_eq!(primary(cx), hsla(Palette::LIGHT.accent));
|
||||
cx.update(|cx| VoelinTheme::set_system_appearance(cx, WindowAppearance::Dark));
|
||||
assert_eq!(primary(cx), hsla(Palette::DARK.accent));
|
||||
cx.update(|cx| VoelinTheme::set_system_appearance(cx, WindowAppearance::VibrantLight));
|
||||
assert_eq!(primary(cx), hsla(Palette::LIGHT.accent));
|
||||
|
||||
cx.update(|cx| VoelinTheme::set_choice(cx, Choice::Dark, WindowAppearance::Light));
|
||||
assert_eq!(primary(cx), hsla(Palette::DARK.accent));
|
||||
cx.update(|cx| VoelinTheme::set_system_appearance(cx, WindowAppearance::Light));
|
||||
assert_eq!(primary(cx), hsla(Palette::DARK.accent), "a dark choice ignores the window");
|
||||
cx.update(|cx| VoelinTheme::set_choice(cx, Choice::Light, WindowAppearance::Dark));
|
||||
assert_eq!(primary(cx), hsla(Palette::LIGHT.accent), "so does a light one");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn the_text_size_scales_the_type_and_the_controls(cx: &mut TestAppContext) {
|
||||
start(cx, Choice::Dark, WindowAppearance::Dark);
|
||||
cx.update(|cx| VoelinTheme::set_font_scale(cx, 1.25));
|
||||
cx.update(|cx| {
|
||||
let theme = VoelinTheme::global(cx);
|
||||
assert!(theme.is_dark(), "the mode stays");
|
||||
assert_eq!(theme.metrics.font_body, 17.5);
|
||||
assert_eq!(theme.metrics.control_height, 45.0);
|
||||
assert_eq!(cx.theme().font_size, px(17.5));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
//! `crates/voelin-ui/ui/theme.slint` against `tokens.rs`: the Slint file is
|
||||
//! read and every token in it is compared with the Rust value of the same
|
||||
//! name, light and dark and at four text sizes; a token on one side only, a
|
||||
//! value that differs, or a declaration of a kind this test does not know
|
||||
//! (or a second brush or string, of which it knows `backdrop`, `mode` and
|
||||
//! `font-family`) fails it. While both front ends live, a token changed in
|
||||
//! one place and not the other is caught here.
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use super::tokens::{Backdrop, FONT_FAMILY, Metrics, Palette, Rgba};
|
||||
|
||||
const SLINT: &str = include_str!("../../../voelin-ui/ui/theme.slint");
|
||||
|
||||
/// What `theme.slint` declares: the kind and the expression of each property
|
||||
/// of the `Theme` global, in file order.
|
||||
fn declarations() -> Vec<(String, String, String)> {
|
||||
declarations_of(SLINT)
|
||||
}
|
||||
|
||||
/// The same for the text of a `.slint` file (the tests below also read
|
||||
/// altered copies of `theme.slint`).
|
||||
fn declarations_of(source: &str) -> Vec<(String, String, String)> {
|
||||
let without_comments: String = source
|
||||
.lines()
|
||||
.map(|line| line.split("//").next().unwrap_or(""))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
let body = without_comments.split_once("export global Theme {").expect("the Theme global").1;
|
||||
let mut found = Vec::new();
|
||||
for statement in body.split(';') {
|
||||
let statement = statement.trim();
|
||||
let Some(rest) = ["in-out property", "out property", "in property"]
|
||||
.iter()
|
||||
.find_map(|prefix| statement.strip_prefix(prefix))
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let (kind, rest) =
|
||||
rest.trim().strip_prefix('<').expect("<kind>").split_once('>').expect("<kind>");
|
||||
let (name, expr) = rest.trim().split_once(':').expect("name: expression");
|
||||
// One line, single spaces: `backdrop` is written over several.
|
||||
let expr = expr.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
found.push((name.trim().to_owned(), kind.trim().to_owned(), expr));
|
||||
}
|
||||
found
|
||||
}
|
||||
|
||||
/// `#rgb`-style literal as `Rgba`.
|
||||
fn colour(text: &str) -> Rgba {
|
||||
let hex = text.trim().strip_prefix('#').unwrap_or_else(|| panic!("a colour, not {text:?}"));
|
||||
let value = u32::from_str_radix(hex, 16).unwrap_or_else(|_| panic!("hex digits in {text:?}"));
|
||||
match hex.len() {
|
||||
6 => Rgba(value << 8 | 0xff),
|
||||
8 => Rgba(value),
|
||||
_ => panic!("#rrggbb or #rrggbbaa, not {text:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Split `dark ? A : B` at its top-level `?` and `:`; `A` for a plain `A`.
|
||||
fn by_mode(expr: &str) -> (String, String) {
|
||||
let Some(rest) = expr.strip_prefix("dark ?") else {
|
||||
return (expr.to_owned(), expr.to_owned());
|
||||
};
|
||||
let mut depth = 0;
|
||||
for (i, c) in rest.char_indices() {
|
||||
match c {
|
||||
'(' => depth += 1,
|
||||
')' => depth -= 1,
|
||||
':' if depth == 0 => {
|
||||
return (rest[..i].trim().to_owned(), rest[i + 1..].trim().to_owned());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
panic!("no `:` in {expr:?}");
|
||||
}
|
||||
|
||||
/// The arithmetic of the length tokens: numbers with a unit, other tokens,
|
||||
/// `*`, `+`, `max(a, b)` and parentheses.
|
||||
struct Eval<'a> {
|
||||
tokens: Vec<String>,
|
||||
at: usize,
|
||||
env: &'a BTreeMap<String, String>,
|
||||
scale: f64,
|
||||
}
|
||||
|
||||
impl<'a> Eval<'a> {
|
||||
fn run(expr: &str, env: &'a BTreeMap<String, String>, scale: f64) -> f64 {
|
||||
let mut tokens = Vec::new();
|
||||
let mut word = String::new();
|
||||
for c in expr.chars() {
|
||||
if c.is_alphanumeric() || matches!(c, '-' | '.' | '%') {
|
||||
word.push(c);
|
||||
} else {
|
||||
if !word.is_empty() {
|
||||
tokens.push(std::mem::take(&mut word));
|
||||
}
|
||||
if !c.is_whitespace() {
|
||||
tokens.push(c.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
if !word.is_empty() {
|
||||
tokens.push(word);
|
||||
}
|
||||
let mut eval = Eval { tokens, at: 0, env, scale };
|
||||
let value = eval.sum();
|
||||
assert_eq!(eval.at, eval.tokens.len(), "all of {expr:?} is read");
|
||||
value
|
||||
}
|
||||
|
||||
fn peek(&self) -> Option<&str> {
|
||||
self.tokens.get(self.at).map(String::as_str)
|
||||
}
|
||||
|
||||
fn take(&mut self) -> String {
|
||||
self.at += 1;
|
||||
self.tokens[self.at - 1].clone()
|
||||
}
|
||||
|
||||
fn sum(&mut self) -> f64 {
|
||||
let mut value = self.product();
|
||||
while self.peek() == Some("+") {
|
||||
self.take();
|
||||
value += self.product();
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
fn product(&mut self) -> f64 {
|
||||
let mut value = self.factor();
|
||||
while self.peek() == Some("*") {
|
||||
self.take();
|
||||
value *= self.factor();
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
fn factor(&mut self) -> f64 {
|
||||
let token = self.take();
|
||||
if token == "(" {
|
||||
let value = self.sum();
|
||||
assert_eq!(self.take(), ")");
|
||||
return value;
|
||||
}
|
||||
if token == "max" {
|
||||
assert_eq!(self.take(), "(");
|
||||
let a = self.sum();
|
||||
assert_eq!(self.take(), ",");
|
||||
let b = self.sum();
|
||||
assert_eq!(self.take(), ")");
|
||||
return a.max(b);
|
||||
}
|
||||
if token == "font-scale" {
|
||||
return self.scale;
|
||||
}
|
||||
if token.starts_with(|c: char| c.is_ascii_digit()) {
|
||||
let number: String =
|
||||
token.chars().take_while(|c| c.is_ascii_digit() || *c == '.').collect();
|
||||
return number.parse().unwrap_or_else(|_| panic!("a number in {token:?}"));
|
||||
}
|
||||
let expr =
|
||||
self.env.get(&token).unwrap_or_else(|| panic!("a token named {token:?}")).clone();
|
||||
Eval::run(&expr, self.env, self.scale)
|
||||
}
|
||||
}
|
||||
|
||||
/// The names `theme.slint` declares that are state, not tokens: the mode and
|
||||
/// what it resolves to, and the text size factor (the factor is a parameter
|
||||
/// of [`Metrics`]).
|
||||
const STATE: [&str; 4] = ["mode", "system-dark", "dark", "font-scale"];
|
||||
|
||||
#[test]
|
||||
fn every_colour_is_the_same_in_both_files() {
|
||||
let slint: Vec<(String, String, String)> =
|
||||
declarations().into_iter().filter(|(_, kind, _)| kind == "color").collect();
|
||||
assert!(slint.len() > 40, "the colours were found: {}", slint.len());
|
||||
let dark: BTreeMap<_, _> = Palette::DARK.entries().into_iter().collect();
|
||||
let light: BTreeMap<_, _> = Palette::LIGHT.entries().into_iter().collect();
|
||||
let mut names = BTreeSet::new();
|
||||
for (name, _, expr) in &slint {
|
||||
let (d, l) = by_mode(expr);
|
||||
assert_eq!(dark.get(name.as_str()), Some(&colour(&d)), "{name} (dark)");
|
||||
assert_eq!(light.get(name.as_str()), Some(&colour(&l)), "{name} (light)");
|
||||
names.insert(name.as_str());
|
||||
}
|
||||
let ours: BTreeSet<&str> = dark.keys().copied().collect();
|
||||
assert_eq!(ours, names, "colours in tokens.rs and not in theme.slint, or the other way");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_length_weight_and_duration_is_the_same_in_both_files() {
|
||||
let all = declarations();
|
||||
let env: BTreeMap<String, String> =
|
||||
all.iter().map(|(name, _, expr)| (name.clone(), expr.clone())).collect();
|
||||
let numeric: Vec<&(String, String, String)> = all
|
||||
.iter()
|
||||
.filter(|(name, kind, _)| {
|
||||
matches!(kind.as_str(), "length" | "int" | "duration")
|
||||
&& !STATE.contains(&name.as_str())
|
||||
})
|
||||
.collect();
|
||||
assert!(numeric.len() > 30, "the numbers were found: {}", numeric.len());
|
||||
for scale in [1.0_f32, 1.25, 0.8, 2.0] {
|
||||
let ours: BTreeMap<&str, f64> = Metrics::new(scale).entries().into_iter().collect();
|
||||
let mut names = BTreeSet::new();
|
||||
for (name, _, expr) in &numeric {
|
||||
let slint = Eval::run(expr, &env, f64::from(scale));
|
||||
let ours = *ours.get(name.as_str()).unwrap_or_else(|| panic!("{name} is in tokens.rs"));
|
||||
assert!(
|
||||
(slint - ours).abs() < 1e-3,
|
||||
"{name} at {scale}: theme.slint {slint}, tokens.rs {ours}"
|
||||
);
|
||||
names.insert(name.as_str());
|
||||
}
|
||||
let rust: BTreeSet<&str> = ours.keys().copied().collect();
|
||||
assert_eq!(rust, names, "numbers in tokens.rs and not in theme.slint, or the other way");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_backdrop_and_the_font_are_the_same_in_both_files() {
|
||||
let all = declarations();
|
||||
let get = |name: &str| {
|
||||
all.iter().find(|(n, _, _)| n == name).unwrap_or_else(|| panic!("{name}")).2.clone()
|
||||
};
|
||||
let gradient = |text: &str| -> Backdrop {
|
||||
let inner = text
|
||||
.trim()
|
||||
.strip_prefix("@linear-gradient(")
|
||||
.and_then(|t| t.strip_suffix(')'))
|
||||
.unwrap_or_else(|| panic!("a linear gradient, not {text:?}"));
|
||||
let mut parts = inner.split(',').map(str::trim);
|
||||
let angle: f32 = parts.next().unwrap().trim_end_matches("deg").parse().unwrap();
|
||||
let stops: Vec<(Rgba, f32)> = parts
|
||||
.map(|stop| {
|
||||
let (colour_text, position) = stop.split_once(' ').unwrap();
|
||||
let percent: f32 = position.trim().trim_end_matches('%').parse().unwrap();
|
||||
(colour(colour_text), percent / 100.0)
|
||||
})
|
||||
.collect();
|
||||
Backdrop { angle, stops: stops.try_into().expect("three stops") }
|
||||
};
|
||||
let (dark, light) = by_mode(&get("backdrop"));
|
||||
assert_eq!(gradient(&dark), Backdrop::DARK);
|
||||
assert_eq!(gradient(&light), Backdrop::LIGHT);
|
||||
assert_eq!(get("font-family"), format!("\"{FONT_FAMILY}\""));
|
||||
}
|
||||
|
||||
/// What the declarations hold that no comparison above covers, one sentence
|
||||
/// each; empty when there is none: a kind of declaration this test does not
|
||||
/// know, a brush other than `backdrop` or a string other than `mode` and
|
||||
/// `font-family` (the two comparisons of those go by name, so a second one
|
||||
/// would pass unseen), a state name that is no longer declared.
|
||||
fn unknown_to_this_test(declared: &[(String, String, String)]) -> Vec<String> {
|
||||
let mut problems = Vec::new();
|
||||
let kinds: BTreeSet<&str> = declared
|
||||
.iter()
|
||||
.filter(|(name, _, _)| !STATE.contains(&name.as_str()))
|
||||
.map(|(_, kind, _)| kind.as_str())
|
||||
.collect();
|
||||
let known = BTreeSet::from(["color", "brush", "length", "int", "duration", "string"]);
|
||||
if kinds != known {
|
||||
problems.push(format!("kinds of declaration {kinds:?}, this test knows {known:?}"));
|
||||
}
|
||||
for (kind, expected) in [("brush", &["backdrop"][..]), ("string", &["mode", "font-family"])] {
|
||||
let found: BTreeSet<&str> = declared
|
||||
.iter()
|
||||
.filter(|(_, declared_kind, _)| declared_kind == kind)
|
||||
.map(|(name, _, _)| name.as_str())
|
||||
.collect();
|
||||
let expected: BTreeSet<&str> = expected.iter().copied().collect();
|
||||
for name in found.symmetric_difference(&expected) {
|
||||
problems.push(format!(
|
||||
"{name}: the <{kind}> declarations are {found:?}, this test compares {expected:?}"
|
||||
));
|
||||
}
|
||||
}
|
||||
for name in STATE {
|
||||
if !declared.iter().any(|(declared, _, _)| declared == name) {
|
||||
problems.push(format!("{name} is not declared"));
|
||||
}
|
||||
}
|
||||
problems
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_file_declares_nothing_this_test_does_not_know() {
|
||||
let problems = unknown_to_this_test(&declarations());
|
||||
assert!(problems.is_empty(), "{problems:#?}");
|
||||
}
|
||||
|
||||
/// `theme.slint` with one more declaration in its `Theme` global.
|
||||
fn with_declaration(declaration: &str) -> String {
|
||||
let opening = "export global Theme {";
|
||||
assert!(SLINT.contains(opening));
|
||||
SLINT.replacen(opening, &format!("{opening}\n {declaration}"), 1)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_second_brush_or_string_is_not_passed_unseen() {
|
||||
// Mutants of the Slint file: a token on one side only.
|
||||
for (declaration, name) in [
|
||||
("out property <brush> backdrop-soft: #123456;", "backdrop-soft"),
|
||||
("out property <string> font-mono: \"Mono\";", "font-mono"),
|
||||
] {
|
||||
let mutant = declarations_of(&with_declaration(declaration));
|
||||
assert!(mutant.iter().any(|(declared, _, _)| declared == name), "the mutant has {name}");
|
||||
let problems = unknown_to_this_test(&mutant);
|
||||
assert!(
|
||||
problems.iter().any(|problem| problem.contains(name)),
|
||||
"{name} goes unnoticed: {problems:#?}"
|
||||
);
|
||||
}
|
||||
// And the file as it is has neither.
|
||||
assert_eq!(unknown_to_this_test(&declarations()), Vec::<String>::new());
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
//! The tokens of `crates/voelin-ui/ui/theme.slint`, light and dark, as Rust
|
||||
//! values: the source of truth the GPUI front end copies. `theme.slint` stays
|
||||
//! the original while the Slint front end lives; the test in
|
||||
//! `theme/slint_parity.rs` reads it and fails when a value, a name or a
|
||||
//! formula here differs from it, so the two cannot drift apart.
|
||||
|
||||
use std::fmt;
|
||||
|
||||
/// A colour as `0xRRGGBBAA`, as the Slint file writes `#rrggbbaa` (`#rrggbb`
|
||||
/// is opaque).
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct Rgba(pub u32);
|
||||
|
||||
impl fmt::Debug for Rgba {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Rgba {
|
||||
/// `#rrggbb`, or `#rrggbbaa` when not opaque.
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.alpha() == 255 {
|
||||
write!(f, "#{:06x}", self.0 >> 8)
|
||||
} else {
|
||||
write!(f, "#{:08x}", self.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Rgba {
|
||||
/// Transparent black, for the widgets that draw nothing.
|
||||
pub const TRANSPARENT: Self = Self(0);
|
||||
|
||||
/// The opacity, 0 to 255.
|
||||
pub fn alpha(self) -> u8 {
|
||||
(self.0 & 0xff) as u8
|
||||
}
|
||||
|
||||
/// The same colour with another opacity.
|
||||
pub fn with_alpha(self, alpha: u8) -> Self {
|
||||
Self((self.0 & 0xffff_ff00) | u32::from(alpha))
|
||||
}
|
||||
|
||||
/// The channels, 0 to 1.
|
||||
pub fn channels(self) -> [f32; 3] {
|
||||
[24, 16, 8].map(|shift| ((self.0 >> shift) & 0xff) as f32 / 255.0)
|
||||
}
|
||||
|
||||
/// Mixed with `other` (of `amount`, 0 to 1), channel by channel, opacity
|
||||
/// from `self`.
|
||||
pub fn mix(self, other: Self, amount: f32) -> Self {
|
||||
let (a, b) = (self.channels(), other.channels());
|
||||
let channel =
|
||||
|i: usize| ((a[i] + (b[i] - a[i]) * amount) * 255.0).round().clamp(0.0, 255.0) as u32;
|
||||
Self(channel(0) << 24 | channel(1) << 16 | channel(2) << 8 | u32::from(self.alpha()))
|
||||
}
|
||||
|
||||
/// The relative luminance of WCAG 2, 0 (black) to 1 (white).
|
||||
pub fn luminance(self) -> f32 {
|
||||
let [r, g, b] = self
|
||||
.channels()
|
||||
.map(|c| if c <= 0.03928 { c / 12.92 } else { ((c + 0.055) / 1.055).powf(2.4) });
|
||||
0.2126 * r + 0.7152 * g + 0.0722 * b
|
||||
}
|
||||
|
||||
/// The contrast ratio of WCAG 2 between two colours, 1 to 21.
|
||||
pub fn contrast(self, other: Self) -> f32 {
|
||||
let (a, b) = (self.luminance(), other.luminance());
|
||||
(a.max(b) + 0.05) / (a.min(b) + 0.05)
|
||||
}
|
||||
|
||||
/// Of white and `ink`, the one that reads better on `self`.
|
||||
pub fn readable(self, ink: Self) -> Self {
|
||||
let white = Self(0xffff_ffff);
|
||||
if self.contrast(white) >= self.contrast(ink) { white } else { ink }
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! palette {
|
||||
($($field:ident $name:literal: $dark:literal, $light:literal;)*) => {
|
||||
/// Every colour token of `theme.slint` for one mode.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct Palette {
|
||||
$(
|
||||
#[doc = concat!("`", $name, "` of `theme.slint`.")]
|
||||
pub $field: Rgba,
|
||||
)*
|
||||
}
|
||||
|
||||
impl Palette {
|
||||
/// The dark palette.
|
||||
pub const DARK: Self = Self { $($field: Rgba($dark),)* };
|
||||
/// The light palette.
|
||||
pub const LIGHT: Self = Self { $($field: Rgba($light),)* };
|
||||
|
||||
/// Every colour by the name it has in `theme.slint`, in its order.
|
||||
pub fn entries(&self) -> Vec<(&'static str, Rgba)> {
|
||||
vec![$(($name, self.$field),)*]
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
palette! {
|
||||
bg_app "bg-app": 0x060a18ff, 0xe9eef9ff;
|
||||
bg_rail "bg-rail": 0x070c1dff, 0xdfe6f4ff;
|
||||
surface "surface": 0x0b1330ff, 0xf7f9feff;
|
||||
surface_2 "surface-2": 0x101a3cff, 0xffffffff;
|
||||
surface_3 "surface-3": 0x16224bff, 0xeaf0fbff;
|
||||
surface_4 "surface-4": 0x1c2b5cff, 0xdce5f7ff;
|
||||
scrim "scrim": 0x02050fc0, 0x0b132b80;
|
||||
scrim_light "scrim-light": 0x02050f73, 0x0b132b33;
|
||||
overlay "overlay": 0x060a18c8, 0x0b1330b0;
|
||||
border "border": 0x1b2750ff, 0xd3dceeff;
|
||||
border_strong "border-strong": 0x2a3a6eff, 0xb9c6e2ff;
|
||||
border_popup "border-popup": 0x3d5296ff, 0x9fb0d4ff;
|
||||
accent "accent": 0x2d6bffff, 0x2458e6ff;
|
||||
accent_hover "accent-hover": 0x4a82ffff, 0x3a6cf0ff;
|
||||
accent_pressed "accent-pressed": 0x1f55d9ff, 0x1b47c0ff;
|
||||
accent_soft "accent-soft": 0x18348aff, 0xd6e2ffff;
|
||||
accent_soft_hover "accent-soft-hover": 0x1d3d9cff, 0xc8d8ffff;
|
||||
accent_text "accent-text": 0x5c9dffff, 0x1d4fd6ff;
|
||||
name_text "name-text": 0x45b9ffff, 0x0f6cc4ff;
|
||||
on_accent "on-accent": 0xffffffff, 0xffffffff;
|
||||
glow "glow": 0x3f7bff90, 0x2458e660;
|
||||
live "live": 0xff2d55ff, 0xe0203fff;
|
||||
live_soft "live-soft": 0x3a0f22ff, 0xffe0e6ff;
|
||||
danger "danger": 0xff4d5eff, 0xd92c3cff;
|
||||
danger_soft "danger-soft": 0x3b1020ff, 0xffe3e6ff;
|
||||
success "success": 0x22d36bff, 0x16a557ff;
|
||||
success_soft "success-soft": 0x0d3326ff, 0xd7f5e4ff;
|
||||
warning "warning": 0xf5b301ff, 0xb77f00ff;
|
||||
warning_soft "warning-soft": 0x3a2a06ff, 0xfff0c8ff;
|
||||
idle "idle": 0xf5b301ff, 0xc98b00ff;
|
||||
dnd "dnd": 0xff4d5eff, 0xd92c3cff;
|
||||
offline "offline": 0x5f6d93ff, 0x8d99b5ff;
|
||||
gold "gold": 0xffc233ff, 0xd99a00ff;
|
||||
info "info": 0x3fb3ffff, 0x1180d6ff;
|
||||
text "text": 0xeef2ffff, 0x0e1733ff;
|
||||
text_secondary "text-secondary": 0xaeb9d8ff, 0x43506fff;
|
||||
text_muted "text-muted": 0x6d7ca6ff, 0x6f7b98ff;
|
||||
text_disabled "text-disabled": 0x46527aff, 0xa7b1c8ff;
|
||||
icon "icon": 0xb9c4e2ff, 0x43506fff;
|
||||
meter_low "meter-low": 0x21d07aff, 0x21d07aff;
|
||||
meter_mid "meter-mid": 0xf5d000ff, 0xf5d000ff;
|
||||
meter_high "meter-high": 0xff4d5eff, 0xff4d5eff;
|
||||
meter_off "meter-off": 0x1a2550ff, 0xd5ddefff;
|
||||
}
|
||||
|
||||
/// `@linear-gradient(angle, stop 0%, stop 55%, stop 100%)`: the window's
|
||||
/// backdrop. GPUI's `Background` has two colour stops, so what it draws
|
||||
/// (`Backdrop::to_gpui`, in the theme module) is the first and the last; the
|
||||
/// middle one stays here for a front end that can use it.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Backdrop {
|
||||
/// The direction in degrees, as CSS and Slint take it (0 is to the top).
|
||||
pub angle: f32,
|
||||
/// Three stops: colour and position (0 to 1).
|
||||
pub stops: [(Rgba, f32); 3],
|
||||
}
|
||||
|
||||
impl Backdrop {
|
||||
/// The dark backdrop.
|
||||
pub const DARK: Self = Self {
|
||||
angle: 160.0,
|
||||
stops: [(Rgba(0x0a1230ff), 0.0), (Rgba(0x060a18ff), 0.55), (Rgba(0x0a1638ff), 1.0)],
|
||||
};
|
||||
/// The light backdrop.
|
||||
pub const LIGHT: Self = Self {
|
||||
angle: 160.0,
|
||||
stops: [(Rgba(0xf4f7fdff), 0.0), (Rgba(0xe6ecf8ff), 0.60), (Rgba(0xdde6f7ff), 1.0)],
|
||||
};
|
||||
}
|
||||
|
||||
/// The family of the UI font (`font-family` of `theme.slint`).
|
||||
pub const FONT_FAMILY: &str = "Inter";
|
||||
|
||||
/// Every size, radius, weight and duration token of `theme.slint` for one
|
||||
/// text size factor: lengths in logical pixels.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Metrics {
|
||||
/// `font-scale`: multiplies every type size and the sizes that follow text.
|
||||
pub font_scale: f32,
|
||||
/// `radius-xs`.
|
||||
pub radius_xs: f32,
|
||||
/// `radius-sm`.
|
||||
pub radius_sm: f32,
|
||||
/// `radius-md`.
|
||||
pub radius_md: f32,
|
||||
/// `radius-lg`.
|
||||
pub radius_lg: f32,
|
||||
/// `radius-xl`.
|
||||
pub radius_xl: f32,
|
||||
/// `radius-pill`.
|
||||
pub radius_pill: f32,
|
||||
/// `space-1`.
|
||||
pub space_1: f32,
|
||||
/// `space-2`.
|
||||
pub space_2: f32,
|
||||
/// `space-3`.
|
||||
pub space_3: f32,
|
||||
/// `space-4`.
|
||||
pub space_4: f32,
|
||||
/// `space-5`.
|
||||
pub space_5: f32,
|
||||
/// `space-6`.
|
||||
pub space_6: f32,
|
||||
/// `space-7`.
|
||||
pub space_7: f32,
|
||||
/// `space-8`.
|
||||
pub space_8: f32,
|
||||
/// `font-xs` (scaled).
|
||||
pub font_xs: f32,
|
||||
/// `font-sm` (scaled).
|
||||
pub font_sm: f32,
|
||||
/// `font-body` (scaled).
|
||||
pub font_body: f32,
|
||||
/// `font-md` (scaled).
|
||||
pub font_md: f32,
|
||||
/// `font-lg` (scaled).
|
||||
pub font_lg: f32,
|
||||
/// `font-xl` (scaled).
|
||||
pub font_xl: f32,
|
||||
/// `font-2xl` (scaled).
|
||||
pub font_2xl: f32,
|
||||
/// `font-3xl` (scaled).
|
||||
pub font_3xl: f32,
|
||||
/// `weight-regular`.
|
||||
pub weight_regular: u16,
|
||||
/// `weight-medium`.
|
||||
pub weight_medium: u16,
|
||||
/// `weight-semibold`.
|
||||
pub weight_semibold: u16,
|
||||
/// `weight-bold`.
|
||||
pub weight_bold: u16,
|
||||
/// `row-height` (scaled).
|
||||
pub row_height: f32,
|
||||
/// `control-height` (scaled).
|
||||
pub control_height: f32,
|
||||
/// `control-height-sm` (scaled).
|
||||
pub control_height_sm: f32,
|
||||
/// `icon-sm`.
|
||||
pub icon_sm: f32,
|
||||
/// `icon-md`.
|
||||
pub icon_md: f32,
|
||||
/// `icon-lg`.
|
||||
pub icon_lg: f32,
|
||||
/// `glow-width`: the ring around focused and selected items.
|
||||
pub glow_width: f32,
|
||||
/// `rail-width`.
|
||||
pub rail_width: f32,
|
||||
/// `sidebar-width`: 264 and more with large text.
|
||||
pub sidebar_width: f32,
|
||||
/// `topbar-height`: 44, taller when large text makes the controls taller.
|
||||
pub topbar_height: f32,
|
||||
/// `right-panel-min`.
|
||||
pub right_panel_min: f32,
|
||||
/// `fast`, in milliseconds.
|
||||
pub fast_ms: u32,
|
||||
/// `normal`, in milliseconds.
|
||||
pub normal_ms: u32,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
/// The tokens at a text size factor (1 is the default).
|
||||
pub fn new(font_scale: f32) -> Self {
|
||||
let s = font_scale;
|
||||
let control_height = 36.0 * s;
|
||||
let space_3 = 8.0;
|
||||
Self {
|
||||
font_scale,
|
||||
radius_xs: 4.0,
|
||||
radius_sm: 6.0,
|
||||
radius_md: 8.0,
|
||||
radius_lg: 12.0,
|
||||
radius_xl: 16.0,
|
||||
radius_pill: 999.0,
|
||||
space_1: 2.0,
|
||||
space_2: 4.0,
|
||||
space_3,
|
||||
space_4: 12.0,
|
||||
space_5: 16.0,
|
||||
space_6: 20.0,
|
||||
space_7: 24.0,
|
||||
space_8: 32.0,
|
||||
font_xs: 11.0 * s,
|
||||
font_sm: 12.0 * s,
|
||||
font_body: 14.0 * s,
|
||||
font_md: 15.0 * s,
|
||||
font_lg: 17.0 * s,
|
||||
font_xl: 20.0 * s,
|
||||
font_2xl: 24.0 * s,
|
||||
font_3xl: 30.0 * s,
|
||||
weight_regular: 400,
|
||||
weight_medium: 500,
|
||||
weight_semibold: 600,
|
||||
weight_bold: 700,
|
||||
row_height: 32.0 * s,
|
||||
control_height,
|
||||
control_height_sm: 28.0 * s,
|
||||
icon_sm: 16.0,
|
||||
icon_md: 20.0,
|
||||
icon_lg: 24.0,
|
||||
glow_width: 2.0,
|
||||
rail_width: 72.0,
|
||||
sidebar_width: 264.0 * s.max(1.0),
|
||||
topbar_height: 44.0_f32.max(control_height + space_3),
|
||||
right_panel_min: 220.0,
|
||||
fast_ms: 120,
|
||||
normal_ms: 200,
|
||||
}
|
||||
}
|
||||
|
||||
/// Every number token by the name it has in `theme.slint`, in its order:
|
||||
/// lengths in pixels, weights as they are, durations in milliseconds.
|
||||
pub fn entries(&self) -> Vec<(&'static str, f64)> {
|
||||
let m = self;
|
||||
[
|
||||
("radius-xs", m.radius_xs),
|
||||
("radius-sm", m.radius_sm),
|
||||
("radius-md", m.radius_md),
|
||||
("radius-lg", m.radius_lg),
|
||||
("radius-xl", m.radius_xl),
|
||||
("radius-pill", m.radius_pill),
|
||||
("space-1", m.space_1),
|
||||
("space-2", m.space_2),
|
||||
("space-3", m.space_3),
|
||||
("space-4", m.space_4),
|
||||
("space-5", m.space_5),
|
||||
("space-6", m.space_6),
|
||||
("space-7", m.space_7),
|
||||
("space-8", m.space_8),
|
||||
("font-xs", m.font_xs),
|
||||
("font-sm", m.font_sm),
|
||||
("font-body", m.font_body),
|
||||
("font-md", m.font_md),
|
||||
("font-lg", m.font_lg),
|
||||
("font-xl", m.font_xl),
|
||||
("font-2xl", m.font_2xl),
|
||||
("font-3xl", m.font_3xl),
|
||||
("row-height", m.row_height),
|
||||
("control-height", m.control_height),
|
||||
("control-height-sm", m.control_height_sm),
|
||||
("icon-sm", m.icon_sm),
|
||||
("icon-md", m.icon_md),
|
||||
("icon-lg", m.icon_lg),
|
||||
("glow-width", m.glow_width),
|
||||
("rail-width", m.rail_width),
|
||||
("sidebar-width", m.sidebar_width),
|
||||
("topbar-height", m.topbar_height),
|
||||
("right-panel-min", m.right_panel_min),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(name, value)| (name, f64::from(value)))
|
||||
.chain([
|
||||
("weight-regular", f64::from(m.weight_regular)),
|
||||
("weight-medium", f64::from(m.weight_medium)),
|
||||
("weight-semibold", f64::from(m.weight_semibold)),
|
||||
("weight-bold", f64::from(m.weight_bold)),
|
||||
("fast", f64::from(m.fast_ms)),
|
||||
("normal", f64::from(m.normal_ms)),
|
||||
])
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Metrics {
|
||||
fn default() -> Self {
|
||||
Self::new(1.0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
//! The window's content. The shell is not built yet (slice 1 of the
|
||||
//! migration): the window is the theme's page with the one line of the root
|
||||
//! state that proves the loops run in a status bar, or, with
|
||||
//! `VOELIN_OPEN=swatch`, the swatch page above that bar.
|
||||
|
||||
use gpui_kit::{
|
||||
Context, Entity, IntoElement, ParentElement as _, Render, Styled as _, Window, div, px,
|
||||
};
|
||||
|
||||
use crate::app::AppState;
|
||||
use crate::dev::Page;
|
||||
use crate::meter::Counters;
|
||||
use crate::swatch::swatch;
|
||||
use crate::theme::{VoelinTheme, hsla};
|
||||
|
||||
/// What the main window draws, from the root state and the theme.
|
||||
pub struct MainView {
|
||||
app: Entity<AppState>,
|
||||
page: Page,
|
||||
counters: Counters,
|
||||
}
|
||||
|
||||
impl MainView {
|
||||
/// A view of `app` that draws again whenever it changes, and that keeps
|
||||
/// the theme in `system` mode in step with the window's appearance.
|
||||
pub fn new(
|
||||
app: Entity<AppState>,
|
||||
page: Page,
|
||||
counters: Counters,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
cx.observe(&app, |_, _, cx| cx.notify()).detach();
|
||||
cx.observe_window_appearance(window, |_, window, cx| {
|
||||
VoelinTheme::set_system_appearance(cx, window.appearance());
|
||||
})
|
||||
.detach();
|
||||
Self { app, page, counters }
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for MainView {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
self.counters.renders.incr();
|
||||
let line = self.app.read(cx).state_line();
|
||||
let theme = VoelinTheme::global(cx).clone();
|
||||
let (c, m) = (&theme.colors, &theme.metrics);
|
||||
let page = match self.page {
|
||||
Page::Swatch => div().flex_1().overflow_hidden().child(swatch(&theme)),
|
||||
Page::Shell => div()
|
||||
.flex_1()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.gap(px(m.space_3))
|
||||
.child(
|
||||
div()
|
||||
.text_size(px(m.font_3xl))
|
||||
.text_color(hsla(c.text))
|
||||
.child(voelin_platform::APP_NAME),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.text_size(px(m.font_body))
|
||||
.text_color(hsla(c.text_muted))
|
||||
.child("The desktop shell is the next slice."),
|
||||
),
|
||||
};
|
||||
div()
|
||||
.size_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.bg(hsla(c.bg_app))
|
||||
.text_color(hsla(c.text))
|
||||
.font_family(crate::theme::FONT_FAMILY)
|
||||
.child(page)
|
||||
.child(
|
||||
div()
|
||||
.h(px(m.control_height_sm))
|
||||
.px(px(m.space_5))
|
||||
.flex()
|
||||
.items_center()
|
||||
.bg(hsla(c.surface))
|
||||
.border_t_1()
|
||||
.border_color(hsla(c.border))
|
||||
.text_size(px(m.font_sm))
|
||||
.text_color(hsla(c.text_secondary))
|
||||
.child(line),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
//! The binary's failure path, end to end: when the main window cannot be
|
||||
//! opened (no display server, no Vulkan or GL driver), `voelin-gpui` prints
|
||||
//! why and exits with status 1 instead of staying alive with no window and no
|
||||
//! message.
|
||||
//!
|
||||
//! It has to start the real binary. GPUI's Linux platform runs the launch
|
||||
//! callback before it starts its event loop, and the loop forgets a quit asked
|
||||
//! for before it started, so a failure handled by quitting inside the
|
||||
//! callback hung the process; the test platform of the unit tests has no such
|
||||
//! loop and cannot show it.
|
||||
//!
|
||||
//! The no-driver test needs a test X server in `VOELIN_X11_TEST_DISPLAY` (an
|
||||
//! Xvfb, as CI has; never the desktop's display) and is skipped without one.
|
||||
|
||||
#![cfg(target_os = "linux")]
|
||||
|
||||
use std::fs;
|
||||
use std::os::unix::fs::PermissionsExt as _;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, ExitStatus, Stdio};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
/// Where the drivers are not: the Vulkan loader, EGL's vendor library
|
||||
/// directory and Mesa's driver directory all point here.
|
||||
const NOWHERE: &str = "/nonexistent-voelin-gpui-test";
|
||||
|
||||
/// Loaded machines are slow, so the wait is generous; a run that works takes a
|
||||
/// second or two.
|
||||
const WAIT: Duration = Duration::from_secs(120);
|
||||
|
||||
/// The scratch directory of one run, removed at the end.
|
||||
struct Scratch(PathBuf);
|
||||
|
||||
impl Drop for Scratch {
|
||||
fn drop(&mut self) {
|
||||
let _ = fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
/// How a run of the binary went.
|
||||
enum Outcome {
|
||||
/// It ended, with this status and this much of the log.
|
||||
Ended(ExitStatus, String),
|
||||
/// It picked a GPU: the window can open, so nothing failed.
|
||||
Opened,
|
||||
/// It was still running after [`WAIT`] with no GPU picked.
|
||||
Hung(String),
|
||||
}
|
||||
|
||||
/// Run the binary with the drivers hidden (`hide_drivers`) on `display`
|
||||
/// (none: no display server at all) and wait for it to end, to pick a GPU or
|
||||
/// to run out of time. Nothing of the user's state, display or session bus is
|
||||
/// in its environment.
|
||||
fn run_binary(name: &str, display: Option<&str>, hide_drivers: bool) -> Outcome {
|
||||
let scratch = Scratch(
|
||||
Path::new(env!("CARGO_TARGET_TMPDIR")).join(format!("{name}-{}", std::process::id())),
|
||||
);
|
||||
let home = scratch.0.join("home");
|
||||
let runtime = scratch.0.join("runtime");
|
||||
fs::create_dir_all(&runtime).unwrap();
|
||||
fs::set_permissions(&runtime, fs::Permissions::from_mode(0o700)).unwrap();
|
||||
let log = scratch.0.join("stderr.log");
|
||||
|
||||
let mut command = Command::new(env!("CARGO_BIN_EXE_voelin-gpui"));
|
||||
command
|
||||
.env_remove("DISPLAY")
|
||||
.env_remove("WAYLAND_DISPLAY")
|
||||
.env_remove("WAYLAND_SOCKET")
|
||||
.env_remove("XDG_SESSION_TYPE")
|
||||
.env_remove("DBUS_SESSION_BUS_ADDRESS")
|
||||
.env_remove("RUST_LOG")
|
||||
.env("HOME", &home)
|
||||
.env("XDG_RUNTIME_DIR", &runtime)
|
||||
.env("XDG_CONFIG_HOME", home.join("config"))
|
||||
.env("XDG_DATA_HOME", home.join("data"))
|
||||
.env("XDG_STATE_HOME", home.join("state"))
|
||||
.env("XDG_CACHE_HOME", home.join("cache"))
|
||||
.env("VOELIN_DATA_DIR", home.join("voelin"))
|
||||
// The log line that tells a GPU was picked.
|
||||
.env("VOELIN_LOG", "warn,voelin_gpui=info,gpui_wgpu=info")
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(fs::File::create(&log).unwrap());
|
||||
if let Some(display) = display {
|
||||
command.env("DISPLAY", display);
|
||||
}
|
||||
if hide_drivers {
|
||||
command
|
||||
.env("VK_DRIVER_FILES", format!("{NOWHERE}/vulkan.json"))
|
||||
.env("VK_ICD_FILENAMES", format!("{NOWHERE}/vulkan.json"))
|
||||
.env("__EGL_VENDOR_LIBRARY_DIRS", NOWHERE)
|
||||
.env("__EGL_VENDOR_LIBRARY_FILENAMES", format!("{NOWHERE}/egl.json"))
|
||||
.env("LIBGL_DRIVERS_PATH", NOWHERE);
|
||||
}
|
||||
let mut child = command.spawn().unwrap();
|
||||
|
||||
let deadline = Instant::now() + WAIT;
|
||||
loop {
|
||||
if let Some(status) = child.try_wait().unwrap() {
|
||||
return Outcome::Ended(status, fs::read_to_string(&log).unwrap_or_default());
|
||||
}
|
||||
let seen = fs::read_to_string(&log).unwrap_or_default();
|
||||
let outcome = if seen.contains("Selected GPU adapter") {
|
||||
Outcome::Opened
|
||||
} else if Instant::now() > deadline {
|
||||
Outcome::Hung(seen)
|
||||
} else {
|
||||
std::thread::sleep(Duration::from_millis(50));
|
||||
continue;
|
||||
};
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
return outcome;
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_window_that_cannot_open_for_want_of_a_driver_ends_the_binary_with_an_error() {
|
||||
let Some(display) = std::env::var("VOELIN_X11_TEST_DISPLAY").ok().filter(|d| !d.is_empty())
|
||||
else {
|
||||
eprintln!("skipped: VOELIN_X11_TEST_DISPLAY is not set");
|
||||
return;
|
||||
};
|
||||
match run_binary("no-driver", Some(&display), true) {
|
||||
Outcome::Ended(status, seen) => {
|
||||
assert_eq!(status.code(), Some(1), "{seen}");
|
||||
assert!(seen.contains("cannot open the main window"), "{seen}");
|
||||
}
|
||||
Outcome::Opened => eprintln!(
|
||||
"skipped: this machine's driver was found in spite of the environment, \
|
||||
so the window can open"
|
||||
),
|
||||
Outcome::Hung(seen) => panic!(
|
||||
"still running after {WAIT:?} with no window and no GPU: a quit asked for in the \
|
||||
launch callback is lost\n{seen}"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn without_a_display_server_the_binary_ends_with_an_error() {
|
||||
match run_binary("no-display", None, false) {
|
||||
Outcome::Ended(status, seen) => {
|
||||
assert_eq!(status.code(), Some(1), "{seen}");
|
||||
assert!(seen.contains("cannot open the main window"), "{seen}");
|
||||
assert!(seen.contains("no display"), "{seen}");
|
||||
}
|
||||
Outcome::Opened => panic!("a GPU was picked without a display server"),
|
||||
Outcome::Hung(seen) => panic!(
|
||||
"still running after {WAIT:?} with no window: GPUI's headless platform keeps \
|
||||
the app alive\n{seen}"
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,13 @@ tracing = "0.1.44"
|
||||
yuv = "0.8.19"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
ashpd = { version = "0.13.13", default-features = false, features = ["camera", "screencast", "tokio"], optional = true }
|
||||
# `async-io`, not `tokio`: GPUI's Linux backend enables ashpd's `async-io`, ashpd
|
||||
# refuses both at once, and a front end holds the portals and GPUI in one binary.
|
||||
# zbus then runs every connection on an I/O thread of its own, whichever thread
|
||||
# builds it: no crate of the workspace turns zbus's `tokio` feature on (with it
|
||||
# zbus would pick tokio for a connection made inside a tokio runtime, and ashpd
|
||||
# shares one connection per process with every later caller).
|
||||
ashpd = { version = "0.13.13", default-features = false, features = ["camera", "screencast", "async-io"], optional = true }
|
||||
memmap2 = { version = "0.9.11", optional = true }
|
||||
pipewire = { version = "0.10.1", optional = true }
|
||||
rustix = { version = "1.1.5", features = ["event", "fs", "stdio"], optional = true }
|
||||
|
||||
@@ -279,14 +279,14 @@ impl FrameSink for QueueSink {
|
||||
pub fn forward(mut frames: FrameReceiver<VideoFrame>, mut sink: Box<dyn FrameSink>) -> Result<()> {
|
||||
std::thread::Builder::new().name("voelin-capture-forward".into()).spawn(move || {
|
||||
loop {
|
||||
match frames.recv_timeout(Duration::from_millis(100)) {
|
||||
Some(frame) => {
|
||||
if sink.wants(frame.timestamp) && !sink.frame(frame.view()) {
|
||||
break;
|
||||
}
|
||||
let Some(frame) = frames.recv_timeout(Duration::from_millis(100)) else {
|
||||
if frames.is_closed() {
|
||||
break;
|
||||
}
|
||||
None if frames.is_closed() => break,
|
||||
None => {}
|
||||
continue;
|
||||
};
|
||||
if sink.wants(frame.timestamp) && !sink.frame(frame.view()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
})?;
|
||||
|
||||
@@ -181,7 +181,9 @@ impl ScreenCapture for PortalCapture {
|
||||
}
|
||||
|
||||
/// Asks the user through the portal dialog (unless a restore token
|
||||
/// applies). Needs a tokio runtime (the D-Bus connection runs on it).
|
||||
/// applies). Any executor will do: ashpd runs on zbus's `async-io` in every
|
||||
/// binary of the workspace (no crate turns zbus's `tokio` feature on), whose
|
||||
/// connection has an I/O thread of its own, whichever thread builds it.
|
||||
fn start(
|
||||
&mut self,
|
||||
source: &SourceId,
|
||||
|
||||
@@ -446,7 +446,7 @@ fn files_in(dir: &Path, base: &str) -> Vec<PathBuf> {
|
||||
matches.then(|| (major_of(&name).unwrap_or(0), e.path()))
|
||||
})
|
||||
.collect();
|
||||
found.sort_by(|a, b| b.0.cmp(&a.0));
|
||||
found.sort_by_key(|entry| std::cmp::Reverse(entry.0));
|
||||
found.into_iter().map(|(_, p)| p).collect()
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ fn ldconfig(base: &str) -> Vec<PathBuf> {
|
||||
name.starts_with(&prefix).then(|| (major_of(name).unwrap_or(0), PathBuf::from(path)))
|
||||
})
|
||||
.collect();
|
||||
found.sort_by(|a, b| b.0.cmp(&a.0));
|
||||
found.sort_by_key(|entry| std::cmp::Reverse(entry.0));
|
||||
found.into_iter().map(|(_, p)| p).collect()
|
||||
}
|
||||
|
||||
|
||||
@@ -603,8 +603,8 @@ mod v4l2 {
|
||||
// Seconds per frame; a stepwise range starts with its smallest
|
||||
// interval, which is the highest rate.
|
||||
let (num, den) = (entry.interval[0], entry.interval[1]);
|
||||
if num > 0 {
|
||||
best = best.max(den / num);
|
||||
if let Some(rate) = den.checked_div(num) {
|
||||
best = best.max(rate);
|
||||
}
|
||||
if entry.type_ != FRMIVAL_DISCRETE {
|
||||
break;
|
||||
|
||||
@@ -24,9 +24,11 @@ tokio = { version = "1", features = ["rt", "sync", "time"] }
|
||||
tracing = "0.1"
|
||||
|
||||
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
|
||||
ashpd = { version = "0.13", default-features = false, features = ["tokio", "global_shortcuts", "file_chooser", "proxy_resolver"], optional = true }
|
||||
# `async-io`, not `tokio`, as in voelin-media: GPUI enables ashpd's `async-io` and
|
||||
# ashpd refuses both features at once.
|
||||
ashpd = { version = "0.13", default-features = false, features = ["async-io", "global_shortcuts", "file_chooser", "proxy_resolver"], optional = true }
|
||||
futures-util = { version = "0.3", optional = true }
|
||||
notify-rust = { version = "4.18", default-features = false, features = ["z-with-tokio"] }
|
||||
notify-rust = { version = "4.18", default-features = false, features = ["z"] }
|
||||
x11rb = { version = "0.13", features = ["xinput"], optional = true }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
@@ -46,8 +48,11 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
|
||||
[target.'cfg(all(unix, not(target_os = "macos")))'.dev-dependencies]
|
||||
x11rb = { version = "0.13", features = ["xinput", "xtest"] }
|
||||
# A stand-in desktop portal on a private session bus (tests/proxy.rs); the
|
||||
# zbus ashpd uses.
|
||||
zbus = { version = "5", default-features = false, features = ["tokio"] }
|
||||
# zbus ashpd uses, on `async-io` like every other zbus in the workspace: a
|
||||
# `tokio` here would put the executor choice of ashpd's connection (zbus picks
|
||||
# tokio when a tokio runtime is current where it builds the connection) into
|
||||
# the tests alone, and tests/proxy.rs checks that the choice does not matter.
|
||||
zbus = { version = "5", default-features = false, features = ["async-io"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -5,6 +5,11 @@
|
||||
//! the real one is started and answers instead. Without `dbus-run-session`,
|
||||
//! or a bus daemon for it, the test says so and checks nothing. Its own test
|
||||
//! binary: answers are kept process-wide.
|
||||
//!
|
||||
//! The second and third tests call ashpd from a thread with no tokio runtime,
|
||||
//! as GPUI's executor would: ashpd runs on zbus's `async-io`, whichever thread
|
||||
//! built its connection (the third lets a tokio caller build it first;
|
||||
//! docs/design/gpui-spikes.md, "Dependencies").
|
||||
|
||||
#![cfg(all(unix, not(target_os = "macos"), feature = "portal"))]
|
||||
|
||||
@@ -61,17 +66,17 @@ fn bus_config(dir: &std::path::Path) -> String {
|
||||
)
|
||||
}
|
||||
|
||||
/// Run this test again under `dbus-run-session` on a bus of its own, and say
|
||||
/// nothing was checked when that bus cannot be had.
|
||||
fn on_a_bus_of_its_own() {
|
||||
/// Run the test `name` again under `dbus-run-session` on a bus of its own, and
|
||||
/// say nothing was checked when that bus cannot be had.
|
||||
fn on_a_bus_of_its_own(name: &str) {
|
||||
let dir = std::env::temp_dir();
|
||||
let config = dir.join(format!("voelin-proxy-test-bus-{}.conf", std::process::id()));
|
||||
let config = dir.join(format!("voelin-proxy-test-bus-{}-{name}.conf", std::process::id()));
|
||||
std::fs::write(&config, bus_config(&dir)).unwrap();
|
||||
let run = std::process::Command::new("dbus-run-session")
|
||||
.arg(format!("--config-file={}", config.display()))
|
||||
.arg("--")
|
||||
.arg(std::env::current_exe().unwrap())
|
||||
.args(["--exact", "the_portal_names_the_proxy", "--nocapture", "--test-threads=1"])
|
||||
.args(["--exact", name, "--nocapture", "--test-threads=1"])
|
||||
.env(ON_ITS_OWN_BUS, "1")
|
||||
.output();
|
||||
let _ = std::fs::remove_file(&config);
|
||||
@@ -104,7 +109,7 @@ fn on_a_bus_of_its_own() {
|
||||
#[tokio::test]
|
||||
async fn the_portal_names_the_proxy() {
|
||||
if std::env::var_os(ON_ITS_OWN_BUS).is_none() {
|
||||
on_a_bus_of_its_own();
|
||||
on_a_bus_of_its_own("the_portal_names_the_proxy");
|
||||
return;
|
||||
}
|
||||
let lookups = Arc::new(AtomicU32::new(0));
|
||||
@@ -133,3 +138,96 @@ async fn the_portal_names_the_proxy() {
|
||||
assert_eq!(proxy_for("https://capped.example:8443/").await, None);
|
||||
assert_eq!(lookups.load(Ordering::SeqCst), 2);
|
||||
}
|
||||
|
||||
/// Run `future` on the calling thread, which parks while it waits: an executor
|
||||
/// of no runtime at all, as a GPUI foreground task is to ashpd.
|
||||
fn block_on<F: std::future::Future>(future: F) -> F::Output {
|
||||
struct Unpark(std::thread::Thread);
|
||||
impl std::task::Wake for Unpark {
|
||||
fn wake(self: Arc<Self>) {
|
||||
self.0.unpark();
|
||||
}
|
||||
}
|
||||
let waker = std::task::Waker::from(Arc::new(Unpark(std::thread::current())));
|
||||
let mut cx = std::task::Context::from_waker(&waker);
|
||||
let mut future = std::pin::pin!(future);
|
||||
loop {
|
||||
if let std::task::Poll::Ready(output) = future.as_mut().poll(&mut cx) {
|
||||
return output;
|
||||
}
|
||||
std::thread::park();
|
||||
}
|
||||
}
|
||||
|
||||
/// The stand-in portal on the bus of its own, served from the calling task.
|
||||
async fn stand_in_portal(lookups: &Arc<AtomicU32>) -> zbus::Connection {
|
||||
zbus::connection::Builder::session()
|
||||
.unwrap()
|
||||
.name("org.freedesktop.portal.Desktop")
|
||||
.unwrap()
|
||||
.serve_at("/org/freedesktop/portal/desktop", Resolver { lookups: lookups.clone() })
|
||||
.unwrap()
|
||||
.build()
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// A lookup through ashpd, from the calling task.
|
||||
async fn lookup() -> Vec<ashpd::Uri> {
|
||||
let resolver = ashpd::desktop::proxy_resolver::ProxyResolver::new().await.unwrap();
|
||||
let uri = ashpd::Uri::parse("https://capped.example/").unwrap();
|
||||
resolver.lookup(&uri).await.unwrap()
|
||||
}
|
||||
|
||||
/// A lookup through ashpd from a thread of its own with no runtime, blocking
|
||||
/// the caller's task for it (the pool's threads, `spawn_blocking`, have the
|
||||
/// runtime in reach). The stand-in portal runs on the test's runtime: keep it
|
||||
/// free while waiting.
|
||||
async fn lookup_without_a_runtime() -> Vec<String> {
|
||||
let caller = std::thread::spawn(|| {
|
||||
assert!(tokio::runtime::Handle::try_current().is_err(), "this thread has no runtime");
|
||||
block_on(lookup()).iter().map(|uri| uri.as_str().to_owned()).collect::<Vec<_>>()
|
||||
});
|
||||
tokio::task::spawn_blocking(move || caller.join().unwrap()).await.unwrap()
|
||||
}
|
||||
|
||||
/// ashpd with `async-io`: a caller outside any tokio runtime gets its answer,
|
||||
/// the connection's I/O running on zbus's own thread.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn the_portal_answers_a_caller_without_a_runtime() {
|
||||
const TEST: &str = "the_portal_answers_a_caller_without_a_runtime";
|
||||
if std::env::var_os(ON_ITS_OWN_BUS).is_none() {
|
||||
on_a_bus_of_its_own(TEST);
|
||||
return;
|
||||
}
|
||||
let lookups = Arc::new(AtomicU32::new(0));
|
||||
let _portal = stand_in_portal(&lookups).await;
|
||||
assert_eq!(lookup_without_a_runtime().await, ["socks://127.0.0.1:2080"]);
|
||||
assert_eq!(lookups.load(Ordering::SeqCst), 1);
|
||||
}
|
||||
|
||||
/// ashpd keeps one session connection for the process, and zbus picks the
|
||||
/// executor of a connection once, when it builds it: tokio if a tokio runtime
|
||||
/// is current on that thread and zbus has its `tokio` feature on, its own
|
||||
/// `async-io` thread otherwise. If the engine's runtime made the connection
|
||||
/// first, a later caller with no runtime (a GPUI foreground task) would find a
|
||||
/// tokio connection with no reactor to run on and panic ("there is no reactor
|
||||
/// running" in zbus's property cache). With zbus on `async-io` alone in every
|
||||
/// binary (notify-rust without `z-with-tokio`, no zbus `tokio` here either)
|
||||
/// the order does not matter.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn the_portal_answers_a_caller_without_a_runtime_after_a_tokio_caller() {
|
||||
const TEST: &str = "the_portal_answers_a_caller_without_a_runtime_after_a_tokio_caller";
|
||||
if std::env::var_os(ON_ITS_OWN_BUS).is_none() {
|
||||
on_a_bus_of_its_own(TEST);
|
||||
return;
|
||||
}
|
||||
let lookups = Arc::new(AtomicU32::new(0));
|
||||
let _portal = stand_in_portal(&lookups).await;
|
||||
// The tokio caller first: it builds the process's session connection.
|
||||
let answer: Vec<_> = lookup().await.iter().map(|uri| uri.as_str().to_owned()).collect();
|
||||
assert_eq!(answer, ["socks://127.0.0.1:2080"]);
|
||||
// Then the caller with no runtime, on the same connection.
|
||||
assert_eq!(lookup_without_a_runtime().await, ["socks://127.0.0.1:2080"]);
|
||||
assert_eq!(lookups.load(Ordering::SeqCst), 2);
|
||||
}
|
||||
@@ -1075,7 +1075,8 @@ impl Task {
|
||||
}
|
||||
Event::IceConnectionStateChange(IceConnectionState::Disconnected) => return false,
|
||||
Event::MediaAdded(m) => {
|
||||
if !self.mids.iter().any(|(mid, _)| *mid == m.mid) {
|
||||
let known = self.mids.iter().any(|(mid, _)| *mid == m.mid);
|
||||
if !known {
|
||||
self.mids.push((m.mid, m.kind));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,7 +801,8 @@ impl StreamerSession {
|
||||
}
|
||||
StreamNotification::JoinRequest { viewer, remove: true, .. }
|
||||
| StreamNotification::ViewerLeft { viewer, .. } => {
|
||||
if self.viewers.remove(&viewer.0).is_some() {
|
||||
let was_viewer = self.viewers.remove(&viewer.0).is_some();
|
||||
if was_viewer {
|
||||
self.emit_viewers(out);
|
||||
self.update_targets(out);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,16 @@ allow = [
|
||||
# Permissive BSD-style license of bzip2, kept by its pure Rust port
|
||||
# (libbz2-rs-sys), which voelin-media uses to unpack Cisco's OpenH264 download.
|
||||
"bzip2-1.0.6",
|
||||
# The GPUI front end (gpui-kit, crates/voelin-gpui) brought two licences no
|
||||
# other crate of ours has. 0BSD, the BSD Zero Clause License (OSI approved;
|
||||
# MIT without the notice requirement): `enum-iterator` and
|
||||
# `enum-iterator-derive`, under gpui-component. CC0-1.0, Creative Commons
|
||||
# Zero (a public domain dedication; no notice to carry): `notify` 8, the
|
||||
# file watcher of gpui-component, and `tiny-keccak`, a hash of the X input
|
||||
# method client under gpui-pre-linux (`zed-xim`, through `ahash`'s
|
||||
# `const-random`).
|
||||
"0BSD",
|
||||
"CC0-1.0",
|
||||
]
|
||||
confidence-threshold = 0.9
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ ARG DEBIAN_FRONTEND=noninteractive
|
||||
# the .deb's dependencies and patchelf for the .tar.gz's bundled libraries.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential ca-certificates cmake curl dpkg-dev git openssh-client patchelf pkg-config \
|
||||
libasound2-dev libfontconfig1-dev libxkbcommon-dev \
|
||||
libasound2-dev libfontconfig1-dev libxkbcommon-dev libxkbcommon-x11-dev libxcb1-dev \
|
||||
libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# Extra CA certificates (PEM, one or more), for building behind a
|
||||
|
||||
+16
-1
@@ -119,10 +119,25 @@ the proxy is on localhost. If the proxy inspects TLS, set
|
||||
|
||||
## Locally without Docker
|
||||
|
||||
- **Rust:** 1.95, the channel `rust-toolchain.toml` pins; `rustup` installs it
|
||||
on the first `cargo` run in the checkout. The workspace's `rust-version` is
|
||||
1.95 too, the oldest Rust the GPUI front end's libraries build with (they
|
||||
call `std::hint::cold_path`, stable since 1.95.0), so a distribution's older
|
||||
`rustc` does not build the workspace.
|
||||
- **Linux:** the packages from the table above need
|
||||
`sudo apt install libasound2-dev libfontconfig1-dev libxkbcommon-dev libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev cmake dpkg-dev patchelf`,
|
||||
`sudo apt install libasound2-dev libfontconfig1-dev libxkbcommon-dev libxkbcommon-x11-dev libxcb1-dev libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev cmake dpkg-dev patchelf`,
|
||||
then `cargo build --release --locked -p voelin-ui -p voelin-gateway`
|
||||
and `scripts/package.sh linux`.
|
||||
- **The GPUI front end** (`cargo build -p voelin-gpui --release`, under construction,
|
||||
in no package yet) builds with the same development packages, which include
|
||||
`libxkbcommon-x11-dev` and `libxcb1-dev` (it links `libxkbcommon-x11` and
|
||||
`libxcb`, as `readelf -d` on the binary shows; the list above did not have
|
||||
their development packages before). At run time it needs those libraries installed, opens `libwayland-client`,
|
||||
the Vulkan loader (`libvulkan.so.1`) and `libEGL.so.1` by name, and draws
|
||||
through wgpu: a Vulkan driver (Mesa's RADV, ANV or NVK, NVIDIA's) or OpenGL,
|
||||
and in a virtual machine or a remote desktop Mesa's lavapipe
|
||||
(`mesa-vulkan-drivers`) in software. X11 needs a window manager for
|
||||
fullscreen and close requests.
|
||||
- **Windows:** [packaging/windows/README.md](../packaging/windows/README.md)
|
||||
(MSVC, vcpkg libvpx and dav1d, NSIS), then
|
||||
`bash scripts/fetch-ffmpeg-windows.sh ffmpeg && FFMPEG_DLL_DIR=ffmpeg bash scripts/package.sh windows`
|
||||
|
||||
+6
-5
@@ -89,9 +89,9 @@ the separate `release.yml` workflow below.
|
||||
|
||||
The workflow shares the repository's local system-dependencies action with
|
||||
GitHub CI and bootstraps rustup if absent, then installs the toolchain and
|
||||
components pinned in `rust-toolchain.toml`. Checkout uses a fully qualified
|
||||
GitHub action URL rather than depending on the instance's action-source
|
||||
configuration.
|
||||
components pinned in `rust-toolchain.toml` (1.95: a channel change there is all
|
||||
the runner needs). Checkout uses a fully qualified GitHub action URL rather
|
||||
than depending on the instance's action-source configuration.
|
||||
|
||||
No GitHub cache/artifact service or reusable-workflow support is required.
|
||||
The job does not need a Docker socket mounted inside its container; the
|
||||
@@ -131,8 +131,9 @@ docker run --rm --init -v "$PWD":/src -w /src -e HOME=/root \
|
||||
ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential ca-certificates cmake curl git jq pkg-config python3 \
|
||||
libasound2-dev libfontconfig1-dev libxkbcommon-dev libvpx-dev \
|
||||
libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev xvfb xauth
|
||||
libasound2-dev libfontconfig1-dev libxkbcommon-dev libxkbcommon-x11-dev \
|
||||
libxcb1-dev libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev \
|
||||
libclang-dev xvfb xauth
|
||||
curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | \
|
||||
sh -s -- -y --profile minimal --default-toolchain none
|
||||
. "$CARGO_HOME/env" && rustup toolchain install
|
||||
|
||||
+130
-17
@@ -14,8 +14,25 @@ listed in "History"), and every figure and check below was run again on
|
||||
the commits after it: nightly clippy is clean (`as_chunks` in `bgra.rs`, and
|
||||
a second lint that the first hid), the video headline says "raw" with the
|
||||
quiet-window pipeline figure beside it, and the `--no-drop` row's XDamage
|
||||
exception is explained (a counter window longer than the case). `gpui-kit`
|
||||
0.8.1 of 2026-10-26 is still unmeasured, as "The version to pin" says.
|
||||
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, but for the two video
|
||||
cases the foundation's review ran again on a quiet machine. 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".
|
||||
The foundation was reviewed and gated the same day (a Sonnet review, then the
|
||||
Opus gate: no blocker and no major, six minors), and the minors are closed in
|
||||
the commits after it: the meter's `/proc` test waits for a CPU tick instead of
|
||||
burning 60 ms, zbus runs on `async-io` alone in every binary (with a test for
|
||||
the order of ashpd's callers), the lock figures and the Lucide 1.43 credit are
|
||||
corrected, the slice list points at "Open choices for step 3", and the parity
|
||||
test sees a second brush or string. The risks the review and the gate left to
|
||||
the slices that meet them are in docs/ui.md, "For the next slices".
|
||||
|
||||
| Spike | The plan's no-go | Seen (software rendering, see Setup) | Verdict |
|
||||
|---|---|---|---|
|
||||
@@ -25,7 +42,8 @@ exception is explained (a counter window longer than the case). `gpui-kit`
|
||||
|
||||
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
|
||||
|
||||
@@ -36,7 +54,7 @@ Every figure on this page comes from one machine and one software stack:
|
||||
| Machine | AMD Ryzen 9 7950X3D (16 cores, 32 threads), 61 GiB, NixOS; no GPU was used |
|
||||
| Display | Xvfb `:91`, 3840x2160x24, openbox, a private D-Bus bus (`spikes/gpui/headless.sh`); the Wayland runs on sway's headless backend with its pixman renderer (`headless-wayland.sh`) |
|
||||
| Device | Mesa 26.2.5 lavapipe (`llvmpipe (LLVM 21.1.8, 256 bits)`) through wgpu's Vulkan backend, the only Vulkan driver (`VK_DRIVER_FILES` = its `lvp_icd.x86_64.json`); GPUI's log: "Selected GPU adapter: llvmpipe … (Vulkan)" |
|
||||
| GPUI | `gpui-kit` 0.8.0 (`gpui-pre` 0.3.9, `gpui-component` 0.8.0, `gpui-kit-assets` 0.8.0) |
|
||||
| GPUI | `gpui-kit` 0.8.0 (`gpui-pre` 0.3.9, `gpui-component` 0.8.0, `gpui-kit-assets` 0.8.0) for every figure on this page; the rebuild on 0.8.1 is under "The version to pin" |
|
||||
| Rust | 1.95.0 (fenix, `spikes/gpui/shell.sh`); nixpkgs 02c087f3fe67 for the libraries and tools |
|
||||
| Load | another task's load generator kept the machine busy for part of the day; every run records the load average before and after it (`<case>.load`), and the tables give it |
|
||||
|
||||
@@ -362,16 +380,67 @@ portal's, see "Dependencies").
|
||||
|
||||
### The version to pin
|
||||
|
||||
**`gpui-kit` 0.8.0, exactly**, the version measured here (gpui-pre 0.3.9).
|
||||
0.8.1 (gpui-pre 0.3.10) came out on 2026-10-26, after these spikes were
|
||||
built; step 3's first commit moves to the newest release only after
|
||||
building the three spikes on it (`cargo update -p gpui-kit --precise` in
|
||||
`spikes/gpui`, then the READMEs' runs). A pre-1.0 release may change any
|
||||
API (the pin is exact for that reason, and `gpui-kit` pins its `gpui-pre`
|
||||
exactly too); upgrades are commits of their own.
|
||||
**`gpui-kit` 0.8.1, exactly** (`gpui-pre` 0.3.10, `gpui-component` 0.8.1,
|
||||
`gpui-kit-assets` 0.8.1; wgpu 30 where 0.8.0 had 29), in the root workspace's
|
||||
`[workspace.dependencies]` and in `spikes/gpui`. The figures on this page were
|
||||
measured on 0.8.0 (`gpui-pre` 0.3.9), the version the spikes were built on;
|
||||
0.8.1 came out on 2026-10-26, a day after, and step 3's first commits rebuilt
|
||||
the three spikes on it before moving the client to it. A pre-1.0 release may
|
||||
change any API (the pin is exact for that reason, and `gpui-kit` pins its
|
||||
`gpui-pre` exactly too); upgrades are commits of their own.
|
||||
|
||||
**Rust 1.95 or newer.** No `gpui-kit` release builds on the client's Rust
|
||||
1.94: every `gpui-pre` 0.3.x (0.3.0 to 0.3.10, which every `gpui-kit` from
|
||||
**What the rebuild on 0.8.1 found** (2026-10-27, Xvfb `:96` with openbox and
|
||||
a private D-Bus bus from `headless.sh`, Mesa 26.2.5 lavapipe through wgpu's
|
||||
Vulkan backend: "Selected GPU adapter: llvmpipe (LLVM 21.1.8, 256 bits)
|
||||
(Vulkan)"; Rust 1.95.0; one run of each README's measurement command):
|
||||
|
||||
- `cargo update -p gpui-kit --precise 0.8.1` (after `=0.8.1` in
|
||||
`spikes/gpui/Cargo.toml`) moves 40 packages of the lock (1,069 entries
|
||||
before, 1,065 after): `gpui-kit`, `gpui-base`, `gpui-component` and
|
||||
`gpui-kit-assets` 0.8.0 to 0.8.1, the 19 `gpui-pre*` crates 0.3.9 to 0.3.10,
|
||||
wgpu (and its `-core`, `-hal`, `-types` and `-naga-bridge`) 29.0.4 to 30.0.1,
|
||||
naga 29 to 30, taffy 0.13 to 0.15, `bit-set` 0.9 to 0.10; `gpu-descriptor`,
|
||||
`gpu-descriptor-types` and `hexf-parse` go, `gpui-pre-ios`, `naga-types` and
|
||||
`objc2-ui-kit` come. **No source change**: the three spikes build as they
|
||||
were (release, 8 min 54 s on 32 threads at a load average of 70).
|
||||
- **Every check passes**: the composer's `drive.sh` 8 PASS (and the emoji
|
||||
probe), `ime.sh` 3 PASS (X11 preedit with fcitx5 and Pinyin), the windows'
|
||||
`drive.sh` 11 PASS (the second window, focus, fullscreen, the global hotkey
|
||||
with the studio window active, both closes). The composer's screenshot of
|
||||
the sample chat differs from the committed one in 579 of its 900,000 pixels
|
||||
(ImageMagick `compare`; by eye, the input's caret).
|
||||
- **The video cases cost what they cost on 0.8.0 per frame.** The machine was
|
||||
busier than for the 0.8.0 runs (load average 64 to 80 against 28 to 53;
|
||||
another task's builds), so the frame rates are lower and are not the
|
||||
comparison: the CPU a shown frame costs is (the process's CPU in percent of
|
||||
a core divided by the frames shown a second, which is 0.1 core-seconds a frame).
|
||||
|
||||
| Case (70 s, 10 not counted) | Shown fps | CPU, process | CPU % per fps shown | Load | 0.8.0's |
|
||||
|---|---|---|---|---|---|
|
||||
| static 2560x1440 (repaints) | 22.7 | 259 % (llvmpipe 250) | 11.4 | 71 / 76 | 11.7 (727 % at 62 fps) |
|
||||
| raw 2560x1440, 60 fps source | 13.4 | 174 % (llvmpipe 149, main 13.7, converter 8.0) | 13.0 | 76 / 64 | 12.5 to 13.1 (525 % at 41.9; 642 % at 49.0) |
|
||||
|
||||
The raw case's memory stays flat (493.8 MiB at the start of the steady part,
|
||||
473.3 at its end), so `cx.drop_image` keeps the atlas flat on 0.8.1 too; the
|
||||
negative control without it (`nodrop-1440p`, 12 s: 2.7 pictures shown a
|
||||
second at this load) grew by 408 MiB in its 10 s steady part, a 14 MiB
|
||||
picture for each one shown, where 0.8.0 grew by 1.9 GiB at 13.9 shown a
|
||||
second. The windows case with both windows open (`windows-both`, 45 s; the
|
||||
other two cases were not run) took 123 % of a core, showed the preview 14.4
|
||||
times of 15 a second, and its memory stayed flat. What the machine's load
|
||||
hid is the absolute frame rate: the busy machine's table above does not
|
||||
reproduce the 0.8.0 figures (62 fps static, 42 to 49 raw), only the cost per
|
||||
frame. The review of the foundation ran the two cases again on a quiet
|
||||
machine (load average 8 to 12, llvmpipe): **static 2560x1440 showed 61 fps
|
||||
and raw 2560x1440 59.1 fps**, so the 1440p60 figures hold on 0.8.1 in
|
||||
software (the raw case above 0.8.0's range); the first GPU run, in the
|
||||
viewer slice, still measures the rates on a real device.
|
||||
- Nothing in the spikes needed a patch for 0.8.1. The one-line emoji patch
|
||||
(below) is still where it was: `load_family` is unchanged in gpui-pre-wgpu
|
||||
0.3.10.
|
||||
|
||||
**Rust 1.95 or newer.** No `gpui-kit` release builds on the Rust 1.94 the
|
||||
client used before 5ce5c0d: every `gpui-pre` 0.3.x (0.3.0 to 0.3.10, which every `gpui-kit` from
|
||||
0.6.0 to 0.8.1 pins) calls `std::hint::cold_path`, stable since 1.95.0:
|
||||
|
||||
```text
|
||||
@@ -407,9 +476,40 @@ 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
|
||||
release binaries are 390 to 480 MB with line tables. A full debug build
|
||||
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 an executor
|
||||
once per connection, tokio when a tokio runtime is current on the thread that
|
||||
builds it and `async-io` with an I/O thread of its own otherwise. ashpd keeps
|
||||
one session connection for the whole process (a static in its `proxy.rs`), so
|
||||
the first ashpd caller decides the executor of every later portal call: when
|
||||
a tokio caller builds it first, a later `Proxy::new` from a thread with no
|
||||
runtime (a GPUI foreground task) panics with "there is no reactor running"
|
||||
(`get_property("version")` sets up zbus's property cache, which calls
|
||||
`tokio::task::spawn`). The move of e325b65 left both compiled in
|
||||
(voelin-platform's notify-rust asked zbus for `tokio`, `z-with-tokio`), and
|
||||
the merged binary was safe only because GPUI's colour-scheme call builds the
|
||||
connection before the engine's portal calls do. *Fixed* (the Opus gate's
|
||||
option a): notify-rust asks for `z` (`async-io`), so zbus is compiled with
|
||||
`async-io` alone in every binary, the Slint app's included, and every
|
||||
connection has an I/O thread of its own whoever builds it first
|
||||
(`cargo tree -e features -i zbus` names `tokio` nowhere; voelin-platform's
|
||||
own test dependency on zbus is `async-io` as well, since a test binary with
|
||||
both features shows the panic again). Two tests in voelin-platform
|
||||
(`tests/proxy.rs`, each on a private D-Bus bus) call ashpd from a thread
|
||||
with no tokio runtime and get the answer, the second after a tokio caller
|
||||
built the connection; that one fails with the panic above on the tree
|
||||
before the change.
|
||||
- **Size and compile time.** In the root workspace, which already carries
|
||||
Slint's and the codecs' dependencies, the foundation adds 292 entries to
|
||||
`Cargo.lock` (218 new names; 279 from gpui-kit, 13 from its `test-support`
|
||||
dev-dependency, which ships in no binary; gpui-kit's are 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.
|
||||
|
||||
@@ -527,6 +627,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<AppState>` 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 |
|
||||
@@ -539,7 +652,7 @@ changes"; emoji need the patch above before the chat slice (4).
|
||||
| New: ashpd features | GPUI and the client's portals cannot share a binary until the client uses `async-io`. |
|
||||
| New: short clicks on links | `InteractiveText` loses a click shorter than a frame. |
|
||||
| New: video upload cost | Every new picture is a new atlas texture plus two copies (spike 1); a persistent texture needs a GPUI change. |
|
||||
| New: Rust 1.95 | gpui-kit needs it; the client is on 1.94. |
|
||||
| New: Rust 1.95 | gpui-kit needs it; the client moved to 1.95.0 in 5ce5c0d (seven lints fixed). |
|
||||
|
||||
### Open choices for step 3
|
||||
|
||||
|
||||
+6
-3
@@ -869,9 +869,12 @@ Notes:
|
||||
covered by other windows may be stale. MIT-SHM needs a local server with
|
||||
MIT-SHM 1.2; otherwise GetImage is used. The only `unsafe` here is mapping
|
||||
our memfd (`capture/x11/shm.rs`).
|
||||
- Portal: `start` needs a tokio runtime (zbus runs on it) and may show the
|
||||
desktop's picker. Choices persist with `PersistMode::ExplicitlyRevoked`: store
|
||||
`PortalCapture::restore_token()` (e.g. in `voelin-store` settings) and pass it to
|
||||
- Portal: `start` runs on any executor (ashpd uses zbus's `async-io`, with an
|
||||
I/O thread of its own, in every binary of the workspace) and may show the
|
||||
desktop's picker; `stop` closes the portal session only inside a tokio
|
||||
runtime (elsewhere the session closes with the connection). Choices persist
|
||||
with `PersistMode::ExplicitlyRevoked`: store `PortalCapture::restore_token()`
|
||||
(e.g. in `voelin-store` settings) and pass it to
|
||||
`PortalCapture::with_restore_token` next time. The cursor is embedded when
|
||||
the portal supports it. Buffers: DMA-BUFs are offered first (a
|
||||
mandatory modifier property we fixate: the sink's tiled modifiers, best
|
||||
|
||||
+279
-1
@@ -6,7 +6,9 @@ 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). What its screens show
|
||||
is made by `crates/voelin-ui-vm`, which knows no UI toolkit ([Two
|
||||
crates](#two-crates)).
|
||||
crates](#two-crates)). `crates/voelin-gpui` is the second front end, on GPUI,
|
||||
under construction and built on the same view models and the same engine; the
|
||||
Slint one stays the app until it reaches parity.
|
||||
|
||||

|
||||
|
||||
@@ -46,6 +48,10 @@ crates/voelin-ui-vm/ view models and state, no UI toolkit
|
||||
the audio settings page (devices, form, microphone test, push to
|
||||
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:
|
||||
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
|
||||
@@ -943,6 +949,278 @@ renderer; the phone layouts are desktop renders, not Android device tests.
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
## 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, ends the app and, when
|
||||
there were sessions, waits 500 ms for the engine to send the
|
||||
closes before the runtime goes (as the Slint front end does)
|
||||
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/<name>.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<Vec<ChatLine>>`
|
||||
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**: the unit 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.
|
||||
`tests/launch_failure.rs` starts the built binary where its window cannot
|
||||
open (below): one of its two cases needs the test display of
|
||||
`VOELIN_X11_TEST_DISPLAY` and is skipped without it, as the X11 tests of
|
||||
the other crates are. `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. The binary
|
||||
links `libxcb` and `libxkbcommon-x11` (the build needs `libxkbcommon-x11-dev`
|
||||
and `libxcb1-dev`, which the package lists before it did not name) and opens
|
||||
`libwayland-client`, `libvulkan.so.1` and `libEGL.so.1` by name. 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).
|
||||
|
||||
A window that cannot open ends the app with the reason and exit status 1; it
|
||||
does not stay up without a window. With no usable driver (none installed, or
|
||||
`VK_DRIVER_FILES` pointing nowhere) the message is
|
||||
|
||||
```
|
||||
Error: cannot open the main window
|
||||
|
||||
Caused by:
|
||||
Failed to create surface: Failed to create surface for any enabled backend: {}
|
||||
```
|
||||
|
||||
and above it the log has the Vulkan loader's own lines (`vkCreateInstance:
|
||||
Found no drivers!`); install a driver or lavapipe. With no display server
|
||||
(neither `DISPLAY` nor `WAYLAND_DISPLAY` set, over ssh for one) it is `cannot
|
||||
open the main window`, caused by `no display: neither DISPLAY nor
|
||||
WAYLAND_DISPLAY names a display server`; GPUI alone would start its headless
|
||||
platform there, which opens windows that draw nothing and runs until it is
|
||||
stopped. `tests/launch_failure.rs` starts the binary both ways (the driver one
|
||||
needs the test display of `VOELIN_X11_TEST_DISPLAY`; it hides the drivers
|
||||
through `VK_DRIVER_FILES`, `__EGL_VENDOR_LIBRARY_DIRS` and
|
||||
`LIBGL_DRIVERS_PATH`, and is skipped where the machine's driver is found
|
||||
anyway).
|
||||
|
||||
| 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 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 colour, length, weight or duration on one side only, a
|
||||
changed value or a kind of declaration it does not know fails the test, and
|
||||
so does a brush other than `backdrop` or a string other than `mode` and
|
||||
`font-family` in the Slint file (those three it compares by name against
|
||||
the one gradient and the one family of `tokens.rs`, which it cannot
|
||||
enumerate: a second brush or string only on the Rust side is not seen).
|
||||
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/<name>.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):
|
||||
first the two open choices of the report that it touches
|
||||
(design/gpui-spikes.md, "Open choices for step 3"): emoji (the one-line
|
||||
`gpui-pre-wgpu` patch for colour emoji, or Noto Color Emoji bundled with a
|
||||
font setup that leaves out DejaVu's emoji range) and links (an `on_click`
|
||||
per link, or a fix of `InteractiveText`); 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`).
|
||||
|
||||
### For the next slices
|
||||
|
||||
What the foundation's review and the Opus gate (2026-10-27) found and left to
|
||||
the slices that meet it; none of it is a defect of what exists today.
|
||||
|
||||
- **The engine-event task drains its channel without yielding** (`app.rs`,
|
||||
`while let Some(event) = events.recv().await`): a burst of events (a server's
|
||||
first sync) keeps the receiver ready, so the loop handles them back to back
|
||||
without returning to GPUI's executor (a tokio receiver is cooperative only
|
||||
inside a tokio runtime), and the window waits for the whole burst. The shell
|
||||
slice takes what is queued in one go (`try_recv` after the first event, one
|
||||
`update`, one `cx.notify()`) or yields between events.
|
||||
- **The tick notifies the root every second** (`AppState::tick`), which draws
|
||||
the window once a second whether or not anything changed. Notify only on a
|
||||
change once the shell shows more than the uptime (the line of state moves
|
||||
with it today, and it is how the loop is seen to run).
|
||||
- **The hotkey portal calls `tokio::spawn`** (`voelin-platform`,
|
||||
`hotkey/portal.rs`, `PortalBackend::new`): it panics where no tokio runtime
|
||||
is current, and a GPUI foreground task has none. The GPUI front end starts
|
||||
the hotkey task on the engine's runtime (`runtime.spawn(...)`), as the Slint
|
||||
front end's `GlobalPtt::start(runtime, ...)` does, not from a foreground task.
|
||||
- **`PortalCapture::stop` closes the portal session only inside a tokio
|
||||
runtime** (`voelin-media`, `capture/portal.rs`: `Handle::try_current()`;
|
||||
elsewhere the session closes only with the connection). Stop a capture inside
|
||||
the engine's runtime, not on GPUI's thread.
|
||||
- **gpui-component's `ThemeRegistry` observer overwrites `VoelinTheme`'s
|
||||
mapping:** any change of the registry (loading JSON themes, `watch_dir`) runs
|
||||
`Theme::change(mode, None, cx)` on the active theme, which puts the registered
|
||||
theme's colours over the `ThemeColor` the second layer wrote. A slice that
|
||||
offers JSON themes or watches a theme directory re-applies `VoelinTheme`
|
||||
after the registry changed.
|
||||
- **The parity test and `build.rs` read `crates/voelin-ui/ui`** (`theme.slint`
|
||||
through `include_str!`, the icons directory), and `fonts.rs` the Inter files
|
||||
there: they move with step 9, when Slint goes (the icons and fonts to this
|
||||
crate, `tokens.rs` as the source of truth, the parity test removed).
|
||||
- **System mode's first frame is Light** until the colour-scheme portal answers
|
||||
(`cx.window_appearance()` before the window exists; `set_system_appearance`
|
||||
follows the answer): a dark desktop sees a light frame at start. The shell
|
||||
slice, which reads the settings, can start from the last resolved mode.
|
||||
- **The gate's deviations from the mapping table** of the report ("The theme
|
||||
against Theme tokens"): `bg-rail` is not mapped (the report has it with
|
||||
`surface` on `sidebar.background`; the sidebar takes `surface` and the shell
|
||||
reads `bg-rail` from `VoelinTheme`), one scrim stands for three (`scrim`,
|
||||
`scrim-light` and `overlay` are three values in `theme.slint`; gpui-component's
|
||||
`overlay` gets `scrim`), and gpui-base's non-colour tokens (radii, spacing,
|
||||
type, shadows, motion) are not written: gpui-base 0.8.1 has no storage to
|
||||
write them to, so those live in `VoelinTheme::metrics` only.
|
||||
- **The close grace is not seen end to end** until a slice opens sessions:
|
||||
`run()` waits `CLOSE_GRACE` (500 ms) for the engine to send the closes only
|
||||
when the window's close found sessions to close, and the binary opens none
|
||||
yet (the unit test counts the closes `shutdown` sends, and the engine ignores
|
||||
a close for a session it never opened). The first slice that opens a session
|
||||
checks against a server that no ghost client stays behind after the window is
|
||||
closed.
|
||||
|
||||
## Limits
|
||||
|
||||
- No drop shadows or blur (the software renderer draws none): glows are
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 160 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 160 KiB |
+1
-1
@@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "1.94"
|
||||
channel = "1.95"
|
||||
components = ["rustfmt", "clippy"]
|
||||
Executable
+99
@@ -0,0 +1,99 @@
|
||||
#!/bin/sh
|
||||
# Take a screenshot of the GPUI front end with development switches set,
|
||||
# headless, and close its window the way a user would (docs/ui.md, "The GPUI
|
||||
# front end"): the equivalent of scripts/shots.sh for `voelin-gpui`.
|
||||
#
|
||||
# scripts/gpui-shot.sh <out.png> [<VOELIN_OPEN> [<width>x<height>]]
|
||||
#
|
||||
# The window opens on a display of its own, never the desktop's: the script
|
||||
# runs itself again under `xvfb-run` (Debian, Ubuntu, the CI image) unless
|
||||
# GPUI_SHOT_HEADLESS=1 says the caller already did that, as on NixOS:
|
||||
#
|
||||
# GPUI_SHOT_HEADLESS=1 spikes/gpui/shell.sh spikes/gpui/headless.sh -- \
|
||||
# scripts/gpui-shot.sh docs/ui/gpui-swatch-dark.png swatch 1440x960
|
||||
#
|
||||
# Needs xdotool, xwd (x11-apps) and ImageMagick.
|
||||
#
|
||||
# Wayland is taken out of the environment (GPUI prefers it, so the window
|
||||
# would open on the desktop), and so are the desktop's session bus and its
|
||||
# portals; the app's state and the XDG directories are a temporary one.
|
||||
# GPUI needs a Vulkan driver or OpenGL at run time: on a machine without a
|
||||
# GPU, Mesa's lavapipe (`mesa-vulkan-drivers`) draws in software. Without a
|
||||
# window manager (xvfb-run alone) the window is stopped with TERM, with one
|
||||
# (openbox, as headless.sh starts) it gets a close request, which is what the
|
||||
# last line says.
|
||||
#
|
||||
# VOELIN_BIN: the binary (default target/release/voelin-gpui, else
|
||||
# target/debug); DELAY: seconds the window is shown before the picture
|
||||
# (default 4). VOELIN_DEV_THEME, VOELIN_FONT_SCALE and the other switches of
|
||||
# `src/dev.rs` are passed on as set.
|
||||
set -eu
|
||||
out=${1:?usage: gpui-shot.sh <out.png> [<VOELIN_OPEN> [<width>x<height>]]}
|
||||
open=${2:-}
|
||||
size=${3:-1440x960}
|
||||
w=${size%x*}
|
||||
h=${size#*x}
|
||||
if [ "${GPUI_SHOT_HEADLESS:-}" != 1 ]; then
|
||||
command -v xvfb-run >/dev/null || {
|
||||
echo "gpui-shot.sh: no xvfb-run; start a display of your own and set GPUI_SHOT_HEADLESS=1" >&2
|
||||
exit 2
|
||||
}
|
||||
GPUI_SHOT_HEADLESS=1 exec xvfb-run -a -s "-screen 0 $((w * 2))x$((h * 2))x24" "$0" "$@"
|
||||
fi
|
||||
[ -n "${DISPLAY:-}" ] || { echo "gpui-shot.sh: no DISPLAY" >&2; exit 2; }
|
||||
# ImageMagick 7 has `magick`; the 6 of Debian and Ubuntu has `convert` and `identify`.
|
||||
if command -v magick >/dev/null 2>&1; then
|
||||
to_png() { magick xwd:- "png:$1"; }
|
||||
size_of() { magick identify -format '%wx%h' "$1"; }
|
||||
else
|
||||
to_png() { convert xwd:- "png:$1"; }
|
||||
size_of() { identify -format '%wx%h' "$1"; }
|
||||
fi
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
bin=${VOELIN_BIN:-}
|
||||
if [ -z "$bin" ]; then
|
||||
target=${CARGO_TARGET_DIR:-$root/target}
|
||||
for kind in release debug; do
|
||||
[ -x "$target/$kind/voelin-gpui" ] && { bin=$target/$kind/voelin-gpui; break; }
|
||||
done
|
||||
fi
|
||||
[ -x "$bin" ] || { echo "gpui-shot.sh: no voelin-gpui binary (cargo build -p voelin-gpui --release)" >&2; exit 2; }
|
||||
work=$(mktemp -d)
|
||||
trap 'kill ${pid:-} 2>/dev/null || true; rm -rf "$work"' EXIT INT TERM
|
||||
mkdir -p "$work/runtime"
|
||||
chmod 700 "$work/runtime"
|
||||
env -u WAYLAND_DISPLAY -u WAYLAND_SOCKET -u XDG_SESSION_TYPE -u DBUS_SESSION_BUS_ADDRESS \
|
||||
XDG_RUNTIME_DIR="$work/runtime" XDG_CONFIG_HOME="$work/config" XDG_DATA_HOME="$work/data" \
|
||||
XDG_CACHE_HOME="$work/cache" XDG_STATE_HOME="$work/state" VOELIN_DATA_DIR="$work/data/voelin" \
|
||||
GPUI_X11_SCALE_FACTOR=1 VOELIN_FFMPEG=0 \
|
||||
VOELIN_OPEN="$open" VOELIN_WINDOW_SIZE="$size" \
|
||||
"$bin" >"$work/app.log" 2>&1 &
|
||||
pid=$!
|
||||
i=0
|
||||
until win=$(xdotool search --name '^Voelin$' 2>/dev/null | head -1) && [ -n "$win" ]; do
|
||||
i=$((i + 1))
|
||||
kill -0 "$pid" 2>/dev/null || { echo "gpui-shot.sh: the app ended before its window:" >&2; tail -20 "$work/app.log" >&2; exit 1; }
|
||||
[ $i -lt 300 ] || { echo "gpui-shot.sh: no window after 30 s:" >&2; tail -20 "$work/app.log" >&2; exit 1; }
|
||||
sleep 0.1
|
||||
done
|
||||
sleep "${DELAY:-4}"
|
||||
xwd -id "$win" -silent | to_png "$out"
|
||||
echo "$out: $(size_of "$out")"
|
||||
# Close it as a user does; with no window manager, ask the process to end.
|
||||
xdotool windowactivate --sync "$win" 2>/dev/null || true
|
||||
xdotool key alt+F4 2>/dev/null || true
|
||||
i=0
|
||||
while kill -0 "$pid" 2>/dev/null; do
|
||||
i=$((i + 1))
|
||||
if [ $i -ge 30 ]; then
|
||||
kill -TERM "$pid" 2>/dev/null || true
|
||||
wait "$pid" 2>/dev/null || true
|
||||
echo "stopped with TERM (no window manager closed it)"
|
||||
exit 0
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
status=0
|
||||
wait "$pid" || status=$?
|
||||
echo "closed by the window manager, exit code $status"
|
||||
exit "$status"
|
||||
Generated
+146
-161
@@ -810,9 +810,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.9.1"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34ddef2995421ab6a5c779542c81ee77c115206f4ad9d5a8e05f4ff49716a3dd"
|
||||
checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d"
|
||||
dependencies = [
|
||||
"bit-vec 0.9.1",
|
||||
]
|
||||
@@ -1213,7 +1213,7 @@ checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"block",
|
||||
"cocoa-foundation 0.1.2",
|
||||
"cocoa-foundation",
|
||||
"core-foundation 0.9.4",
|
||||
"core-graphics 0.23.2",
|
||||
"foreign-types",
|
||||
@@ -1221,22 +1221,6 @@ dependencies = [
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa"
|
||||
version = "0.26.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad36507aeb7e16159dfe68db81ccc27571c3ccd4b76fb2fb72fc59e7a4b1b64c"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"block",
|
||||
"cocoa-foundation 0.2.1",
|
||||
"core-foundation 0.10.1",
|
||||
"core-graphics 0.24.0",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa-foundation"
|
||||
version = "0.1.2"
|
||||
@@ -1251,19 +1235,6 @@ dependencies = [
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa-foundation"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81411967c50ee9a1fc11365f8c585f863a22a9697c89239c452292c40ba79b0d"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"block",
|
||||
"core-foundation 0.10.1",
|
||||
"core-graphics-types 0.2.0",
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "codespan-reporting"
|
||||
version = "0.13.1"
|
||||
@@ -2599,12 +2570,6 @@ version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.2.0"
|
||||
@@ -3023,31 +2988,11 @@ dependencies = [
|
||||
"windows 0.62.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gpu-descriptor"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b89c83349105e3732062a895becfc71a8f921bb71ecbbdd8ff99263e3b53a0ca"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"gpu-descriptor-types",
|
||||
"hashbrown 0.15.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gpu-descriptor-types"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gpui-base"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d5cd7de73d5b2d3d18b94a928abf343922091fa77bc472f77b7d2e7e8b1823a7"
|
||||
checksum = "d862bc8f2e27710039013d075ac4995892e9687ff207fa530f880cbcd513936f"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"anyhow",
|
||||
@@ -3086,9 +3031,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-component"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4097e161cc81e86323b439664be0cdd4f7c56148e867ed6f67fd72b966b6c2d1"
|
||||
checksum = "46ce53430332e30f303364eaabfa10ed2aa23dfaf2a147e04370e0e9c423578b"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@@ -3133,9 +3078,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-component-macros"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b98496748463b60ad69eab80cd91fc9b3807fed9a0e01ab4d5c159c949fd814"
|
||||
checksum = "a512c830553e7dddc43c3f8faffc2d2d7bd24db21fe3dc1326dde9c470013768"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -3145,9 +3090,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-kit"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3cdcb78553bef8785669e572e79759b0eab47fdd9d318fe0cce1def798189432"
|
||||
checksum = "25210f6e59ea9ffac3a033dbce9edafe5ff0dd2900f894fd1316f54da2fe2b89"
|
||||
dependencies = [
|
||||
"gpui-base",
|
||||
"gpui-component",
|
||||
@@ -3160,9 +3105,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-kit-assets"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b037e2fa43d53a567a8aa5be6b1a8931f416cbd010ceee8d4a3727a71e9b1d05"
|
||||
checksum = "c214017b45e5654665f18faa551f58a2c2c8d25efe6632b1a443ba8edf365e96"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"gpui-pre",
|
||||
@@ -3175,9 +3120,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34f61c1cfd36fc9c436af09308c963822ae27a45a84feb21a77ba5c9e051f1c0"
|
||||
checksum = "df4b5f8d0c278308df2f11e0bfe0212dd77d7848ce1bdc4b9d513334414396f6"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"anyhow",
|
||||
@@ -3240,9 +3185,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-apple"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b52f58893fe1a0836464428dfad2b5eaf42c9c303a9638f4c2aced5a69072a15"
|
||||
checksum = "e97cd068d8134b4e073321b946491760aa1e4511e486084a92e73b9174bff78a"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-task",
|
||||
@@ -3282,9 +3227,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-collections"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "920c2f5b2f1a7813114d89f4841f26f6060d9c35d7c8a852a4205d1a767a7ce0"
|
||||
checksum = "8f89bf8941a7437dd761161c552543fb8268b9633fe74e29eafbe0014cd2164b"
|
||||
dependencies = [
|
||||
"gpui-pre-util",
|
||||
"indexmap",
|
||||
@@ -3293,9 +3238,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-derive-refineable"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "947395f26228296c0c79fb889d3687b205e552c25bbcdece216fb2394ea9bcd1"
|
||||
checksum = "2998b1cebbaa0fa004fe4939a513bbf4103c7fb69ae2e84ee73634554e3f7edc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -3304,9 +3249,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-http-client"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c56cdaa3f1a271162b7fede1d4557879eedb056e293cedbb82743600650b755e"
|
||||
checksum = "e516820ee56ac357a87ff97b1a2c5f22c8d5dcd2a50cdd15c16949f24464d98e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
@@ -3322,10 +3267,32 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-linux"
|
||||
version = "0.3.9"
|
||||
name = "gpui-pre-ios"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e28213c3fde6f13e91ba0b74b90cbaadec9373e36a031eda98561d31059870f3"
|
||||
checksum = "5773a1e3a399df64f3ecc5538727fd0575279bd190959cf97a9e2b698c0310b8"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"block2 0.6.2",
|
||||
"futures",
|
||||
"gpui-pre",
|
||||
"gpui-pre-apple",
|
||||
"log",
|
||||
"objc2 0.6.4",
|
||||
"objc2-core-foundation",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-quartz-core 0.3.2",
|
||||
"objc2-ui-kit",
|
||||
"parking_lot",
|
||||
"raw-window-handle",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-linux"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c6ffd2dce7b75cce0bb3382994912f84c2a05389a4a236bb8bd72cb098fc083"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"accesskit_unix",
|
||||
@@ -3368,15 +3335,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-macos"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7c988b7e49775cc8542dbe48d5a10e073d8e898a023ef3ff3d24f33363e9863"
|
||||
checksum = "7e07a5e5c84f0b2160c194a1c852cc89d1942db66867938ceabcd7f763cb4386"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"accesskit_macos",
|
||||
"anyhow",
|
||||
"block2 0.6.2",
|
||||
"cocoa 0.26.1",
|
||||
"core-foundation 0.10.1",
|
||||
"core-foundation-sys",
|
||||
"core-graphics 0.24.0",
|
||||
@@ -3392,9 +3358,9 @@ dependencies = [
|
||||
"image",
|
||||
"itertools 0.14.0",
|
||||
"log",
|
||||
"objc",
|
||||
"objc2 0.6.4",
|
||||
"objc2-app-kit 0.3.2",
|
||||
"objc2-core-graphics",
|
||||
"objc2-core-video",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-user-notifications",
|
||||
@@ -3408,9 +3374,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-macros"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bb80dac5e1f6b8cde1d2740389e77dfc0071bfcc81fba5526d5dc90f68171cc"
|
||||
checksum = "9c95d70a9fe10701533606c6135f9a1d4cd96e87e4e6062b3d426eb57b415daf"
|
||||
dependencies = [
|
||||
"heck 0.5.0",
|
||||
"proc-macro-crate",
|
||||
@@ -3421,13 +3387,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-platform"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbdbdac421178313fed8929fe95b42634a266a735079fcf03ff231bc2ccb2c5e"
|
||||
checksum = "e8a7f07a15187e82ec76491492c7e3245db1b59633d3bedb00b828ffaf67c4b8"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"console_error_panic_hook",
|
||||
"gpui-pre",
|
||||
"gpui-pre-ios",
|
||||
"gpui-pre-linux",
|
||||
"gpui-pre-macos",
|
||||
"gpui-pre-web",
|
||||
@@ -3436,9 +3403,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-refineable"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "237703b3b219d11adb50dd33bb0fcca3d34fc001623b3143e72cb051d0fb3777"
|
||||
checksum = "4ce7e83592bc6c1ead2affd91b333f11b60c3eb7d06cae1605dd56f149fe8674"
|
||||
dependencies = [
|
||||
"gpui-pre-derive-refineable",
|
||||
]
|
||||
@@ -3495,9 +3462,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-scheduler"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83f342555282a59ed8dd58dd7e0a920524fa8ef6aa8c8f30e2edb7019a8f72cb"
|
||||
checksum = "87c2c6b0fabcd20e6773a0be30afa1f25637c53a06201bb80ab24a21fe198865"
|
||||
dependencies = [
|
||||
"async-task",
|
||||
"backtrace",
|
||||
@@ -3512,9 +3479,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-shared-string"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71f488bf4780735f6b2dad24f8db1e3d9e2593de0ec298e3574c788f571b81c4"
|
||||
checksum = "8068f94355f173558a51998a32985a434af54cc6c7262a060fffc369a505998f"
|
||||
dependencies = [
|
||||
"schemars",
|
||||
"serde",
|
||||
@@ -3523,9 +3490,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-sum-tree"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aadb3bd3da22617e2158b1842f5a9c29c1626c926ad0686163ced1a009963ff3"
|
||||
checksum = "c1ce66c57e9b5fd6c7a90fa9f9de2f9bb342127d670ca3c8fe5885270079eefa"
|
||||
dependencies = [
|
||||
"gpui-pre-ztracing",
|
||||
"heapless",
|
||||
@@ -3535,9 +3502,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-util"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a04ec9abd7a87ac05a221f4629403831c44c17123bc33cb5d271a6303259b340"
|
||||
checksum = "162dc29b2d2c0223ee4bb4e9f5e913eab4f62cad0943eb0c1122a74ac82b0768"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"log",
|
||||
@@ -3546,9 +3513,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-web"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aedd55b99dc77e28df8202b0ea868aa5c90fda4aefff539ea21087d7c2ff4bfb"
|
||||
checksum = "1acd86af2347f0dd8b63c441a5dbd43b3fcd7dac69b340827c3497da5a13d6fb"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-channel",
|
||||
@@ -3576,9 +3543,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-wgpu"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b1cdb26c1503bf9662ee8fbc5ab0b44b2deeee4b5c12dc67491ba6fb5fc544b"
|
||||
checksum = "ce693915768aae38bf788f245af75aae78e3e1179245860fc80ce831d0a8f74e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytemuck",
|
||||
@@ -3603,9 +3570,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-windows"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "513d4f0fc7d596d3bdef2a73a524ffb83dabc95bf484f2855a698e7f431290a9"
|
||||
checksum = "80670f987b920fba019917b2e222ecf2b377f2a6d77872010c7d284c235837b3"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"accesskit_windows",
|
||||
@@ -3633,9 +3600,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-ztracing"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f17bfd6bd1f77ba5c58181fa6f82fc7a63015a1c58bef94a76e5acb9f8e42572"
|
||||
checksum = "814cc08c526961c88703806a68ba4cf216a1d988ffbbdc673304f4dd25858952"
|
||||
dependencies = [
|
||||
"gpui-pre-ztracing-macro",
|
||||
"tracing",
|
||||
@@ -3643,9 +3610,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpui-pre-ztracing-macro"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b0d73e1bc02eef886a5947f41b8512708792e9e5d3053d181843311a487f96f"
|
||||
checksum = "e0f9dae92b9bc15baa6e530c90bdd4c689d3710bd4d18c3566deb1d6ae182daf"
|
||||
|
||||
[[package]]
|
||||
name = "granit-parser"
|
||||
@@ -3738,15 +3705,6 @@ version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
dependencies = [
|
||||
"foldhash 0.1.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.16.1"
|
||||
@@ -3755,7 +3713,7 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
"foldhash 0.2.0",
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3764,7 +3722,7 @@ version = "0.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
||||
dependencies = [
|
||||
"foldhash 0.2.0",
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3816,12 +3774,6 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e712f64ec3850b98572bffac52e2c6f282b29fe6c5fa6d42334b30be438d95c1"
|
||||
|
||||
[[package]]
|
||||
name = "hexf-parse"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
||||
|
||||
[[package]]
|
||||
name = "hickory-net"
|
||||
version = "0.26.3"
|
||||
@@ -5105,9 +5057,9 @@ checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d"
|
||||
|
||||
[[package]]
|
||||
name = "naga"
|
||||
version = "29.0.4"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2bf919621e7975acb27d881bae2fb993e0d45c8e0446e85e6272971e00dc8df"
|
||||
checksum = "a616d2fb8c89516ac2723a581f69d6c18576046bed761bd6b305e5618e6ae130"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-set",
|
||||
@@ -5116,11 +5068,11 @@ dependencies = [
|
||||
"cfg_aliases",
|
||||
"codespan-reporting",
|
||||
"half",
|
||||
"hashbrown 0.16.1",
|
||||
"hexf-parse",
|
||||
"hashbrown 0.17.1",
|
||||
"indexmap",
|
||||
"libm",
|
||||
"log",
|
||||
"naga-types",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"rustc-hash 1.1.0",
|
||||
@@ -5129,6 +5081,18 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "naga-types"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "590afbf58a6f4f62873cd5cff4468061844bafa1cdf399cc954537c22d768d49"
|
||||
dependencies = [
|
||||
"hashbrown 0.17.1",
|
||||
"indexmap",
|
||||
"rustc-hash 1.1.0",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk"
|
||||
version = "0.9.0"
|
||||
@@ -5552,7 +5516,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"block2 0.6.2",
|
||||
"dispatch2",
|
||||
"libc",
|
||||
"objc2 0.6.4",
|
||||
]
|
||||
|
||||
@@ -5715,6 +5681,7 @@ dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"objc2 0.6.4",
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-graphics",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-metal 0.3.2",
|
||||
]
|
||||
@@ -5728,6 +5695,20 @@ dependencies = [
|
||||
"objc2-core-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-ui-kit"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"block2 0.6.2",
|
||||
"objc2 0.6.4",
|
||||
"objc2-core-foundation",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-quartz-core 0.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-user-notifications"
|
||||
version = "0.3.2"
|
||||
@@ -6545,7 +6526,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools 0.13.0",
|
||||
"itertools 0.14.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
@@ -7404,7 +7385,7 @@ checksum = "e806c2a9701cbd6043992cd935c30cb1fdb128fa15e7b506f3b46f97045737c0"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"base62",
|
||||
"foldhash 0.2.0",
|
||||
"foldhash",
|
||||
"globwalk",
|
||||
"itertools 0.11.0",
|
||||
"normpath",
|
||||
@@ -7818,7 +7799,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8050abb251097357e24aff63ba2c52a6309ecb7d23a5474023df960a02694d8"
|
||||
dependencies = [
|
||||
"annotate-snippets",
|
||||
"base64 0.22.1",
|
||||
"base64 0.23.1",
|
||||
"encoding_rs_io",
|
||||
"granit-parser",
|
||||
"nohash-hasher",
|
||||
@@ -8756,11 +8737,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "taffy"
|
||||
version = "0.13.0"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c034e05f6ee85a12daa63863c2245797715075c70649947aa0da54f3f2ab1d0f"
|
||||
checksum = "31f7bd2d97198df05186f93a3a3c306845f40e8b3c22bf9279cdd7e5cf5fea7d"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"serde",
|
||||
"slotmap",
|
||||
"smallvec",
|
||||
@@ -8808,7 +8788,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom 0.3.4",
|
||||
"getrandom 0.4.3",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.61.2",
|
||||
@@ -10185,9 +10165,9 @@ checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
|
||||
|
||||
[[package]]
|
||||
name = "wgpu"
|
||||
version = "29.0.4"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76e8840e1ba2881d4cbb18d2147627a56af426ff064c0401eb0c8410c6325d07"
|
||||
checksum = "527ccdf43dd5b2e8676eed9984ce00e2bbb0a1b85b70c1969dcb6cd2eb55ab9e"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags 2.13.2",
|
||||
@@ -10195,7 +10175,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"document-features",
|
||||
"hashbrown 0.16.1",
|
||||
"hashbrown 0.17.1",
|
||||
"js-sys",
|
||||
"log",
|
||||
"naga",
|
||||
@@ -10215,9 +10195,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "29.0.4"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f519832254e56965a9940c4af57dcb75f702b6f6fa4a0b172f685395843a4d7"
|
||||
checksum = "14c018fce9b6270aa203c2fdd56f3cce996713534bd757e4ea58c8560b121f14"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-set",
|
||||
@@ -10226,10 +10206,11 @@ dependencies = [
|
||||
"bytemuck",
|
||||
"cfg_aliases",
|
||||
"document-features",
|
||||
"hashbrown 0.16.1",
|
||||
"hashbrown 0.17.1",
|
||||
"indexmap",
|
||||
"log",
|
||||
"naga",
|
||||
"naga-types",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"portable-atomic",
|
||||
@@ -10249,45 +10230,45 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-core-deps-apple"
|
||||
version = "29.0.4"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5e39e26c4c0e07589e67d18546cf79ff45383659fc72fca4dd293358a0347f3"
|
||||
checksum = "061f3d319a40d39d00b1ecc2c33b89fe21d4e6fe01859df3500a3a8ecccd6b68"
|
||||
dependencies = [
|
||||
"wgpu-hal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-core-deps-emscripten"
|
||||
version = "29.0.4"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01e09be551dc939498bdd5f6b2c66e55ab275dad25825267a08605a80fc9f0af"
|
||||
checksum = "d98b86cf4abf524a902dd35f18ca6a3f08fc2ae9847c8f10b48e30491b1f0b86"
|
||||
dependencies = [
|
||||
"wgpu-hal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-core-deps-wasm"
|
||||
version = "29.0.4"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af1fb1798be2a912497d4c224f72d39bb0cb34af50e8bcc29865bc339c943059"
|
||||
checksum = "d260ca2ca8adc654f513a869bf3cac0b47f5b8d3f87803d6942015f8de597aae"
|
||||
dependencies = [
|
||||
"wgpu-hal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-core-deps-windows-linux-android"
|
||||
version = "29.0.4"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e592c1bbef6ad047647ae6e666ebd8cee7a32bb4544d9700ec96cbf73230257"
|
||||
checksum = "7586165fd5f6d881cb9ce4bb71f40d6caab2c0f1837e3fc1d9788a197fb6004f"
|
||||
dependencies = [
|
||||
"wgpu-hal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-hal"
|
||||
version = "29.0.4"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97ace1c17727311c22a46e4e3faf56ea6de81af99dcc839bdfb54857b94d448d"
|
||||
checksum = "b6b7fb58561a792bc237628ba0792e332de418fefe145f13b5ed8201e6d52f58"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"arrayvec",
|
||||
@@ -10301,17 +10282,18 @@ dependencies = [
|
||||
"glow",
|
||||
"glutin_wgl_sys",
|
||||
"gpu-allocator",
|
||||
"gpu-descriptor",
|
||||
"hashbrown 0.16.1",
|
||||
"hashbrown 0.17.1",
|
||||
"js-sys",
|
||||
"khronos-egl",
|
||||
"libc",
|
||||
"libloading",
|
||||
"log",
|
||||
"naga",
|
||||
"naga-types",
|
||||
"ndk-sys",
|
||||
"objc2 0.6.4",
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-graphics",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-metal 0.3.2",
|
||||
"objc2-quartz-core 0.3.2",
|
||||
@@ -10326,6 +10308,7 @@ dependencies = [
|
||||
"raw-window-metal",
|
||||
"renderdoc-sys",
|
||||
"smallvec",
|
||||
"static_assertions",
|
||||
"thiserror 2.0.21",
|
||||
"wasm-bindgen",
|
||||
"wayland-sys",
|
||||
@@ -10339,9 +10322,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-naga-bridge"
|
||||
version = "29.0.4"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95226013f547544b223281cd16a4fb549aa9dcb562adbda0faae4c73ffbbc161"
|
||||
checksum = "d2f62e73117bb7a62bfd9c5a5841438a823f6566c6442a808ee269d2d055c081"
|
||||
dependencies = [
|
||||
"naga",
|
||||
"wgpu-types",
|
||||
@@ -10349,15 +10332,17 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "29.0.4"
|
||||
version = "30.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84bf84cd9ca8ca45e2b223a3868f1adf9bfc0c66aeac212e76ee7e40fdadf8f5"
|
||||
checksum = "99dad6f1fbdbbdb4c278a6508b059d44688f5cebddf78d005a46a31340269286"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"bytemuck",
|
||||
"js-sys",
|
||||
"log",
|
||||
"naga-types",
|
||||
"raw-window-handle",
|
||||
"static_assertions",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
@@ -10408,7 +10393,7 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -11433,7 +11418,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6b338d705ae33a43ca00287c11129303a7a0aa57b101b72a1c08c863f698ac8"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cocoa 0.25.0",
|
||||
"cocoa",
|
||||
"core-graphics-helmer-fork",
|
||||
"log",
|
||||
"objc",
|
||||
|
||||
@@ -16,7 +16,7 @@ publish = false
|
||||
|
||||
[workspace.dependencies]
|
||||
# GPUI, gpui-component and their assets, pinned exactly (pre-1.0).
|
||||
gpui-kit = "=0.8.0"
|
||||
gpui-kit = "=0.8.1"
|
||||
spike-common = { path = "common" }
|
||||
# The client's crates, read only. voelin-core brings LocalPreview (the test
|
||||
# pattern through the real encoder and decoder).
|
||||
|
||||
@@ -19,9 +19,11 @@ read only, by path (`voelin-core`, `voelin-media`, `voelin-platform`,
|
||||
|
||||
## Toolchain
|
||||
|
||||
`gpui-kit` 0.8.0 is pinned exactly. No `gpui-kit` release builds with the
|
||||
repository's Rust 1.94: every `gpui-pre` 0.3.x (the GPUI snapshot under all
|
||||
of them) calls `std::hint::cold_path`, stable since 1.95.0 (E0658 on 1.94).
|
||||
`gpui-kit` 0.8.1 is pinned exactly (`gpui-pre` 0.3.10; the report's figures are
|
||||
0.8.0's, and its "The version to pin" tells what the rebuild on 0.8.1 found).
|
||||
No `gpui-kit` release builds with the Rust 1.94 the repository used before
|
||||
5ce5c0d: every `gpui-pre` 0.3.x (the GPUI snapshot under all of them) calls
|
||||
`std::hint::cold_path`, stable since 1.95.0 (E0658 on 1.94).
|
||||
The workspace says `rust-version = "1.95"`; the spikes build with 1.95.0
|
||||
(the default of `shell.sh`) and nightly 2026-10-24 (`TOOLCHAIN=nightly`,
|
||||
rustc 1.101.0-nightly of 2026-10-23), both from one pinned fenix; clippy
|
||||
|
||||
@@ -434,7 +434,8 @@ impl Roundtrip {
|
||||
GatewayUpdate::Reaction { message_id, added: true, .. }
|
||||
if self.step == Step::React && *message_id == self.remote =>
|
||||
{
|
||||
if self.reacted_row {
|
||||
let reacted = self.reacted_row;
|
||||
if reacted {
|
||||
self.next(engine, Step::Topic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +324,8 @@ async fn listen(
|
||||
let end = pump(con, deadline, |con, item| {
|
||||
match item {
|
||||
StreamItem::BookEvents(events) => {
|
||||
if print_events(con.get_state()?, &events, json, expect)? {
|
||||
let done = print_events(con.get_state()?, &events, json, expect)?;
|
||||
if done {
|
||||
return Ok(Flow::Stop);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user