Files
Netcatty/domain/sftpTerminalIdentity.ts
T
69497ccc6a fix(terminal): offer saved password identities in SSH re-auth dialog (#3477)
* fix(#3475): automated AI fix

* fix: address Codex review on PR #3477

* fix: keep SSH identity picker state accurate

* style: keep SSH identity picker source ASCII-only

* fix: require usernames for saved SSH identity retries

* Keep selected SSH identity for terminal SFTP

* Share reauthenticated identity with all terminal SFTP entry points

* Pass SFTP identity source setter into layer effects

* Use effective identity for preset SFTP panel

* fix: keep focused SFTP identity in sync for toggle

* fix(terminal): use selected vault identity without exposing password

---------

Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com>
Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
2026-09-27 15:43:25 +08:00

36 lines
1.3 KiB
TypeScript

import type { Host } from "./models";
/** Compare the selected SFTP target, including the temporary login identity. */
export function isSameSftpHostSelection(left: Host | null | undefined, right: Host | null | undefined): boolean {
if (!left || !right) return false;
return left.id === right.id
&& left.hostname === right.hostname
&& left.port === right.port
&& left.protocol === right.protocol
&& left.username === right.username
&& left.identityId === right.identityId
&& left.sftpSudo === right.sftpSudo
&& (left.sftpFileProtocol || "auto") === (right.sftpFileProtocol || "auto");
}
/** Keep a terminal's authenticated identity when its SFTP panel follows that terminal. */
export function resolveTerminalSftpHost({
sessionHost,
storedHost,
authenticatedHost,
followsTerminal,
}: {
sessionHost?: Host | null;
storedHost?: Host | null;
authenticatedHost?: Host | null;
followsTerminal: boolean;
}): Host | null {
if (followsTerminal && sessionHost && authenticatedHost
&& authenticatedHost.id === sessionHost.id
&& authenticatedHost.hostname === sessionHost.hostname
&& (authenticatedHost.port || 22) === (sessionHost.port || 22)) {
return authenticatedHost;
}
return sessionHost ?? storedHost ?? null;
}