Skip to content

docs(gpui): correct async and test context docs - #83

Merged
kirillDevPro merged 1 commit into
masterfrom
docs/gpui-context-async
Sep 24, 2026
Merged

kirillDevPro merged 1 commit into
masterfrom
docs/gpui-context-async

Conversation

@kirillDevPro

Copy link
Copy Markdown
Collaborator

What & why

crates/moon-gpui/docs/contexts.md described async and test contexts in a way the code does not.

  • It said calling to_async makes entity calls fallible because the context can outlive the app. AsyncApp holds a weak app reference. Entity::update on that context panics if the app is already gone (app().expect(...)) and does not return Result. AsyncApp::update_window and AsyncWindowContext::update return Result when the app was dropped, the app is quitting, or the window is gone.
  • It said TestAppContext panics on a missing app or window. The context owns the app through Rc. TestAppContext::update_window returns Result when the window is gone. VisualTestContext::update unwraps that result and panics.
  • It said WindowHandle::update yields a Window. The method takes an AppContext and a closure FnOnce(&mut V, &mut Window, &mut Context<V>) -> R and returns Result.

How to verify

Markdown only. Compared the new sentences with App::to_async, Window::to_async, Context::spawn / spawn_in, AsyncApp::update_entity / update_window, AsyncWindowContext::update, Entity::update, WeakEntity::update, TestAppContext, VisualTestContext::update, and WindowHandle::update.

A clean-context review disputed three claims. Those parts were dropped or narrowed before push, and the diff was not sent back for a second reading:

  • Context<T> does not lack to_async. It dereferences to App, so cx.to_async() is App::to_async.
  • Not every app-using AsyncApp method panics. The panic claim is limited to Entity::update. Window updates return Result, including when the app was released.
  • TestAppContext has no clock helpers of its own. advance_clock lives on BackgroundExecutor. The clock sentence was removed.

contexts.md said every async entity call is fallible and that
TestAppContext panics when the app or window is missing.
Entity::update on AsyncApp panics if the app is gone. Window
updates return Result. TestAppContext owns the app, and its
update_window returns Result.
@kirillDevPro
kirillDevPro merged commit 3d9ae15 into master Sep 24, 2026
4 checks passed
@kirillDevPro
kirillDevPro deleted the docs/gpui-context-async branch September 24, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant