Skip to content

fix: replace the draft when editing ends or a version is restored - #641

Merged
Sev7eNup merged 1 commit into
mainfrom
fix/discard-and-restore-replace-draft
Oct 24, 2026
Merged

Sev7eNup merged 1 commit into
mainfrom
fix/discard-and-restore-replace-draft

Conversation

@Sev7eNup

Copy link
Copy Markdown
Owner

Fixes #596

After End editing (confirmed discard) the editor only released the lock, and a version restore only refetched the workflow. The editor refuses fresh server data while the draft is dirty, so the discarded draft stayed on the canvas and autosave wrote it back five seconds later, also over a just-restored version.

  • New replaceDraft(operation) in useWorkflowPersistence: stops autosave and follow-up saves, waits for a save already in flight, runs the server operation, and only on success drops the draft so the next sync shows the server state. On failure the draft stays dirty.
  • End editing and version restore both run through it. The dirty-draft confirmation moved from the header button into the lifecycle, so the button, the command palette and Ctrl+U all ask before discarding. An unlock failure now shows a toast.
  • Designer docs (DE/EN) and docs/workflow-designer-features.md mention the behavior.

Tests run locally (vitest, on top of #638):

  • WorkflowEditorPage.test.tsx: two new scenario tests (End editing on a dirty draft; restore over a dirty draft). Both fail without the fix.
  • useWorkflowPersistence.test.tsx: replaceDraft waits for the running save and skips its follow-up; a failed operation keeps the draft dirty.
  • WorkflowDiffModal.test.tsx: restore runs through replaceDraft
  • hooks, editor page, overlays, designer components, demo: 81 files, 1065 tests passed; tsc clean

🤖 Generated with Claude Code

End editing only released the lock, and a version restore only refetched
the workflow. The editor refused the fresh server state while the draft was
dirty, so the discarded draft stayed on the canvas and autosave wrote it
back five seconds later, also over a just-restored version.

Both now run through replaceDraft in the persistence hook: it stops
autosave and follow-up saves, waits for a save already in flight, runs the
server operation and only then drops the draft, so the next sync shows the
server state. If the operation fails the draft stays dirty. The dirty-draft
confirmation moved into the lifecycle, so the button, the command palette
and Ctrl+U all ask before discarding.

Fixes #596

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Sev7eNup
Sev7eNup merged commit f278f06 into main Oct 24, 2026
17 checks passed
@Sev7eNup
Sev7eNup deleted the fix/discard-and-restore-replace-draft branch October 24, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discard and version restore do not replace the current workflow draft

1 participant