From 2a85fc809e1c8ab403856a18366ebfb833cde39a Mon Sep 17 00:00:00 2001 From: Endri Bezati Date: Fri, 4 Sep 2026 15:07:14 +0200 Subject: [PATCH] fix: opening a different graph in a diagram that is already open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The open command stashes the requested graph name and then calls `vscode.openWith`. The stash is read by the INITIAL model request, and an editor that already exists does not make one — `openWith` focuses it instead. So asking for a different graph inside a file you were already looking at did nothing: the name was recorded, the tab came forward, and the diagram kept showing what it showed before. That is the ordinary way to move between the graphs in one file, and it is the case where nothing happening is hardest to read, because the command plainly did SOMETHING — the editor took focus. A reader has no way to tell a command that silently declined from one that is not wired up. When a diagram for the file is already open, the command now refreshes it with the requested name. A refresh already carries `networkName` into a fresh model request; that is the mechanism a drill-down relies on, so this reuses it rather than adding a second path. "Already open" is asked before opening, because opening is what makes it true. The split-view command had the same shape and is fixed the same way. Leaving a known identical bug beside a fixed one is worse than fixing both. Neither path changes for a diagram that is not yet open: the stash is still what the initial request reads, and no extra round trip is added to a fresh open. --- .../src/extension/diagram/glsp-activation.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/packages/extension-core/src/extension/diagram/glsp-activation.ts b/packages/extension-core/src/extension/diagram/glsp-activation.ts index 02eb5b5..46e1e7d 100644 --- a/packages/extension-core/src/extension/diagram/glsp-activation.ts +++ b/packages/extension-core/src/extension/diagram/glsp-activation.ts @@ -1127,6 +1127,9 @@ function registerCalDiagramCommands( }); return; } + // Whether a diagram for this file is already on screen, asked + // BEFORE opening, because opening is what makes it true. + const alreadyOpen = editorProvider?.getClientIdForDocumentUri(sourceUri) !== undefined; // Stash the requested graph the same way a drill-down does, so the // initial model request picks it up. `vscode.openWith` carries no // arbitrary data, so this side channel is the only way a name known @@ -1140,6 +1143,26 @@ function registerCalDiagramCommands( sourceUri, profile.customEditorViewType ); + if (requestedNetwork && alreadyOpen) { + // The stash above is read by the INITIAL model request, and an + // editor that already exists does not make one — `openWith` + // focuses it instead. So asking for a different graph inside a + // file you were already looking at did nothing at all: the name + // was recorded, the tab came forward, and the diagram kept + // showing what it showed before. + // + // That is the ordinary way to move between the graphs in one + // file, and the case where nothing happening is hardest to + // read, because the command plainly did SOMETHING — the editor + // took focus. + // + // A refresh carries the name into a fresh model request, which + // is the mechanism a drill-down already relies on. + await refreshActiveDiagramModel({ + sourceUri: sourceUri.toString(), + workflowName: requestedNetwork + }); + } }) ); @@ -1169,6 +1192,7 @@ function registerCalDiagramCommands( return; } // Open the source file with the network diagram editor in a split view + const alreadyOpenBeside = editorProvider?.getClientIdForDocumentUri(sourceUri) !== undefined; if (requestedNetwork) { putPending(state.pendingNetworkBySourceUri, sourceUri.toString(), requestedNetwork); } @@ -1178,6 +1202,15 @@ function registerCalDiagramCommands( profile.customEditorViewType, vscode.ViewColumn.Beside ); + if (requestedNetwork && alreadyOpenBeside) { + // Same reasoning as the non-split command above: the stash is + // read by the initial model request, and an editor that already + // exists does not make one. + await refreshActiveDiagramModel({ + sourceUri: sourceUri.toString(), + workflowName: requestedNetwork + }); + } }) );