Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions browser_tests/tests/groupColorPicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getGroupTitlePosition } from '@e2e/fixtures/utils/groupHelpers'
// setColorOption, producing a visibly different shade from the toolbar
// circle-swatch picker for the same color choice.
const RED_GROUP_COLOR = '#A88'
const RED_NODE_COLOR = 'rgb(85, 51, 51)'

test.describe(
'Group Color - right-click menu matches toolbar swatch',
Expand Down Expand Up @@ -118,5 +119,50 @@ test.describe(
'group-color-right-click-matches-toolbar-swatch.png'
)
})

test('refreshes the selected group toolbar swatch after menu color change', async ({
comfyPage
}) => {
const groupPos = await getGroupTitlePosition(
comfyPage,
'Right-Click Menu Group'
)

await test.step('Select the group and show its toolbar', async () => {
await comfyPage.page.mouse.click(groupPos.x, groupPos.y)
await comfyPage.nextFrame()
await expect(comfyPage.selectionToolbox).toBeVisible()
})

await test.step('Change the group color through its context menu', async () => {
await comfyPage.page.mouse.click(groupPos.x, groupPos.y, {
button: 'right'
})
await expect(comfyPage.contextMenu.primeVueMenu).toBeVisible()
await comfyPage.page.getByText('Color', { exact: true }).click()
const redSwatch = comfyPage.page.getByTitle('Red').first()
await expect(redSwatch).toBeVisible()
await redSwatch.click()
})

await test.step('Refresh the toolbar swatch without reselecting the group', async () => {
await expect(comfyPage.selectionToolbox).toBeVisible()
await expect(
comfyPage.page.getByTestId(
TestIds.selectionToolbox.colorPickerCurrentColor
)
).toHaveCSS('color', RED_NODE_COLOR)
await expect
.poll(() =>
comfyPage.page.evaluate(
() =>
window.app!.graph.groups.find(
(group) => group.title === 'Right-Click Menu Group'
)?.color
)
)
.toBe(RED_GROUP_COLOR)
})
})
}
)
15 changes: 15 additions & 0 deletions browser_tests/tests/vueNodes/interactions/canvas/selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ test.describe(
await expect(comfyPage.selectionToolbox).toBeHidden()
})

test('selectItems with an empty array clears selection and hides the toolbox', async ({
comfyPage
}) => {
const a = await comfyPage.vueNodes.getFixtureByTitle('Node A')
await a.title.click()
await expect(a.root).toHaveClass(/outline-node-component-outline/)
await expect(comfyPage.selectionToolbox).toBeVisible()

await comfyPage.page.evaluate(() => window.app!.canvas.selectItems([]))

await expect(comfyPage.vueNodes.selectedNodes).toHaveCount(0)
await expect(a.root).not.toHaveClass(/outline-node-component-outline/)
await expect(comfyPage.selectionToolbox).toBeHidden()
})

