feat(editor): handle tabs after connection disconnect

This commit is contained in:
javalover123 authored and GitHub committed 2026-09-20 01:12:21 +08:00
1 parent 3cb1faf1c6
commit 28cc1b9768
31 files changed
+1137 -60

No files matched your search

@@ -153,7 +153,8 @@ async function confirmDeleteSelectedConnections() {
try {
await connectionStore.removeConnections(ids);
for (const connectionId of ids) {
connectionStore.disconnect(connectionId).catch((error) => {
// 页签已由 removeConnections 按「删除连接」策略处理,这里只清会话。
connectionStore.disconnect(connectionId, { skipTabHandling: true }).catch((error) => {
console.warn("[DBX][connection:delete:disconnect-failed]", { connectionId, error });
});
}
@@ -416,13 +416,14 @@ function tabTitleText(tab: QueryTab) {
}
function tabConnectionLabel(tab: QueryTab) {
return connectionStore.getConfig(tab.connectionId)?.name || tab.connectionId;
// 连接已删除但页签被保留时,回退到原连接名,避免显示成裸 uuid。
return connectionStore.getConfig(tab.connectionId)?.name || tab.detachedConnectionName || tab.connectionId;
}
function tabConnectionTargetLabel(tab: QueryTab) {
const connection = connectionStore.getConfig(tab.connectionId);
const host = connection?.host.trim();
return connection && host ? `${host}:${connection.port}` : tab.connectionId;
return connection && host ? `${host}:${connection.port}` : tab.detachedConnectionName || tab.connectionId;
}
function databaseTabGroupBaseLabel(tab: QueryTab) {