mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-21 06:49:37 +00:00
feat(persistence): fix QuotaExceededError and cross-workspace draft leakage (#8520)
## Summary Completes the workflow persistence overhaul by integrating the new draft system into the app and migrating existing data. Fixes two critical bugs: 1. **QuotaExceededError** - localStorage fills up with workflow drafts, breaking auto-save 2. **Cross-workspace data leakage** - Drafts from one ComfyUI instance appear in another ## Changes - **What**: - `useWorkflowPersistenceV2.ts` - Main composable that hooks into graph changes with 512ms debounce - `migrateV1toV2.ts` - One-time migration of existing drafts to the new scoped format - Updated E2E tests for new storage key patterns - **Why**: Users lose work when storage quota is exceeded, and see confusing workflows from other instances ## How It Works - **Workspace scoping**: Each ComfyUI instance (identified by server URL) has isolated draft storage - **LRU eviction**: When storage is full, oldest drafts are automatically removed (keeps 32 most recent) - **Tab isolation**: Each browser tab tracks its own active/open workflows via sessionStorage - **Debounced saves**: Graph changes are batched with 512ms delay to reduce storage writes ## Migration Existing V1 drafts are automatically migrated on first load. The migration: 1. Reads drafts from old `Comfy.Workflow.*` keys 2. Converts to new workspace-scoped format 3. Cleans up old keys after successful migration --- *Part 4 of 4 in the workflow persistence improvements stack* --------- Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Simula_r <18093452+simula-r@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import { t } from '@/i18n'
|
||||
import { isCloud } from '@/platform/distribution/types'
|
||||
import { useTelemetry } from '@/platform/telemetry'
|
||||
import { useToastStore } from '@/platform/updates/common/toastStore'
|
||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
|
||||
import type { BillingPortalTargetTier } from '@/stores/firebaseAuthStore'
|
||||
@@ -51,6 +52,17 @@ export const useFirebaseAuthActions = () => {
|
||||
}
|
||||
|
||||
const logout = wrapWithErrorHandlingAsync(async () => {
|
||||
const workflowStore = useWorkflowStore()
|
||||
if (workflowStore.modifiedWorkflows.length > 0) {
|
||||
const dialogService = useDialogService()
|
||||
const confirmed = await dialogService.confirm({
|
||||
title: t('auth.signOut.unsavedChangesTitle'),
|
||||
message: t('auth.signOut.unsavedChangesMessage'),
|
||||
type: 'dirtyClose'
|
||||
})
|
||||
if (!confirmed) return
|
||||
}
|
||||
|
||||
await authStore.logout()
|
||||
toastStore.add({
|
||||
severity: 'success',
|
||||
|
||||
Reference in New Issue
Block a user