Repository navigation
fix(ios): ask the SSH host key question from the screen that owns the connect attempt - #3002
Merged
Merged
Conversation
…t whenever that attempt ends
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Signed-off-by: Ngô Quốc Đạt <[email protected]>
This was referenced Sep 20, 2026
This was referenced Oct 23, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On iPhone and iPad, connecting over SSH to a server whose host key is new brought up the "Trust" alert and then closed it again in under a second, with no answer from the user. Every connect after that hung on Connecting… or dropped back to the connection list, and nothing short of relaunching the app helped. Reported against TestFlight build 22.
Root cause
The question was one app-wide alert (
HostKeyPromptPresenter.shared) attached to the root of the window, and the open connection is afullScreenCoverpresented from that same root. One presenter cannot do both.Measured on the iOS 27 simulator against a real
sshd, with the app's own log:pendingstayed set and its continuation was never resumed.openConnection set -> nil, which is the drop back to the list), and the cover's re-presentation then tore the alert down. The dismiss binding counted that as Cancel: the ~0.87 second flash, in 4 of 7 runs.Two things then turned a lost question into a permanent hang:
ConnectionCoordinator.connect()joined any in-flight attempt with no bound, the coordinator outlives the cover, and the back button never cancelled. Each reopen loggedjoins in-flight taskand sat on Connecting for 25 seconds at a time.ask()refused every later request while one was pending, so the next unknown-host connect failed instantly with "host key was not trusted" and no prompt.Microsoft Entra sign-in had the same shape and the same defect.
The fix
The question now belongs to the connect attempt, and the screen that owns the attempt shows it.
TableProDatabasegainsConnectionQuestion(.unknownHostKey,.changedHostKey) and aConnectionPrompter, threaded throughConnectionManager.connect(_:prompter:)andSSHProvider.createTunnel.HostKeyVerifierasks it; the wording and the buttons live in the app.ConnectionPromptQueue, one perConnectionCoordinatorand one for Test Connection, holds the questions in order, never refuses a second one, and answers every waiter. A question asked by an already-cancelled attempt is never shown; cancelling or retiring the attempt answers what is pending, so no tunnel is left suspended.ConnectedViewpresents them with.connectionPrompts(coordinator.prompts)inside the cover. Measured: an alert attached there waits for the cover to finish presenting, never dismisses it, and survives a root sheet, background and foreground, and the app-lock window. The alert holds the question it presented, so a dismissal answers what the user was looking at, and an externally emptied queue takes the alert down instead of leaving dead buttons.AttemptJoiners), so the last screen to leave abandons it while a screen replaced by another does not; the Connections button cancels; andcancelConnect()answers pending questions even for a reconnect or a database switch, which own noconnectTask.Verification
sshd, before and after, logs insshrepro/runs/:tunnel forwarding started, then connected). A dismissal the user did not cause answers the question and ends the attempt inline with Retry, leaving no suspended tunnel; three further connects each asked and answered cleanly, including through a 2.5s delay proxy and a 20s stall, with nothing left pending.TableProDatabaseTests: 30 passed. New tests cover the queue (answer, cancel before and during the wait, retire, ordering, notices, a stale notice), the verifier (trust only on an explicit yes, refuse, changed key, no prompter fails at once), the joiner count, and that the prompter reaches the tunnel.Not verified on a device or an older runtime: iOS 18 to 26 (only the iOS 27 runtime is installed here). One case has unit tests only: retiring an attempt while its question is on screen. The alert is modal, so nothing in the app can reach that path from the simulator, and every route tried (background and foreground, an edit, a sample reset, a deep link) either never cancels or is intercepted by the system first.
Deliberately not fixed here
Found while investigating, each with a reproduction, none of them the reported bug:
connectexcept host-key rejection).ConnectionManager.connectawaits the previous session's teardown with no deadline.jumpHostsis ignored on iOS, so a connection that reaches its database through a bastion dials the target directly.