Skip to content

Commit 26b159d

Browse files
authored
Fix node status synchronization (#3497)
Signed-off-by: Ayoub LABIDI <[email protected]>
1 parent 202d98b commit 26b159d

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/components/network-modification-tree-pane.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ export const NetworkModificationTreePane = ({ studyUuid, currentRootNetworkUuid
311311
studyUpdatedForce.eventData.headers.updateType === NotificationType.NODE_BUILD_STATUS_UPDATED &&
312312
studyUpdatedForce.eventData.headers.rootNetworkUuid === currentRootNetworkUuidRef.current
313313
) {
314-
updateNodes(studyUpdatedForce.eventData.headers.nodes);
314+
// Note: The actual node updates are now handled globally in study-container.jsx
315+
// to ensure all workspaces open in other browser tabs (including those without tree panel) stay synchronized.
316+
// Here we only handle tree-specific cleanup operations.
315317
if (studyUpdatedForce.eventData.headers.nodes.some((nodeId) => nodeId === currentNodeRef.current?.id)) {
316318
dispatch(removeNotificationByNode([currentNodeRef.current?.id]));
317319
// when the current node is updated, we need to reset the logs filter

src/components/study-container.jsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { PARAMS_LOADED } from '../utils/config-params';
1313
import {
1414
closeStudy,
1515
loadNetworkModificationTreeSuccess,
16+
networkModificationTreeNodesUpdated,
1617
openStudy,
1718
resetEquipmentsPostComputation,
1819
setCurrentRootNetworkUuid,
@@ -37,7 +38,7 @@ import NetworkModificationTreeModel from './graph/network-modification-tree-mode
3738
import { getFirstNodeOfType } from './graph/util/model-functions';
3839
import { BUILD_STATUS } from './network/constants';
3940
import { useAllComputingStatus } from './computing-status/use-all-computing-status';
40-
import { fetchNetworkModificationTree } from '../services/study/tree-subtree';
41+
import { fetchNetworkModificationTree, fetchNetworkModificationTreeNode } from '../services/study/tree-subtree';
4142
import { fetchNetworkExistence, fetchRootNetworkIndexationStatus } from '../services/study/network';
4243
import { fetchStudy, recreateStudyNetwork, reindexAllRootNetwork } from 'services/study/study';
4344

@@ -271,9 +272,26 @@ export function StudyContainer() {
271272
}
272273
displayErrorNotifications(eventData);
273274
dispatch(studyUpdated(eventData));
275+
276+
// Handle build status updates globally so all workspaces open in other browser tabs update currentTreeNode
277+
// This fixes the issue where tabs without tree panel don't get updates
278+
if (
279+
updateTypeHeader === NotificationType.NODE_BUILD_STATUS_UPDATED &&
280+
eventData.headers.rootNetworkUuid === currentRootNetworkUuidRef.current
281+
) {
282+
// Fetch updated nodes and dispatch to Redux to sync currentTreeNode
283+
const updatedNodeIds = eventData.headers.nodes;
284+
Promise.all(
285+
updatedNodeIds.map((nodeId) =>
286+
fetchNetworkModificationTreeNode(studyUuid, nodeId, currentRootNetworkUuidRef.current)
287+
)
288+
).then((values) => {
289+
dispatch(networkModificationTreeNodesUpdated(values));
290+
});
291+
}
274292
},
275293
// Note: dispatch doesn't change
276-
[dispatch, displayErrorNotifications, sendAlert]
294+
[dispatch, displayErrorNotifications, sendAlert, studyUuid]
277295
);
278296

279297
useNotificationsListener(NotificationsUrlKeys.STUDY, { listenerCallbackMessage: handleStudyUpdate });

0 commit comments

Comments
 (0)