Repository navigation
perf(cua-driver): reuse one session-bus connection for the GNOME helper - #4879
Merged
Merged
Conversation
Every WinRects call spawned a gdbus subprocess, and owner attestation alone makes three D-Bus calls before the real one. A live preview pays that on every frame. Replace the subprocess with one zbus connection on a dedicated single-thread Tokio runtime, so callers inside or outside Tokio can block on it without nesting runtimes. Bodies are typed on the wire, and replies keep the textual shape the existing parsers read (GetRects now arrives as raw JSON, which also avoids gdbus quoting). A timeout or transport error drops the connection and the next call reconnects; a mutation is never replayed. An error reply, such as no helper on the bus, keeps the connection. T3 Code measured window capture going from 381 ms to 58 ms with this transport. Ported from their Linux patch to Cua Driver 0.34.0 (pingdotgg/t3code#16975, MIT, Copyright (c) 2026 T3 Tools Inc.); the reply-versus-transport split is new here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Parse the typed GetRects reply as raw JSON instead of slicing a bracket span, and reuse that parser for focus. Salvaged from #4809, including the malformed-snapshot fixtures and the Nix dbus check input. Co-authored-by: injaneity <44902825+injaneity@users.noreply.github.com>
cursor
Bot
force-pushed
the
perf/cua-driver-gnome-dbus-transport
branch
from
October 8, 2026 13:45
4d98119 to
0d0c5f7
Compare
dbus-daemon --session needs the system session.conf, which the Nix build sandbox lacks; the daemon then exits without an address. Write a minimal session config listening in a temp dir instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On GNOME Wayland every call to the WinRects helper (
org.cua.WinRects) spawned agdbussubprocess and polled it for exit. Owner attestation alone (GetNameOwner,GetConnectionUnixProcessID,GetConnectionUnixUser, plusGetVersionwhen gated) costs three or four of those before the real call, and a live window preview pays that on every frame.This replaces the subprocess with a persistent transport (
wayland/shell_helper/transport.rs):('…',)and(uint32 N,).GetRectsnow arrives as raw JSON, which the[…]extraction already handles and which avoids gdbus quoting of titles with apostrophes.Activatecannot apply twice. An error reply keeps the connection, for example no helper on the bus or a refused argument. This split is new relative to T3's version, which reconnected after any failure, including every call on a machine without the helper.Related: #4809. Because
GetRectsnow arrives as a typed string, this also fixes the bug #4809 reports. gdbus's GVariant text adds a second layer of escaping, so an apostrophe or quote in any window title made the whole snapshot unparseable and hid every window. The test serves a title with an apostrophe, quotes, a backslash, a newline and non-ASCII, and checks thatparse_windowsandparse_window_originstill find every window.wait_timeoutand the gdbus plumbing are removed. Owner attestation and the unique-name addressing are unchanged.Credit
Ported from T3 Code's Linux patch to Cua Driver 0.34.0: pingdotgg/t3code#16975,
patches/cua-driver-linux/0.34.0.patch. T3 Code is MIT-licensed, Copyright (c) 2026 T3 Tools Inc. T3 measured window capture at 381 → 58 ms with this transport. The THIRD_PARTY_NOTICES row comes with #4877 and is extended here once that merges.Testing
typed_roundtrips_on_one_private_connectionstarts a privatedbus-daemonand serves a fake helper. It checks:Capturedecoding;Failure::Reply;It skips if
dbus-daemonis not installed. Linux CI runs it.Linear: CUA-1235 (tracking CUA-1233)
🤖 Generated with Claude Code