diff --git a/src/renderer/extensions/minimap/composables/useMinimap.intervalLifecycle.test.ts b/src/renderer/extensions/minimap/composables/useMinimap.intervalLifecycle.test.ts index 029cbb9c193..e59c37a903d 100644 --- a/src/renderer/extensions/minimap/composables/useMinimap.intervalLifecycle.test.ts +++ b/src/renderer/extensions/minimap/composables/useMinimap.intervalLifecycle.test.ts @@ -39,6 +39,8 @@ const mockCanvas = { setDirty: vi.fn() } +const mockCompletedActivePalette = { light_theme: false } + vi.mock('@/renderer/core/canvas/canvasStore', () => ({ useCanvasStore: vi.fn(() => ({ canvas: mockCanvas })) })) @@ -52,7 +54,7 @@ vi.mock('@/platform/settings/settingStore', () => ({ vi.mock('@/stores/workspace/colorPaletteStore', () => ({ useColorPaletteStore: vi.fn(() => ({ - completedActivePalette: { light_theme: false } + completedActivePalette: mockCompletedActivePalette })) })) @@ -124,6 +126,7 @@ describe('useMinimap change-detection interval', () => { vi.useFakeTimers() context = createMockCanvas2DContext() mockNodes[0].pos = [0, 0] + mockCompletedActivePalette.light_theme = false }) afterEach(() => { @@ -154,6 +157,17 @@ describe('useMinimap change-detection interval', () => { expect(drawCalls()).toBe(settled) }) + it('redraws after the palette theme changes without a graph edit', async () => { + await initMinimap() + await vi.advanceTimersByTimeAsync(POLL_MS + 10) + const settled = drawCalls() + + mockCompletedActivePalette.light_theme = true + await vi.advanceTimersByTimeAsync(POLL_MS + 10) + + expect(drawCalls()).toBeGreaterThan(settled) + }) + it('stops polling when hidden and resumes only after the next interval', async () => { const minimap = await initMinimap() diff --git a/src/renderer/extensions/minimap/composables/useMinimapGraph.ts b/src/renderer/extensions/minimap/composables/useMinimapGraph.ts index c60b11b39ca..e29e9eacd1b 100644 --- a/src/renderer/extensions/minimap/composables/useMinimapGraph.ts +++ b/src/renderer/extensions/minimap/composables/useMinimapGraph.ts @@ -6,6 +6,7 @@ import { useChainCallback } from '@/composables/functional/useChainCallback' import type { LGraphEventMap } from '@/lib/litegraph/src/infrastructure/LGraphEventMap' import type { LGraph, LGraphNode } from '@/lib/litegraph/src/litegraph' import { layoutStore } from '@/renderer/core/layout/store/layoutStore' +import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore' import { api } from '@/scripts/api' import { useExecutionStore } from '@/stores/executionStore' @@ -72,6 +73,13 @@ function computeGraphDigests(graph: LGraph): GraphDigests { let geometry = mixIn(layoutStore.nodeGeometryVersion, graph._nodes.length) let visual = 0 + // The renderer derives its theme-aware colors from this flag. Include it in + // the digest so a palette switch repaints even when the graph is untouched. + visual = mixIn( + visual, + useColorPaletteStore().completedActivePalette.light_theme ? 1 : 0 + ) + for (const node of graph._nodes) { const [x, y] = node.pos const [width, height] = node.size