Skip to content

fix(ssh): flag a macOS host whose managed server outlived its launching SSH session - #29371

Merged
nwparker merged 5 commits into
mainfrom
nwparker/macos-lan-responsible-sshd
Oct 16, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/macos-lan-responsible-sshd

Conversation

@nwparker

@nwparker nwparker commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​490 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​490
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​585 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​580

ELI5

On a Mac that you reach over SSH, macOS decides which programs may talk to devices on the local network by looking at "who started this". For Orca's managed server, the answer is the SSH session that launched it. When that SSH session closes, macOS can no longer check it, and programs in Orca's terminals on that Mac (kubectl, Homebrew node and python, .local names) start failing with "no route to host". This PR does not prevent that. It notices when it has happened, tells you, and offers a one-click restart that starts the server again from your current connection.

What Changed

  • Before: On a macOS 15+ SSH host, LAN connections from terminals could stop working some time after connecting. Nothing in Orca explained why, and the fix was to kill the server by hand over a separate SSH session.
  • After: On a macOS host, when the SSH session that started the managed server has ended, the host's card in Settings → SSH shows: "Terminals on this Mac may have lost local network access because the SSH session that started the managed server ended. Restart the managed server to restore it." A Restart managed server… button asks for confirmation, then restarts the server from the current connection. If any terminal is still running on the host (or Orca can't count them), it refuses and says so instead of restarting. It never ends terminals and never restarts on its own.

Mechanism:

  1. orcadLaunchCommand (macOS nohup launches only) walks the launching shell's parents with ps -o ppid= / ps -o comm= to the nearest sshd* process. It writes <orcad pid> <sshd pid> <sshd start time> to .orcad-launch-ssh-session in the slot dir after $! is recorded. Linux, WSL (setsid) and Windows launch commands are byte-for-byte unchanged.
  2. After a managed connect is published, a background check (macOS hosts only, using the platform the tunnel build already recorded) runs a probe on the host. The probe answers live, exited or unverifiable, plus not-recorded and not-applicable. The warning appears only on exited: the sshd pid is gone, or the pid now has a different start time because it was reused. A ps that can't answer gives unverifiable, and no warning shows. Hosts below macOS 15, and launches with no record or a record whose orcad pid doesn't match .orcad-pid (an older client launched it), show nothing.
  3. Restart (runtimeEnvironments:restartOrcad) runs in the target's lifecycle queue. It reads the terminal census and refuses unless liveSessions === 0. It then stops the active slot under the activation fence through the rollback's managed stop with idle-daemon retirement (orcad closes terminal admission and retires the daemon only when no session exists), starts it again with the existing wake, and rebuilds the tunnel in case the port moved. If the daemon wasn't retired, the server is still started again, but the result says so and the warning stays.
  4. Docs: a new "macOS hosts: local network access" section in docs/site/content/docs/ssh.mdx covers what happens and the admin workaround: the com.apple.network.local-network AllowedEthernetLocalNetworkAddresses / AllowedWiFiLocalNetworkAddresses defaults, macOS 15.5+, sudo, then restart.

Why

