Skip to content

fix(relay): honor the remote OpenSSH login shell for Windows SSH terminals - #9455

Merged
nwparker merged 2 commits into
stablyai:mainfrom
rodboev:pr/ssh-windows-default-shell-login
Jul 24, 2026
Merged

nwparker merged 2 commits into
stablyai:mainfrom
rodboev:pr/ssh-windows-default-shell-login

Conversation

@rodboev

@rodboev rodboev commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Windows SSH terminals now open the shell the remote host actually configured, honoring the OpenSSH DefaultShell registry value instead of always falling back to inbox PowerShell.

ELI5

When you SSH into a Windows machine, it has a setting for which shell to launch. We were ignoring that setting and forcing PowerShell; now we read it and give you the shell the server was told to use.

Root cause & fix

resolveWindowsDefaultShell never consulted the OpenSSH DefaultShell value in HKLM\SOFTWARE\OpenSSH, so a host configured for a different login shell was overridden by the inbox-PowerShell fallback. The fix adds an exported readOpenSshDefaultShell() that runs reg.exe query, parses and memoizes the value, and inserts it into the resolution chain between the $SHELL check and the PowerShell fallback. On failure, malformed output, or a missing path it returns '', so the existing $SHELL → WindowsPowerShell → ComSpec → powershell.exe order is preserved unchanged.

Evidence

Validated & rebased onto latest main during a bug-bash triage on 2026-07-23. Rebase was clean onto merge-base 7ab601487c; the PR touches only src/relay/pty-shell-utils.ts and its test.

  • On branch: 27 tests passed (1 file).
  • Fix reverted to main, test kept: 4 failed | 23 passed — new export/behavior absent on main (TypeError: readOpenSshDefaultShell is not a function).
  • Failing assertions when reverted include "reads and memoizes the OpenSSH DefaultShell registry value", "treats malformed OpenSSH DefaultShell output as empty", and "treats reg.exe failures as empty".
  • Lint clean: oxlint src/relay/pty-shell-utils.ts — no findings.
# on branch (fix present)
Test Files  1 passed   |  Tests 27 passed

# fix reverted to origin/main, test kept
Test Files  1 failed   |  Tests 4 failed | 23 passed
  x reads and memoizes the OpenSSH DefaultShell registry value
    TypeError: readOpenSshDefaultShell is not a function

Trade-offs

None — pure fix.

Regression risk

Zero-regression by construction: the registry lookup is reached only when $SHELL is unset/nonexistent, and empty or failed reads short-circuit to the prior fallback chain, so non-SSH and non-Windows paths are unchanged. The code path is gated behind process.platform === 'win32', and the result is memoized in a module-scoped var (injectable in tests). Proven by the passing branch tests and the revert-fails check.

Credit to @rodboev for the original fix. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Windows shell resolution now reads and caches the OpenSSH DefaultShell registry value using reg.exe. The configured shell is selected after a valid env.SHELL path and before existing PowerShell and ComSpec fallbacks. Shell reading is injectable for testing, and registry failures or malformed output produce an empty value. Tests cover memoization, invalid data, command failures, fallback ordering, and mock state reset.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the fix well, but it misses several required template sections like Screenshots, Testing, AI Review Report, Security Audit, and Notes. Add the missing template sections, including screenshots or 'No visual change', a testing checklist, AI review report, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change addresses #9327 by reading Windows OpenSSH DefaultShell, preserving fallback order, and covering invalid or missing registry data.
Out of Scope Changes check ✅ Passed The diff stays focused on relay shell resolution and related tests, with no unrelated UI, Electron, or broader platform changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly matches the main change: honoring the remote OpenSSH login shell on Windows SSH terminals.

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.

@AmethystLiang
AmethystLiang requested a review from OrcaWin July 19, 2026 19:12
@AmethystLiang
AmethystLiang requested a review from Jinwoo-H July 20, 2026 18:26
@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang removed the request for review from Jinwoo-H July 20, 2026 18:35
@nwparker
nwparker force-pushed the pr/ssh-windows-default-shell-login branch from eb5f9d1 to 29c4076 Compare July 23, 2026 11:49
@nwparker
nwparker merged commit 26e48e4 into stablyai:main Jul 24, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Thanks so much for this, @rodboev — honor the remote OpenSSH login shell for Windows SSH terminals. Verified (fail-on-main/pass-on-branch), rebased on latest main, reviewed, and merged. Really appreciate it! 🙏

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…inals (stablyai#9455)

* fix(relay): honor the remote OpenSSH login shell for Windows SSH terminals (stablyai#9327)

* Prove OpenSSH DefaultShell fallback stays safe on bad registry reads
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.

4 participants