mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-11 16:30:57 +00:00
## Summary Phase 1 of the dialog migration kicked off in #11719. Migrates the two simplest production dialogs — `PromptDialogContent` and `ConfirmationDialogContent` — from PrimeVue `Dialog` onto the Reka-UI primitives landed in Phase 0. Public API of `useDialogService` / `dialogStore` is unchanged. Parent: [FE-571](https://linear.app/comfyorg/issue/FE-571/dialog-system-migration-primevue-reka-ui-parent) This phase: [FE-573](https://linear.app/comfyorg/issue/FE-573/phase-1-migrate-promptdialog-confirmationdialog-closes-11688) Predecessor: #11719 (merged at `0788e7139`) Refs #11688 (closed manually after Phase 0; the actual user-visible max-width fix ships in this PR) ## Changes ### `src/services/dialogService.ts` | Call site | Renderer | Size | Width override | | --- | --- | --- | --- | | `prompt()` | `'reka'` | `md` | — | | `confirm()` | `'reka'` | `md` | — | | `showBillingComingSoonDialog()` | `'reka'` | `sm` | `contentClass: 'max-w-[360px]'` | ### `src/components/dialog/content/ConfirmationDialogContent.vue` - Drops `import Message from 'primevue/message'` — the only PrimeVue dependency in the component - Replaces `<Message>` with a Tailwind `role="status"` alert keeping the `pi pi-info-circle` icon and muted-foreground severity ### `src/stores/dialogStore.ts` + `src/components/dialog/GlobalDialog.vue` - Adds `contentClass?: HTMLAttributes['class']` on `CustomDialogComponentProps` - Forwards it to `<DialogContent :class="...">` on the Reka branch (PrimeVue path keeps using `pt`) ## Why this scope 1. **Smallest content surface** — `PromptDialogContent` is 43 LOC; the only PrimeVue dependency in `ConfirmationDialogContent` is the `<Message>` info banner. 2. **Closes #11688 ergonomics** — Reka's `md` size = `max-w-xl` (576px / 36rem), exactly the max-width the issue reporter asked for. 3. **Three known callers** — all in `dialogService.ts`. No other callers needed to change. 4. **Renderer branch is already proven by Phase 0**; this PR just flips the flag. ## Visual proof Verified live in Storybook (`Components / Dialog / Dialog → Default` and `… → All Sizes`) at viewport `1920×1080`. DOM inspection confirms the rendered widths match the design intent: | Story | size | Rendered width | Computed `max-width` | | --- | --- | --- | --- | | `Default` | `md` | **576 px** | **576 px (= 36rem)** | | `All Sizes` (sm slot) | `sm` | 384 px | 384 px (= 24rem) | The `md` measurement directly answers the #11688 reporter screenshot (1558 px wide PrimeVue dialog → 576 px Reka dialog on the same display). Local screenshot artifacts (not committed): `temp/screenshots/phase1-md-576px-1920w.png`, `temp/screenshots/phase1-md-allsizes-1920w.png`, `temp/screenshots/phase1-sm-384px-1920w.png` — drag-drop into the PR body before marking ready for review. ## Quality gates - [x] `pnpm typecheck` — clean - [x] `pnpm lint` — clean - [x] `pnpm format` — applied (oxfmt) - [x] `pnpm test:unit` (touched files): **26/26 passed** - `ConfirmationDialogContent.test.ts` (9 tests, no longer needs PrimeVue plugin) - `PromptDialogContent.test.ts` (5 tests, unchanged) - `GlobalDialog.test.ts` (9 tests, Phase 0 coverage still passes after the contentClass forwarder addition) - `dialogService.renderer.test.ts` **new** — 3 tests asserting each call site sets `renderer: 'reka'` (regression net) - [ ] `pnpm test:browser:local --grep "@mobile confirm dialog"` — **could not run locally** (no ComfyUI Python backend on `localhost:8188` in this session); CI will gate the existing fixture, which is already renderer-agnostic (`getByRole('dialog')` + `getByRole('button', ...)` in `browser_tests/fixtures/components/ConfirmDialog.ts`). ## Public API impact None. `useDialogService().prompt(...)` / `confirm(...)` / `showBillingComingSoonDialog(...)` keep their existing signatures. Custom-node extensions calling `app.extensionManager.dialog.*` continue to work. ## Out of scope (later phases) - `ErrorDialogContent`, `NodeSearchBox`, `SecretFormDialog`, `VideoHelpDialog`, `CustomizationDialog` — Phase 2 (FE-574) - Settings dialog — Phase 3 (FE-575) - Manager dialog — Phase 4 (FE-576) - `ConfirmDialog` callers (`SecretsPanel`, `BaseWorkflowsSidebarTab`) — Phase 5 (FE-577) - Removing PrimeVue `Dialog` imports + `<style>` cleanup in `GlobalDialog.vue` — Phase 6 (FE-578) - Legacy `ComfyDialog` (`src/scripts/ui/dialog.ts`) - Deduplicating `Dialogue.vue` / `ImageLightbox.vue` ## Screenshot <img width="865" height="497" alt="Screenshot 2026-05-08 at 4 35 45 PM" src="https://github.com/user-attachments/assets/6aead2ad-2e0b-478a-9154-bb632a6bf3d1" /> <img width="1363" height="964" alt="Screenshot 2026-05-08 at 4 38 16 PM" src="https://github.com/user-attachments/assets/10647752-a063-4901-a206-842799cc5d7a" /> <img width="889" height="486" alt="Screenshot 2026-05-08 at 4 46 57 PM" src="https://github.com/user-attachments/assets/81899a81-205a-46f2-bddd-7639624607f6" /> ## Test plan - [x] Unit: 26/26 pass on touched files - [ ] CI: `@mobile confirm dialog` spec on the migrated path - [ ] Manual (post-CI on a real backend): open prompt and confirm dialogs on 1920×1080 viewport, verify ≤ 36rem max-width, ESC closes, backdrop click closes, Enter submits prompt, focus trap holds - [ ] Manual: open Billing Coming Soon dialog — verify it stays at the existing `max-w-[360px]` width
283 lines
8.3 KiB
TypeScript
283 lines
8.3 KiB
TypeScript
import type { Locator } from '@playwright/test'
|
|
|
|
import type {
|
|
GraphAddOptions,
|
|
LGraph,
|
|
LGraphNode
|
|
} from '@/lib/litegraph/src/litegraph'
|
|
import type {
|
|
ComfyWorkflowJSON,
|
|
NodeId
|
|
} from '@/platform/workflow/validation/schemas/workflowSchema'
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import { DefaultGraphPositions } from '@e2e/fixtures/constants/defaultGraphPositions'
|
|
import type { Position, Size } from '@e2e/fixtures/types'
|
|
import { NodeReference } from '@e2e/fixtures/utils/litegraphUtils'
|
|
|
|
export class NodeOperationsHelper {
|
|
public readonly promptDialogInput: Locator
|
|
|
|
constructor(private comfyPage: ComfyPage) {
|
|
this.promptDialogInput = this.page.getByRole('dialog').getByRole('textbox')
|
|
}
|
|
|
|
private get page() {
|
|
return this.comfyPage.page
|
|
}
|
|
|
|
async getGraphNodesCount(): Promise<number> {
|
|
return await this.page.evaluate(() => {
|
|
return window.app?.graph?.nodes?.length || 0
|
|
})
|
|
}
|
|
|
|
async getSelectedGraphNodesCount(): Promise<number> {
|
|
return await this.page.evaluate(() => {
|
|
return (
|
|
window.app?.graph?.nodes?.filter(
|
|
(node: LGraphNode) => node.is_selected === true
|
|
).length || 0
|
|
)
|
|
})
|
|
}
|
|
|
|
async getSelectedNodeIds(): Promise<NodeId[]> {
|
|
return await this.page.evaluate(() => {
|
|
const selected = window.app?.canvas?.selected_nodes
|
|
if (!selected) return []
|
|
return Object.keys(selected).map(Number)
|
|
})
|
|
}
|
|
|
|
/**
|
|
* Add a node to the graph by type.
|
|
* @param type - The node type (e.g. 'KSampler', 'VAEDecode')
|
|
* @param options - GraphAddOptions (ghost, skipComputeOrder). When ghost is
|
|
* true and position is provided, a synthetic MouseEvent is created as the
|
|
* dragEvent.
|
|
* @param position - When ghost is true, client coordinates for the ghost
|
|
* placement dragEvent. Otherwise, world coordinates assigned to node.pos.
|
|
*/
|
|
async addNode(
|
|
type: string,
|
|
options?: Omit<GraphAddOptions, 'dragEvent'>,
|
|
position?: Position
|
|
): Promise<NodeReference> {
|
|
const id = await this.page.evaluate(
|
|
([nodeType, opts, pos]) => {
|
|
const node = window.LiteGraph!.createNode(nodeType)!
|
|
const addOpts: Record<string, unknown> = { ...opts }
|
|
if (opts?.ghost && pos) {
|
|
addOpts.dragEvent = new MouseEvent('click', {
|
|
clientX: pos.x,
|
|
clientY: pos.y
|
|
})
|
|
} else if (pos) {
|
|
node.pos = [pos.x, pos.y]
|
|
}
|
|
window.app!.graph.add(node, addOpts as GraphAddOptions)
|
|
return node.id
|
|
},
|
|
[type, options ?? {}, position ?? null] as const
|
|
)
|
|
return new NodeReference(id, this.comfyPage)
|
|
}
|
|
|
|
/** Remove all nodes from the graph and clean. */
|
|
async clearGraph() {
|
|
await this.comfyPage.settings.setSetting('Comfy.ConfirmClear', false)
|
|
await this.comfyPage.command.executeCommand('Comfy.ClearWorkflow')
|
|
}
|
|
|
|
/** Reads from `window.app.graph` (the root workflow graph). */
|
|
async getNodeCount(): Promise<number> {
|
|
return await this.page.evaluate(() => window.app!.graph.nodes.length)
|
|
}
|
|
|
|
async getNodes(): Promise<LGraphNode[]> {
|
|
return await this.page.evaluate(() => {
|
|
return window.app!.graph.nodes
|
|
})
|
|
}
|
|
|
|
async waitForGraphNodes(count: number): Promise<void> {
|
|
await this.page.waitForFunction((count) => {
|
|
return window.app?.canvas.graph?.nodes?.length === count
|
|
}, count)
|
|
}
|
|
|
|
async getFirstNodeRef(): Promise<NodeReference | null> {
|
|
const id = await this.page.evaluate(() => {
|
|
return window.app!.graph.nodes[0]?.id
|
|
})
|
|
if (!id) return null
|
|
return this.getNodeRefById(id)
|
|
}
|
|
|
|
async getNodeRefById(id: NodeId): Promise<NodeReference> {
|
|
return new NodeReference(id, this.comfyPage)
|
|
}
|
|
|
|
async getNodeRefsByType(
|
|
type: string,
|
|
includeSubgraph: boolean = false
|
|
): Promise<NodeReference[]> {
|
|
return Promise.all(
|
|
(
|
|
await this.page.evaluate(
|
|
({ type, includeSubgraph }) => {
|
|
const graph = (
|
|
includeSubgraph ? window.app!.canvas.graph : window.app!.graph
|
|
) as LGraph
|
|
const nodes = graph.nodes
|
|
return nodes
|
|
.filter((n: LGraphNode) => n.type === type)
|
|
.map((n: LGraphNode) => n.id)
|
|
},
|
|
{ type, includeSubgraph }
|
|
)
|
|
).map((id: NodeId) => this.getNodeRefById(id))
|
|
)
|
|
}
|
|
|
|
async getNodeRefsByTitle(title: string): Promise<NodeReference[]> {
|
|
return Promise.all(
|
|
(
|
|
await this.page.evaluate((title) => {
|
|
return window
|
|
.app!.graph.nodes.filter((n: LGraphNode) => n.title === title)
|
|
.map((n: LGraphNode) => n.id)
|
|
}, title)
|
|
).map((id: NodeId) => this.getNodeRefById(id))
|
|
)
|
|
}
|
|
|
|
async selectNodes(nodeTitles: string[]): Promise<void> {
|
|
await this.page.keyboard.down('Control')
|
|
try {
|
|
for (const nodeTitle of nodeTitles) {
|
|
const nodes = await this.getNodeRefsByTitle(nodeTitle)
|
|
for (const node of nodes) {
|
|
await node.click('title')
|
|
}
|
|
}
|
|
} finally {
|
|
await this.page.keyboard.up('Control')
|
|
await this.comfyPage.nextFrame()
|
|
}
|
|
}
|
|
|
|
async getSerializedGraph(): Promise<ComfyWorkflowJSON> {
|
|
return this.page.evaluate(
|
|
() => window.app!.graph.serialize() as ComfyWorkflowJSON
|
|
)
|
|
}
|
|
|
|
async loadGraph(data: ComfyWorkflowJSON): Promise<void> {
|
|
await this.page.evaluate(
|
|
(d) => window.app!.loadGraphData(d, true, true, null),
|
|
data
|
|
)
|
|
}
|
|
|
|
async repositionNodes(
|
|
positions: Record<string, [number, number]>
|
|
): Promise<void> {
|
|
const data = await this.getSerializedGraph()
|
|
applyNodePositions(data, positions)
|
|
await this.loadGraph(data)
|
|
}
|
|
|
|
async resizeNode(
|
|
nodePos: Position,
|
|
nodeSize: Size,
|
|
ratioX: number,
|
|
ratioY: number,
|
|
revertAfter: boolean = false
|
|
): Promise<void> {
|
|
const bottomRight = {
|
|
x: nodePos.x + nodeSize.width,
|
|
y: nodePos.y + nodeSize.height
|
|
}
|
|
const target = {
|
|
x: nodePos.x + nodeSize.width * ratioX,
|
|
y: nodePos.y + nodeSize.height * ratioY
|
|
}
|
|
// -1 to be inside the node. -2 because nodes currently get an arbitrary +1 to width.
|
|
await this.comfyPage.canvasOps.dragAndDrop(
|
|
{ x: bottomRight.x - 2, y: bottomRight.y - 1 },
|
|
target
|
|
)
|
|
if (revertAfter) {
|
|
await this.comfyPage.canvasOps.dragAndDrop(
|
|
{ x: target.x - 2, y: target.y - 1 },
|
|
bottomRight
|
|
)
|
|
}
|
|
}
|
|
|
|
async convertAllNodesToGroupNode(groupNodeName: string): Promise<void> {
|
|
await this.comfyPage.canvas.press('Control+a')
|
|
const node = await this.getFirstNodeRef()
|
|
if (!node) {
|
|
throw new Error('No nodes found to convert')
|
|
}
|
|
await node.clickContextMenuOption('Convert to Group Node')
|
|
await this.fillPromptDialog(groupNodeName)
|
|
}
|
|
|
|
async fillPromptDialog(value: string): Promise<void> {
|
|
await this.promptDialogInput.fill(value)
|
|
await this.page.keyboard.press('Enter')
|
|
await this.promptDialogInput.waitFor({ state: 'hidden' })
|
|
await this.comfyPage.nextFrame()
|
|
}
|
|
|
|
async panToNode(nodeRef: NodeReference): Promise<void> {
|
|
const nodePos = await nodeRef.getPosition()
|
|
await this.page.evaluate((pos) => {
|
|
const canvas = window.app!.canvas
|
|
canvas.ds.offset[0] = -pos.x + canvas.canvas.width / 2
|
|
canvas.ds.offset[1] = -pos.y + canvas.canvas.height / 2 + 100
|
|
canvas.setDirty(true, true)
|
|
}, nodePos)
|
|
await this.comfyPage.nextFrame()
|
|
}
|
|
|
|
async selectNodeWithPan(nodeRef: NodeReference): Promise<void> {
|
|
await this.panToNode(nodeRef)
|
|
await nodeRef.click('title')
|
|
}
|
|
|
|
async dragTextEncodeNode2(): Promise<void> {
|
|
await this.comfyPage.canvasOps.dragAndDrop(
|
|
DefaultGraphPositions.textEncodeNode2,
|
|
{
|
|
x: DefaultGraphPositions.textEncodeNode2.x,
|
|
y: 300
|
|
}
|
|
)
|
|
}
|
|
|
|
async adjustEmptyLatentWidth(): Promise<void> {
|
|
await this.page.locator('#graph-canvas').click({
|
|
position: DefaultGraphPositions.emptyLatentWidgetClick
|
|
})
|
|
const dialogInput = this.page.locator('.graphdialog input[type="text"]')
|
|
await dialogInput.click()
|
|
await dialogInput.fill('128')
|
|
await dialogInput.press('Enter')
|
|
await this.comfyPage.nextFrame()
|
|
}
|
|
}
|
|
|
|
function applyNodePositions(
|
|
data: ComfyWorkflowJSON,
|
|
positions: Record<string, [number, number]>
|
|
): void {
|
|
for (const node of data.nodes) {
|
|
const pos = positions[String(node.id)]
|
|
if (pos) node.pos = pos
|
|
}
|
|
}
|