From 39057f1425b7033b9c60fdb67b323982ec5bf51f Mon Sep 17 00:00:00 2001 From: STRIX Date: Wed, 9 Sep 2026 10:34:59 +0800 Subject: [PATCH] fix: re-fetch host from DB before connecting so persisted password applies persistPassword writes the DB directly; ConnectionsPage keeps a long-lived in-memory host list, so reconnects used a stale passwordEnc=null copy and prompted again despite 'remember password'. connectHost now re-reads the host profile before building ConnectSpec. Verified E2E: tick remember -> connect -> READY -> close -> reconnect goes straight to READY (no prompt), command execution verified (PW-FREE-OK). --- entry/src/main/ets/ui/ConnectionsPage.ets | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/entry/src/main/ets/ui/ConnectionsPage.ets b/entry/src/main/ets/ui/ConnectionsPage.ets index b688f6a..cd49b06 100644 --- a/entry/src/main/ets/ui/ConnectionsPage.ets +++ b/entry/src/main/ets/ui/ConnectionsPage.ets @@ -124,6 +124,25 @@ export struct ConnectionsPage { } private connectHost(host: HostProfile): void { + this.launchFromDb(host.id, host); + } + + /** + * Re-fetch the host from the DB before connecting so a password persisted + * by an earlier session (persistPassword writes the DB, not this page's + * in-memory list) is picked up without requiring a page reload. + */ + private async launchFromDb(id: number, fallback: HostProfile): Promise { + let host: HostProfile = fallback; + try { + const repo: HostRepository = await this.ensureRepo(); + const fresh: HostProfile | null = await repo.getById(id); + if (fresh !== null) { + host = fresh; + } + } catch (e) { + // Fall back to the in-memory copy on any DB hiccup. + } this.launch(specFromHost(host)); }