From 33c457aca011adfbe6e40dc24810d04b34b460bd Mon Sep 17 00:00:00 2001 From: Alexander Brown <448862+DrJKL@users.noreply.github.com> Date: Sun, 25 Jan 2026 01:05:20 -0800 Subject: [PATCH] Assorted fixes for issues that happen when routing instead of reloading --- src/composables/node/useNodeBadge.ts | 3 +++ src/composables/useCoreCommands.ts | 3 +-- .../subscription/composables/useSubscription.ts | 4 ++++ src/platform/settings/settingStore.test.ts | 12 +++++++++--- src/platform/settings/settingStore.ts | 6 +++++- .../minimap/composables/useMinimapGraph.test.ts | 14 ++------------ .../minimap/composables/useMinimapGraph.ts | 4 +--- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/composables/node/useNodeBadge.ts b/src/composables/node/useNodeBadge.ts index 91fa1115d..cfe2ad66f 100644 --- a/src/composables/node/useNodeBadge.ts +++ b/src/composables/node/useNodeBadge.ts @@ -71,6 +71,9 @@ export const useNodeBadge = () => { } onMounted(() => { + if (extensionStore.isExtensionInstalled('Comfy.NodeBadge')) return + + // TODO: Fix the composables and watchers being setup in onMounted const nodePricing = useNodePricing() watch( diff --git a/src/composables/useCoreCommands.ts b/src/composables/useCoreCommands.ts index 8f3f72304..319970071 100644 --- a/src/composables/useCoreCommands.ts +++ b/src/composables/useCoreCommands.ts @@ -67,10 +67,9 @@ import { useWorkflowTemplateSelectorDialog } from './useWorkflowTemplateSelector import { useMaskEditorStore } from '@/stores/maskEditorStore' import { useDialogStore } from '@/stores/dialogStore' -const { isActiveSubscription, showSubscriptionDialog } = useSubscription() - const moveSelectedNodesVersionAdded = '1.22.2' export function useCoreCommands(): ComfyCommand[] { + const { isActiveSubscription, showSubscriptionDialog } = useSubscription() const workflowService = useWorkflowService() const workflowStore = useWorkflowStore() const dialogService = useDialogService() diff --git a/src/platform/cloud/subscription/composables/useSubscription.ts b/src/platform/cloud/subscription/composables/useSubscription.ts index f5948ee69..7d8e8a4f8 100644 --- a/src/platform/cloud/subscription/composables/useSubscription.ts +++ b/src/platform/cloud/subscription/composables/useSubscription.ts @@ -203,6 +203,10 @@ function useSubscriptionInternal() { if (loggedIn) { try { await fetchSubscriptionStatus() + } catch (error) { + // Network errors are expected during navigation/component unmount + // and when offline - log for debugging but don't surface to user + console.error('Failed to fetch subscription status:', error) } finally { isInitialized.value = true } diff --git a/src/platform/settings/settingStore.test.ts b/src/platform/settings/settingStore.test.ts index 60d7acd1c..16b827a78 100644 --- a/src/platform/settings/settingStore.test.ts +++ b/src/platform/settings/settingStore.test.ts @@ -82,18 +82,24 @@ describe('useSettingStore', () => { expect(store.settingsById['test.setting']).toEqual(setting) }) - it('should throw error for duplicate setting ID', () => { + it('should warn and skip for duplicate setting ID', () => { const setting: SettingParams = { id: 'test.setting', name: 'test.setting', type: 'text', defaultValue: 'default' } + const consoleWarnSpy = vi + .spyOn(console, 'warn') + .mockImplementation(() => {}) store.addSetting(setting) - expect(() => store.addSetting(setting)).toThrow( - 'Setting test.setting must have a unique ID.' + store.addSetting(setting) + + expect(consoleWarnSpy).toHaveBeenCalledWith( + 'Setting already registered: test.setting' ) + consoleWarnSpy.mockRestore() }) it('should migrate deprecated values', () => { diff --git a/src/platform/settings/settingStore.ts b/src/platform/settings/settingStore.ts index 2c9e8e0a3..c09740574 100644 --- a/src/platform/settings/settingStore.ts +++ b/src/platform/settings/settingStore.ts @@ -170,7 +170,11 @@ export const useSettingStore = defineStore('setting', () => { throw new Error('Settings must have an ID') } if (setting.id in settingsById.value) { - throw new Error(`Setting ${setting.id} must have a unique ID.`) + // Setting already registered - skip to allow component remounting + // TODO: Add store reset methods to bootstrapStore and settingStore, then + // replace window.location.reload() with router.push() in SidebarLogoutIcon.vue + console.warn(`Setting already registered: ${setting.id}`) + return } settingsById.value[setting.id] = setting diff --git a/src/renderer/extensions/minimap/composables/useMinimapGraph.test.ts b/src/renderer/extensions/minimap/composables/useMinimapGraph.test.ts index 835f38e71..2bad9ed45 100644 --- a/src/renderer/extensions/minimap/composables/useMinimapGraph.test.ts +++ b/src/renderer/extensions/minimap/composables/useMinimapGraph.test.ts @@ -139,21 +139,11 @@ describe('useMinimapGraph', () => { expect(mockGraph.onConnectionChange).toBe(originalOnConnectionChange) }) - it('should handle cleanup for never-setup graph', () => { - const consoleErrorSpy = vi - .spyOn(console, 'error') - .mockImplementation(() => {}) - + it('should handle cleanup for never-setup graph silently', () => { const graphRef = ref(mockGraph as any) const graphManager = useMinimapGraph(graphRef, onGraphChangedMock) - graphManager.cleanupEventListeners() - - expect(consoleErrorSpy).toHaveBeenCalledWith( - 'Attempted to cleanup event listeners for graph that was never set up' - ) - - consoleErrorSpy.mockRestore() + expect(() => graphManager.cleanupEventListeners()).not.toThrow() }) it('should detect node position changes', () => { diff --git a/src/renderer/extensions/minimap/composables/useMinimapGraph.ts b/src/renderer/extensions/minimap/composables/useMinimapGraph.ts index 54d6320fd..9d7b620d3 100644 --- a/src/renderer/extensions/minimap/composables/useMinimapGraph.ts +++ b/src/renderer/extensions/minimap/composables/useMinimapGraph.ts @@ -102,9 +102,7 @@ export function useMinimapGraph( const originalCallbacks = originalCallbacksMap.get(g.id) if (!originalCallbacks) { - console.error( - 'Attempted to cleanup event listeners for graph that was never set up' - ) + // Graph was never set up (e.g., minimap destroyed before init) - nothing to clean up return }