feat(connection): notify sidebar when keepalive loses connection

This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-09-30 19:49:52 +08:00
1 parent 3ffff92c8f
commit dc503877f9
13 files changed
+864 -27

No files matched your search

+22
View File
@@ -122,6 +122,7 @@ import type { QueryEditability } from "@/lib/sql/sqlAnalysis";
import { isTerminalTransferProgress } from "@/lib/backend/transferProgress";
import type {
ActivePluginSession,
ConnectionLivenessMessage,
PluginBinaryEvent,
PluginConnectionActionResult,
PluginEvent,
@@ -1563,6 +1564,17 @@ export async function checkConnectionHealth(connectionId: string): Promise<void>
return invokeBackend("check_connection_health", { connectionId });
}
/**
* Read-only counterpart of `checkConnectionHealth`: reports whether the connection still has a
* pool, without probing or mutating anything (#4339).
*
* Liveness events must be confirmed through this, never through `checkConnectionHealth`: the
* latter removes unhealthy pools and is the path `ensureConnected` uses to trigger a reconnect.
*/
export async function connectionIsOpen(connectionId: string): Promise<boolean> {
return invokeBackend("connection_is_open", { connectionId });
}
export async function prewarmConnection(connectionId: string, database?: string, catalog?: string, clientSessionId?: string): Promise<void> {
return invokeBackend("prewarm_connection", { connectionId, database, catalog, clientSessionId });
}
@@ -2853,6 +2865,16 @@ export async function subscribePluginEvents(onEvent: (event: PluginEvent) => voi
};
}
/**
* Subscribe to backend connection-liveness messages (#4339).
*
* The listener receives the message unwrapped; the web transport's SSE handler parses the same
* shape, so the store can stay transport-agnostic.
*/
export async function subscribeConnectionLiveness(onEvent: (event: ConnectionLivenessMessage) => void): Promise<UnlistenFn> {
return listen<ConnectionLivenessMessage>("dbx-connection-liveness", (event) => onEvent(event.payload));
}
export async function listJdbcDrivers(): Promise<JdbcDriverInfo[]> {
return invoke("list_jdbc_drivers");
}