fix: clear draft on workflow close to prevent stale state on reopen#8854
fix: clear draft on workflow close to prevent stale state on reopen#8854pythongosssss merged 1 commit intomainfrom
Conversation
closeWorkflow() only called removeDraft() for temporary workflows. Persisted workflows called unload() but left the draft in localStorage, so re-opening the workflow would overlay the stale draft onto the clean disk copy. Additionally, the close flow switches to the next tab before removing the closing workflow, which triggers beforeLoadNewGraph() and re-saves the dirty draft. Remove the draft before the tab switch to prevent this. Amp-Thread-ID: https://ampcode.com/threads/T-019c58b5-679f-75cf-a8b1-d6f57599264f
📝 WalkthroughWalkthroughThe changes ensure consistent draft cleanup when closing workflows by making draft store removal unconditional for all workflow closures. Draft removal now occurs before the temporary workflow check, with tests added to verify behavior for both persisted and temporary workflows. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
Playwright: ✅ 516 passed, 0 failed · 5 flaky 📊 Browser Reports
|
🎨 Storybook Build Status✅ Build completed successfully! ⏰ Completed at: 02/13/2026, 09:50:20 PM UTC 🔗 Links🎉 Your Storybook is ready for review! |
Bundle Size ReportSummary
Category Glance Per-category breakdownApp Entry Points — 21.7 kB (baseline 21.7 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 879 kB (baseline 879 kB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 68.9 kB (baseline 68.9 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 9 added / 9 removed Panels & Settings — 427 kB (baseline 427 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 10 added / 10 removed User & Accounts — 16.1 kB (baseline 16.1 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 5 added / 5 removed Editors & Dialogs — 785 B (baseline 785 B) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 1 added / 1 removed UI Components — 36.6 kB (baseline 36.6 kB) • ⚪ 0 BReusable component library chunks
Status: 5 added / 5 removed Data & Services — 2.15 MB (baseline 2.15 MB) • 🔴 +48 BStores, services, APIs, and repositories
Status: 12 added / 12 removed Utilities & Hooks — 237 kB (baseline 237 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 13 added / 13 removed Vendor & Third-Party — 8.69 MB (baseline 8.69 MB) • ⚪ 0 BExternal libraries and shared vendor chunks
Other — 7.31 MB (baseline 7.31 MB) • ⚪ 0 BBundles that do not match a named category
Status: 51 added / 51 removed |
Port two bug fixes to V2 persistence system: From #8854 (clear draft on workflow close): - workflowStore.ts: removeDraft() now runs for ALL workflows, not just temporary - workflowService.ts: remove draft BEFORE tab switch to prevent re-saving From #8851 (skip drafts when Persist disabled): - comfyWorkflow.ts: guard draft loading with Persist setting check - useWorkflowPersistenceV2.ts: watch to clear drafts when Persist toggled off Amp-Thread-ID: https://ampcode.com/threads/T-019c5898-2097-7710-aab9-52c38a97399a
…8854) ## Summary Clear the workflow draft from localStorage when any workflow tab is closed, preventing stale cached state from being served when the workflow is re-opened. ## Changes - **What**: `closeWorkflow()` in `workflowStore.ts` now calls `removeDraft()` for all workflows, not just temporary ones. `closeWorkflow()` in `workflowService.ts` removes the draft before switching tabs, preventing `beforeLoadNewGraph()` from re-saving it. ## Review Focus - Draft is removed before the tab switch in `workflowService.closeWorkflow()` to prevent `beforeLoadNewGraph()` from re-saving it during the switch - Crash recovery is preserved: drafts are only cleared on explicit close, not on unload/crash - Tab restore on restart is unaffected: drafts for intentionally-open tabs are saved on graph change events, not on close Fixes #8778 Fixes Comfy-Org/ComfyUI#12323 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8854-fix-clear-draft-on-workflow-close-to-prevent-stale-state-on-reopen-3066d73d365081a2a633c9b352d0b0d1) by [Unito](https://www.unito.io)
…8854) ## Summary Clear the workflow draft from localStorage when any workflow tab is closed, preventing stale cached state from being served when the workflow is re-opened. ## Changes - **What**: `closeWorkflow()` in `workflowStore.ts` now calls `removeDraft()` for all workflows, not just temporary ones. `closeWorkflow()` in `workflowService.ts` removes the draft before switching tabs, preventing `beforeLoadNewGraph()` from re-saving it. ## Review Focus - Draft is removed before the tab switch in `workflowService.closeWorkflow()` to prevent `beforeLoadNewGraph()` from re-saving it during the switch - Crash recovery is preserved: drafts are only cleared on explicit close, not on unload/crash - Tab restore on restart is unaffected: drafts for intentionally-open tabs are saved on graph change events, not on close Fixes #8778 Fixes Comfy-Org/ComfyUI#12323 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8854-fix-clear-draft-on-workflow-close-to-prevent-stale-state-on-reopen-3066d73d365081a2a633c9b352d0b0d1) by [Unito](https://www.unito.io)
…8854) ## Summary Clear the workflow draft from localStorage when any workflow tab is closed, preventing stale cached state from being served when the workflow is re-opened. ## Changes - **What**: `closeWorkflow()` in `workflowStore.ts` now calls `removeDraft()` for all workflows, not just temporary ones. `closeWorkflow()` in `workflowService.ts` removes the draft before switching tabs, preventing `beforeLoadNewGraph()` from re-saving it. ## Review Focus - Draft is removed before the tab switch in `workflowService.closeWorkflow()` to prevent `beforeLoadNewGraph()` from re-saving it during the switch - Crash recovery is preserved: drafts are only cleared on explicit close, not on unload/crash - Tab restore on restart is unaffected: drafts for intentionally-open tabs are saved on graph change events, not on close Fixes #8778 Fixes Comfy-Org/ComfyUI#12323 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8854-fix-clear-draft-on-workflow-close-to-prevent-stale-state-on-reopen-3066d73d365081a2a633c9b352d0b0d1) by [Unito](https://www.unito.io)
…8854) ## Summary Clear the workflow draft from localStorage when any workflow tab is closed, preventing stale cached state from being served when the workflow is re-opened. ## Changes - **What**: `closeWorkflow()` in `workflowStore.ts` now calls `removeDraft()` for all workflows, not just temporary ones. `closeWorkflow()` in `workflowService.ts` removes the draft before switching tabs, preventing `beforeLoadNewGraph()` from re-saving it. ## Review Focus - Draft is removed before the tab switch in `workflowService.closeWorkflow()` to prevent `beforeLoadNewGraph()` from re-saving it during the switch - Crash recovery is preserved: drafts are only cleared on explicit close, not on unload/crash - Tab restore on restart is unaffected: drafts for intentionally-open tabs are saved on graph change events, not on close Fixes #8778 Fixes Comfy-Org/ComfyUI#12323 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8854-fix-clear-draft-on-workflow-close-to-prevent-stale-state-on-reopen-3066d73d365081a2a633c9b352d0b0d1) by [Unito](https://www.unito.io)
|
@christian-byrne Successfully backported to #8868 |
|
@christian-byrne Successfully backported to #8869 |
|
@christian-byrne Successfully backported to #8870 |
|
@christian-byrne Successfully backported to #8871 |
…ale state on reopen (#8868) Backport of #8854 to `core/1.38` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8868-backport-core-1-38-fix-clear-draft-on-workflow-close-to-prevent-stale-state-on-reopen-3076d73d36508163a919fdfb66616844) by [Unito](https://www.unito.io) Co-authored-by: Christian Byrne <cbyrne@comfy.org>
…tale state on reopen (#8869) Backport of #8854 to `cloud/1.38` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8869-backport-cloud-1-38-fix-clear-draft-on-workflow-close-to-prevent-stale-state-on-reopen-3076d73d365081a7b0f5f602c2a609ea) by [Unito](https://www.unito.io) Co-authored-by: Christian Byrne <cbyrne@comfy.org>
…ale state on reopen (#8870) Backport of #8854 to `core/1.39` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8870-backport-core-1-39-fix-clear-draft-on-workflow-close-to-prevent-stale-state-on-reopen-3076d73d365081448562eccd00a790b0) by [Unito](https://www.unito.io) Co-authored-by: Christian Byrne <cbyrne@comfy.org>
…tale state on reopen (#8871) Backport of #8854 to `cloud/1.39` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8871-backport-cloud-1-39-fix-clear-draft-on-workflow-close-to-prevent-stale-state-on-reopen-3076d73d3650818484b5c4ca1c7a0bcf) by [Unito](https://www.unito.io) Co-authored-by: Christian Byrne <cbyrne@comfy.org>
Port two bug fixes to V2 persistence system: From #8854 (clear draft on workflow close): - workflowStore.ts: removeDraft() now runs for ALL workflows, not just temporary - workflowService.ts: remove draft BEFORE tab switch to prevent re-saving From #8851 (skip drafts when Persist disabled): - comfyWorkflow.ts: guard draft loading with Persist setting check - useWorkflowPersistenceV2.ts: watch to clear drafts when Persist toggled off Amp-Thread-ID: https://ampcode.com/threads/T-019c5898-2097-7710-aab9-52c38a97399a
Port two bug fixes to V2 persistence system: From #8854 (clear draft on workflow close): - workflowStore.ts: removeDraft() now runs for ALL workflows, not just temporary - workflowService.ts: remove draft BEFORE tab switch to prevent re-saving From #8851 (skip drafts when Persist disabled): - comfyWorkflow.ts: guard draft loading with Persist setting check - useWorkflowPersistenceV2.ts: watch to clear drafts when Persist toggled off Amp-Thread-ID: https://ampcode.com/threads/T-019c5898-2097-7710-aab9-52c38a97399a
Port two bug fixes to V2 persistence system: From #8854 (clear draft on workflow close): - workflowStore.ts: removeDraft() now runs for ALL workflows, not just temporary - workflowService.ts: remove draft BEFORE tab switch to prevent re-saving From #8851 (skip drafts when Persist disabled): - comfyWorkflow.ts: guard draft loading with Persist setting check - useWorkflowPersistenceV2.ts: watch to clear drafts when Persist toggled off Amp-Thread-ID: https://ampcode.com/threads/T-019c5898-2097-7710-aab9-52c38a97399a
Port two bug fixes to V2 persistence system: From #8854 (clear draft on workflow close): - workflowStore.ts: removeDraft() now runs for ALL workflows, not just temporary - workflowService.ts: remove draft BEFORE tab switch to prevent re-saving From #8851 (skip drafts when Persist disabled): - comfyWorkflow.ts: guard draft loading with Persist setting check - useWorkflowPersistenceV2.ts: watch to clear drafts when Persist toggled off Amp-Thread-ID: https://ampcode.com/threads/T-019c5898-2097-7710-aab9-52c38a97399a
Port two bug fixes to V2 persistence system: From #8854 (clear draft on workflow close): - workflowStore.ts: removeDraft() now runs for ALL workflows, not just temporary - workflowService.ts: remove draft BEFORE tab switch to prevent re-saving From #8851 (skip drafts when Persist disabled): - comfyWorkflow.ts: guard draft loading with Persist setting check - useWorkflowPersistenceV2.ts: watch to clear drafts when Persist toggled off Amp-Thread-ID: https://ampcode.com/threads/T-019c5898-2097-7710-aab9-52c38a97399a
Port two bug fixes to V2 persistence system: From #8854 (clear draft on workflow close): - workflowStore.ts: removeDraft() now runs for ALL workflows, not just temporary - workflowService.ts: remove draft BEFORE tab switch to prevent re-saving From #8851 (skip drafts when Persist disabled): - comfyWorkflow.ts: guard draft loading with Persist setting check - useWorkflowPersistenceV2.ts: watch to clear drafts when Persist toggled off Amp-Thread-ID: https://ampcode.com/threads/T-019c5898-2097-7710-aab9-52c38a97399a
Port two bug fixes to V2 persistence system: From #8854 (clear draft on workflow close): - workflowStore.ts: removeDraft() now runs for ALL workflows, not just temporary - workflowService.ts: remove draft BEFORE tab switch to prevent re-saving From #8851 (skip drafts when Persist disabled): - comfyWorkflow.ts: guard draft loading with Persist setting check - useWorkflowPersistenceV2.ts: watch to clear drafts when Persist toggled off Amp-Thread-ID: https://ampcode.com/threads/T-019c5898-2097-7710-aab9-52c38a97399a
Port two bug fixes to V2 persistence system: From #8854 (clear draft on workflow close): - workflowStore.ts: removeDraft() now runs for ALL workflows, not just temporary - workflowService.ts: remove draft BEFORE tab switch to prevent re-saving From #8851 (skip drafts when Persist disabled): - comfyWorkflow.ts: guard draft loading with Persist setting check - useWorkflowPersistenceV2.ts: watch to clear drafts when Persist toggled off Amp-Thread-ID: https://ampcode.com/threads/T-019c5898-2097-7710-aab9-52c38a97399a
Port two bug fixes to V2 persistence system: From #8854 (clear draft on workflow close): - workflowStore.ts: removeDraft() now runs for ALL workflows, not just temporary - workflowService.ts: remove draft BEFORE tab switch to prevent re-saving From #8851 (skip drafts when Persist disabled): - comfyWorkflow.ts: guard draft loading with Persist setting check - useWorkflowPersistenceV2.ts: watch to clear drafts when Persist toggled off Amp-Thread-ID: https://ampcode.com/threads/T-019c5898-2097-7710-aab9-52c38a97399a
Summary
Clear the workflow draft from localStorage when any workflow tab is closed, preventing stale cached state from being served when the workflow is re-opened.
Changes
closeWorkflow()inworkflowStore.tsnow callsremoveDraft()for all workflows, not just temporary ones.closeWorkflow()inworkflowService.tsremoves the draft before switching tabs, preventingbeforeLoadNewGraph()from re-saving it.Review Focus
workflowService.closeWorkflow()to preventbeforeLoadNewGraph()from re-saving it during the switchFixes #8778
Fixes Comfy-Org/ComfyUI#12323
┆Issue is synchronized with this Notion page by Unito