InvokeAI icon indicating copy to clipboard operation
InvokeAI copied to clipboard

feat(ui): workflows undo/redo

Open psychedelicious opened this issue 1 year ago • 1 comments

Summary

Adds undo/redo to workflows. This required splitting up the workflow editor state a bit so that undoable state is isolated from the rest of it.

In order to split things up, I needed to rewrite the auto-connection logic. In the end, that logic is much cleaner. I fixed a number of fiddly interactions and improved some things:

  • Jank in the auto-add-node and auto-connect logic.
  • Rewrote copy and paste logic. Should be identical now, except the position of pasted nodes may need some tweaking.
  • Collect node inputs now narrow to accept connections only from fields of the same type as are already connected.
  • Selecting an edge moves it to the front so that when you grab an existing edge, it prefers the currently selected edge.
  • Editable field titles do not allow whitespace only labels.
  • Disconnected fields "collapse" and move up to the top of the node, hiding their UI input component.

Note: The grouping of undoable actions needs some tuning. You might find that you need to undo multiple times to see any change. Each undo is doing something, but it may not result in any visible change. Conversely, you might undo and find it undoes too much. I'll refine this as I use it more - it's tricky to find the edge cases.

Related Issues / Discussions

Closes #4137

QA Instructions

Play around with undo/redo, copy/paste, auto-connect and auto-node.

Due to interactions between reactflow and undo/redo, it may be hard to provide consistent reproductions when undo/redo don't do what you expect. Ideally you can take a screen recording, starting from a fresh load of the page, showing the problem.

Merge Plan

This needs user testing before release. I don't plan on an OSS release until next week.

Checklist

  • [x] The PR has a short but descriptive title, suitable for a changelog
  • [ ] Tests added / updated (if applicable)
  • [x] Documentation added / updated (if applicable)

psychedelicious avatar May 16 '24 14:05 psychedelicious

I was fiddling around with schema parsing and added a couple test cases for parseSchema, which was previously untested.

psychedelicious avatar May 17 '24 00:05 psychedelicious

  • Fixed the most of the jank with undo/redo grouping.
  • Extracted node execution state from the undoable nodesSlice - we shouldn't be undoing generation progress

psychedelicious avatar May 17 '24 03:05 psychedelicious