Skip to content

fix(desktop): show a specific message for failed SSH host installs (does not fix the reported connection failure) - #1989

Merged
vastsa merged 1 commit into
vastsa:mainfrom
afsuyadi:fix/remote-host-bootstrap-failed-message
Oct 30, 2026
Merged

vastsa merged 1 commit into
vastsa:mainfrom
afsuyadi:fix/remote-host-bootstrap-failed-message

Conversation

@afsuyadi

@afsuyadi afsuyadi commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Relates to #1968 (does not close it — see Scope below)

What

remoteHostErrorKey() (apps/desktop/src/lib/remote-host-errors.ts) now has a case for HOST_BOOTSTRAP_FAILED, mapping it to a new, dedicated remote:hostBootstrapFailed message added to both the English and Chinese catalogs in apps/desktop/src/locales/remote.ts.

Why

The SSH remote-host bootstrap flow (apps/desktop/electron/main/remote/ssh-bootstrap.ts / ssh-transport.ts) throws HOST_BOOTSTRAP_FAILED for 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 in remoteHostErrorKey's switch, so it fell through to the generic remote:operationFailed fallback. 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. remoteHostErrorKey still 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/perf only, per CONTRIBUTING.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 .errorCode and the IPC-wire .code field), 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 real RemoteHostsPage, clicks "Add via SSH", fills the label/host fields, submits the form, and reads the actual toast text — the only mocked collaborator is api.bootstrapRemoteHost (the SSH/IPC edge), rejected with HOST_BOOTSTRAP_FAILED. Everything else (form validation, remoteHostErrorKey, i18n, the toast call) is real production code. I verified this test fails against the pre-fix remote-host-errors.ts/remote.ts with 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.mjs convention (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 (with DISPLAY set).
  • pnpm --filter @pi-desktop/desktop typecheck: clean.
  • pnpm lint: clean.
  • pnpm check:pr-base: passes, branch is current with origin/main.
  • Not run: a live SSH install against a real failing remote host (no test SSH target available) — not needed, since the executed-path test above already drives the real component/service boundary and only mocks the external SSH/IPC call itself.

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.

@afsuyadi
afsuyadi marked this pull request as ready for review October 30, 2026 02:48

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@afsuyadi
afsuyadi force-pushed the fix/remote-host-bootstrap-failed-message branch from c5965e5 to 0029d01 Compare October 30, 2026 03:59
@afsuyadi afsuyadi changed the title fix(desktop): show a specific message for failed SSH host installs fix(desktop): show a specific message for failed SSH host installs (does not fix the reported connection failure) Oct 30, 2026
@afsuyadi
afsuyadi marked this pull request as draft October 30, 2026 04:00

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@afsuyadi
afsuyadi marked this pull request as ready for review October 30, 2026 04:11
@vastsa
vastsa merged commit 7260d0a into vastsa:main Oct 30, 2026
6 checks passed
@afsuyadi
afsuyadi deleted the fix/remote-host-bootstrap-failed-message branch October 30, 2026 04:18

This branch was previously deployed

1 inactive deployment
Preview — 0029d014 Deployed Oct 30, 2026 by vercel[bot]
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.

2 participants