Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): workflows undo/redo #6379

Merged
merged 25 commits into from
May 17, 2024
Merged

Conversation

psychedelicious
Copy link
Collaborator

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

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

@github-actions github-actions bot added the frontend PRs that change frontend files label May 16, 2024
@psychedelicious psychedelicious force-pushed the psyche/feat/ui/workflows-history branch from d46ed2f to b60701e Compare May 17, 2024 00:37
@psychedelicious
Copy link
Collaborator Author

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

We need the undoable slice to be only undoable state - settings are not undoable.
Templates are stored in nanostores. All hooks, selectors, etc are reworked to reference the nanostore.
- Do not allow whitespace-only field titles
- Make only preview text trigger editable
- Tooltip over the preview, not the whole "row"
The schema fixture wasn't formatted quite right - doesn't affect the test but still.
@psychedelicious psychedelicious force-pushed the psyche/feat/ui/workflows-history branch from b60701e to 4b858a2 Compare May 17, 2024 00:41
This state is ephemeral and not undoable.
@psychedelicious
Copy link
Collaborator Author

  • 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 psychedelicious enabled auto-merge (rebase) May 17, 2024 03:24
@psychedelicious psychedelicious merged commit ad8778d into main May 17, 2024
14 checks passed
@psychedelicious psychedelicious deleted the psyche/feat/ui/workflows-history branch May 17, 2024 03:24
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(nodes): History / undo / redo
2 participants