Repository navigation
fix(ssh): repair a rebuildable node-pty failure once, instead of asking the user to reconnect - #17907
Conversation
The relay could only say "terminals are unavailable" and then list three remedies for four different faults, none of which the user could verify (#17830). Two things were destroying the evidence: - `loadPtyUncached` caught the load error into bare `catch {}` blocks (pty-handler.ts:539, :551) and returned null. The only cause anyone had was discarded on the spot. - node-pty's own loader walks three directories and rethrows only the LAST failure, so even an uncaught error arrives as `Cannot find module '../prebuilds/...'` — the GLIBC/ABI/arch sentence is already gone. The relay now keeps the load error, recovers the real dlopen message with an out-of-process load of the file node-pty would have opened, reads what node-gyp configured the binding for (`build/config.gypi`), captures the host's Node ABI, arch and glibc, and probes the toolchain only when nothing was compiled. Each fault gets its own message naming values the user can check: toolchain_missing, dependency_missing, abi_mismatch, arch_mismatch, libc_floor, shared_library_missing, load_crashed, and load_failed which quotes the loader verbatim. A probe that did not answer stays `unverifiable` and prescribes nothing. The classification is now also structured data on the error, so a client can repair the host instead of printing a paragraph: an additive, schema-validated `data` field on an existing JSON-RPC error, with `repairable` true only for a proved fault that recompiling on the host actually fixes. Reuses orcad's loader-message parsers and out-of-process probe rather than adding a second copy; `classifyLoaderMessage` moves to a shared module and gains architecture and missing-shared-library cases, which the orcad boot precondition picks up too.
…ng the user to reconnect
|
Too many files changed for review (274 files, 100 file limit). Bypass the limit by tagging |
There was a problem hiding this comment.
Caution
This PR does not contain the change its title and description claim. The diff is a max-lines module-splitting refactor with no node-pty repair code at all.
Reviewed changes
Reviewed all 274 changed files across the 8 commits in this run. The actual content is a mechanical decomposition of oversized modules, not the SSH node-pty repair the title announces.
- Preload bridge split —
src/preload/index.tsis decomposed into ~100 per-domainsrc/preload/api/*-bridge.tsmodules plus a newpreload-runtime-support.ts. - Renderer runtime/store split —
sync-runtime-graph.ts,web-session-tabs-sync.ts, and theagent-status/browser/linear/tabs/uislices are split into per-domain modules behind barrel re-exports. - Keybindings split —
src/shared/keybindings.tsbecomes a facade re-exporting fromsrc/shared/keybindings/*. - Baseline pruning —
config/max-lines-baseline.txtandconfig/tsconfig.tc.web.jsonare updated to match the split.
🚨 The described node-pty repair is absent from the diff
The PR body claims this "acts on" the structured cause from #17891 by adding a repair ledger (mayRepairFromCause, forgetRelayNodePtyRepairs, outcomes like repaired/ptys-live/already-attempted) and driving one relay reconnect through tryAcquireRelayRepairLock. None of that exists in the changed files: searches for mayRepairFromCause, forgetRelayNodePtyRepairs, tryAcquireRelayRepairLock, and the outcome strings return no matches in the diff, and no src/main/ssh, src/relay, src/main/providers, or src/shared/terminal-unavailable-cause.ts file is touched. The three changed test files (github-ipc-channel-parity.test.ts, browser-workspace-tab-close-census.test.ts, host-session-mirror-settle-census.test.ts) are census tests for the module split, not the 25 repair tests the body's verification section describes.
⚠️ The branch is not stacked on the diagnosis commit it cites
The base tip 3641310e3d ("fix(relay): diagnose why node-pty will not load instead of hedging") is not an ancestor of the head; the merge-base of the two is the older 41ef1ddd80. So the structured-cause work this PR claims to consume is also absent from the branch, and the diff cannot show a repair built on it.
Technical details
# Reconcile PR title/description with branch content
## Affected sites
- All 274 changed files — preload/renderer/store/keybindings module splits only.
- `config/max-lines-baseline.txt`, `config/tsconfig.tc.web.json` — baseline pruning.
## Required outcome
- Either push the actual node-pty repair commits (rebased onto `3641310e3d` so the diagnosis is present), or retitle/rewrite the PR to describe the module-splitting refactor it actually contains.
## Open questions for the human
- Was the wrong branch pushed, or was this PR force-pushed over the repair commits?DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
c475d23 to
62f8fb8
Compare
There was a problem hiding this comment.
Important
The repair logic now matches the PR description, but the ledger is cleared on the wrong teardown path: forgetRelayNodePtyRepairs runs on dispose, not on the ssh:disconnect path (detach), so the "fresh attempt on disconnect" the body promises never happens for an ordinary disconnect.
Reviewed changes
- Added the client spawn-repair seam (
spawnWithTerminalRuntimeRepair) and wired it intoSshPtyProvider.spawn. - Added the once-per-host-per-reason repair ledger (
recoverRelayNodePtyForSpawn,claimRepairAttempt,forgetRelayNodePtyRepairs). - Added
terminalUnavailableCauseFromErrorto recover the relay's structured cause from the rejected call'sdata. - Wired
SshRelaySessionto drive one locked reconnect on a proved-repairable spawn failure and hand back the post-reconnect provider. - Added 25 tests covering the seam, the ledger, and the locked deploy rebuild.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| this._state = 'disposed' | ||
| // Why here and not on reconnect: an explicit disconnect is user action, so the host earns a | ||
| // fresh node-pty repair attempt. A reconnect must not, or the repair becomes a loop. | ||
| forgetRelayNodePtyRepairs(this.targetId) |
There was a problem hiding this comment.
This clears the repair ledger only on dispose, but the user-facing disconnect (ssh:disconnect → disconnectRegisteredSshTarget → detachAndPersist) runs runDetach, not runDisposal. So a user who disconnects and reconnects after a spent repair attempt still hits already-attempted on the next spawn failure — the fresh attempt the PR body promises on disconnect is never earned except by removing the target or restarting the app. runDisposal is only reached by ssh:terminateSessions, target removal, and app shutdown.
Technical details
# Clear the ledger on the disconnect path
## Affected sites
- src/main/ssh/ssh-relay-session.ts:860 — `forgetRelayNodePtyRepairs(this.targetId)` placed in `runDisposal`, commented as "an explicit disconnect is user action".
- src/main/ipc/ssh-session-teardown.ts:14 — `disconnectRegisteredSshTarget` calls `session.detachAndPersist()`, which routes to `runDetach`, not `runDisposal`.
## Required outcome
- A user disconnect earns a fresh repair attempt, matching the PR body's "Cleared only on disconnect."
## Suggested approach (optional)
- Also call `forgetRelayNodePtyRepairs(this.targetId)` in `runDetach` (and decide whether `beginShutdownDetach` needs it — it does not, since the app is quitting and the module-level ledger dies with the process).|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughAdds terminal-unavailable cause extraction and a one-shot SSH PTY spawn retry. Adds relay repair tracking by target and cause, live-PTY checks, reconnect outcomes, and provider resolution. Integrates recovery with SSH relay sessions while preserving grace time across reconnects and clearing repair state on explicit disposal. Adds Vitest coverage for client retries, repair outcomes, lock behavior, non-repairable causes, and session repair state. ✨ Finishing Touches📝 Generate docstrings
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. Comment |
…ng the user to reconnect (stablyai#17907) * fix(relay): diagnose why node-pty will not load instead of hedging The relay could only say "terminals are unavailable" and then list three remedies for four different faults, none of which the user could verify (stablyai#17830). Two things were destroying the evidence: - `loadPtyUncached` caught the load error into bare `catch {}` blocks (pty-handler.ts:539, :551) and returned null. The only cause anyone had was discarded on the spot. - node-pty's own loader walks three directories and rethrows only the LAST failure, so even an uncaught error arrives as `Cannot find module '../prebuilds/...'` — the GLIBC/ABI/arch sentence is already gone. The relay now keeps the load error, recovers the real dlopen message with an out-of-process load of the file node-pty would have opened, reads what node-gyp configured the binding for (`build/config.gypi`), captures the host's Node ABI, arch and glibc, and probes the toolchain only when nothing was compiled. Each fault gets its own message naming values the user can check: toolchain_missing, dependency_missing, abi_mismatch, arch_mismatch, libc_floor, shared_library_missing, load_crashed, and load_failed which quotes the loader verbatim. A probe that did not answer stays `unverifiable` and prescribes nothing. The classification is now also structured data on the error, so a client can repair the host instead of printing a paragraph: an additive, schema-validated `data` field on an existing JSON-RPC error, with `repairable` true only for a proved fault that recompiling on the host actually fixes. Reuses orcad's loader-message parsers and out-of-process probe rather than adding a second copy; `classifyLoaderMessage` moves to a shared module and gains architecture and missing-shared-library cases, which the orcad boot precondition picks up too. * fix(ssh): repair a rebuildable node-pty failure once, instead of asking the user to reconnect Mirror-Of: f9587f7
…ng the user to reconnect (stablyai#17907) * fix(relay): diagnose why node-pty will not load instead of hedging The relay could only say "terminals are unavailable" and then list three remedies for four different faults, none of which the user could verify (stablyai#17830). Two things were destroying the evidence: - `loadPtyUncached` caught the load error into bare `catch {}` blocks (pty-handler.ts:539, :551) and returned null. The only cause anyone had was discarded on the spot. - node-pty's own loader walks three directories and rethrows only the LAST failure, so even an uncaught error arrives as `Cannot find module '../prebuilds/...'` — the GLIBC/ABI/arch sentence is already gone. The relay now keeps the load error, recovers the real dlopen message with an out-of-process load of the file node-pty would have opened, reads what node-gyp configured the binding for (`build/config.gypi`), captures the host's Node ABI, arch and glibc, and probes the toolchain only when nothing was compiled. Each fault gets its own message naming values the user can check: toolchain_missing, dependency_missing, abi_mismatch, arch_mismatch, libc_floor, shared_library_missing, load_crashed, and load_failed which quotes the loader verbatim. A probe that did not answer stays `unverifiable` and prescribes nothing. The classification is now also structured data on the error, so a client can repair the host instead of printing a paragraph: an additive, schema-validated `data` field on an existing JSON-RPC error, with `repairable` true only for a proved fault that recompiling on the host actually fixes. Reuses orcad's loader-message parsers and out-of-process probe rather than adding a second copy; `classifyLoaderMessage` moves to a shared module and gains architecture and missing-shared-library cases, which the orcad boot precondition picks up too. * fix(ssh): repair a rebuildable node-pty failure once, instead of asking the user to reconnect

Completes #17830. #17891 made the relay say why node-pty would not load; this acts on it.
The gap this closes
The fault is proved on the relay, at spawn time. The only thing that can fix it —
repairInstalledNativeDepsinssh-relay-deploy.ts— runs on the client, during deploy, undertryAcquireRelayRepairLock. Nothing connected the two, so a user whose remote Node changed under an existing install got a paragraph of guesses. Reconnecting genuinely worked; they just had no way to know that was the step.Deliberately indirect
This does not touch the remote
node_modules. It drives one relay reconnect and lets the locked deploy path do the rebuild, so all mutation stays behindtryAcquireRelayRepairLock. #17891 rejected a relay-side rebuild for exactly this reason — an unlocked rebuild could collide with a concurrent reconnect's repair — and this keeps that property rather than working around it.The invariant that matters more than the recovery
At most one repair per host per reason, and the attempt is recorded before the reconnect starts, not after it succeeds. A repair that ran and failed has still spent the attempt, and that host renders the relay's message from then on.
That ordering is the whole safety argument: a rebuild loop against someone's remote host is worse than the bug it is chasing.
forgetRelayNodePtyRepairsclears the ledger on disconnect, since that is user action and may earn a fresh attempt.Outcomes are explicit rather than boolean, so each refusal is greppable and testable:
not-repairable,already-attempted,ptys-live,reconnect-failed,no-provider,repaired.Guards
ptys-live— no rebuild while this client still holds live PTYs on the relay about to be rebuilt. Yanking node-pty from under a running session destroys someone's work.mayRepairFromCauseis re-derived client-side; the peer'srepairableflag is never trusted on its own. That is the [Bug]: Direct SSH Connect hangs on Deploying relay (native probe never finishes) #14830 lesson — anunverifiableprobe must never authorize a destructive repair.abi_mismatch,arch_mismatch,libc_floor,load_crashedanddependency_missingqualify, and only when the toolchain is not known-missing.toolchain_missingandshared_library_missingnever repair — the rebuild would need the very thing that is absent.Verification
Coverage includes the refusals, not just the happy path: a repairable cause repairs exactly once; a second identical failure does not repair again; an
unverifiablecause never repairs;toolchain_missingnever repairs; live PTYs block it; and an unavailable repair lock degrades to today's message rather than proceeding.Answering the question #17891 left open
A user hitting #17830 with an ABI or arch mismatch now recovers with no action — the failed spawn triggers one reconnect, the locked deploy path rebuilds node-pty against the remote's actual Node, and the retry runs on the new provider.
toolchain_missingandshared_library_missingstill require the user, correctly — we cannot install a compiler or a system library for them — but they now get one named cause and an exact command instead of four hedged possibilities.Fixes #17830
ELI5
Follow-up to the above: when the remote's terminal library is broken in a way a rebuild can fix, Orca now just fixes it instead of telling you to reconnect.
User-facing regression risk
toolchain_missing/shared_library_missing— a rebuild needs the thing that is missing.