mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 07:30:11 +00:00
fix(litegraph): restore link tooltips by resolving data via linkId
- Add linkId to LinkSegment/RenderedLinkSegment - Set linkId on rendered segments; resolve model link in drawLinkTooltip - Remove data copy on render objects to keep them ephemeral
This commit is contained in:
@@ -5108,13 +5108,14 @@ export class LGraphCanvas
|
||||
}
|
||||
ctx.fill()
|
||||
|
||||
// @ts-expect-error TODO: Better value typing
|
||||
const { data } = link
|
||||
// Resolve the underlying model link for data/overrides
|
||||
const modelLink = this.graph?.getLink(
|
||||
(link.linkId ?? (link.id as unknown)) as LinkId
|
||||
)
|
||||
const data = modelLink?.data
|
||||
if (this.onDrawLinkTooltip?.(ctx, modelLink ?? null, this) === true) return
|
||||
if (data == null) return
|
||||
|
||||
// @ts-expect-error TODO: Better value typing
|
||||
if (this.onDrawLinkTooltip?.(ctx, link, this) == true) return
|
||||
|
||||
let text: string | null = null
|
||||
|
||||
if (typeof data === 'number') text = data.toFixed(2)
|
||||
@@ -5639,7 +5640,8 @@ export class LGraphCanvas
|
||||
id: reroute.id,
|
||||
origin_id: link.origin_id,
|
||||
origin_slot: link.origin_slot,
|
||||
parentId: reroute.parentId
|
||||
parentId: reroute.parentId,
|
||||
linkId: link.id
|
||||
})
|
||||
rendered.colour = baseColour
|
||||
this.renderLink(
|
||||
@@ -5689,7 +5691,8 @@ export class LGraphCanvas
|
||||
id: link.id,
|
||||
origin_id: link.origin_id,
|
||||
origin_slot: link.origin_slot,
|
||||
parentId: link.parentId
|
||||
parentId: link.parentId,
|
||||
linkId: link.id
|
||||
})
|
||||
rendered.colour = baseColour
|
||||
this.renderLink(
|
||||
@@ -5711,7 +5714,8 @@ export class LGraphCanvas
|
||||
id: link.id,
|
||||
origin_id: link.origin_id,
|
||||
origin_slot: link.origin_slot,
|
||||
parentId: link.parentId
|
||||
parentId: link.parentId,
|
||||
linkId: link.id
|
||||
})
|
||||
rendered.colour = baseColour
|
||||
this.renderLink(
|
||||
|
||||
@@ -12,6 +12,8 @@ export class RenderedLinkSegment implements LinkSegment {
|
||||
readonly origin_id: NodeId
|
||||
readonly origin_slot: number
|
||||
readonly parentId?: RerouteId
|
||||
/** Source link id for resolving runtime data/tooltips. */
|
||||
readonly linkId?: LinkId
|
||||
|
||||
path?: Path2D
|
||||
readonly _pos: Float32Array = new Float32Array(2)
|
||||
@@ -24,10 +26,12 @@ export class RenderedLinkSegment implements LinkSegment {
|
||||
origin_id: NodeId
|
||||
origin_slot: number
|
||||
parentId?: RerouteId
|
||||
linkId?: LinkId
|
||||
}) {
|
||||
this.id = args.id
|
||||
this.origin_id = args.origin_id
|
||||
this.origin_slot = args.origin_slot
|
||||
this.parentId = args.parentId
|
||||
this.linkId = args.linkId
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +188,8 @@ export interface LinkSegment {
|
||||
readonly id: LinkId | RerouteId
|
||||
/** The {@link id} of the reroute that this segment starts from (output side), otherwise `undefined`. */
|
||||
readonly parentId?: RerouteId
|
||||
/** The source link id (if this segment belongs to a link). */
|
||||
readonly linkId?: LinkId
|
||||
|
||||
/** The last canvas 2D path that was used to render this segment */
|
||||
path?: Path2D
|
||||
|
||||
Reference in New Issue
Block a user