Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 15 additions & 12 deletions src/composables/graph/useGraphNodeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import type {
LGraphTriggerAction,
LGraphTriggerEvent,
LGraphTriggerParam
} from '../../lib/litegraph/src/litegraph'
import { NodeSlotType } from '../../lib/litegraph/src/types/globalEnums'
} from '@/lib/litegraph/src/litegraph'
import type { TitleMode } from '@/lib/litegraph/src/types/globalEnums'
import { NodeSlotType } from '@/lib/litegraph/src/types/globalEnums'

export interface WidgetSlotMetadata {
index: number
Expand All @@ -55,26 +56,27 @@ export interface SafeWidgetData {
}

export interface VueNodeData {
executing: boolean
id: NodeId
title: string
type: string
mode: number
selected: boolean
executing: boolean
title: string
type: string
apiNode?: boolean
badges?: (LGraphBadge | (() => LGraphBadge))[]
subgraphId?: string | null
widgets?: SafeWidgetData[]
inputs?: INodeInputSlot[]
outputs?: INodeOutputSlot[]
hasErrors?: boolean
bgcolor?: string
color?: string
flags?: {
collapsed?: boolean
pinned?: boolean
}
color?: string
bgcolor?: string
hasErrors?: boolean
inputs?: INodeInputSlot[]
outputs?: INodeOutputSlot[]
shape?: number
subgraphId?: string | null
titleMode?: TitleMode
widgets?: SafeWidgetData[]
}

export interface GraphNodeManager {
Expand Down Expand Up @@ -262,6 +264,7 @@ export function useGraphNodeManager(graph: LGraph): GraphNodeManager {
title: typeof node.title === 'string' ? node.title : '',
type: nodeType,
mode: node.mode || 0,
titleMode: node.title_mode,
selected: node.selected || false,
executing: false, // Will be updated separately based on execution state
subgraphId,
Expand Down
16 changes: 15 additions & 1 deletion src/renderer/extensions/vueNodes/components/LGraphNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@
@dragleave="handleDragLeave"
@drop.stop.prevent="handleDrop"
>
<div class="flex flex-col justify-center items-center relative">
<div
v-if="displayHeader"
class="flex flex-col justify-center items-center relative"
>
<template v-if="isCollapsed">
<SlotConnectionDot
v-if="hasInputs"
Expand Down Expand Up @@ -145,6 +148,7 @@ import {
LiteGraph,
RenderShape
} from '@/lib/litegraph/src/litegraph'
import { TitleMode } from '@/lib/litegraph/src/types/globalEnums'
import { useSettingStore } from '@/platform/settings/settingStore'
import { useTelemetry } from '@/platform/telemetry'
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
Expand All @@ -165,6 +169,7 @@ import { app } from '@/scripts/app'
import { useExecutionStore } from '@/stores/executionStore'
import { useNodeOutputStore } from '@/stores/imagePreviewStore'
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
import { isTransparent } from '@/utils/colorUtil'
import {
getLocatorIdFromNodeData,
getNodeByLocatorId
Expand Down Expand Up @@ -215,6 +220,8 @@ const hasAnyError = computed((): boolean => {
)
})

const displayHeader = computed(() => nodeData.titleMode !== TitleMode.NO_TITLE)

const isCollapsed = computed(() => nodeData.flags?.collapsed ?? false)
const bypassed = computed(
(): boolean => nodeData.mode === LGraphEventMode.BYPASS
Expand Down Expand Up @@ -368,6 +375,13 @@ const { latestPreviewUrl, shouldShowPreviewImg } = useNodePreviewState(

const borderClass = computed(() => {
if (hasAnyError.value) return 'border-node-stroke-error'
//FIXME need a better way to detecting transparency
if (
!displayHeader.value &&
nodeData.bgcolor &&
isTransparent(nodeData.bgcolor)
)
return 'border-0'
return ''
})

Expand Down
9 changes: 9 additions & 0 deletions src/utils/colorUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ export interface ColorAdjustOptions {
opacity?: number
}

export function isTransparent(color: string) {
if (color === 'transparent') return true
if (color[0] === '#') {
if (color.length === 5) return color[4] === '0'
if (color.length === 9) return color.substring(7) === '00'
}
return false
}
Comment on lines +24 to +31
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Limited transparency detection may not cover all formats.

The function only detects:

  • The literal string 'transparent'
  • 4-digit hex with alpha 0 (#RGBA where A=0)
  • 8-digit hex with alpha 00 (#RRGGBBAA where AA=00)

It doesn't detect rgba(r, g, b, 0) or hsla(h, s, l, 0) formats. This aligns with the FIXME comment in LGraphNode.vue (line 378) indicating "need a better way to detecting transparency."

If nodes can have rgba/hsla background colors with zero alpha, consider extending the function:

🔎 Proposed enhancement
 export function isTransparent(color: string): boolean {
   if (color === 'transparent') return true
   if (color[0] === '#') {
     if (color.length === 5) return color[4] === '0'
     if (color.length === 9) return color.substring(7) === '00'
   }
+  // Check rgba/hsla with zero alpha
+  if (color.startsWith('rgba(') || color.startsWith('hsla(')) {
+    const match = color.match(/,\s*(0|0\.0+)\s*\)$/)
+    if (match) return true
+  }
   return false
 }

Do you want me to verify if rgba/hsla formats are used for node backgrounds in the codebase?

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function isTransparent(color: string) {
if (color === 'transparent') return true
if (color[0] === '#') {
if (color.length === 5) return color[4] === '0'
if (color.length === 9) return color.substring(7) === '00'
}
return false
}
export function isTransparent(color: string): boolean {
if (color === 'transparent') return true
if (color[0] === '#') {
if (color.length === 5) return color[4] === '0'
if (color.length === 9) return color.substring(7) === '00'
}
// Check rgba/hsla with zero alpha
if (color.startsWith('rgba(') || color.startsWith('hsla(')) {
const match = color.match(/,\s*(0|0\.0+)\s*\)$/)
if (match) return true
}
return false
}
🤖 Prompt for AI Agents
In src/utils/colorUtil.ts around lines 24 to 31, isTransparent only checks the
literal 'transparent' and hex variants (#RGBA and #RRGGBBAA) so it misses
rgba(...) and hsla(...) values with zero alpha; update the function to also
parse and detect zero-alpha in CSS functional notations by testing for
/^rgba?\(\s*.../ and /^hsla?\(\s*.../ patterns, extracting the alpha component
and treating alpha === 0 (or 0.0) as transparent, while preserving current hex
and literal checks and ensuring robust trimming and case-insensitive matching.


function rgbToHsl({ r, g, b }: RGB): HSL {
r /= 255
g /= 255
Expand Down