dbeaver/pro#9638 [CB] refresh is needed to see replaced connectionfolder in another instance (#4464)

* dbeaver/pro#9638 fix: update project filtering logic to use project IDs for active projects

Changed all four spots from reference equality to id comparison, matching the rest of the codebase, see https://github.com/dbeaver/cloudbeaver/issues/4430

* dbeaver/pro#9638 refactor(connectionUpdateHandler): move node to a new parent on change

* dbeaver/pro#9638 revert commit eb2ba7871e

* dbeaver/pro#9638 fix: update node parents on move in other session

Server events don't carry the actual data, so besides outdating (which lets the handlers invalidate the previous state, e.g. the old location in the navigation tree) we explicitly load the connection to guarantee that the handlers receive the actual state

* dbeaver/pro#9638 fix: sync connection folder move from another session

* dbeaver/pro#9638 fix: revert back connectionUpdateHandler

* dbeaver/pro#9638 fix: remove try catch

---------

Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com>
This commit is contained in:
Sychev Andrey
2026-07-23 17:33:26 +02:00
committed by GitHub
co-authored by Evgenia
parent 16dda810d7
commit 9e682617e6
5 changed files with 37 additions and 11 deletions
@@ -96,7 +96,7 @@ export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoPar
connectionInfoEventHandler: ConnectionInfoEventHandler,
connectionStateEventHandler: ConnectionStateEventHandler,
userInfoResource: UserInfoResource,
navTreeResource: NavTreeResource,
private readonly navTreeResource: NavTreeResource,
) {
super();
@@ -214,18 +214,18 @@ export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoPar
connectionInfoEventHandler.onEvent<ResourceKeyList<IConnectionInfoParams>>(
ServerEventId.CbDatasourceUpdated,
key => {
if (this.isConnected(key)) {
if (this.isConnected(key) && !this.isOutdated(key)) {
const connection = this.get(key);
this.dataSynchronizationService
.requestSynchronization('connection', connection.map(connection => connection?.name).join('\n'))
.then(state => {
if (state) {
this.markOutdated(key);
this.updateFromEvent(key);
}
});
} else {
this.markOutdated(key);
this.updateFromEvent(key);
}
},
data =>
@@ -297,6 +297,32 @@ export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoPar
return this.get(key).every(connection => connection?.connected ?? false);
}
private async updateFromEvent(key: ResourceKeyList<IConnectionInfoParams>): Promise<void> {
for (const connectionKey of key) {
const currentConnection = this.get(connectionKey);
const newConnection = await this.refresh(connectionKey);
if (currentConnection?.nodePath !== newConnection?.nodePath) {
if (currentConnection?.nodePath) {
const parent = this.navNodeInfoResource.getParent(currentConnection.nodePath);
if (parent) {
this.navTreeResource.markOutdated(parent);
}
}
if (newConnection?.nodePath) {
await this.navNodeInfoResource.loadNodeParents(newConnection.nodePath);
const parent = this.navNodeInfoResource.getParent(newConnection.nodePath);
if (parent) {
this.navTreeResource.markOutdated(parent);
}
}
}
}
}
getConnectionIdForNodeId(projectId: string, nodeId: string): IConnectionInfoParams | undefined {
if (!NodeManagerUtils.isDatabaseObject(nodeId)) {
return;
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2025 DBeaver Corp and others
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@ export function navigationTreeProjectFilter(
if (isRMProjectNode(node)) {
const project = projectsNavNodeService.getProject(node.uri);
if (!project || !projectsService.activeProjects.includes(project)) {
if (!project || !projectsService.activeProjects.some(({ id }) => id === project.id)) {
return false;
}
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ export function navigationTreeProjectsExpandStateGetter(
let active = false;
const project = projectsNavNodeService.getByNodeId(nodeId);
if (project) {
active = projectsService.activeProjects.includes(project);
active = projectsService.activeProjects.some(({ id }) => id === project.id);
}
return {
@@ -37,7 +37,7 @@ export function navigationTreeProjectFilter(
if (isProjectNode(node)) {
const project = projectsNavNodeService.getProject(node.uri);
if (!project || !projectsService.activeProjects.includes(project)) {
if (!project || !projectsService.activeProjects.some(({ id }) => id === project.id)) {
return false;
}
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ export function navigationTreeProjectsExpandStateGetter(
let active = false;
const project = projectsNavNodeService.getByNodeId(nodeId);
if (project) {
active = projectsService.activeProjects.includes(project);
active = projectsService.activeProjects.some(({ id }) => id === project.id);
}
return {