Skip to content

fix(mosh): restore Windows reconnect startup#2241

Open
binaricat wants to merge 4 commits into
mainfrom
codex/fix-mosh-reconnect-await-close
Open

fix(mosh): restore Windows reconnect startup#2241
binaricat wants to merge 4 commits into
mainfrom
codex/fix-mosh-reconnect-await-close

Conversation

@binaricat

@binaricat binaricat commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the Windows Mosh reconnect failure reported in #2240, where reconnecting to some hosts could surface Mosh SSH startup failed: no MOSH CONNECT from mosh-server (UDP client not started) even though the remote mosh-server had started.

Root cause

There were two Windows-specific failure modes in the same reconnect path:

  1. The renderer used a fire-and-forget netcatty:close before reconnecting with the same sessionId. If the old close reached the main process after the new Mosh start, it could kill the replacement SSH bootstrap before MOSH CONNECT was parsed.
  2. Windows OpenSSH under ConPTY can inject cursor-control CSI sequences into the mosh-server startup output. On the reproduced host, MOSH CONNECT <port> <key> was immediately followed by a cursor move and the mosh-server banner without a CRLF, so the visible terminal showed a valid line while the parser saw key + banner text and rejected the handshake.

Changes

  • Add an acknowledged netcatty:close:await IPC path and proxy it in terminal worker mode.
  • Make closeSession awaitable through the preload and renderer backend wrapper, while keeping the legacy fire-and-forget fallback.
  • Await cleanup before manual/auto reconnect starts a replacement backend session.
  • Guard the awaited reconnect continuation with a retry token and termRef.current re-check so close/cancel/unmount cannot start a ghost reconnect.
  • Parse MOSH CONNECT from raw ConPTY output by skipping ANSI controls inside the key and stopping cleanly at cursor movement before banner text.
  • Add regression coverage for ConPTY-split keys, cursor moves after keys, and Mosh startup session behavior.

Validation

  • node --test electron\bridges\moshHandshake.test.cjs electron\bridges\terminalBridge.moshHandshakeSession.test.cjs
  • npm run lint -- --quiet
  • Real Windows SSH bootstrap against the reproduced host now parses MOSH CONNECT before visible output is emitted.
  • A local 1.1.68 Windows package built from this branch was tested and confirmed to reconnect successfully.

@binaricat binaricat marked this pull request as ready for review July 16, 2026 02:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5894f4ce74

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/Terminal.tsx
@binaricat binaricat changed the title fix(mosh): await close before reconnect fix(mosh): restore Windows reconnect startup Jul 16, 2026
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