fix(workflow): keep a newer local edit over a save's response - #8540
fix(workflow): keep a newer local edit over a save's response#8540yangzhang75 wants to merge 1 commit into
Conversation
Every save's response is fed back as the workflow's metadata: the canvas autosave, the menu's own save (rename, description, revert) and the Form View switch's save. Saves go out one at a time, so a response can land after a newer local edit and put the old name or description back. Rename while an autosave is out and the title flips back until the rename's own save answers; rename while the Form View switch's save is out and the rename is lost, since the switch left as soon as its own save had completed and the page load aborted the rename's. WorkflowPersistService, the one place every save goes through, now relays each response with the page's current name and description in place of the ones the save was sent with (left alone when another workflow is open by then; kept for a workflow the save has just created, which still carries the default id locally), and exposes whenSavesDrained(), which the Form View switch waits for before leaving, so a save queued behind its own lands before the page unloads. Closes apache#8536. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY
Automated Reviewer SuggestionsBased on the
|
Backport auto-label reportThis
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8540 +/- ##
=========================================
Coverage 95.90% 95.91%
Complexity 459 459
=========================================
Files 589 589
Lines 33953 33969 +16
Branches 4246 4249 +3
=========================================
+ Hits 32564 32581 +17
Misses 811 811
+ Partials 578 577 -1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What changes were proposed in this PR?
Closes #8536, the item deferred from #8456 on review.
Every save's response is fed back as the workflow's metadata (the canvas autosave in
workspace.component.ts, the menu's own save for a rename / description / revert, the Form View switch's save). Saves go out one at a time, so a response can land after a newer local edit and put the old name or description back: rename while an autosave is out and the title flips back until the rename's own save answers; rename while the Form View switch's save is out and the rename is lost, since the switch left as soon as its own save had completed and the page load aborted the rename's.Handled once, in
WorkflowPersistService, the one place every save goes through:whenSavesDrained()emits once every save asked for so far has answered or failed (at once when none is pending). The Form View switch waits for it before leaving, so a save queued behind its own (a rename's, a description's, which save through the menu itself and do not go throughworkflowChanged) lands before the page unloads. A queued save that fails reports its error through its own caller and does not hold the hand-over (before this change it was simply aborted by the page load).Verified in a real browser against a dev server, with every persist response held back 1.5 s: before, a rename made while an earlier rename's save was out flipped the title back to the old name when that response landed, and a rename made during the Form View switch's save was lost (the page left after 1.9 s with the old name stored); after, the title stays on the new name, and the switch leaves once the rename's save has landed, with the new name stored.
Any related issues, documentation, discussions?
Closes #8536. Follow-up to #8456 (threads on
menu.component.ts:692and:231); part of the Form View feature (parent issue #8011).How was this PR tested?
Unit tests (vitest): the persist service relays a response with the page's current name and description and the server's other fields, keeps the local name for a just-created workflow, leaves a response alone when another workflow is open;
whenSavesDrainedemits at once when idle, only after the last of two queued saves has answered, and after a failed save; the menu's switch leaves only once the queue has drained. Each new guard was deletion-checked (removing it turns the corresponding test red). eslint, prettier and the production (AOT) build pass; every changed line is statement and function covered.Was this PR authored or co-authored using generative AI tooling?
Yes. Generated-by: Claude Code (Claude Fable 5.1, Anthropic). Co-authored with Claude, reviewed line by line by the author before submission.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY