@@ -56,7 +56,7 @@ function buildBastionParentTitle(label: string | null | undefined, host: string)
5656 return name
5757}
5858
59- export function connectAssetInfoLogic ( db : Database . Database , uuid : string ) : any {
59+ export function connectAssetInfoLogic ( db : Database . Database , uuid : string , fallback ?: { organizationUuid ?: string ; ip ?: string } ) : any {
6060 try {
6161 const stmt = db . prepare ( `
6262 SELECT uuid, asset_ip, asset_type, auth_type, port, username, password, key_chain_id, need_proxy, proxy_name
@@ -89,6 +89,26 @@ export function connectAssetInfoLogic(db: Database.Database, uuid: string): any
8989 ; ( result as any ) . host = ( result as any ) . asset_ip
9090 }
9191
92+ // Fallback: uuid stale after asset refresh — look up by organizationUuid + host
93+ if ( ! result && fallback ?. organizationUuid && fallback ?. ip ) {
94+ const fallbackStmt = db . prepare ( `
95+ SELECT oa.hostname, oa.host, oa.bastion_comment as comment, a.asset_ip, oa.organization_uuid, oa.uuid, oa.jump_server_type,
96+ a.asset_type, a.auth_type, a.port, a.username, a.password, a.key_chain_id, a.need_proxy, a.proxy_name
97+ FROM t_organization_assets oa
98+ JOIN t_assets a ON oa.organization_uuid = a.uuid
99+ WHERE oa.organization_uuid = ? AND oa.host = ?
100+ LIMIT 1
101+ ` )
102+ result = fallbackStmt . get ( fallback . organizationUuid , fallback . ip )
103+ if ( result ) {
104+ if ( ( result as any ) . jump_server_type ) {
105+ sshType = ( result as any ) . jump_server_type
106+ } else {
107+ sshType = extractBastionType ( ( result as any ) . asset_type || 'organization' )
108+ }
109+ }
110+ }
111+
92112 if ( ! result ) {
93113 return null
94114 }
0 commit comments