test('marquee selects enclosed nodes and replaces the previous selection', async ({
comfyPage
}) => {
Expand Down
40 changes: 40 additions & 0 deletions docs/adr/CANVAS-SELECTION-0031-ordered-set-storage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# ADR-CANVAS-SELECTION-0031: Ordered Set Storage for Selection

Date: 2026-09-15

## Status

Proposed

## Context

[ADR-CANVAS-SELECTION-0028](CANVAS-SELECTION-0028-single-selection-store.md)
requires ordered, graph-scoped session selection with synchronous legacy hooks.
An immutable array reducer copies existing membership for every selected item.
Selecting 200 nodes reconstructs 19,900 existing keys before producing the final
selection. Hooks can read selection between individual additions.

## Decision

Use a reactive native Set in each store bucket. Preserve insertion order and
publish each command synchronously. Return array snapshots to readers.
Selection has no undo history, so retaining prior internal states has no caller.

Reject deferred bulk publication: it changes what synchronous hooks observe.
An immutable collection library would preserve snapshots with cheaper writes,
but selection does not need that dependency or its API.

## Consequences

### Positive

- Add and remove no longer copy existing membership.
- Native Set operations preserve order, uniqueness, and no-op reactivity.

### Negative

- Snapshot reads and ordered replacement still take linear work. A synchronous
consumer that reads a full snapshot after every addition can still cause
quadratic work.
- The store owns mutable collections. Callers must use commands rather than
retain references to those collections.
1 change: 1 addition & 0 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ An Architecture Decision Record captures an important architectural decision mad
| [BILLING-WEB-0031](BILLING-WEB-0031-static-spa-boundary.md) | Static SPA Boundary for Hosted Billing | Proposed | 2026-09-10 |
| [CANVAS-GESTURE-0029](CANVAS-GESTURE-0029-pointer-gesture-state-machine.md) | Pointer Gesture State Machine | Proposed | 2026-09-06 |
| [CANVAS-SELECTION-0028](CANVAS-SELECTION-0028-single-selection-store.md) | Single Selection Store | Proposed | 2026-09-04 |
| [CANVAS-SELECTION-0031](CANVAS-SELECTION-0031-ordered-set-storage.md) | Ordered Set Storage for Selection | Proposed | 2026-09-15 |
| [CRDT-AUTHORITY-0035](CRDT-AUTHORITY-0035-human-canvas-authority-and-draft-reconciliation.md) | Human Canvas Authority and Draft Reconciliation | Proposed | 2026-09-19 |
| [CRDT-FOLLOWER-0025](CRDT-FOLLOWER-0025-in-app-agent-crdt-follower-and-distribution-resolved-boundaries.md) | In-App Agent CRDT Follower and Distribution-Resolved Boundaries | Proposed | 2026-08-21 |
| [CRDT-FOLLOWER-0035](CRDT-FOLLOWER-0035-bounded-ack-timeout-retry-for-unacknowledged-doc-subscribe.md) | Bounded Ack-Timeout Retry for Unacknowledged CRDT Doc Subscribe | Proposed | 2026-09-19 |
Expand Down
6 changes: 0 additions & 6 deletions src/components/graph/GraphCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ import { useAgentDockMount } from '@/workbench/extensions/agent/composables/useA
import NodeSearchboxPopover from '@/components/searchbox/NodeSearchBoxPopover.vue'
import SideToolbar from '@/components/sidebar/SideToolbar.vue'
import WorkflowTabs from '@/components/topbar/WorkflowTabs.vue'
import { useChainCallback } from '@/composables/functional/useChainCallback'
import { useGroupContextMenu } from '@/composables/graph/useGroupContextMenu'
import { installErrorClearingHooks } from '@/composables/graph/useErrorClearingHooks'
import type { NodeState } from '@/types/nodeState'
Expand Down Expand Up @@ -591,11 +590,6 @@ onMounted(async () => {
const sharedStatus =
await workflowPersistence.loadSharedWorkflowFromUrlIfPresent()

comfyApp.canvas.onSelectionChange = useChainCallback(
comfyApp.canvas.onSelectionChange,
() => canvasStore.updateSelectedItems()
)

// Run query-param deep-link loaders (?invite, ?create_workspace, ?pricing, ?topup)
await runUrlActionLoaders()

Expand Down
61 changes: 31 additions & 30 deletions src/components/graph/SelectionToolbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useSettingStore } from '@/platform/settings/settingStore'
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
import { useCanvasInteractions } from '@/renderer/core/canvas/useCanvasInteractions'
import { useExtensionService } from '@/services/extensionService'
import { setCanvasSelection } from '@/utils/__tests__/canvasSelectionTestUtils'
import { useCommandStore } from '@/stores/commandStore'
import { ComfyNodeDefImpl, useNodeDefStore } from '@/stores/nodeDefStore'
import { createMockCanvas } from '@/utils/__tests__/litegraphTestUtils'
Expand Down Expand Up @@ -202,21 +203,21 @@ describe('SelectionToolbox', () => {

it('should show info button only for single selections', () => {
// Single node selection
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container } = renderComponent()
expect(container.querySelector('.info-button')).toBeTruthy()

// Multiple node selection - render in separate test scope
canvasStore.selectedItems = [
setCanvasSelection([
new LGraphNode('Test Node'),
new LGraphNode('Test Node')
]
])
const { container: container2 } = renderComponent()
expect(container2.querySelector('.info-button')).toBeFalsy()
})

it('should not show info button when node definition is not found', () => {
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
vi.mocked(useNodeDefStore().fromLGraphNode).mockReturnValue(null)
const { container } = renderComponent()
expect(container.querySelector('.info-button')).toBeFalsy()
Expand All @@ -227,7 +228,7 @@ describe('SelectionToolbox', () => {
'Comfy.UseNewMenu': 'Disabled',
'Comfy.NodeLibrary.NewDesign': true
})
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])

const { container } = renderComponent()

Expand All @@ -239,7 +240,7 @@ describe('SelectionToolbox', () => {
'Comfy.UseNewMenu': 'Disabled',
'Comfy.NodeLibrary.NewDesign': false
})
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])

const { container } = renderComponent()

Expand All @@ -251,7 +252,7 @@ describe('SelectionToolbox', () => {
'Comfy.UseNewMenu': 'Top',
'Comfy.NodeLibrary.NewDesign': false
})
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])

const { container } = renderComponent()

