Skip to content

Conversation

@Pfannkuchensack
Copy link
Collaborator

@Pfannkuchensack Pfannkuchensack commented Nov 23, 2025

Summary

This PR adds a Canvas Workflow Integration feature that allows users to execute workflows directly on canvas layers, with a dedicated canvas_output backend node and an entry-based staging area that supports multiple output images.

Canvas Workflow Integration

Adds a new modal dialog accessible from raster layer context menus that enables users to:

  • Select workflows that have Form Builder enabled, at least one image input field, and a Canvas Output node
  • Automatically pass the current canvas layer as the image input
  • Adjust workflow parameters through an interactive form interface (supports all field types: string, int, float, bool, enum, scheduler, board, model, image)
  • Execute the workflow and have results appear in the canvas staging area

Canvas Output Node

Adds a new CanvasOutputInvocation backend node (canvas_output) that explicitly marks which images should be routed to the canvas staging area. This replaces a fragile heuristic that detected output nodes by scanning for board input fields.

Breaking change: Workflows need a Canvas Output node to work with canvas workflow integration.

Entry-Based Staging Area

Rearchitects the staging area so each canvas_output node in a workflow produces its own navigable entry. A workflow with 2 Canvas Output nodes will show 2 separate thumbnails in the staging area strip, each individually selectable and acceptable.

Bug Fixes

  • Fixes "Input should be a valid dictionary or instance of BoardField" error when queuing workflows containing nodes with board fields. The frontend stores board values as 'auto'/'none' strings which the backend rejects — these are now filtered during graph construction.
  • Fixes async race condition in staging area where optimistic status updates could overwrite complete data, using a generation counter pattern.
  • Handles workflow execution errors and invocation failures with proper state cleanup and user-facing error toasts.

QA Instructions

  1. Setup: Create a workflow with Form Builder enabled, an image input field, and at least one Canvas Output node
  2. Single output: Run workflow from canvas → verify result appears in staging area and can be accepted onto canvas
  3. Multiple outputs: Create workflow with 2 Canvas Output nodes → verify 2 separate entries appear in staging area strip, each with its own thumbnail, individually navigable with arrow keys
  4. Parameter adjustment: Verify all field types render correctly in the modal form and values are applied during execution
  5. Board field fix: Create workflow that includes a save_image node alongside canvas_output → verify it queues without "BoardField" validation error
  6. Workflow filtering: Verify workflows without a canvas_output node do NOT appear in the canvas workflow selector
  7. Error handling: Test with an invalid workflow configuration → verify error toast appears and modal returns to usable state
  8. Navigation: With multiple entries, verify next/prev cycling wraps correctly across item boundaries
  9. Accept: Select a specific entry from a multi-output item → verify only that single image is accepted onto the canvas

Video Demo

Demo

Merge Plan

No special merge considerations. Standard merge to main is fine.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

claude and others added 6 commits November 12, 2025 01:18
This commit implements a new feature that allows users to run workflows
directly from the unified canvas. Users can now:

- Access a "Run Workflow" option from the canvas layer context menu
- Select a workflow with image parameters from a modal dialog
- Customize workflow parameters (non-image fields)
- Execute the workflow with the current canvas layer as input
- Have the result automatically added back to the canvas

Key changes:
- Added canvasWorkflowIntegrationSlice for state management
- Created CanvasWorkflowIntegrationModal and related UI components
- Added context menu item to raster layers
- Integrated workflow execution with canvas image extraction
- Added modal to global modal isolator

This integration enhances the canvas by allowing users to leverage
custom workflows for advanced image processing directly within the
canvas workspace.

Implements feature request for deeper workflow-canvas integration.
- Extract WorkflowFieldRenderer component for individual field rendering
- Add WorkflowFormPreview component to handle workflow parameter display
- Remove workflow compatibility filtering - allow all workflows
- Simplify workflow selector to use flattened workflow list
- Add comprehensive field type support (String, Integer, Float, Boolean, Enum, Scheduler, Board, Model, Image, Color)
- Implement image field selection UI with radio
- Add useFilteredWorkflows hook to filter workflows with ImageField inputs
- Add workflowHasImageField utility to check for ImageField in Form Builder
- Only show workflows that have Form Builder with at least one ImageField
- Add loading state while filtering workflows
- Improve error messages to clarify Form Builder requirement
- Update modal description to mention Form Builder and parameter adjustment
- Add fallback error message for workflows without Form Builder
…on state

