Ability to view differences between Flow versions

Issue #2468 open
Phil W created an issue

Salesforce is investing heavily in flows and the flow orchestrator. There are features (such as templating and override support) that fit very well with ISV flow usage (packaging flows in managed 1GPs and managed/unlocked 2GPs).

The Salesforce UI provides an excellent visual editor for flows. However, when the metadata is examined, it is very difficult to understand since it is a flat list of elements that are related by name references. Unlike traditional code, you cannot read the XML linearly to understand the code structure and there is no useful reference traversal other than text-based search.

This is problematic when a developer wants to understand the structure and logic in a flow, meaning that the developer typically has to deploy/push the flow to an org and then use the Salesforce UI to review it.

Even then, this does not support the ubiquitous use case of reviewing changes made to a flow.

Reviewing is an essential part of any software development lifecycle, which is why tools like git allow a diff to be viewed (and github/bitbucket/others provide commit and pull request UIs that support commenting). Unfortunately, in the case of flows, this diff is unhelpful due to the opacity of their XML representation, making the review process difficult and error prone.

This enhancement request is to:

  1. Add a visualization of the flow, perhaps similar to the Salesforce UI’s flow editor (though can be read only, at least at this stage). This might be similar to how markdown files can show a preview in IDEA. Ideally, clicking on elements in the visualization would navigate to the equivalent XML element.
  2. Add a visualization of a flow, like above, but able to visualize the differences between one version of the flow and another (through git, local history and/or against the clipboard, much as the standard IDEA diff tool). This might show elements that are unchanged, modified or added as part of the main visualization, and show deleted elements in a separate area, for example. Again click navigation would be useful.

This enhancement does not include visual editing (that would be an equally useful future enhancement).

As reference, a simple visualization tool has been created for use with VSCode.

Comments (9)

  1. Scott Wells repo owner

    Leaving a few notes for myself for when I circle back around to this. It looks like this could be most easily accomplished by transforming the Flow graph into a Markdown Mermaid graph (specifically a flowchart. JetBrains IDEs already support Markdown OOTB, and JetBrains offers a free plugin that extends Markdown for rendering of Mermaid graphs:

    https://plugins.jetbrains.com/plugin/20146-mermaid

    That would help with the visualization aspect. Providing a useful diff view for Flow versions is perhaps another beast altogether and probably requires some research on existing best practices for providing useful visual differences between versions of graph-based content before contriving something from scratch.

  2. Scott Wells repo owner

    I've been tinkering with Mermaid flowchart syntax a bit, manually converting a few test flows into flowcharts with limited formatting/styling. Here are a few examples:

    Obviously not beautiful, but it's a good proof-of-concept that the core information in the Flow can be translated into a diagram quite easily with existing and free JetBrains plugins.

    The big piece of work, then, is going to be providing a (reasonably) comprehensive adapter from Flow XML to the corresponding Mermaid flowchart. My guess is that, instead of trying to boil the ocean, I'll probably get it working for all of the sample Flows to which I have convenient access, get that out there for people to play with, then the gaps will be reported.

    If anyone interested in this feature wants to provide a good resource for open source Flows that cover the majority of use cases, that would be wonderful input into such an exercise.

    No guarantees on when this will come to light, but it’s a nice thing to work on in the background and I think a first version should be possible, particularly over the holidays when I’m trying not to release anything potentially risky but almost certainly won’t want to step away from forward progress entirely…

  3. Scott Wells repo owner

    Okay, very good progress on this today. I've gotten it basically working end-to-end with a split editor for Flow metadata that shows a live flowchart in the preview pane. I've implemented support for all Flow node types, though many of those nodes would benefit from extra node type-specific details being added to the graphical view. That's obviously a delicate balance because too much information can dilute the value of a more simple visual view of the process. Here are a few real-world examples from Salesforce open source projects:

    There's still some work to do to keep the preview live as the Flow metadata changes, but hopefully I'll be able to get out a v1 of this early next week before the holidays.

  4. Scott Wells repo owner

    Visualization has been delivered in 2.2.9.4. I’ll leave this open to mull on showing differences, though I may also break that out into its own distinct enhancement and resolve this one.

  5. Log in to comment