Expand All @@ -260,17 +261,17 @@ describe('SelectionToolbox', () => {

it('should show color picker for all selections', () => {
// Single node selection
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container } = renderComponent()
expect(
container.querySelector('[data-testid="color-picker-button"]')
).toBeTruthy()

// Multiple node selection
canvasStore.selectedItems = [
setCanvasSelection([
new LGraphNode('Test Node'),
new LGraphNode('Test Node')
]
])
const { container: container2 } = renderComponent()
expect(
container2.querySelector('[data-testid="color-picker-button"]')
Expand All @@ -279,40 +280,40 @@ describe('SelectionToolbox', () => {

it('should show frame nodes only for multiple selections', () => {
// Single node selection
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container } = renderComponent()
expect(container.querySelector('.frame-nodes')).toBeFalsy()

// Multiple node selection
canvasStore.selectedItems = [
setCanvasSelection([
new LGraphNode('Test Node'),
new LGraphNode('Test Node')
]
])
const { container: container2 } = renderComponent()
expect(container2.querySelector('.frame-nodes')).toBeTruthy()
})

it('should show bypass button for appropriate selections', () => {
// Single node selection
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container } = renderComponent()
expect(
container.querySelector('[data-testid="bypass-button"]')
).toBeTruthy()

// Multiple node selection
canvasStore.selectedItems = [
setCanvasSelection([
new LGraphNode('Test Node'),
new LGraphNode('Test Node')
]
])
const { container: container2 } = renderComponent()
expect(
container2.querySelector('[data-testid="bypass-button"]')
).toBeTruthy()
})

it('should show common buttons for all selections', () => {
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container } = renderComponent()

expect(
Expand All @@ -331,24 +332,24 @@ describe('SelectionToolbox', () => {
imageNode.previewMediaType = 'image'

// Single image node
canvasStore.selectedItems = [imageNode]
setCanvasSelection([imageNode])
const { container } = renderComponent()
expect(container.querySelector('.mask-editor-button')).toBeTruthy()

// Single non-image node
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container: container2 } = renderComponent()
expect(container2.querySelector('.mask-editor-button')).toBeFalsy()
})

it('should show Color picker button only for single Load3D nodes', () => {
// Single Load3D node
canvasStore.selectedItems = [new LGraphNode('Test Node', 'Load3D')]
setCanvasSelection([new LGraphNode('Test Node', 'Load3D')])
const { container } = renderComponent()
expect(container.querySelector('.load-3d-viewer-button')).toBeTruthy()

// Single non-Load3D node
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container: container2 } = renderComponent()
expect(container2.querySelector('.load-3d-viewer-button')).toBeFalsy()
})
Expand All @@ -362,19 +363,19 @@ describe('SelectionToolbox', () => {
filterOutputNodesSpy.mockReturnValue([
{ type: 'SaveImage' }
] as LGraphNode[])
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container } = renderComponent()
expect(container.querySelector('.execute-button')).toBeTruthy()

// Without output node selected
isOutputNodeSpy.mockReturnValue(false)
filterOutputNodesSpy.mockReturnValue([])
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container: container2 } = renderComponent()
expect(container2.querySelector('.execute-button')).toBeFalsy()

// No selection at all
canvasStore.selectedItems = []
setCanvasSelection([])
const { container: container3 } = renderComponent()
expect(container3.querySelector('.execute-button')).toBeFalsy()
})
Expand All @@ -383,7 +384,7 @@ describe('SelectionToolbox', () => {
describe('Divider Visibility Logic', () => {
it('should show dividers between button groups when both groups have buttons', () => {
// Setup single node to show info + other buttons
canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container } = renderComponent()

const dividers = container.querySelectorAll('.vertical-divider')
Expand All @@ -392,7 +393,7 @@ describe('SelectionToolbox', () => {

it('should not show dividers when adjacent groups are empty', () => {
// No selection should show minimal buttons and dividers
canvasStore.selectedItems = []
setCanvasSelection([])
const { container } = renderComponent()

expect(
Expand Down Expand Up @@ -421,7 +422,7 @@ describe('SelectionToolbox', () => {
invokeExtensionsAsync: vi.fn()
} as ReturnType<typeof useExtensionService>)

canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container } = renderComponent()

expect(container.querySelector('.extension-command-button')).toBeTruthy()
Expand All @@ -431,7 +432,7 @@ describe('SelectionToolbox', () => {
const mockExtensionService = vi.mocked(useExtensionService)
mockExtensionService.mockReturnValue(createMockExtensionService())

canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container } = renderComponent()

expect(container.querySelector('.extension-command-button')).toBeFalsy()
Expand All @@ -456,7 +457,7 @@ describe('SelectionToolbox', () => {
const mockExtensionService = vi.mocked(useExtensionService)
mockExtensionService.mockReturnValue(createMockExtensionService())

canvasStore.selectedItems = [new LGraphNode('Test Node')]
setCanvasSelection([new LGraphNode('Test Node')])
const { container } = renderComponent()

const panel = container.querySelector('[data-testid="selection-toolbox"]')
Expand All @@ -474,7 +475,7 @@ describe('SelectionToolbox', () => {
})

it('should hide most buttons when no items selected', () => {
canvasStore.selectedItems = []
setCanvasSelection([])
const { container } = renderComponent()

expect(container.querySelector('.info-button')).toBeFalsy()
Expand Down
Loading
Loading