fix(connection): show built-in driver update hint on connection failure (#2111)

This commit is contained in:
zipg authored and GitHub committed 2026-06-30 01:52:37 +08:00
1 parent 96f265507d
commit dab1d145bc
6 files changed
+99 -28

No files matched your search

@@ -4,11 +4,13 @@ import { supportsDriverManagement } from "./databaseCapabilities";
export interface AgentDriverInstallState {
db_type: string;
installed: boolean;
update_available?: boolean;
}
function agentDriverInstallKey(dbType: DatabaseType | undefined, driverProfile?: string): string | undefined {
if (dbType === "oracle") return "oracle";
if (dbType === "mongodb") return "mongodb";
if (dbType === "dameng") return "dameng";
return driverProfile && driverProfile !== dbType ? driverProfile : dbType;
}
@@ -17,3 +19,15 @@ export function showAgentDriverInstallHint(dbType: DatabaseType | undefined, dri
const driverKey = agentDriverInstallKey(dbType, driverProfile);
return drivers.find((driver) => driver.db_type === driverKey)?.installed !== true;
}
export function hasAgentDriverUpdate(dbType: DatabaseType | undefined, drivers: readonly AgentDriverInstallState[], driverProfile?: string): boolean {
if (!supportsDriverManagement(dbType)) return false;
const driverKey = agentDriverInstallKey(dbType, driverProfile);
return drivers.find((driver) => driver.db_type === driverKey)?.update_available === true;
}
export function appendAgentDriverUpdateHint(message: string, hint: string): string {
if (!message.trim()) return hint;
if (message.includes(hint)) return message;
return `${message}\n\n${hint}`;
}