- Add _version field (v1) to canvasWorkflowIntegrationState for future migrations
- Add persistConfig with migration function to handle version upgrades
- Add persistDenylist to exclude transient state (isOpen, isProcessing, sourceEntityIdentifier)
- Use es-toolkit isPlainObject and tsafe assert for type-safe migration
- Persist selectedWorkflowId and fieldValues across sessions
@github-actions github-actions bot added the frontend PRs that change frontend files label Nov 23, 2025
@Pfannkuchensack Pfannkuchensack changed the title Canvas Workflow Integration - Run Workflow on Raster Layer Feature(UI): Canvas Workflow Integration - Run Workflow on Raster Layer Nov 23, 2025
@Pfannkuchensack Pfannkuchensack marked this pull request as ready for review December 6, 2025 05:43
@joshistoast
Copy link
Contributor

This feature looks like an awesome addition to Invoke! Just from watching the video my only feedback would be to do away with that image checkbox and upload section, I think we can safely assume they're running that workflow on the image layer and don't need that extra semi-confusing step. Unless I'm missing something ofc.

@Pfannkuchensack
Copy link
Collaborator Author

Some workflows can have more then one Image input so you need that selection Option. Maybe not if there is only one but this can be done later.

@lstein lstein assigned lstein and dunkeroni and unassigned lstein Jan 30, 2026
@lstein lstein added the v6.13.x label Jan 30, 2026
@dunkeroni
Copy link
Collaborator

Some issues I ran into with my testing:

  1. (minor) If the workflow errors, then the canvas stays in the result selection mode with an "in progress" item that never goes away until the user cancels. Not sure if we can capture and escape that easily, but it would be nice to do.
  2. (QOL) If a workflow only has one not-yet-filled image field, then it should be automatically selected. I expect that sort of input structure will be the primary use case.
  3. If the form builder has other image fields (requiring upload, or already containing an image by default) then they are not visually contained to the upload box in the modal.
Screenshot From 2026-02-05 19-50-38 4. If the workflow has multiple image intermediates, then it seems like only the first one is returned as the result to canvas. Should we use a special node that exits only to identify an image as a return for the canvas operations? That could allow the user to control one or multiple results as well. image

@Pfannkuchensack
Copy link
Collaborator Author

Pfannkuchensack commented Feb 11, 2026

  1. If the workflow has multiple image intermediates, then it seems like only the first one is returned as the result to canvas. Should we use a special node that exits only to identify an image as a return for the canvas operations? That could allow the user to control one or multiple results as well.

The way I actually wanted is to have a Save Image node at the end and no other node that can save images. (Many Nodes that have a Output image can save images but are not the Save Image Node)

The special node way would mean you have workflows that work only for the canvas. (or have a not needed node in the workflow tab.)

There are 2 others ways:
Form Builder annotation approach — In the canvas workflow integration modal, let the user tag which image-producing output nodes should return results to canvas, similar to how they already select the input ImageField via radio buttons. The execution code would only apply CANVAS_OUTPUT_PREFIX to those tagged nodes.

For the staging area to support multiple returns, getOutputImageName would need to become getOutputImageNames (return all canvas output images), and each would appear as a separate staging area item.

…rm UX

- Clear processing state when workflow execution fails at enqueue time
  or during invocation, so the modal doesn't get stuck
- Optimistically update listAllQueueItems cache on queue item status
  changes so the staging area immediately exits on failure
- Clear processing state on invocation_error for canvas workflow origin
- Auto-select the only unfilled ImageField in workflow form
- Fix image field overflow and thumbnail sizing in workflow form
@dunkeroni
Copy link
Collaborator

The special node way would mean you have workflows that work only for the canvas. (or have a not needed node in the workflow tab.)

I don't necessarily see that as a bad thing. If I have lots of workflows saved, it is helpful for the canvas interactions to only show the compatible subset that I have made to work as raster layer filters. It could also allow sending back multiple results or intermediates per workflow without that functionality being tied to (or intercepting) the save to gallery. If I do have a workflow that already takes an image and outputs another, then adding one node after my normal save image makes it "canvas-capable".

If in the future we expand the feature to also take bbox inputs (composite raster area, inpaint mask, regional collection), then that will also require a specialty node as well. I think it's a good idea to build around explicit workflow definitions intended for canvas in that case.

Add a dedicated `canvas_output` backend invocation node that explicitly
marks which images go to the canvas staging area, replacing the fragile
board-based heuristic. Each `canvas_output` node produces a separate
navigable entry in the staging area, allowing workflows with multiple
outputs to be individually previewed and accepted.

Key changes:
- New `CanvasOutputInvocation` backend node (canvas.py)
- Entry-based staging area model where each output image is a separate
  navigable entry with flat next/prev cycling across all items
- Frontend execute hook uses `canvas_output` type detection instead of
  board field heuristic, with proper board field value translation
- Workflow filtering requires both Form Builder and canvas_output node
- Updated QueueItemPreviewMini and StagingAreaItemsList for entries
- Tests for entry-based navigation, multi-output, and race conditions
@github-actions github-actions bot added python PRs that change python files invocations PRs that change invocations labels Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend PRs that change frontend files invocations PRs that change invocations python PRs that change python files v6.13.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants