voelin-gpui: closing the window gives the engine time to send the session closes

The window's close sends CloseSession for every session (AppState::shutdown)
and ended the app straight into runtime.shutdown_timeout(2 s), which waits for
blocking tasks only and drops the engine's async tasks: the commands could go
with the runtime and leave ghost clients on the servers until they time out.
voelin-ui sleeps 500 ms in that case before shutting its runtime down
(app.rs after ui.run()); run() does the same now. shutdown() returns how many
sessions it told the engine to close, the close handler keeps that number for
run() (the App and its entities are gone once GPUI's loop has returned), and
run() waits CLOSE_GRACE only when it is not zero. A comment in run() tells the
slices that add another way to end the app to call shutdown() too.

The GPUI window cannot open a session in this slice, so the wait is not seen
end to end; the tests pin the count: with an engine a state holding a session
answers 1 and a state with none 0, without an engine 0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-27 09:42:10 +03:00
1 parent a4694e944b
commit efc7db57a3
3 files changed
+61 -8

No files matched your search

+3 -1
View File
@@ -968,7 +968,9 @@ 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 and ends the app
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,