diff --git a/browser_tests/colorPalette.spec.ts b/browser_tests/colorPalette.spec.ts index aa5f30f9a..7b0ac58b4 100644 --- a/browser_tests/colorPalette.spec.ts +++ b/browser_tests/colorPalette.spec.ts @@ -134,8 +134,11 @@ const customColorPalettes = { test.describe('Color Palette', () => { test('Can show custom color palette', async ({ comfyPage }) => { await comfyPage.setSetting('Comfy.CustomColorPalettes', customColorPalettes) - await comfyPage.setSetting('Comfy.ColorPalette', 'custom_obsidian_dark') - await comfyPage.nextFrame() + // Reload to apply the new setting. Setting Comfy.CustomColorPalettes directly + // doesn't update the store immediately. + await comfyPage.reload() + + await comfyPage.setSetting('Comfy.ColorPalette', 'obsidian_dark') await expect(comfyPage.canvas).toHaveScreenshot( 'custom-color-palette-obsidian-dark.png' ) @@ -150,6 +153,12 @@ test.describe('Color Palette', () => { }, customColorPalettes.obsidian_dark) expect(await comfyPage.getToastErrorCount()).toBe(0) + await comfyPage.setSetting('Comfy.ColorPalette', 'obsidian_dark') + await comfyPage.nextFrame() + await expect(comfyPage.canvas).toHaveScreenshot( + 'custom-color-palette-obsidian-dark.png' + ) + // Legacy `custom_` prefix is still supported await comfyPage.setSetting('Comfy.ColorPalette', 'custom_obsidian_dark') await comfyPage.nextFrame() await expect(comfyPage.canvas).toHaveScreenshot( diff --git a/browser_tests/colorPalette.spec.ts-snapshots/custom-color-palette-obsidian-dark-chromium-2x-linux.png b/browser_tests/colorPalette.spec.ts-snapshots/custom-color-palette-obsidian-dark-chromium-2x-linux.png index 578fc0f21..6a8787a66 100644 Binary files a/browser_tests/colorPalette.spec.ts-snapshots/custom-color-palette-obsidian-dark-chromium-2x-linux.png and b/browser_tests/colorPalette.spec.ts-snapshots/custom-color-palette-obsidian-dark-chromium-2x-linux.png differ diff --git a/browser_tests/colorPalette.spec.ts-snapshots/custom-color-palette-obsidian-dark-chromium-linux.png b/browser_tests/colorPalette.spec.ts-snapshots/custom-color-palette-obsidian-dark-chromium-linux.png index 487aaf815..4586043de 100644 Binary files a/browser_tests/colorPalette.spec.ts-snapshots/custom-color-palette-obsidian-dark-chromium-linux.png and b/browser_tests/colorPalette.spec.ts-snapshots/custom-color-palette-obsidian-dark-chromium-linux.png differ diff --git a/browser_tests/nodeBadge.spec.ts-snapshots/node-badge-unknown-color-palette-chromium-2x-linux.png b/browser_tests/nodeBadge.spec.ts-snapshots/node-badge-unknown-color-palette-chromium-2x-linux.png index 1dec24b3f..d2d61a372 100644 Binary files a/browser_tests/nodeBadge.spec.ts-snapshots/node-badge-unknown-color-palette-chromium-2x-linux.png and b/browser_tests/nodeBadge.spec.ts-snapshots/node-badge-unknown-color-palette-chromium-2x-linux.png differ diff --git a/browser_tests/nodeBadge.spec.ts-snapshots/node-badge-unknown-color-palette-chromium-linux.png b/browser_tests/nodeBadge.spec.ts-snapshots/node-badge-unknown-color-palette-chromium-linux.png index ae36a6920..6638fec58 100644 Binary files a/browser_tests/nodeBadge.spec.ts-snapshots/node-badge-unknown-color-palette-chromium-linux.png and b/browser_tests/nodeBadge.spec.ts-snapshots/node-badge-unknown-color-palette-chromium-linux.png differ diff --git a/src/components/dialog/content/setting/ColorPaletteMessage.vue b/src/components/dialog/content/setting/ColorPaletteMessage.vue index b6cfd3d6f..af4f24482 100644 --- a/src/components/dialog/content/setting/ColorPaletteMessage.vue +++ b/src/components/dialog/content/setting/ColorPaletteMessage.vue @@ -42,11 +42,12 @@ import { storeToRefs } from 'pinia' import Button from 'primevue/button' import Message from 'primevue/message' import Select from 'primevue/select' -import { watch } from 'vue' import { useColorPaletteService } from '@/services/colorPaletteService' +import { useSettingStore } from '@/stores/settingStore' import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore' +const settingStore = useSettingStore() const colorPaletteStore = useColorPaletteStore() const colorPaletteService = useColorPaletteService() const { palettes, activePaletteId } = storeToRefs(colorPaletteStore) @@ -54,11 +55,7 @@ const { palettes, activePaletteId } = storeToRefs(colorPaletteStore) const importCustomPalette = async () => { const palette = await colorPaletteService.importColorPalette() if (palette) { - colorPaletteService.loadColorPalette(palette.id) + settingStore.set('Comfy.ColorPalette', palette.id) } } - -watch(activePaletteId, () => { - colorPaletteService.loadColorPalette(activePaletteId.value) -}) diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 287858fa7..266d4d765 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -223,11 +223,21 @@ watch( ) const colorPaletteService = useColorPaletteService() -watchEffect(() => { - if (!canvasStore.canvas) return +const colorPaletteStore = useColorPaletteStore() +watch( + [() => canvasStore.canvas, () => settingStore.get('Comfy.ColorPalette')], + ([canvas, currentPaletteId]) => { + if (!canvas) return - colorPaletteService.loadColorPalette(settingStore.get('Comfy.ColorPalette')) -}) + colorPaletteService.loadColorPalette(currentPaletteId) + } +) +watch( + () => colorPaletteStore.activePaletteId, + (newValue) => { + settingStore.set('Comfy.ColorPalette', newValue) + } +) const workflowStore = useWorkflowStore() const persistCurrentWorkflow = () => { @@ -343,7 +353,6 @@ onMounted(async () => { comfyAppReady.value = true // Load color palette - const colorPaletteStore = useColorPaletteStore() colorPaletteStore.customPalettes = settingStore.get( 'Comfy.CustomColorPalettes' ) diff --git a/src/constants/coreSettings.ts b/src/constants/coreSettings.ts index 97431d722..62a4cc7c5 100644 --- a/src/constants/coreSettings.ts +++ b/src/constants/coreSettings.ts @@ -672,7 +672,11 @@ export const CORE_SETTINGS: SettingParams[] = [ name: 'The active color palette id', type: 'hidden', defaultValue: 'dark', - versionModified: '1.6.7' + versionModified: '1.6.7', + migrateDeprecatedValue(value: string) { + // Legacy custom palettes were prefixed with 'custom_' + return value.startsWith('custom_') ? value.replace('custom_', '') : value + } }, { id: 'Comfy.CustomColorPalettes', diff --git a/src/services/colorPaletteService.ts b/src/services/colorPaletteService.ts index a6fe6f67f..8c5babf60 100644 --- a/src/services/colorPaletteService.ts +++ b/src/services/colorPaletteService.ts @@ -143,7 +143,6 @@ export const useColorPaletteService = () => { app.canvas.setDirty(true, true) colorPaletteStore.activePaletteId = colorPaletteId - settingStore.set('Comfy.ColorPalette', colorPaletteId) } /** @@ -180,7 +179,7 @@ export const useColorPaletteService = () => { return { addCustomColorPalette: wrapWithErrorHandling(addCustomColorPalette), deleteCustomColorPalette: wrapWithErrorHandling(deleteCustomColorPalette), - loadColorPalette: wrapWithErrorHandling(loadColorPalette), + loadColorPalette: wrapWithErrorHandlingAsync(loadColorPalette), exportColorPalette: wrapWithErrorHandling(exportColorPalette), importColorPalette: wrapWithErrorHandlingAsync(importColorPalette) }