From 520bf87d5b61e45393278df8f4bc87b69eaa8fe6 Mon Sep 17 00:00:00 2001 From: gigalasr Date: Thu, 29 Jan 2026 21:36:27 +0100 Subject: [PATCH 1/2] feat-fix(diagram): wait for flowr session - #364 --- src/flowr/diagrams/diagram.ts | 5 +++++ src/flowr/internal-session.ts | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/flowr/diagrams/diagram.ts b/src/flowr/diagrams/diagram.ts index 9b6b209..12755db 100644 --- a/src/flowr/diagrams/diagram.ts +++ b/src/flowr/diagrams/diagram.ts @@ -68,6 +68,11 @@ class DiagramUpdateCoordinator { const options = optionsFromDiagramType(type); const mermaid = await definition.retrieve(options as never, editor); + // Don't show a panel if generation failed + if(mermaid === '') { + return; + } + const panel = createDiagramWebview({ mermaid: mermaid, options: options, diff --git a/src/flowr/internal-session.ts b/src/flowr/internal-session.ts index 9f7acf1..11df2fa 100644 --- a/src/flowr/internal-session.ts +++ b/src/flowr/internal-session.ts @@ -105,11 +105,29 @@ export class FlowrInternalSession implements FlowrSession { } private async startWorkWithProgressBar(document: vscode.TextDocument, actionFn: (analyzer: FlowrAnalyzer) => Promise, action: WorkActions, showErrorMessage: boolean, defaultOnErr = {} as T): Promise { + this.setWorking(true); + + // Wait for the flowr session if(!this.parser) { - return defaultOnErr; + const times = [3000, 2000, 1000]; + while(times.length != 0) { + const timeout = times.pop(); + this.outputChannel.appendLine(`FlowR Session not available - retrying in ${timeout}ms`); + await new Promise(res => setTimeout(res, timeout)); + + if(this.parser) { + break; + } + } + + if(!this.parser) { + this.setWorking(false); + await vscode.window.showErrorMessage('Failed to generate diagram - FlowR Analyzer Session is not ready!'); + return defaultOnErr; + } } - this.setWorking(true); + const analyzer = await analyzerFromDocument(document, this.parser); // update the vscode ui From 0560999c2fc89ca80865870461c5d94d79b89683 Mon Sep 17 00:00:00 2001 From: gigalasr Date: Mon, 2 Feb 2026 19:51:44 +0100 Subject: [PATCH 2/2] feat(diagram): suggestions from code review - #364 --- src/flowr/diagrams/diagram.ts | 1 + src/flowr/internal-session.ts | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flowr/diagrams/diagram.ts b/src/flowr/diagrams/diagram.ts index 12755db..68c8d7e 100644 --- a/src/flowr/diagrams/diagram.ts +++ b/src/flowr/diagrams/diagram.ts @@ -70,6 +70,7 @@ class DiagramUpdateCoordinator { // Don't show a panel if generation failed if(mermaid === '') { + await vscode.window.showErrorMessage('Failed to generate diagram - FlowR Analyzer Session is not ready. Check if flowrR is connected and try again.'); return; } diff --git a/src/flowr/internal-session.ts b/src/flowr/internal-session.ts index 11df2fa..7806d0f 100644 --- a/src/flowr/internal-session.ts +++ b/src/flowr/internal-session.ts @@ -110,7 +110,7 @@ export class FlowrInternalSession implements FlowrSession { // Wait for the flowr session if(!this.parser) { const times = [3000, 2000, 1000]; - while(times.length != 0) { + while(times.length !== 0) { const timeout = times.pop(); this.outputChannel.appendLine(`FlowR Session not available - retrying in ${timeout}ms`); await new Promise(res => setTimeout(res, timeout)); @@ -122,7 +122,6 @@ export class FlowrInternalSession implements FlowrSession { if(!this.parser) { this.setWorking(false); - await vscode.window.showErrorMessage('Failed to generate diagram - FlowR Analyzer Session is not ready!'); return defaultOnErr; } }