Skip to content

Conversation

@christian-byrne
Copy link
Contributor

@christian-byrne christian-byrne commented Sep 22, 2025

Summary

Fixes #5680 by allowing Vue nodes to properly synchronize color changes with LiteGraph nodes, implementing header darkening and light theme adjustments.

Screenshot from 2025-09-21 20-00-36

Changes

  • What: Implemented color property synchronization between LiteGraph and Vue node rendering systems
  • Core Fix: Added nodeData.color and nodeData.bgcolor to v-memo dependencies to trigger re-renders on color changes
  • Color Logic: Added header darkening using memoized color adjustments to match LiteGraph's ColorOption system
  • Event System: Enhanced property change instrumentation in LGraphNode.setColorOption to emit color/bgcolor events

Review Focus

Vue component reactivity timing - the v-memo fix was critical for immediate color updates. Verify light theme color adjustments match the drawNode monkey patch behavior in app.ts.

Technical Details

graph TD
    A[User Sets Color] --> B[LGraphNode.setColorOption]
    B --> C[Sets node.color & node.bgcolor]
    C --> D[Triggers property:changed events]
    D --> E[Vue Node Manager Updates]
    E --> F[v-memo Detects Change]
    F --> G[NodeHeader Re-renders]
    G --> H[Header Darkening Applied]

    style A fill:#f9f9f9,stroke:#333,color:#000
    style H fill:#f9f9f9,stroke:#333,color:#000
Loading

┆Issue is synchronized with this Notion page by Unito

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 22, 2025
@github-actions
Copy link

github-actions bot commented Sep 22, 2025

🎭 Playwright Test Results

⚠️ Tests passed with flaky tests

⏰ Completed at: 09/27/2025, 10:04:55 PM UTC

📈 Summary

  • Total Tests: 471
  • Passed: 438 ✅
  • Failed: 0
  • Flaky: 4 ⚠️
  • Skipped: 29 ⏭️

📊 Test Reports by Browser

  • chromium: View Report • ✅ 431 / ❌ 0 / ⚠️ 4 / ⏭️ 29
  • chromium-2x: View Report • ✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0
  • chromium-0.5x: View Report • ✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0
  • mobile-chrome: View Report • ✅ 4 / ❌ 0 / ⚠️ 0 / ⏭️ 0

🎉 Click on the links above to view detailed test results for each browser configuration.

Comment on lines 130 to 141
headerColor = adjustColor(nodeData.color, { lightness: -0.15 })
}
// Apply light theme lightening on top of base darkening (same as drawNode monkey patch)
if (colorPaletteStore.completedActivePalette.light_theme) {
headerColor = adjustColor(headerColor, { lightness: 0.5 })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way to do this with CSS? adjustColor is memoized though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

color-mix() with white ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's safe to assume that would be more performant right? Not sure performance different is measurable though, so maybe other pros/cons should be considered. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we were able to bind to a CSS variable and derive from it a lighter and a darker shade, we could eliminate all of this logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to support any arbitrary color set by extensions though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would work, the css variable can be dynamic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TY, let me try tomorrow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is a bit convulated when trying to do in CSS especially since we need to serialize color in the workflow, decided against it for this PR.

@christian-byrne christian-byrne requested review from DrJKL, Myestery and benceruleanlu and removed request for DrJKL September 22, 2025 04:42
transform: `translate(${layoutPosition.x ?? position?.x ?? 0}px, ${(layoutPosition.y ?? position?.y ?? 0) - LiteGraph.NODE_TITLE_HEIGHT}px)`,
zIndex: zIndex
zIndex: zIndex,
// Explicitly set backgroundColor to ensure reset works properly
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Explicitly set backgroundColor to ensure reset works properly
color: nodeData.color || ''

Where are we setting color?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming in Litegraph is poor.
They're both surface colors, one for the header, one for the body, neither for the text.

.click()

await expect(comfyPage.canvas).toHaveScreenshot(
'vue-node-custom-color-blue.png'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the screenshot, can we have another test that reads the color or backgroundColor prop from the node?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What additional signal would that provide?

DrJKL
DrJKL previously approved these changes Sep 22, 2025
christian-byrne and others added 7 commits September 27, 2025 11:21
…view feedback

Adds CSS background-color property validation in addition to screenshot comparison
to verify header and body colors are correctly applied to DOM elements.

Co-authored-by: Myestery <[email protected]>
…resses review feedback

Moves color and bgcolor property change tracking to the standard LGraphNodeProperties
system instead of manual event firing in setColorOption. This reduces custom code
and leverages the existing property instrumentation infrastructure.

Co-authored-by: DrJKL <[email protected]>
The :style binding was accidentally removed, causing TypeScript error about
unused headerStyle computed property. This binding is needed for Vue node
header color functionality.
Now correctly implements all aspects of the LiteGraph drawNode monkey patch:

1. Header colors: Apply opacity + lightness adjustments like LiteGraph
2. Body colors: Apply same adjustments to background as LiteGraph
3. Opacity setting: Support 'Comfy.Node.Opacity' setting from user preferences
4. Light theme: Apply lightness=0.5 to both header and body in light theme

This ensures Vue nodes have pixel-perfect color matching with LiteGraph nodes
across all themes and opacity settings.
@christian-byrne christian-byrne force-pushed the vue-node/fix/color-change-node branch from 30e010a to 481aa82 Compare September 27, 2025 18:22
@christian-byrne christian-byrne added the New Browser Test Expectations New browser test screenshot should be set by github action label Sep 27, 2025
@christian-byrne christian-byrne merged commit a25d898 into main Sep 27, 2025
21 checks passed
@christian-byrne christian-byrne deleted the vue-node/fix/color-change-node branch September 27, 2025 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:customization area:vue-migration New Browser Test Expectations New browser test screenshot should be set by github action size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't change the nodes' color or bypass a node

4 participants