Repository navigation
feat(desktop): connect Windows to WSL Host over stdio mux - #7056
Conversation
Generated-by: Maka
Generated-by: Maka
Generated-by: Maka
Generated-by: Maka
…st-channel-opener
Generated-by: Maka
There was a problem hiding this comment.
Update at ca2f2329fda88da2e14995b4c08506723db06120: both earlier CI P2 findings are resolved and withdrawn. I read the full increment from 635010da71e472fe3a3820e315d6fad48c9ebf10: it adds the WSL bridge, web-time and Yamux inventory entries and restores the existing component digests in the notice manifest. The current tooling job and Linux job both passed. Their original logs execute the dependency inventory check and notice coverage check; the tested inventory/manifest match this head.
The original omitted-inventory and clipboard-rs digest findings applied to the earlier head. The corresponding inline comments are marked resolved below.
This is a scoped build-metadata fix verification, not full acceptance of the 23-file Windows/WSL transport. Normal window-close retirement remains unchecked in the PR body. Root identity and authority across restart, startup/residency handoff, cancellation/half-close, journal isolation, all existing local/remote consumers, and real Windows/WSL Desktop behavior still require full validation. I did not run local Cargo tests or native GUI verification. Other CI failures remain, and I have not attributed them all to this change. No protocol epoch file is changed; that alone does not establish compatibility.
Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.
| tokio = { workspace = true, features = ["io-util", "sync"] } | ||
| tokio-util = { workspace = true, features = ["compat"] } | ||
| uuid.workspace = true | ||
| yamux = "0.13.10" |
There was a problem hiding this comment.
Resolved at ca2f2329fda88da2e14995b4c08506723db06120; the earlier P2 is withdrawn. The missing distribution inventory entries are now present and tooling job 136006388078 passed. This resolves this scoped CI finding, not full transport acceptance.
| "cargo:[email protected] registry+https://github.com/rust-lang/crates.io-index": "663bce254470eb5563d5b41d8a8b2eceb366748b2784728fe4135b7c0cd4a3dd", | ||
| "cargo:[email protected] registry+https://github.com/rust-lang/crates.io-index": "059622eb0e6a6598829c284732c57f80f934f7c818105e7fbacc32306b915823", | ||
| "cargo:[email protected] git+https://github.com/maka-agent/cua?rev=b97a7e7a97b1dabc669b7c362ba39691766df761#b97a7e7a97b1dabc669b7c362ba39691766df761": "e8154cd8ea7de8534d8b6b013574384e3fac91e1b80d02cffc097a660a17fa47", | ||
| "cargo:[email protected] git+https://github.com/maka-agent/cua?rev=b97a7e7a97b1dabc669b7c362ba39691766df761#b97a7e7a97b1dabc669b7c362ba39691766df761": "850710858a2299e8104689c650715d9cd56be498291ca81e2cdb20e8b0a3c72a", |
There was a problem hiding this comment.
Resolved at ca2f2329fda88da2e14995b4c08506723db06120; the earlier P2 is withdrawn. The existing component digest is restored and Linux notice coverage job 136006388235 passed. This resolves this scoped CI finding, not full transport acceptance.
Generated-by: Maka
Generated-by: Maka
Generated-by: Maka
Generated-by: Maka
Generated-by: Maka
Generated-by: Maka
|
CI comparison for f50086c: the Windows Desktop 2 lane failed on MAIN_DRAFT and Close side pane. The exact rust-preview base 0716ea7 reproduces MAIN_DRAFT (job 136177901986); the earlier unchanged rust-preview base 874817f reproduces both (job 136099594884). This is baseline evidence for the assertions, not a request to waive CI. |
There was a problem hiding this comment.
English
This is a huge improvement over #7011 — the maka-wsl-bridge protocol layer, stdio exclusivity, residency handoff, and the 512 KiB half-close bridge test are all clean and minimal.
There is one merge-blocking bug in the Windows Desktop lifecycle path and two smaller P2 issues to address before merging (reviewed at 367e5164):
1. [P1] run_app_with_config calls std::process::exit, making the WSL reconnect loop and host::quit unreachable
- In
third-party/nsh/crates/nsh-platform-windows/src/app.rs(lines 697–720), once the UI thread finishes,run_app_with_configcallsstd::process::exit(if succeeded { 0 } else { 1 })directly (intentionally, to avoid graphics driver teardown deadlocks under the loader lock — see lines 617–628). - Because
run_app_with_confignever returns after a window opens:- When the WSL anchor disconnects,
direct2d.rs:74–76callsquit_app(), which ends the entiremaka-desktop-shell.exeprocess. The cleanup block indirect2d.rs:94–118,bridge.close(), and the reconnectloopindesktop-shell/src/wsl_stdio.rs:58–70are all unreachable. - Explicit user exit ("Quit Maka" / closing the window) also bypasses
direct2d.rs:105(host::quit(bindings)). Local Windows mode still retires ephemeral Hosts because the parent launcher incli/src/desktop.rs:58–61holds a localClientand callsquit_ephemeral()after the shell exits 0, whereas the new WSL launcher path (cli/src/desktop.rs:85–92) simply forwards the exit code. Observing an ephemeral Host eventually exit after pipe EOF does not confirm that an explicitQuitwas delivered.
- When the WSL anchor disconnects,
- Suggested fix: keep the Windows message loop and window alive instead of exiting via
quit_app()on disconnect (and don't changensh-platform-windows'sstd::process::exittoreturn, which would reintroduce the driver teardown hang).AppView::load_with_config(nsh-platform-windows/src/app.rs:504) already exists, so Windows can follow the same in-window rebind pattern asappkit.rs:144–260:- Drive disconnect detection (without gating on
foreground.wait_for(|active| *active), which stalls if the window starts or stays unfocused in the background), close the oldbindings+bridge, reconnect with backoff (avoiding tight crash loops), and rebind in place viawith_running_view(|view| view.load_with_config(config)). - On explicit user quit, run
host::quit(bindings)andbridge.close()before callingquit_app().
- Drive disconnect detection (without gating on
- Verification: re-verify on the updated SHA against an isolated Root by logging the
maka-desktop-shell.exePID alongside the Host epoch — after terminating the Host, confirm the same shell PID completes calls against the new epoch, and on explicit menu quit confirm the Host actually receivesQuit.
2. [P2] "Choose folder…" in WSL mode passes a Windows path straight to the Linux Host
direct2d.rs:143–150returns the Windows native picker path (e.g.C:\src\project) verbatim to Workbench, which submits it toupdateWorkspaceLocations. On the Linux Host,PublishedDirectory::opencheckspath.is_absolute()and rejects it withpublished root must be absolute.- Minimal fix: disable/hide the Windows native folder picker for WSL sessions so Workbench uses the existing Host directory browser (or explicitly translate paths for the selected distro).
3. [P2] cli/src/wsl_stdio.rs enforces an arbitrary 128-channel cap and relies on an implicit first-stream assumption
- At
cli/src/wsl_stdio.rs:117–119,if channels.len() >= 128returnsErr("too many WSL IPC channels")and tears down the entire WSL helper and all active calls (and withoutbiased;, completed tasks inchannels.join_next()aren't guaranteed to be reaped beforemux.accept()). This128cap has no basis here:yamux::Config::default()already bounds concurrent streams and receive windows at the mux layer, and localHost::serveimposes no arbitrary channel cap on same-user IPC. Remove thechannels.len() >= 128check altogether, and addbiased;withchannels.join_next()ahead ofmux.accept()so finished tasks are reaped promptly. - At
cli/src/wsl_stdio.rs:121,closed.take()implicitly binds anchor-loss tracking to whichever non-bootstrap stream is accepted first. If any caller ever probesClient::statusover the opener beforeClient::connect_on, that short-lived stream closing will immediately trigger anchor loss. Either mark the anchor stream explicitly or document and enforce the invariant at the bridge boundary.
简体中文
相比 #7011 提升非常大——maka-wsl-bridge 协议层、stdio 独占、residency 交接以及 512 KiB 半关闭行为测试都很干净克制。
按 367e5164 逐行核对下来,Windows Desktop 生命周期路径里有一处卡合并的 P1,另外有两处 P2 建议合入前一起修掉:
1. [P1] run_app_with_config 退出时直接调用 std::process::exit,导致 WSL 重连循环和 host::quit 全部不可达
- 在
third-party/nsh/crates/nsh-platform-windows/src/app.rs(697–720 行),UI 线程结束后run_app_with_config会直接调用std::process::exit(if succeeded { 0 } else { 1 })(这是有意为之,用来规避显卡驱动在线程析构时于 loader lock 下挂死,见 617–628 行注释)。 - 因此只要窗口正常打开,
run_app_with_config根本不会 return:- WSL anchor 断开后,
direct2d.rs:74–76调用quit_app(),直接结束了整个maka-desktop-shell.exe进程。direct2d.rs:94–118的清理逻辑、bridge.close()以及desktop-shell/src/wsl_stdio.rs:58–70的重连loop全都走不到。 - 用户主动退出(Quit Maka / 关窗)同样会绕过
direct2d.rs:105的host::quit(bindings)。本地 Windows 模式之所以还能退掉 ephemeral Host,是因为父进程cli/src/desktop.rs:58–61持有本机Client在子进程返回 0 后代发quit_ephemeral();而新增的 WSL 启动器路径(cli/src/desktop.rs:85–92)只是透传退出码,没人发过显式Quit。管道强制断开后空闲 Host 最终自行退休,并不能说明显式Quit已送达。
- WSL anchor 断开后,
- 建议修法:保持 Windows 消息循环与现有窗口存活,不要在断线时通过
quit_app()结束进程(也不要把nsh-platform-windows的std::process::exit改成return,否则会重新引入显卡驱动析构死锁)。AppView::load_with_config(nsh-platform-windows/src/app.rs:504)已经现成可用,建议参考appkit.rs:144–260的窗口内换绑模式:- 在后台任务中监听断线(不要卡在
foreground.wait_for(|active| *active)上,否则窗口在后台启动或未获焦点时断线会一直假死),关闭旧bindings和旧bridge,带退避重连(避免 crash loop 死循环),然后通过with_running_view(|view| view.load_with_config(config))在当前窗口内换绑新连接。 - 用户明确退出时,先完成当前 epoch 的
host::quit(bindings)和bridge.close(),再调用quit_app()退出进程。
- 在后台任务中监听断线(不要卡在
- 验收建议:修改后用独立 Root 实测时记录
maka-desktop-shell.exe的 PID 和 Host epoch——杀掉 Host 后确认同一个 shell PID 能向新 epoch 完成调用,并从菜单退出确认 Host 确实收到了Quit。
2. [P2] WSL 模式下 “Choose folder…” 会把 Windows 路径原样提交给 Linux Host
direct2d.rs:143–150把系统对话框返回的 Windows 路径(如C:\src\project)原样交给 Workbench,Workbench 随即提交给updateWorkspaceLocations。Linux Host 的PublishedDirectory::open校验path.is_absolute()时会直接报published root must be absolute拒绝。- 最小修法:在 WSL 会话下收起 Windows 原生目录选择器,让 Workbench 走已有的 Host 目录浏览入口(或者按所选 distro 显式做路径转换)。
3. [P2] cli/src/wsl_stdio.rs 有无依据的 128 通道硬上限,且隐式假设第 1 条普通流必为 anchor
cli/src/wsl_stdio.rs:117–119在channels.len() >= 128时直接返回Err("too many WSL IPC channels"),把整个 WSL helper 和所有在途调用一起杀掉(且tokio::select!未加biased;,已完成任务可能还没走channels.join_next()就先被mux.accept()计入)。这个128上限本身没有依据:yamux::Config::default()在多路复用层已经有并发流数与接收窗口控制,本机Host::serve对同用户 IPC 也不设这种随手拍的通道数上限。建议直接删掉channels.len() >= 128检查,并给tokio::select!加biased;将channels.join_next()放到mux.accept()之前,确保已结束的任务被及时收割即可。cli/src/wsl_stdio.rs:121的closed.take()隐式把第一条接受的非 bootstrap 子流绑定为 anchor 断线监控。如果以后有调用方在Client::connect_on之前先经同一 opener 探测一次Client::status,该短命流关闭后会立刻误触发 anchor 丢失。建议显式标记 anchor 流,或在桥接边界明确约束该不变量。
EnglishPushed
Verification
简体中文已推送
验证记录
|
M4n5ter
left a comment
There was a problem hiding this comment.
All review items addressed and verified end-to-end on Windows 11 + WSL2.
Summary
Connect Windows Desktop to the same user's WSL Host using
wsl.exe --exec, a Yamux session over stdin/stdout, and the existing Linux local IPC endpoint. Local Windows Desktop remains unchanged. WSL does not need a TCP listener, address discovery, or peer credentials.Uses the Host client channel opener already merged into rust-preview in #7028. Supersedes the WSL transport experiment in #7011; ordinary remote Linux and mobile transports are not part of this change.
Verification
--no-default-features).~/.maka/wsl-stdio-e2e. The Host reported ephemeral lifecycle and three concurrent active calls.Follow-ups before merge
AI use
Tool(s) and scope: Maka implemented and exercised the bridge and prepared this PR.
Checklist
Does this PR entail a change in behavior?