mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-10 23:50:00 +00:00
Feat: Persist all unsaved workflow tabs (#6050)
## Summary - Keep all drafts in localStorage, mirroring the logic from VSCode. - Fix a bug where newly created blank workflow tabs would incorrectly restore as defaultGraph instead of blankGraph after page refresh. Resolves https://github.com/Comfy-Org/desktop/issues/910, Resolves https://github.com/Comfy-Org/ComfyUI_frontend/issues/4057, Fixes https://github.com/Comfy-Org/ComfyUI_frontend/issues/3665 ## Changes ### What - Fix `restoreWorkflowTabsState` to parse and pass workflow data from drafts when recreating temporary workflows - Add error handling for invalid draft data with fallback to default workflow - Fix E2E test `should not serialize color adjustments in workflow` to wait for workflow persistence before assertions - Add proper validation for workflow nodes array in test assertions ### Breaking - None ### Dependencies - No new dependencies added ## Review Focus 1. **Workflow restoration**: Verify that blank workflows correctly restore as blankGraph after page refresh 2. **Error handling**: Check that invalid draft data gracefully falls back to default workflow 3. **Test coverage**: Ensure E2E test correctly waits for workflow persistence before checking node properties 4. **Edge cases**: Test with multiple tabs, switching between tabs, and rapid refresh scenarios --------- Co-authored-by: Yourz <crazilou@vip.qq.com>
This commit is contained in:
@@ -232,11 +232,25 @@ test.describe('Node Color Adjustments', () => {
|
||||
}) => {
|
||||
await comfyPage.setSetting('Comfy.Node.Opacity', 0.5)
|
||||
await comfyPage.setSetting('Comfy.ColorPalette', 'light')
|
||||
const saveWorkflowInterval = 1000
|
||||
const workflow = await comfyPage.page.evaluate(() => {
|
||||
return localStorage.getItem('workflow')
|
||||
})
|
||||
for (const node of JSON.parse(workflow ?? '{}').nodes) {
|
||||
await comfyPage.nextFrame()
|
||||
const parsed = await (
|
||||
await comfyPage.page.waitForFunction(
|
||||
() => {
|
||||
const workflow = localStorage.getItem('workflow')
|
||||
if (!workflow) return null
|
||||
try {
|
||||
const data = JSON.parse(workflow)
|
||||
return Array.isArray(data?.nodes) ? data : null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
},
|
||||
{ timeout: 3000 }
|
||||
)
|
||||
).jsonValue()
|
||||
expect(parsed.nodes).toBeDefined()
|
||||
expect(Array.isArray(parsed.nodes)).toBe(true)
|
||||
for (const node of parsed.nodes) {
|
||||
if (node.bgcolor) expect(node.bgcolor).not.toMatch(/hsla/)
|
||||
if (node.color) expect(node.color).not.toMatch(/hsla/)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user