Skip to content

Commit 0743869

Browse files
DrJKLampcode-com
andcommitted
fix: cache promoted widget views, use standard prototype, revert nav test
- Cache _getPromotedViews result for reference stability (widgets getter) - Replace Object.create(null) with {} for standard Object prototype - Revert navigateIntoSubgraph to dblclick approach (title button click fails in CI) Amp-Thread-ID: https://ampcode.com/threads/T-019c59d8-632b-750c-a1a2-93920c89f63e Co-authored-by: Amp <amp@ampcode.com>
1 parent 73cb297 commit 0743869

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

browser_tests/fixtures/utils/litegraphUtils.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,15 @@ export class NodeReference {
458458
const nodePos = await this.getPosition()
459459
const nodeSize = await this.getSize()
460460

461-
// Click the enter_subgraph title button (top-right of title bar).
462-
// This is more reliable than dblclick on the node body because
463-
// promoted DOM widgets can overlay the body and intercept events.
464-
const buttonPos = {
465-
x: nodePos.x + nodeSize.width - 15,
466-
y: nodePos.y - titleHeight / 2
467-
}
461+
// Try multiple positions to avoid DOM widget interference
462+
const clickPositions = [
463+
{ x: nodePos.x + nodeSize.width / 2, y: nodePos.y + titleHeight + 5 },
464+
{
465+
x: nodePos.x + nodeSize.width / 2,
466+
y: nodePos.y + nodeSize.height / 2
467+
},
468+
{ x: nodePos.x + 20, y: nodePos.y + titleHeight + 5 }
469+
]
468470

469471
const checkIsInSubgraph = async () => {
470472
return this.comfyPage.page.evaluate(() => {
@@ -474,13 +476,20 @@ export class NodeReference {
474476
}
475477

476478
await expect(async () => {
477-
await this.comfyPage.canvas.click({
478-
position: buttonPos,
479-
force: true
480-
})
481-
await this.comfyPage.nextFrame()
482-
483-
if (await checkIsInSubgraph()) return
479+
for (const position of clickPositions) {
480+
// Clear any selection first
481+
await this.comfyPage.canvas.click({
482+
position: { x: 250, y: 250 },
483+
force: true
484+
})
485+
await this.comfyPage.nextFrame()
486+
487+
// Double-click to enter subgraph
488+
await this.comfyPage.canvas.dblclick({ position, force: true })
489+
await this.comfyPage.nextFrame()
490+
491+
if (await checkIsInSubgraph()) return
492+
}
484493
throw new Error('Not in subgraph yet')
485494
}).toPass({ timeout: 5000, intervals: [100, 200, 500] })
486495
}

src/core/graph/subgraph/promotedWidgetView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function createPromotedWidgetView(
3636
): PromotedWidgetView {
3737
const bareNodeId = stripGraphPrefix(nodeId as NodeId)
3838

39-
const view: PromotedWidgetView = Object.create(null)
39+
const view = {} as PromotedWidgetView
4040

4141
// Identity — own data properties
4242
Object.defineProperties(view, {

src/lib/litegraph/src/subgraph/SubgraphNode.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
6969
private _viewCache = new Map<string, PromotedWidgetView>()
7070
private _proxyWidgetsRaw?: unknown
7171
private _promotionList: Array<[string, string]> = []
72+
private _viewsCached: PromotedWidgetView[] = []
73+
private _viewsCacheDirty = true
7274

7375
// Declared as accessor via Object.defineProperty in constructor.
7476
// TypeScript doesn't allow overriding a property with get/set syntax,
@@ -80,17 +82,21 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
8082
if (raw === undefined || raw === null) {
8183
this._proxyWidgetsRaw = raw
8284
this._promotionList = []
85+
this._viewsCacheDirty = true
8386
return this._promotionList
8487
}
8588
if (raw !== this._proxyWidgetsRaw) {
8689
this._proxyWidgetsRaw = raw
8790
this._promotionList = parseProxyWidgets(raw)
91+
this._viewsCacheDirty = true
8892
}
8993
return this._promotionList
9094
}
9195

9296
private _getPromotedViews(): PromotedWidgetView[] {
9397
const list = this._getPromotionList()
98+
if (!this._viewsCacheDirty) return this._viewsCached
99+
94100
const views: PromotedWidgetView[] = []
95101
const seenKeys = new Set<string>()
96102
let hadLegacyEntries = false
@@ -133,6 +139,8 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
133139
this._promotionList = resolved
134140
}
135141

142+
this._viewsCached = views
143+
this._viewsCacheDirty = false
136144
return views
137145
}
138146

0 commit comments

Comments
 (0)