Skip to content

refactor: AppProxy wake-on-send via MainThreadPoster#14

Merged
BumpyClock merged 2 commits into
mainfrom
feat/appproxy-wake-on-send
Jul 17, 2026
Merged

refactor: AppProxy wake-on-send via MainThreadPoster#14
BumpyClock merged 2 commits into
mainfrom
feat/appproxy-wake-on-send

Conversation

@BumpyClock

Copy link
Copy Markdown
Owner

What

Replace the AppProxy poll loop with a MainThreadPoster, so cross-thread work wakes the main thread on send instead of being drained by a fixed 16ms timer. Removes idle wakeups and the up-to-16ms latency floor on posted work.

Re-pin

gpui PR #7 merged; fork main is now 2a03ae6e (squash of the poster commit). This bumps the gpui/gpui_platform revs and the vendor/gpui submodule to fork main.

Per the compatibility discipline, a gpui rev change is a pre-1.0 minor bump: workspace version 0.5.10.6.0, with the [workspace.dependencies] path-crate versions synced and a new docs/COMPATIBILITY.md row. The annotated tag v0.6.0 is created at merge time, not in this PR.

Supersedes the auto-closed PR #11 (its base feat/app-platform merged to main); non-draft now that its precondition landed.

Gates (local)

cargo test -p gpui-component-app (52 passed, incl. 3 gpui::test behavior tests + headless), workspace clippy --all-targets -- --deny warnings, fmt, both examples --smoke exit 0.

AppProxy scheduled cross-thread work onto the main thread by draining an
mpsc channel from a foreground task that woke every 16ms via a background
timer. That poll loop was flagged as a wart: an idle tray app paid a fixed
wakeup cost forever, purely because the fork had no dependency-free way to
wake the main thread from a Send context.

The fork now provides that primitive. App::main_thread_poster hands back a
Clone+Send+Sync MainThreadPoster whose post() enqueues a closure and wakes
the run loop through the platform dispatcher, so an idle app stays parked.

Back AppProxy with the poster and delete the timer loop. The shutdown
boundary stays ours: a `closed` AtomicBool, set at ShutdownRequested (which
precedes app teardown), is checked in dispatch and re-checked inside each
posted closure on the main thread. Since close() also runs on the main
thread, any closure the pump dispatches after close() drops its payload,
preserving the old drain loop's discard-after-close contract. The poster's
own after-teardown false is a second layer, not a replacement.

Pins gpui/gpui_platform and the vendor submodule to 2ee4fa6 (gpui#7). The
workspace version and COMPATIBILITY.md bump is deferred to merge time via
/update-gpui discipline.
gpui PR #7 merged; fork main is now 2a03ae6e (squash of the poster
commit 2ee4fa6). Point the gpui/gpui_platform revs and the vendor/gpui
submodule at fork main.

Bump the workspace version 0.5.1 -> 0.6.0: a gpui rev change is a
minor bump while pre-1.0, per the compatibility discipline. Sync the
[workspace.dependencies] path-crate version requirements, plus the
hardcoded [package] versions in ui/macros/assets that do not inherit
version.workspace. Add the 0.6.0 row to docs/COMPATIBILITY.md.

The annotated tag v0.6.0 is created at merge time, not here.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 422c0c00-d2ee-408b-b0d4-808e8c2bb979

📥 Commits

Reviewing files that changed from the base of the PR and between 27f6057 and 8d8906c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • Cargo.toml
  • crates/app/Cargo.toml
  • crates/app/src/handles.rs
  • crates/assets/Cargo.toml
  • crates/macros/Cargo.toml
  • crates/ui/Cargo.toml
  • docs/COMPATIBILITY.md
  • vendor/gpui

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Summary by CodeRabbit

  • New Features

    • Improved cross-thread app message delivery for more responsive main-thread updates.
    • Messages queued during shutdown are safely discarded.
  • Documentation

    • Added compatibility information for version 0.6.0.
  • Release

    • Updated the component suite to version 0.6.0.

Walkthrough

The release updates the workspace and crates to 0.6.0 with a new gpui revision. AppProxy now uses MainThreadPoster for push-based main-thread dispatch, atomic shutdown checks, and revised runtime tests.

Changes

AppProxy and 0.6.0 release

Layer / File(s) Summary
0.6.0 and gpui revision alignment
Cargo.toml, crates/assets/Cargo.toml, crates/macros/Cargo.toml, crates/ui/Cargo.toml, vendor/gpui, docs/COMPATIBILITY.md
Workspace and crate versions move to 0.6.0, gpui dependencies and the vendor submodule use revision 2a03ae6e789b77e98f9d9bd5489758a082313c75, and the compatibility matrix records the pairing.
Main-thread proxy dispatch and installation
crates/app/src/handles.rs, crates/app/Cargo.toml
AppProxy replaces the polling channel with MainThreadPoster and an atomic shutdown flag; installation removes the drain task and wires the proxy directly to the app context.
Shutdown and queue semantics validation
crates/app/src/handles.rs
Runtime tests cover main-thread execution, post-close rejection, queued-work discard, and FIFO discard after shutdown.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant AppProxy
  participant MainThreadPoster
  participant MainThread
  Caller->>AppProxy: dispatch(callback)
  AppProxy->>MainThreadPoster: post guarded callback
  MainThreadPoster->>MainThread: execute posted callback
  MainThread->>AppProxy: re-check shutdown flag
  MainThread-->>Caller: run callback when open
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/appproxy-wake-on-send

Comment @coderabbitai help to get the list of available commands.

@BumpyClock
BumpyClock merged commit 7c2f196 into main Jul 17, 2026
7 of 8 checks passed
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