Skip to content

refactor(pty): drop SSH spawn, liveness and kill branches - #27529

Merged
OrcaWin merged 3 commits into
mainfrom
OrcaWin/p399-A4
Oct 11, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
OrcaWin/p399-A4

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​714 $\color{#cf222e}{\Huge{\mathbf{−}}}$​655
Prod 31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​199 $\color{#cf222e}{\Huge{\mathbf{−}}}$​759 $\color{#cf222e}{\Huge{\mathbf{−}}}$​560

ELI5

A terminal can only be started, checked or stopped by this app when it runs on this computer. Terminals on an SSH host are run by that host's own Orca server. The terminal code still had extra branches for the old way of driving SSH terminals directly, through a relay that was deleted earlier in this phase. Those branches could no longer run, so this PR removes them. Nothing changes for the user.

What Changed

Before and after, as the user sees it: no difference. Local, WSL, folder-workspace and paired-server terminals start, reattach and stop exactly as before. A terminal left over from the old SSH relay era (an ssh: id) still gets the same treatment when it is closed: its old lease is marked terminated, it reports a synthetic exit, and its liveness stays unverifiable, never exited.

The mechanism:

  • Spawn (both the renderer pty:spawn path and the runtime/CLI path). Since refactor(pty): delete the SSH PTY provider and its registry slot #27499, the provider lookup at the top of preflight throws PtyHostNotDispatchableError for any SSH connection. Nothing after that line can see a connectionId, so every connectionId branch after it is removed: the SSH env stripping, the relay "session expired" handling that marked a lease expired, the relay id bookkeeping (effectiveSessionRelayId), the SSH binding host in the commit, and the SSH lease claim (pane/ssh-pane-lease-claim.ts). One comment now marks the preflight line where only local spawns continue. Three helpers that were only called after that line lose their connectionId parameter: recoverFreshSpawnProviderRouting, withClaudeProfileTerminalEnv and persistAdmittedStablePaneBinding. swapReplacedPaneBinding and setAdoptedPtyOwnership lose theirs too.
  • Liveness. providers/ssh-pty-errors.ts is deleted. Its error classes were constructed only by the relay provider that refactor(pty): delete the SSH PTY provider and its registry slot #27499 deleted. isPtyAlreadyGoneError keeps only the daemon's Session not found match. Stable-pane adoption now checks SessionNotFoundError directly. That is the same verdict as before, because the two relay-only predicates could no longer be true.
  • Kill. runtime/undelivered-ssh-kill.ts is deleted, along with the controller's recordUnconfirmedStop. They wrote a "replay this kill on the next relay handshake" order that nothing in this build reads. The runtime close reply therefore never sets pendingKillRecorded. It already never did on a real path: an ssh: PTY is marked unregistered before that call, and a local PTY always returned false. The shared wire type keeps the optional field for older hosts. Provider-path checks on connectionId are removed, because a provider exists only for local PTYs.
  • Runtime. OrcaRuntime.acceptPtyDataBounded and resetPtyModelAfterMigrationFailure are removed, along with the onPtyData receipt parameter and the RuntimePtyDataAdmission type. They had no production caller. Three tests that used them now drive onPtyData, or use preparePtyExecutionContext(…, { resetIncarnation: true }), which runs the same dispose.

Net lines: production about −560 (+195 / −756), tests about −640 (+56 / −697).

Why

New terminal work no longer has to step around relay branches that cannot run. Each removed arm either sat after a point that already throws for SSH, or was keyed on an error type that nothing constructs any more. Where an ssh: PTY can still arrive (closing a relay-era tab), the existing typed handling is kept and it never falls through to the local provider (Phase 3.99 principle 8). A wider sweep of connectionId in the files that run before preflight (spawn-begin, spawn-early, spawn-options and the stable-owner lookup) was left out. Those run before the dispatch point and belong to their own callers' PRs.

Persisted relay-era data keeps today's load and save semantics. The one persisted write no longer made is the undelivered-kill intent, which this build never reads. A5 retires its writer domain.

Proof that the removed code is unreachable:

  • rg over src config tests mobile .github for every removed symbol (stripRemotePaneEnvWhenHooksDisabled, isHostReportedPtyAbsenceError, isObservedPtyExitEvidence, isSshPty*, SshPty*RelayError, claimSshPaneLease, recordUndeliveredSshPtyKill, recordUnconfirmedExplicitSshStop, recordUnconfirmedStop, acceptPtyDataBounded, resetPtyModelAfterMigrationFailure, RuntimePtyDataAdmission, captureModelReceipt, effectiveSessionRelayId, and the three deleted module paths) finds 0 hits. The same scan over all 159 // @ts-nocheck files also finds 0 hits. The renderer keeps its own SSH_PTY_IDENTITY_MISMATCH string constant for older hosts.
  • No local or daemon producer of the relay's PTY "<id>" not found wording exists (the daemon raises Session not found: <id>).
  • build:electron-vite, build:cli and build:orcad pass.

Linked Issue

Phase 3.99 cleanup, PR A4 (internal plan). No issue.

Visual Proof

N/A. This is a behaviour-preserving deletion with no UI change.

Testing

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

pnpm tc, oxlint, pnpm run check:code-quality:changed (0 new findings), pnpm lint. Vitest suites: src/main/ipc (all suites), src/main/runtime, and src/main/claude-accounts. Two SSH-only suites were deleted because the code they tested is gone: pty-ssh-undelivered-kill.test.ts and spawn-commit-ssh-lease-cardinality.test.ts. Two persistence commit-durability tests that called the commit step directly with an SSH connection (a path preflight now refuses) run through local PTYs only. The relay-error stable-pane tests were rewritten to use the daemon's SessionNotFoundError, and the file was renamed stable-pane-absence-respawn.test.ts. The routing test still pins that PtyHostNotDispatchableError is never read as gone or as an observed exit. I did not run Electron or Docker locally; CI covers those lanes.

Review

Self-review plus an independent read-only reviewer. P0/P1 only.

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

  • Security: no change.
  • Cross-platform: the Windows and WSL spawn checks are unchanged for local spawns. They were only ever skipped for SSH.
  • SSH: an unreachable ssh: PTY stays unverifiable.
  • Mobile and wire compatibility: no change. pendingKillRecorded stays optional in the shared type.
  • Folder workspaces: unaffected.

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 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 52219c7e-376a-4581-a3fb-96953e8885e8

📥 Commits

Reviewing files that changed from the base of the PR and between 3c580efa5f0585e5a33e5bf53e355d45ee860d2b and 77864c7.


📒 Files selected for processing (1)
  • src/main/persistence/loading-store/pty-spawn-exit-durability.test.ts

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



📝 Walkthrough

Walkthrough

PTY spawn preparation and registration now apply routing, environment, and ownership behavior without several connection-ID-specific branches. The change removes SSH PTY lease claiming, undelivered kill recording, and SSH-specific PTY error handling. Stable-pane absence handling uses typed session-not-found errors. The runtime also removes bounded terminal-data admission and its completion receipt; terminal data continues through the queued write path.


Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 77864

PTY routing and stop handling are simplified; no user-visible regression is established, so no demonstrated issue blocks merging.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 21.62% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 37 functions across 31 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: removing SSH-relay-specific PTY spawn, liveness, and kill branches.
Description check Passed The description is comprehensive and covers the required explanation, scope, rationale, testing, compatibility, visual proof, review, and checklist sections. It also explains why no linked issue is pr…
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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • 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.

@OrcaWin
OrcaWin merged commit 2779dfe into main Oct 11, 2026
46 checks passed
Jinwoo-H added a commit that referenced this pull request Oct 11, 2026
…heck (#27557)

#27529 removed two main-process layout writers after the ratchet landed, so main's
baseline went stale and every PR failed the check. Prune the baseline and report a
shrunk count as a warning; only growth fails.
Jinwoo-H added a commit that referenced this pull request Oct 11, 2026
#27431 and #27529 landed together; #27529 removed a writer from each spawn-commit file, so the ratchet now fails on main.
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