No launch mode keeps both Full Disk Access (granted to remote users through sshd) and Local Network access for a process that outlives its SSH session (Apple TN3179; https://developer.apple.com/forums/thread/811712). So we keep nohup and add detection and recovery instead of changing how the server is launched.

  • Why refuse instead of "warn, then end the terminals": the terminal daemon deliberately outlives orcad restarts, and the PTYs are spawned by that daemon. Restarting orcad while terminals are running would keep the old daemon and its broken attribution, so it wouldn't fix anything. Ending terminals would need a new path that kills the daemon, which this design has always avoided. Telling the user to close terminals first is the honest, non-destructive version.
  • Why a host-side record file instead of a new orcad health field: by the time orcad's JS runs, the launching shell has already exited and orcad has been reparented to launchd, so orcad can't find its sshd ancestor itself. The record is written by the launch command and read by a host-side probe. There is no wire change, and mixed versions fall back to "unknown, no warning".
  • Why only the nearest sshd ancestor: that process exits with the session. A long-lived listener higher up would never read as exited, which is the safe direction.

Linked Issue

Refs #25934. This is the short-term mitigation; the underlying macOS attribution is unchanged, so the issue stays open.

Visual Proof

N/A for a live capture. The warning appears only on a macOS 15+ SSH host whose launching session ended, which can't be reproduced on a CI or local display. The line and dialog use the existing status-line tone and Dialog/Button primitives, the same as "Move anyway…". Component tests cover their rendering and outcomes.

Testing

  • src/main/ssh/orcad-launch-ssh-session.test.ts: runs the real generated shell through /bin/sh against a fake ps table and sw_vers. It covers the ancestor walk (nearest sshd, no session outside SSH), the record written by the full macOS launch command (which still prints the runtime PID last), stale-record removal, exited, PID reuse, unverifiable ps, older-client and missing records, below macOS 15 and off macOS, and that Linux and setsid launches carry nothing.

  • src/main/ssh/orcad-managed-launch-session.test.ts: restart never stops a server while terminals run or are uncounted, stops then wakes then rebuilds when there are none, and leaves an unconfirmed stop running. The probe runs nothing on Linux.

  • SshHostRestartServerAction.test.tsx and ssh-host-server-status-copy.test.ts: the warning line, the confirmation, and each refusal message.

  • pnpm tc, pnpm run check:code-quality:changed, and existing launch/shell integration tests pass.

  • Not yet verified on a real macOS 27 SSH host (see Notes).

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Still needs a real macOS 27 SSH host:

  • Confirm ps -o comm= names the session sshd-session and that the nearest one exits when the connection closes, including with ControlMaster multiplexing.
  • Confirm that a restart with zero terminals produces a fresh terminal daemon (the idle daemon retires before the new orcad adopts it) and that LAN access then works for Homebrew binaries.
  • Full Disk Access may be lost the same way; this PR only words the warning around local network.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dbebb593-4ac4-4a4d-a589-063e5c80148d
📥 Commits

Reviewing files that changed from the base of the PR and between f1a3407 and 1aae3dd.

📒 Files selected for processing: 1
  • src/renderer/src/i18n/locales/en.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3ac87b81-1f2f-474b-9837-70a40041fa0a
📥 Commits

Reviewing files that changed from the base of the PR and between 43e2491 and f1a3407.

📒 Files selected for processing: 5
  • src/main/ssh/orcad-launch-ssh-session.test.ts
  • src/main/ssh/orcad-launch-ssh-session.ts
  • src/main/ssh/orcad-managed-launch-session.test.ts
  • src/main/ssh/orcad-managed-launch-session.ts
  • src/main/ssh/orcad-remote-launch.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

📝 Walkthrough

The change records and probes the SSH session that launched a managed Orcad server on eligible macOS hosts. It detects when that session has ended and displays a warning in SSH settings. A new restart flow checks terminal status, stops and wakes the server, and reports whether the restart succeeded. The preload API and IPC handler connect the settings action to that flow. SSH documentation describes the status, restart action, and macOS address-range exemptions.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to f1a34

Restart remains guarded, but its refusal message says “1 terminals.” This is a minor wording issue that can be fixed before merge or accepted as follow-up.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 44.83% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 21 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title is concise, specific, and accurately summarizes the primary macOS SSH managed-server change.
Description check Passed The description is detailed and covers the user impact, mechanism, rationale, linked issue reference, visual proof, testing, platform considerations, and checklist. It also clearly records that real m…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6cc03037-7cd7-4571-9e3b-5d03e37a4171
📥 Commits

Reviewing files that changed from the base of the PR and between a49295f and 43e2491.

📒 Files selected for processing: 22
  • docs/site/content/docs/ssh.mdx
  • src/main/ipc/managed-orcad-actions.ts
  • src/main/ipc/orcad-runtime-maintenance-handlers.ts
  • src/main/ipc/runtime-environment-handler-channels.ts
  • src/main/ipc/runtime-environment-managed-tunnel.ts
  • src/main/ipc/ssh-connect-flow.ts
  • src/main/ipc/ssh-host-launch-session-note.ts
  • src/main/ssh/orcad-launch-ssh-session.test.ts
  • src/main/ssh/orcad-launch-ssh-session.ts
  • src/main/ssh/orcad-managed-launch-session.test.ts
  • src/main/ssh/orcad-managed-launch-session.ts
  • src/main/ssh/orcad-remote-launch.ts
  • src/preload/api/managed-orcad-api.ts
  • src/renderer/src/components/settings/SshHostDeltaMoveDialog.test.tsx
  • src/renderer/src/components/settings/SshHostRestartServerAction.test.tsx
  • src/renderer/src/components/settings/SshHostRestartServerAction.tsx
  • src/renderer/src/components/settings/SshTargetServerStatus.tsx
  • src/renderer/src/ssh/ssh-host-launch-session-copy.ts
  • src/renderer/src/ssh/ssh-host-server-status-copy.test.ts
  • src/renderer/src/ssh/ssh-host-server-status-copy.ts
  • src/shared/orcad-managed-runtime.ts
  • src/shared/ssh-types.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment on lines +110 to +114
return translate(
'auto.components.settings.restartServer.terminalsRunning',
'{{count}} terminals are still running on this host. Close them, then restart the managed server.',
{ count: result.liveSessions }
)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

The message says "1 terminals" when the count is 1.

The message text has no plural form. If liveSessions is 1, the UI shows "1 terminals are still running". Add i18next plural keys (_one/_other) or use wording that works for any count.

…ng SSH session

macOS Local Network privacy pins a nohup-launched orcad to the sshd-session
that started it; once that session ends, its terminals lose LAN access (#25934).
A macOS launch now records that session, a connect reports it when it proved
exited, and the host status offers a restart when no terminals are running.
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