diff --git a/crates/voelin-gpui/src/app.rs b/crates/voelin-gpui/src/app.rs index 003eed7..93a1f8a 100644 --- a/crates/voelin-gpui/src/app.rs +++ b/crates/voelin-gpui/src/app.rs @@ -21,7 +21,7 @@ //! //! The root notifies on every batch of events and on every move of the user's; //! it is the views (`crate::shell`) that decide whether what they show changed -//! and draw again only then. What a transition asks for besides the state +//! and tell the window only then (the window draws every part). What a transition asks for besides the state //! (`Update`) is carried out as far as this front end has the parts: the //! engine's commands go out, the status line is set, what is to be kept goes //! to the store, a setting the theme follows is applied and the warnings are diff --git a/crates/voelin-gpui/src/shell/main_panel.rs b/crates/voelin-gpui/src/shell/main_panel.rs index 0d84c59..7c1c15a 100644 --- a/crates/voelin-gpui/src/shell/main_panel.rs +++ b/crates/voelin-gpui/src/shell/main_panel.rs @@ -2,7 +2,7 @@ //! empty page: the "no server selected" state with the way to add one, and for //! a server on screen its name, address and state with the buttons that //! connect, disconnect and edit it. An entity of its own: it observes the root -//! state and draws again only when what it shows changed. +//! state and tells the window only when what it shows changed. use gpui_kit::component::button::{Button, ButtonVariants as _}; use gpui_kit::prelude::FluentBuilder as _; diff --git a/crates/voelin-gpui/src/shell/mod.rs b/crates/voelin-gpui/src/shell/mod.rs index 5ebc4bd..541a092 100644 --- a/crates/voelin-gpui/src/shell/mod.rs +++ b/crates/voelin-gpui/src/shell/mod.rs @@ -1,9 +1,10 @@ //! The desktop shell of the GPUI front end (`ui/shells/desktop.slint` and //! the server callbacks of `bind/servers.rs`): the server rail, the top bar, //! the sidebar, the main area, the server form and the toast, each an entity -//! that observes the root state ([`crate::app::AppState`]) and draws again -//! only when what it shows changed, and the actions the user's moves are -//! ([`actions`]). [`crate::view::MainView`] puts them in the window. +//! that observes the root state ([`crate::app::AppState`]) and tells the window +//! only when what it shows changed (the window then draws every part), and the +//! actions the user's moves are ([`actions`]). [`crate::view::MainView`] puts +//! them in the window. pub mod actions; mod form; diff --git a/crates/voelin-gpui/src/shell/rail.rs b/crates/voelin-gpui/src/shell/rail.rs index dea9a2b..12eaf40 100644 --- a/crates/voelin-gpui/src/shell/rail.rs +++ b/crates/voelin-gpui/src/shell/rail.rs @@ -1,7 +1,7 @@ //! The server rail: the saved servers as avatars with their state, the //! selection, the add-server button and the settings button (`ServerRail` of //! `ui/shells/desktop.slint`). An entity of its own: it observes the root -//! state and draws again only when the servers it lists changed. +//! state and tells the window only when the servers it lists changed. use gpui_kit::prelude::FluentBuilder as _; use gpui_kit::{ diff --git a/crates/voelin-gpui/src/shell/sidebar.rs b/crates/voelin-gpui/src/shell/sidebar.rs index 269c32f..73587f9 100644 --- a/crates/voelin-gpui/src/shell/sidebar.rs +++ b/crates/voelin-gpui/src/shell/sidebar.rs @@ -2,7 +2,7 @@ //! `shells/common.slint`): the server on screen, the place of its channel tree //! (the next slice), the voice card while voice is connecting or connected, and //! the user's own card with the voice buttons. An entity of its own: it -//! observes the root state and draws again only when what it shows changed. +//! observes the root state and tells the window only when what it shows changed. use gpui_kit::prelude::FluentBuilder as _; use gpui_kit::{ diff --git a/crates/voelin-gpui/src/view.rs b/crates/voelin-gpui/src/view.rs index 2810a61..f54b6c6 100644 --- a/crates/voelin-gpui/src/view.rs +++ b/crates/voelin-gpui/src/view.rs @@ -234,8 +234,10 @@ fn report(app: &Entity, window: &Window, cx: &mut App) { impl Render for MainView { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { - // One render of the window is one frame: the parts draw when they are - // told, and the window is drawn when one was. + // One render of the window is one frame. A part that has something new + // tells the window, and the window then renders every part (gpui-pre + // renders each uncached child view on every frame); a window nobody + // tells is not drawn. self.counters.renders.incr(); let theme = VoelinTheme::global(cx).clone(); let (c, m) = (&theme.colors, &theme.metrics); diff --git a/docs/design/gpui-spikes.md b/docs/design/gpui-spikes.md index 71fa5be..a74e319 100644 --- a/docs/design/gpui-spikes.md +++ b/docs/design/gpui-spikes.md @@ -37,8 +37,9 @@ the slices that meet them are in docs/ui.md, "For the next slices". Item 5, the desktop shell, is slice 1 of the step's list and landed on `phase5/gpui-shell` (2026-10-27): the store at start (the client's database, the settings with the UI's keys, the secrets, the default identity), the server rail, the sidebar, -the top bar and the main area as entities that draw when what they show -changed, the eleven callbacks of `bind/servers.rs` as actions through +the top bar and the main area as entities that tell the window when what they +show changed (the window then draws every part: gpui-pre 0.3.10 renders every +uncached child view on every frame), the eleven callbacks of `bind/servers.rs` as actions through `voelin-ui-vm`'s logic and the engine's commands, the window's size and position kept in `ui.window`, the engine-event task in steps and a tick that draws nothing. What it shows, what it costs idle and what it leaves to the diff --git a/docs/ui.md b/docs/ui.md index fde833d..ecf6f8b 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -1141,9 +1141,15 @@ is the server form. What is on screen, each part an entity of `crates/voelin-gpui/src/shell/` that observes the root state, makes its view of it (`voelin_ui_vm::servers::logic`: `rail`, `toolbar`) and tells the window only when the view differs from the one -it showed: an engine event about a talker, a setting that is not the theme's or -a tick draws nothing (the `what_changes_nothing_shown_draws_nothing` test counts -the parts told). +it showed (`cx.notify()`): an engine event about a talker, a setting that is not +the theme's or a tick tells no part, so the window is not drawn at all (the +`what_changes_nothing_shown_draws_nothing` test counts the parts told). A part +that is told tells the window, and **the window draws every part**: in gpui-pre +0.3.10 a child view embedded with `.child(entity)` is rendered again on every +frame (only `Entity::cached` and `AnyView::cached`, which need a definite size, +reuse a subtree until its entity is notified), so the parts' comparison saves the +frames of a window nobody changes, not the work inside a frame ("For the next +slices" says what the heavy panes do about it). - **The rail** (`rail.rs`): the app's mark, then the saved servers as 46 pixel rounded squares (the server's icon from the engine's cache, else its initials @@ -1358,6 +1364,35 @@ entries); the in-window keys as GPUI key bindings and the global ones through 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. +- **A part's notify draws the whole window, and `Update.refresh` is not used + yet.** The root notifies on every batch and each part compares the whole view + it would show with the one it showed; a part that differs tells the window, + and the window renders every uncached child view (gpui-pre 0.3.10: only + `Entity::cached` and `AnyView::cached` skip one). With a rail, a sidebar and a + top bar that costs little; the channel tree and the members of slice 2 (and + later the chat's list and the stream tiles) are heavy, and one talker's + indicator must not render the rail and the chat. Slice 2 embeds the heavy panes + with `Entity::cached` (a definite size is needed: the pane's bounds come from + its place in the layout) and turns `Update.refresh` (`voelin_ui_vm::host:: + Refresh`: `servers`, `toolbar`, `tree`, `chat`, ...; `perform` drops it today) + into per-area signals, a generation or a flag per pane that its entity + observes, so that a change of the tree or the members notifies those panes and + not the rail and the chat. +- **`Update.reloaded` is ignored, and `img()` caches by path.** `perform` drops + `Update.reloaded` (the pictures the engine wrote again, whose decoded copies a + front end drops). GPUI's `img()` caches what it decoded per source in the + asset cache, so a picture rewritten into the same cache file (a server icon or + an avatar that changed) stays stale on screen. The slice that shows engine + pictures (slice 2: avatars, the tree's icons) drops the decoded copy for each + path of `reloaded` (`ImageSource::remove_asset`, and `drop_image` for what the + atlas holds) or keys the image by something that changes with the file. +- **`SettingChanged` for the audio and the playback keys is not reloaded.** + `AppState::setting_changed` follows `ui.theme` and `ui.font_scale` only; the + Slint front end also reloads `audio` (unless the page has unsaved edits) and + `client_playback`, the crash-reports flag and the decoder keys. The values the + window keeps copies of (`vm.audio`, `vm.playback`) go stale when a command, + the config file or another window changes them; the settings slice (5) adds + the reload with the page that shows them. - **Settled by the shell slice: the engine-event task and the tick.** The task takes what is queued (64 events at most) in one `update` with one `cx.notify()` and yields between steps, and the tick notifies nobody (the