perf(wsl): stop asking twice whether a distro is ready

Every pane on a WSL workspace ran `ensure_wsl_server` from the client
before it even connected to the daemon — and then the daemon ran the very
same probe inside `router::open_link` before opening the link. Two full
rounds of five serial `wsl.exe` calls, to learn one fact.

The client's copy bought nothing. It threw the answer away and kept only
the error, which the route ack reports just as well; and the consent
question for a first install still finds its way here, because the daemon
runs its probe under `RouteSetup::blocking`, which installs the relay that
turns that question into a frame on this connection.

Measured on a distro that was already running and connected: 800ms to open
a tab, down to 440ms. Issue #454 is the same code on a machine where one
`wsl.exe` round trip takes 3.3s, where the duplicate was costing 15s a tab.
This commit is contained in:
l0ng-ai
2026-08-11 09:36:51 +08:00
parent edfadb7df2
commit f676fb96de
+12 -5
View File
@@ -2105,11 +2105,18 @@ fn connect_routed(route: &PaneRoute) -> anyhow::Result<Stream> {
tty7_core::host::guard_off_ui();
if let crate::daemon::router::RouteTarget::Wsl { distro } = &header.target {
crate::daemon::install::wsl::ensure_wsl_server(distro)
.map_err(|e| anyhow::anyhow!("prepare tty7-server in WSL `{distro}`: {e}"))?;
}
// No `ensure_wsl_server` here on purpose. The daemon runs exactly the same
// probe inside `router::open_link` before it opens the link, so asking from
// this side too bought nothing and cost a second full round of `wsl.exe`
// invocations — five of them, serially, on every single pane. On a machine
// where a `wsl.exe` round trip is slow (issue #454 measured 3.3s) that
// duplicate was half of the wait before a new tab could take a key.
//
// Nothing is lost by dropping it: the returned path was discarded, the
// failure is reported just as well through the route ack below, and the
// first-install consent question still reaches this process — the daemon
// runs its probe under `RouteSetup::blocking`, which installs the relay
// that turns the question into a frame on this very connection.
let mut stream = connect()?;
let ack = crate::daemon::router::negotiate(&mut stream, header)
.map_err(|e| anyhow::anyhow!("route this pane to {}: {e}", header.describe()))?;