hermes-agent/apps/desktop/src/app/settings/ssh-host-selection.ts
yoniebans faa3bce6dc style(desktop): satisfy merged eslint/prettier config
The SSH modules predate the stricter lint config that landed on main (curly, no-empty, perfectionist sorting, prettier). Mechanical lint:fix + fmt pass, empty catch blocks filled with the codebase's void-0 convention, and inline no-control-regex disables on the three deliberate control-char patterns (same pattern as lib/ansi.ts).
2026-07-20 23:01:49 +02:00

43 lines
954 B
TypeScript

type SshHostState = {
sshHost: string
sshUser: string
sshPort: number | null
sshKeyPath: string
sshRemoteHermesPath: string
}
type ResolvedSshHost = {
identityFile?: string | null
port?: number | null
user?: string | null
}
function selectSshHost<T extends SshHostState>(state: T, host: string): T {
if (host === state.sshHost) {
return state
}
return {
...state,
sshHost: host,
sshUser: '',
sshPort: null,
sshKeyPath: '',
sshRemoteHermesPath: ''
}
}
function enrichSelectedSshHost<T extends SshHostState>(state: T, host: string, resolved: ResolvedSshHost): T {
if (state.sshHost !== host) {
return state
}
return {
...state,
sshUser: state.sshUser || resolved.user || '',
sshPort: state.sshPort ?? (resolved.port === 22 ? null : (resolved.port ?? null)),
sshKeyPath: state.sshKeyPath || resolved.identityFile || ''
}
}
export { enrichSelectedSshHost, selectSshHost }