Skip to Content
FlowsResults

Flow results & widgets

When a Flow run completes (or is still running), lensless stores the execution state that contains:

  1. input – The user’s initial input.
  2. results – Output objects from each step, keyed by step ID.
  3. ui – Optional UI configuration for how to display results, especially ui.results.widgets.

By referencing ui.results.widgets, we can generate a user-friendly Results page that organizes final outputs into images, JSON objects, or downloadable links.


Where Is Results Defined?

In your Flow’s top-level JSON, there’s an optional ui.results field. For example:

{ "title": "Example Flow", "description": "Demonstrates final results config", "ui": { "results": { "widgets": [ { "type": "Images", "sources": ["imageGeneratorStep, secondImageGenerator"] }, { "type": "Objects", "sources": ["myObjectStep"] }, { "type": "Download", "sources": ["zipOutput"] } ] } }, "steps": [ ... ] }

Here, we’re telling the front-end to display:

  1. Images from imageGeneratorStep and secondImageGenerator.
  2. Objects from myObjectStep.
  3. A Download link from zipOutput.

The Result “Widgets”

Each entry in widgets is an object like:

{ "type": "Images", // or "Objects" or "Download" "sources": ["stepId1", "stepId2"...] }

1. Images

When type: "Images", lensless looks at each source step: • If the step is an ImageGenerator (or it has a .images array in its final result), we collect those images. • Each image has a url. We sign these URLs so the user can view them securely.

Displayed as a gallery.

2. Objects

When type: "Objects", the front-end: • Fetches the JSON output from each listed step. • Displays it in a collapsible or raw JSON viewer.

Useful for showing structured data generated by ObjectGenerator or ObjectTransformer.

3. Download

When type: "Download", we check the .url field from each listed step, typically used by: • Zipper step: produces a single .zip with a .url. • Could also be any step that returns a link.

We then render a hyperlink for the user to download the file(s).

Putting it all together

Flow State: 1. steps – The array describing each step in your pipeline. 2. results – Each step’s final output, e.g. results[myStepId]. 3. ui.results.widgets – Instructs how to present those results.

Front-End: 1. Looks up the user’s Flow run and reads its state. 2. Derives the list of widgets from ui.results. 3. For each widget: - Gathers data from the relevant steps. - Renders an appropriate view: images, object viewers, or download links.

Progress & Status

During execution, the Flow might be RUNNING, PENDING, or eventually SUCCEEDED/FAILED. The UI can show a progress bar based on how many steps are complete.

During peak times, a flow might stay in the Pending state (or 0% progress) for a while. However, if we detect it is stuck (in pending for more than 2 hours), we will automatically cancel it.

Tips & Best Practices

We recommend always adding a Zipper step along with a Download result widget if your Flow results contain more than 10 images. Users will usually want to download these and having to do it individually can be cumbersome depending on the amount of items. The same tip applies to flows with lots of JSON results.

  1. Plan your UI: Decide which steps produce final “viewable” data. Add those step IDs to ui.results.widgets.
  2. Multiple Widget Types: If you want to show multiple categories of images, make multiple Objects or Images entries with different sources.
  3. Combining results: To combine result data from multiple steps, simply add multiple step IDs into the sources object of the same widget. They need to be of the same type.
  4. Download: If your Flow has a final .zip or other file, ensure it’s included in a Download widget so users can retrieve it easily.
  5. Fallback: If you omit ui.results.widgets, the system might show a plain fallback with all raw results data.
Last updated on