Repository navigation
fix(desktop): show a specific message for failed SSH host installs (does not fix the reported connection failure) - #1989
Conversation
vastsa
left a comment
There was a problem hiding this comment.
Independently checked #1968 and the production submitSsh → bootstrapRemoteHost → remoteHostErrorKey path. The missing mapping is real: executing main and this head with HOST_BOOTSTRAP_FAILED changes remote:operationFailed to remote:hostBootstrapFailed. The 11 error-mapping/settings tests pass and diff --check passes.
However, this does not establish or fix the linked issue's SSH connection failure. No connection, authentication, bootstrap, or recovery behavior changes; Permission denied, checksum mismatch and host-start-failed still all produce one shared message. #1968 has no logs that identify its cause. The new tests demonstrate message selection only, and settings-remote-hosts is a source contract, not an executed install-failure user path. Accordingly this cannot currently land as Fixes #1968 under the repository's root-cause intake rule.
Please either reproduce the connection failure and minimally fix its actual cause, or explicitly scope this as an independently confirmed error-reporting defect: remove the auto-closing Fixes #1968 claim, leave that issue open for diagnosis, and add an executed failure-path test from the settings submission/service boundary through the localized visible error (mock only the external SSH/IPC edge). The save/test-connection feature need not be added here. Do not expose raw stderr or credentials. With an honest narrower scope and demonstrated user-path coverage, the small mapping change can be reassessed on its own merits.
No live SSH target, full typecheck, or integration E2E was run this round; merge withheld pending the scope/root-cause and user-path evidence above.
remoteHostErrorKey() had no case for HOST_BOOTSTRAP_FAILED, the error code the SSH bootstrap flow throws for almost every mid-install failure (unreachable host, bad credentials, missing Node.js on the remote machine, checksum mismatch, forward setup failure, etc.). It fell through to the generic "remote:operationFailed" fallback, so the Settings > Remote Hosts "Install" button always surfaced the same unhelpful "The remote operation failed. Check the Host connection and try again." toast regardless of what actually went wrong — the exact toast shown in issue vastsa#1968's screenshot. Add a dedicated remote:hostBootstrapFailed message (English and Chinese) and map HOST_BOOTSTRAP_FAILED to it, matching the existing pattern of a tailored string per error code. The renderer's policy of never showing raw stderr is preserved; only the mapped summary changes. This narrows and does not close vastsa#1968: the issue's own connection failure has no attached logs and was not reproduced here, so its root cause is still unknown, and several genuinely different failures (bad password, checksum mismatch, host-start failure) still collapse into this one shared message. This is scoped as an independently confirmed error-reporting defect, not a fix for the reported connection failure itself. Two tests cover it: - remote-host-errors.test.mjs: the error-key mapping in isolation (HOST_BOOTSTRAP_FAILED -> remote:hostBootstrapFailed, unmapped codes still fall back to the generic message, both locale strings exist and differ from the generic fallback). - remote-host-ssh-install-user-path.test.mjs: the executed path, rendering the real RemoteHostsPage, filling and submitting the SSH form as a user would, and asserting the actual toast text, mocking only api.bootstrapRemoteHost (the SSH/IPC edge). Verified this test fails against the pre-fix code with the exact generic toast from the issue's screenshot, and passes with the fix. Follows the existing *-user-path.test.mjs convention; spawns the real Electron binary and self-skips on Linux without a display, so it also skips in CI's main "Unit tests" step today, same as its sibling tests.
c5965e5 to
0029d01
Compare
vastsa
left a comment
There was a problem hiding this comment.
Re-reviewed head 0029d0148f19a2a5e9ba242bc245a1a7941afc3a. The revised title/body correctly scope this as an independently confirmed error-reporting defect and remove the auto-close claim for #1968; that issue remains open. The three production lines fix the missing HOST_BOOTSTRAP_FAILED mapping without changing SSH behavior or exposing stderr/credentials.
Independent validation: ran the real RemoteHostsPage Electron submission test with main’s error mapper: it fails with the old generic toast. Restoring the candidate makes all 12 mapping/settings/user-path tests pass, zero skips. The fixture uses real form/validation/error mapping/i18n, an SSH API rejection and a lightweight store/toast capture; it does not exercise live SSH or actual toast rendering. Style-token check and diff --check pass. Current main is an ancestor; GitHub merge candidate and tested head have identical tree a681c45c67927c283a6d6215b1742b40f09bc967.
Local Desktop typecheck is NOT PASS: reused workspace declaration outputs produce identical errors byte-for-byte on pristine main and candidate. pnpm also refuses the linked root node_modules task-state directory; direct tsc was used for comparison. Clean CI typecheck has passed its step; remaining CI suites must finish green before merge. Live SSH installation was not run and no connection-failure resolution is claimed. Previous scope/evidence blocker is resolved.
Relates to #1968 (does not close it — see Scope below)
What
remoteHostErrorKey()(apps/desktop/src/lib/remote-host-errors.ts) now has acaseforHOST_BOOTSTRAP_FAILED, mapping it to a new, dedicatedremote:hostBootstrapFailedmessage added to both the English and Chinese catalogs inapps/desktop/src/locales/remote.ts.Why
The SSH remote-host bootstrap flow (
apps/desktop/electron/main/remote/ssh-bootstrap.ts/ssh-transport.ts) throwsHOST_BOOTSTRAP_FAILEDfor nearly every mid-install failure: unreachable host, wrong credentials, missing Node.js on the remote machine, checksum mismatch, forward setup failure, host-start failure, etc. That code had no entry inremoteHostErrorKey's switch, so it fell through to the genericremote:operationFailedfallback. As a result, the Settings → Remote Hosts "Install" button showed the same uninformative toast — "Install failed: The remote operation failed. Check the Host connection and try again." — regardless of cause, which is exactly the toast in #1968's screenshot.Scope (read before reviewing)
This is not a fix for #1968's reported connection failure. The issue has no logs, uses a private IP, and was not reproduced here, so its actual root cause is unknown and unaddressed.
remoteHostErrorKeystill maps many genuinely different failures (bad password, checksum mismatch, host-start failure) to one shared message — this PR does not disambiguate them. This is scoped and should be reviewed as an independently confirmed error-reporting defect only: today, an install failure reports a dead-end generic message instead of one that at least tells the user to check connectivity/credentials/remote requirements. #1968 should stay open for the connection failure itself.Also out of scope: the issue's second ask (save the SSH form and offer a "test connection" step before the current one-shot Install) is a
feat, outside this repository's temporary Pull Request Acceptance Scope for outside contributors (fix/perfonly, perCONTRIBUTING.md). Not included here.How tested
apps/desktop/test/remote-host-errors.test.mjs(new): the error-key mapping in isolation —HOST_BOOTSTRAP_FAILED→remote:hostBootstrapFailed(via both.errorCodeand the IPC-wire.codefield), an unmapped code still falls back to the generic message, both locales define the new key distinctly from the generic fallback.apps/desktop/test/remote-host-ssh-install-user-path.test.mjs(new): an executed failure path, not just the mapping function in isolation. Renders the realRemoteHostsPage, clicks "Add via SSH", fills the label/host fields, submits the form, and reads the actual toast text — the only mocked collaborator isapi.bootstrapRemoteHost(the SSH/IPC edge), rejected withHOST_BOOTSTRAP_FAILED. Everything else (form validation,remoteHostErrorKey, i18n, the toast call) is real production code. I verified this test fails against the pre-fixremote-host-errors.ts/remote.tswith the exact generic toast text from the issue's screenshot, and passes with the fix restored. It follows this repo's existing*-user-path.test.mjsconvention (e.g.config-sync-user-path.test.mjs,plugin-view-bounds-sync.test.mjs): it spawns the real Electron binary and self-skips on Linux without a display, so — like its sibling tests — it also skips in CI's main "Unit tests" step today.node --test test/remote-host-errors.test.mjs test/remote-host-ssh-install-user-path.test.mjs test/settings-remote-hosts.test.mjs: 12/12 pass locally (withDISPLAYset).pnpm --filter @pi-desktop/desktop typecheck: clean.pnpm lint: clean.pnpm check:pr-base: passes, branch is current withorigin/main.Scope of the diff
Only the error-message mapping, its two new locale strings, and the two new tests. No change to
HOST_BOOTSTRAP_FAILED's semantics, the bootstrap/install logic, or any other error code's mapping.