Repository navigation
Conversation
A turn started from the phone failed on a Windows host with "cannot start sh: CreateProcessW ... (os error 2)": the phone asks the host to run `sh` (the login shell wrapper and the bridge are POSIX), and Windows has no `sh` on PATH. * leon-pty: on Windows, `sh` is the one Git for Windows ships (on PATH, beside git.exe, or in Program Files) when PATH has none. It has everything the bridge uses (mkfifo, stty). A folder `sh` printed (/c/Users/me) is started in as C:/Users/me. leon-host's exec uses both. * leon-turn: the bridge's marks are an OSC (ESC ]5379; ... BEL) instead of text between record separators: the Windows pseudo-console drops a lone 0x1E, and the phone never saw the bridge was ready. ESC and BEL are, like 0x1E, never unescaped in a JSON line; terminals ignore an OSC they do not know. Anything else between ESC and BEL stays output.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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 and why
Starting a conversation from the phone with a Windows computer as the host fails before the agent runs:
Where it comes from
leon-mobileasks the host to start every turn as a POSIX command:leon_turn::shell::login_argv(the login-shell wrapper) aroundleon_turn::bridge::argv(the bridge script, which usesmkfifo,sttyand a FIFO). The host spawns it as is (leon-ptyfor the turn's terminal,leon-host::execfor the probes like$HOME/$PWD). Windows has noshonPATH, soCreateProcessWfails.With
shfound, two more things break on Windows. I checked both on a real ConPTY:0x1E). ConPTY re-renders the output and drops a lone0x1E, soleon-ready/leon-ack:…arrive as plain text. The phone never sees the bridge is ready, and nothing gets written.shprints$HOME/$PWDas/c/Users/me. When no project is shared, that comes back as the turn'scwd, andCreateProcessWcannot use it.The fix
leon-pty::spec::program: on Windows, the programshis the one Git for Windows ships. It is looked up onPATHfirst, then next togit.exeonPATH(<Git>\cmd\git.exe→<Git>\bin\sh.exe), then in%ProgramFiles%\Git\bin\sh.exe. Any other program, andshon any other OS, is started unchanged. Git'sshhas everything the bridge and the login wrapper use. Bothcommand_builder_with(terminals) andleon-host::exec(probes) go through it.leon-pty::spec::folder: on Windows,/xor/x/...becomesX:/.... Anything else is kept as it is. Both spawn paths use it.leon-turn::bridge: a mark is now an OSC of its own,ESC ]5379;leon-… BEL, instead of0x1E leon-… 0x1E. Like0x1E, ESC and BEL never appear unescaped in a JSON line. Terminals ignore an OSC they do not know, and ConPTY passes it on.Marksopens on ESC and closes on BEL. Anything between them that is not a mark (the shell's or ConPTY's own sequences, such asESC[6norESC]0;title BEL) is now kept as output. Before, it was dropped.leon-mobile's turn engine splits its input on the new closing byte (bridge::CLOSE).The bridge script travels from the client, and the parser lives in the client, so both ends change together. A phone build with this change works with any host. A host only needs the
sh/folder change, which matters only on Windows.How it was checked
cargo fmt --all --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --locked(all pass)Beyond the unit tests (new:
sh_is_found_beside_git_or_in_its_install_folder,a_folder_sh_printed_is_the_drives_on_windows,what_opens_no_mark_is_output_whole), I ran the exact argv the phone sends,sh -c LOGIN_SHELL leon sh -c BRIDGE leon-bridge 1 <json> cat, throughPtyProcess::spawnon ConPTY:cannot start sh … (os error 2). With only theshchange, the output showsleon-readywith no fences, and every mark is lost.$HOME, a 5000-byte line). Output isESC]5379;leon-ready BEL+ the line +ESC]5379;leon-ack:1:end BEL, and it exits 0.0x1E, APC (ESC _ … ST) and DCS are dropped; an unknown OSC passes through.I have not yet run it end to end from a rebuilt phone app.
Notes for the reviewer
shprobes (home_dir,subdirs,which) benefit from the same lookup.0x1Emarks, and the new parser treats them as output. That only affects turns that were running during the upgrade.mobile/) needs a rebuild ofleon-mobilefor the bridge change to reach phones.