mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-24 06:35:10 +00:00
refactor(subgraph): address small review nits batch
- promotedWidgetView.ts: seed ensureHostWidgetState from this.value (full effective resolution chain) instead of resolveAtHost(), so a restored promoted value isn't shadowed on first render - LGraphNode.ts: add JSDoc to clone() documenting the borrowed source-id window between clone() and graph.add() (replaces former -1 sentinel) - appModeStore.test.ts: add suite-level afterEach(restoreAllMocks) so a failing assertion can't leak per-test console.warn spies - AppBuilder.vue: prefer entry.displayName over opaque entry.entityId for resolved-input title fallback; mirrors symmetric branch on :240 Amp-Thread-ID: https://ampcode.com/threads/T-019e2812-d683-710e-946f-9ddb9018ff5a Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -226,7 +226,7 @@ const renderedInputs = computed<[string, MaybeRef<BoundStyle> | undefined][]>(
|
||||
:class="
|
||||
cn(dragClass, 'my-2 rounded-lg bg-primary-background/30 p-2')
|
||||
"
|
||||
:title="entry.widget.label ?? entry.entityId"
|
||||
:title="entry.widget.label ?? entry.displayName"
|
||||
:sub-title="entry.node.title"
|
||||
can-rename
|
||||
:remove="() => appModeStore.removeSelectedInput(entry.widget)"
|
||||
|
||||
@@ -241,7 +241,10 @@ class PromotedWidgetView implements IPromotedWidgetView {
|
||||
*/
|
||||
ensureHostWidgetState(): void {
|
||||
if (this.getHostWidgetState()) return
|
||||
this.registerHostWidgetState(this.resolveAtHost()?.widget.value)
|
||||
// Seed from the effective promoted value (host → linked → deepest →
|
||||
// interior fallback) instead of the raw interior default, so a restored
|
||||
// promoted value isn't shadowed on first render.
|
||||
this.registerHostWidgetState(this.value)
|
||||
}
|
||||
|
||||
private registerHostWidgetState(value: IBaseWidget['value']): void {
|
||||
|
||||
@@ -997,7 +997,16 @@ export class LGraphNode
|
||||
return o
|
||||
}
|
||||
|
||||
/* Creates a clone of this node */
|
||||
/**
|
||||
* Creates a clone of this node.
|
||||
*
|
||||
* Note: between this call returning and `graph.add(clone)` running, the
|
||||
* returned node briefly carries the **source node's id** rather than the
|
||||
* historical `-1` sentinel. This is required so that subclass `configure()`
|
||||
* implementations (e.g. {@link SubgraphNode}) which key per-instance state
|
||||
* by id hydrate into the correct slot. `graph.add` will reassign a fresh id
|
||||
* (or detect the collision and reassign) on insert.
|
||||
*/
|
||||
clone(): LGraphNode | null {
|
||||
if (this.type == null) return null
|
||||
const node = LiteGraph.createNode(this.type)
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createTestingPinia } from '@pinia/testing'
|
||||
import { fromAny, fromPartial } from '@total-typescript/shoehorn'
|
||||
import { setActivePinia } from 'pinia'
|
||||
import { nextTick } from 'vue'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import type { LGraphNode, NodeId } from '@/lib/litegraph/src/LGraphNode'
|
||||
import { SubgraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
@@ -118,6 +118,12 @@ describe('appModeStore', () => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
// Restore any per-test spies (e.g. console.warn) so an assertion failure
|
||||
// can't leak the spy into the next test.
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
describe('enterBuilder', () => {
|
||||
it('navigates to builder:arrange when in app mode with outputs', () => {
|
||||
workflowStore.activeWorkflow = createBuilderWorkflowWithOutputs('app')
|
||||
|
||||
Reference in New Issue
Block a user