Skip to content

fix(ssh): apply node-pty console fallback to Windows relays - #9638

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/issue-9586-windows-ssh-attachconsole
Jul 21, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/issue-9586-windows-ssh-attachconsole

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Apply Orca's existing node-pty@1.1.0 console-list fallback to the independently installed Windows SSH relay dependency.
  • Ship a strict, atomic patch asset, include it in Windows relay version hashes, and verify it during native-dependency health probes.
  • Preserve the [shellPid] cleanup fallback without upgrading to a broad node-pty beta or adding a process-wide exception handler.
  • Add a deterministic Node 22 Windows relay/ConPTY regression harness plus package and source-drift coverage.

Closes #9586.

Screenshots

No visual change.

Testing

  • pnpm lint — targeted lint passes; the full command reaches two unchanged switch-exhaustiveness failures in daemon-server.ts and skill-freshness-group.tsx.
  • pnpm typecheck — pnpm run typecheck:node passes; web/CLI projects were not changed.
  • pnpm test — focused suites pass; the full suite was not run.
  • pnpm build — pnpm run build:relay passes for all relay targets; the full desktop/native build was not run.
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused results:

  • Node 22.22.0 + pristine npm node-pty@1.1.0, detached through Win32_Process.Create: real ConPTY spawn/shutdown succeeds and deterministically emits AttachConsole failed from helper SHA-256 0d010879...c85e52.
  • Loopback SSH E2E (ssh2.Server on 127.0.0.1, real SshConnection/SFTP): Node 22 detection, upload, native install, patch, detached WMI launch, named-pipe bridge/handshake, and cmd + Windows PowerShell ConPTY spawn/shutdown all pass; relay status returns zero active PTYs and both relay logs contain no AttachConsole failed (1/1 passed, 15.49s). The host had no sshd, so no service, firewall, account, or credential configuration was changed.
  • The same packaged relay with the patch: cmd and Windows PowerShell both handshake, spawn, shut down, report zero active PTYs, close the bridge, and exit after grace with no AttachConsole error; helper SHA-256 is 84df20cf...dcd857 and the native binding is present.
  • pnpm exec vitest run --config config/vitest.config.ts config/scripts/node-pty-console-list-agent-patch.test.mjs src/main/ssh/ssh-relay-native-deps-install.test.ts config/scripts/package-electron-runtime-contract.test.mjs — 53 passed.
  • Electron builder contract — 20 passed, 1 skipped.
  • pnpm run typecheck:node, targeted oxlint, oxfmt check, 44 reliability gates, and max-lines ratchet pass.
  • Independent artifact verification confirms only win32-x64/win32-arm64 outputs contain the exact patch asset and every relay .version matches its recomputed content hash.

AI Review Report

Three merge-base-anchored adversarial rounds reviewed the complete diff and the real Windows evidence. Review covered dependency ownership, exact upstream release contents, old-Windows/WinPTY behavior, cmd/PowerShell shells, ARM64/x64 packaging, process-tree cleanup, Node/Electron ABI stability, reconnect/install recovery, source drift, macOS/Linux no-op behavior, and packaging contents.

The first rounds flagged two hardening opportunities that were implemented: validate the entire published helper by exact hashes, and replace it atomically so an interrupted remote install remains recoverable. The final round found no remaining in-scope issues. There is no terminal hot-path change; reconnect adds only an ~800-byte helper hash inside the existing native-dependency probe.

A node-pty beta bump was rejected because beta.11 spans 108 commits/222 files, removes the WinPTY fallback, weakens this failure fallback to [], and predates later ConPTY lifecycle/leak fixes. Forcing bundled ConPTY was also rejected because it changes backend and process-tree cleanup semantics.

Cross-platform review confirmed the patch/install command is Windows-gated, the asset is shipped only in Windows relay outputs, local terminals are unchanged, and macOS/Linux relay dependency installation remains unchanged.

Security Audit

  • The remote patch is restricted to exact node-pty@1.1.0 original/patched source hashes and fails closed on version or source drift.
  • Replacement is atomic and idempotent; health probes verify the installed bytes on reconnect.
  • Node and asset paths continue through existing PowerShell literal escaping, with no new user-controlled shell fragments.
  • No dependency or lockfile changes, new credentials, auth behavior, IPC surface, or broad uncaughtException handler.
  • The fallback catches only the native console-list call and retains the known shell PID for cleanup.

Notes

The reproduction corrects part of the issue report's causal chain: the console-list helper is forked during PTY kill, and its failure does not itself crash the relay/socket. The baseline relay remained alive and the bridge exited successfully. This PR fixes the verified missing relay patch and AttachConsole error; it does not claim that this helper exception independently explains every reported client startup failure.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a SHA-256-guarded patch for node-pty 1.1.0 that wraps console process discovery with a fallback. Windows relay builds package the patch and include it in version hashing. Windows native dependency installation and rebuild apply and verify the patch. Tests cover patch behavior and packaging contracts. A Windows-only repro script drives relay PTY lifecycle operations, records AttachConsole behavior, and cleans up temporary processes and files.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements the requested Windows relay backport for node-pty v1.1.0, plus hashing, health checks, and regression tests.
Out of Scope Changes check ✅ Passed The changes appear focused on the Windows SSH relay node-pty fix and its build/test support, with no clear unrelated additions.
Title check ✅ Passed The title clearly summarizes the main change: applying the node-pty console fallback to Windows relays.
Description check ✅ Passed All required sections are present, and the testing, review, security, and notes sections include the requested details.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
config/scripts/build-relay.mjs (1)

29-35: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Patch filename literal is duplicated across three files. 'node-pty-1.1.0-console-list-agent-patch.cjs' is hardcoded independently in the build script, the deploy source, and the repro tool; a rename or version bump can silently desync them since nothing but the string-matching contract test would catch a partial update.

  • config/scripts/build-relay.mjs#L29-L35: source of truth for NODE_PTY_CONSOLE_LIST_PATCH_FILENAME; consider moving this (and the version) to a small shared module importable by all three consumers.
  • src/main/ssh/ssh-relay-deploy.ts#L506-L507: replace the locally re-declared NODE_PTY_CONSOLE_LIST_PATCH_FILENAME literal with the shared constant.
  • config/scripts/windows-ssh-attach-console-repro.mjs#L12-L12: replace NODE_PTY_PATCH_FILENAME's literal with the same shared constant instead of a third independent copy.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f511d799-d4d8-444a-9d24-b54563ddeb46

📥 Commits

Reviewing files that changed from the base of the PR and between 0e7b0ac and 5b171d5.

📒 Files selected for processing (6)
  • config/relay-assets/node-pty-1.1.0-console-list-agent-patch.cjs
  • config/scripts/build-relay.mjs
  • config/scripts/node-pty-console-list-agent-patch.test.mjs
  • config/scripts/package-electron-runtime-contract.test.mjs
  • config/scripts/windows-ssh-attach-console-repro.mjs
  • src/main/ssh/ssh-relay-deploy.ts

@OrcaWin
OrcaWin merged commit 88c7861 into main Jul 21, 2026
2 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
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.

[Bug]: Remote relay crashes on Windows SSH with "AttachConsole failed" (node-pty v1.1.0 + Node.js v22)

1 participant