Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/flowr/diagrams/diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ 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 === '') {
await vscode.window.showErrorMessage('Failed to generate diagram - FlowR Analyzer Session is not ready. Check if flowrR is connected and try again.');
return;
}

const panel = createDiagramWebview({
mermaid: mermaid,
options: options,
Expand Down
21 changes: 19 additions & 2 deletions src/flowr/internal-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,28 @@ export class FlowrInternalSession implements FlowrSession {
}

private async startWorkWithProgressBar<T = void>(document: vscode.TextDocument, actionFn: (analyzer: FlowrAnalyzer) => Promise<T>, action: WorkActions, showErrorMessage: boolean, defaultOnErr = {} as T): Promise<T> {
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);
return defaultOnErr;
}
}

this.setWorking(true);

const analyzer = await analyzerFromDocument(document, this.parser);

// update the vscode ui
Expand Down