Repository navigation
fix(minimap): redraw after palette changes #15531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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) | ||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+160
to
+169
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Assert the palette-dependent node color in this regression I confirmed the earlier output-assertion finding with a mutation: forcing
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+160
to
+170
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Assert palette-dependent output, not only mock-call counts.
As per path instructions, the regression test must verify observable minimap redraw behavior rather than mock calls alone. 🤖 Prompt for AI AgentsSource: Path instructions |
||||||||||||||||||||||||||||||||||||||||||||||
| it('stops polling when hidden and resumes only after the next interval', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||
| const minimap = await initMinimap() | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||
|
Comment on lines
+76
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Nit: Remove the added implementation comment I am treating this as a merge-policy blocker because the supplied engineering guidance explicitly prohibits added implementation comments, including rationale. The adjacent palette digest input already expresses the dependency, and the PR description contains the rationale. I would delete these two lines without changing the fix.
Suggested change
|
||||||
| visual = mixIn( | ||||||
| visual, | ||||||
| useColorPaletteStore().completedActivePalette.light_theme ? 1 : 0 | ||||||
| ) | ||||||
|
|
||||||
|
Comment on lines
+76
to
+82
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Include the active palette identity or revision in the digest.
Suggested digest input+ const paletteStore = useColorPaletteStore()
+ visual = mixIn(visual, hashString(paletteStore.activePaletteId))
visual = mixIn(
visual,
- useColorPaletteStore().completedActivePalette.light_theme ? 1 : 0
+ paletteStore.completedActivePalette.light_theme ? 1 : 0
)🤖 Prompt for AI Agents |
||||||
| for (const node of graph._nodes) { | ||||||
| const [x, y] = node.pos | ||||||
| const [width, height] = node.size | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Comfy-Org/ComfyUI_frontend
Length of output: 2320
🏁 Script executed:
Repository: Comfy-Org/ComfyUI_frontend
Length of output: 26789
🏁 Script executed:
Repository: Comfy-Org/ComfyUI_frontend
Length of output: 2581
🏁 Script executed:
Repository: Comfy-Org/ComfyUI_frontend
Length of output: 3675
Move all shared mock fixtures used by
vi.mock()intovi.hoisted().The
canvasStore,colorPaletteStore, andscripts/appmock factories close over top-level fixtures. Static imports evaluate these factories before the fixtures initialize, causing a temporal-dead-zoneReferenceError. Hoist the complete fixture graph, includingmockNodes, or construct it inside the mock factories.🤖 Prompt for AI Agents
Source: Path instructions