From 709e1fee6bd7ffc937fca4151d11884e95b80f05 Mon Sep 17 00:00:00 2001 From: Glary Bot Date: Sat, 3 Oct 2026 09:06:57 +0000 Subject: [PATCH 01/10] fix(dialog): keep modal size independent of the docked Agent panel Dialogs read --workspace-inset-right, the width the docked Agent panel publishes, in two places: every size variant subtracted it from max-width, and the centring offset shifted the box by half of it. Large dialogs pin their own max-width (Templates, Settings, Manager all set sm:max-w-*), so the offset applied without the matching clamp: at 1280 with a 420px panel the Templates browser landed at x=-146, clipping its left nav off screen while still overlapping the panel. Size variants now resolve against the viewport alone, and the offset is clamped so a dialog stops at the viewport gutter instead of leaving it. A dialog still centres in the space beside the panel when it fits there, and covers the panel rather than shrinking when it does not. --- .../fixtures/utils/workspaceInset.ts | 31 ++++++ .../dialogs/dialogAgentPanelInset.spec.ts | 100 ++++++++++++++++++ src/components/ui/dialog/dialog.variants.ts | 12 +-- .../composables/useAssetBrowserDialog.ts | 2 +- .../sharing/composables/useShareDialog.ts | 3 +- src/services/dialogService.ts | 5 +- 6 files changed, 141 insertions(+), 12 deletions(-) create mode 100644 browser_tests/fixtures/utils/workspaceInset.ts create mode 100644 browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts diff --git a/browser_tests/fixtures/utils/workspaceInset.ts b/browser_tests/fixtures/utils/workspaceInset.ts new file mode 100644 index 00000000000..75d528b275b --- /dev/null +++ b/browser_tests/fixtures/utils/workspaceInset.ts @@ -0,0 +1,31 @@ +import type { Page } from '@playwright/test' + +import { WORKSPACE_INSET_RIGHT } from '@/composables/useWorkspaceInset' + +/** `PANEL_MIN_WIDTH` in `agentPanelStore` — the narrowest docked Agent panel. */ +export const DOCKED_AGENT_PANEL_WIDTH = 420 + +/** Half of the `1rem` gutter `dialogContentVariants` reserves around a dialog. */ +export async function dialogViewportGutter(page: Page): Promise { + return page.evaluate( + () => parseFloat(getComputedStyle(document.documentElement).fontSize) / 2 + ) +} + +/** + * Declares the inset a docked right-hand surface publishes, standing in for the + * Agent panel so layout can be exercised without the feature flags, consent and + * backend a real panel needs. A real panel owns this property and rewrites it + * whenever it resizes, so measure before resizing the viewport or opening one. + */ +export async function publishWorkspaceInsetRight( + page: Page, + widthPx: number +): Promise { + await page.evaluate( + ({ property, widthPx }) => { + document.documentElement.style.setProperty(property, `${widthPx}px`) + }, + { property: WORKSPACE_INSET_RIGHT, widthPx } + ) +} diff --git a/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts new file mode 100644 index 00000000000..d6d363f5834 --- /dev/null +++ b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts @@ -0,0 +1,100 @@ +import { + comfyExpect as expect, + comfyPageFixture as test +} from '@e2e/fixtures/ComfyPage' +import { + DOCKED_AGENT_PANEL_WIDTH, + dialogViewportGutter, + publishWorkspaceInsetRight +} from '@e2e/fixtures/utils/workspaceInset' + +/** + * A docked Agent panel publishes its width as `--workspace-inset-right`, and + * dialogs shift left to stay beside it. Opening the panel — which happens + * unprompted for first-time users — must not resize a dialog or push it off + * screen, which inset-aware sizing and an unclamped shift used to do (PM-1865). + */ +const templateViewports = [ + { room: 'too narrow for the dialog beside the panel', width: 1280 }, + { room: 'wide enough for both', width: 1920 } +] + +test.describe('Dialog layout against the docked Agent panel', () => { + test.describe('the Templates browser', () => { + for (const { room, width } of templateViewports) { + test.describe(`on a viewport ${room}`, () => { + test.use({ viewport: { width, height: 800 } }) + + test('keeps its size and stays on screen', async ({ comfyPage }) => { + await comfyPage.command.executeCommand('Comfy.BrowseTemplates') + await expect(comfyPage.templates.content).toBeVisible() + + const dialog = comfyPage.templatesDialog.root + await expect + .poll(() => + dialog.evaluate((element) => element.getAnimations().length) + ) + .toBe(0) + const withoutPanel = await dialog.boundingBox() + if (!withoutPanel) throw new Error('Templates dialog is not laid out') + + await publishWorkspaceInsetRight( + comfyPage.page, + DOCKED_AGENT_PANEL_WIDTH + ) + + await expect(dialog).toHaveBounds( + { + ...withoutPanel, + x: Math.max( + await dialogViewportGutter(comfyPage.page), + (width - DOCKED_AGENT_PANEL_WIDTH - withoutPanel.width) / 2 + ) + }, + { numDigits: 1 } + ) + }) + }) + } + }) + + test.describe('a dialog sized by its size variant', () => { + const width = 800 + test.use({ viewport: { width, height: 800 } }) + + test('keeps the width its variant asks for', async ({ comfyPage }) => { + await comfyPage.page.evaluate(() => { + window + .app!.extensionManager.dialog.confirm({ + title: 'Confirm', + type: 'default', + message: 'Does this dialog keep its width?' + }) + .catch(() => {}) + }) + + const dialog = comfyPage.confirmDialog.root + await expect(dialog).toBeVisible() + await expect + .poll(() => + dialog.evaluate((element) => element.getAnimations().length) + ) + .toBe(0) + const withoutPanel = await dialog.boundingBox() + if (!withoutPanel) throw new Error('Confirm dialog is not laid out') + + await publishWorkspaceInsetRight(comfyPage.page, DOCKED_AGENT_PANEL_WIDTH) + + await expect(dialog).toHaveBounds( + { + ...withoutPanel, + x: Math.max( + await dialogViewportGutter(comfyPage.page), + (width - DOCKED_AGENT_PANEL_WIDTH - withoutPanel.width) / 2 + ) + }, + { numDigits: 1 } + ) + }) + }) +}) diff --git a/src/components/ui/dialog/dialog.variants.ts b/src/components/ui/dialog/dialog.variants.ts index dbe7ddb99aa..db45a173639 100644 --- a/src/components/ui/dialog/dialog.variants.ts +++ b/src/components/ui/dialog/dialog.variants.ts @@ -5,16 +5,16 @@ export const dialogContentVariants = cva({ base: 'fixed z-1700 flex flex-col rounded-lg border border-border-subtle bg-base-background shadow-lg outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', variants: { size: { - sm: 'sm:max-w-[min(24rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))]', - md: 'sm:max-w-[min(36rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))]', - lg: 'sm:max-w-[min(48rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))]', - xl: 'sm:max-w-[min(64rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))]', - full: 'sm:max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)]' + sm: 'sm:max-w-96', + md: 'sm:max-w-xl', + lg: 'sm:max-w-3xl', + xl: 'sm:max-w-5xl', + full: 'sm:max-w-[calc(100vw-1rem)]' }, maximized: { true: 'inset-2 top-2 left-2 size-auto max-h-none max-w-none sm:max-w-none', false: - 'top-1/2 left-[calc(50%-var(--workspace-inset-right,0px)/2)] max-h-[85vh] w-[calc(100vw-1rem)] -translate-1/2' + 'top-1/2 left-1/2 max-h-[85vh] w-[calc(100vw-1rem)] translate-x-[max(calc(0.5rem-50vw),calc(-50%-var(--workspace-inset-right,0px)/2))] -translate-y-1/2' } }, defaultVariants: { diff --git a/src/platform/assets/composables/useAssetBrowserDialog.ts b/src/platform/assets/composables/useAssetBrowserDialog.ts index 44f0b53b7a3..55f78b75327 100644 --- a/src/platform/assets/composables/useAssetBrowserDialog.ts +++ b/src/platform/assets/composables/useAssetBrowserDialog.ts @@ -26,7 +26,7 @@ interface BrowseOptions { const DIALOG_KEY = 'global-asset-browser' const ASSET_BROWSER_DIALOG_PROPS = { contentClass: - 'w-fit max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)] sm:max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)] border-none bg-transparent shadow-none' + 'w-fit max-w-[calc(100vw-1rem)] sm:max-w-[calc(100vw-1rem)] border-none bg-transparent shadow-none' } satisfies DialogComponentProps export const useAssetBrowserDialog = () => { diff --git a/src/platform/workflow/sharing/composables/useShareDialog.ts b/src/platform/workflow/sharing/composables/useShareDialog.ts index 4b57e30f52a..f1850e78df6 100644 --- a/src/platform/workflow/sharing/composables/useShareDialog.ts +++ b/src/platform/workflow/sharing/composables/useShareDialog.ts @@ -66,8 +66,7 @@ export function useShareDialog() { onClose: hide }, dialogComponentProps: { - contentClass: - 'sm:max-w-[min(36rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))] rounded-2xl overflow-hidden' + contentClass: 'sm:max-w-xl rounded-2xl overflow-hidden' } }) } diff --git a/src/services/dialogService.ts b/src/services/dialogService.ts index 981b982f853..821936474aa 100644 --- a/src/services/dialogService.ts +++ b/src/services/dialogService.ts @@ -619,8 +619,7 @@ export const useDialogService = () => { closable: true, // Contents bring their own width and separators — shrink-wrap the // chrome and zero the section padding. - contentClass: - 'w-fit max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)] sm:max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)] border-border-default', + contentClass: `${HUG_CONTENT_CLASS} border-border-default`, headerClass: 'p-0', bodyClass: 'p-0 overflow-y-hidden', footerClass: 'p-0', @@ -1044,7 +1043,7 @@ export const useDialogService = () => { dialogComponentProps: { closable: false, contentClass: - 'w-170 max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)] sm:max-w-[min(42.5rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))] rounded-2xl overflow-hidden', + 'w-170 max-w-[calc(100vw-1rem)] sm:max-w-[min(42.5rem,calc(100vw-1rem))] rounded-2xl overflow-hidden', onRemoved: () => resolve() } }) From d91e71f7c2331dc47c0d80172473d0234345e6ac Mon Sep 17 00:00:00 2001 From: Glary Bot Date: Sat, 3 Oct 2026 10:27:07 +0000 Subject: [PATCH 02/10] test(dialog): pin the sm breakpoint and the reported viewport for the panel inset The durable matrix covered 800/1280/1920, which left the two viewports that matter least covered: 640, where the sm: size variants start to bind, and 1440, where PM-1865 was reported. Reverting the production files now fails four of the five cases - Templates at 1280 (x=-146) and 1440 (x=-138), and the size variant at 640 (width 204) and 800 (width 364). 1920 stays green as the control for the branch where the clamp does not engage. The shared measure-dock-assert body moves into the fixtures util so adding viewports does not copy it again. --- .../fixtures/utils/workspaceInset.ts | 40 +++++++- .../dialogs/dialogAgentPanelInset.spec.ts | 93 +++++++------------ 2 files changed, 69 insertions(+), 64 deletions(-) diff --git a/browser_tests/fixtures/utils/workspaceInset.ts b/browser_tests/fixtures/utils/workspaceInset.ts index 75d528b275b..7aa8463e89e 100644 --- a/browser_tests/fixtures/utils/workspaceInset.ts +++ b/browser_tests/fixtures/utils/workspaceInset.ts @@ -1,12 +1,13 @@ -import type { Page } from '@playwright/test' +import type { Locator, Page } from '@playwright/test' import { WORKSPACE_INSET_RIGHT } from '@/composables/useWorkspaceInset' +import { comfyExpect } from '@e2e/fixtures/utils/customMatchers' /** `PANEL_MIN_WIDTH` in `agentPanelStore` — the narrowest docked Agent panel. */ -export const DOCKED_AGENT_PANEL_WIDTH = 420 +const DOCKED_AGENT_PANEL_WIDTH = 420 /** Half of the `1rem` gutter `dialogContentVariants` reserves around a dialog. */ -export async function dialogViewportGutter(page: Page): Promise { +async function dialogViewportGutter(page: Page): Promise { return page.evaluate( () => parseFloat(getComputedStyle(document.documentElement).fontSize) / 2 ) @@ -18,7 +19,7 @@ export async function dialogViewportGutter(page: Page): Promise { * backend a real panel needs. A real panel owns this property and rewrites it * whenever it resizes, so measure before resizing the viewport or opening one. */ -export async function publishWorkspaceInsetRight( +async function publishWorkspaceInsetRight( page: Page, widthPx: number ): Promise { @@ -29,3 +30,34 @@ export async function publishWorkspaceInsetRight( { property: WORKSPACE_INSET_RIGHT, widthPx } ) } + +/** + * Measures an open dialog, docks a panel beside it, and requires the box to + * keep every dimension while moving to the one position the layout allows: + * centred in what the panel leaves, or the viewport gutter when that is less + * than nothing. + */ +export async function expectDialogHoldsSizeWhenPanelDocks( + page: Page, + dialog: Locator, + viewportWidth: number +): Promise { + await comfyExpect + .poll(() => dialog.evaluate((element) => element.getAnimations().length)) + .toBe(0) + const withoutPanel = await dialog.boundingBox() + if (!withoutPanel) throw new Error('Dialog is not laid out') + + await publishWorkspaceInsetRight(page, DOCKED_AGENT_PANEL_WIDTH) + + await comfyExpect(dialog).toHaveBounds( + { + ...withoutPanel, + x: Math.max( + await dialogViewportGutter(page), + (viewportWidth - DOCKED_AGENT_PANEL_WIDTH - withoutPanel.width) / 2 + ) + }, + { numDigits: 1 } + ) +} diff --git a/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts index d6d363f5834..e4fca4b37f5 100644 --- a/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts +++ b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts @@ -2,11 +2,7 @@ import { comfyExpect as expect, comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' -import { - DOCKED_AGENT_PANEL_WIDTH, - dialogViewportGutter, - publishWorkspaceInsetRight -} from '@e2e/fixtures/utils/workspaceInset' +import { expectDialogHoldsSizeWhenPanelDocks } from '@e2e/fixtures/utils/workspaceInset' /** * A docked Agent panel publishes its width as `--workspace-inset-right`, and @@ -16,11 +12,18 @@ import { */ const templateViewports = [ { room: 'too narrow for the dialog beside the panel', width: 1280 }, + { room: 'the width PM-1865 was reported at', width: 1440 }, { room: 'wide enough for both', width: 1920 } ] +/** `sm:` applies from 640px, which is where the size variants start to bind. */ +const sizeVariantViewports = [ + { room: 'exactly at the sm breakpoint', width: 640 }, + { room: 'above the sm breakpoint', width: 800 } +] + test.describe('Dialog layout against the docked Agent panel', () => { - test.describe('the Templates browser', () => { + test.describe('the Templates browser, which pins its own max-width', () => { for (const { room, width } of templateViewports) { test.describe(`on a viewport ${room}`, () => { test.use({ viewport: { width, height: 800 } }) @@ -29,29 +32,10 @@ test.describe('Dialog layout against the docked Agent panel', () => { await comfyPage.command.executeCommand('Comfy.BrowseTemplates') await expect(comfyPage.templates.content).toBeVisible() - const dialog = comfyPage.templatesDialog.root - await expect - .poll(() => - dialog.evaluate((element) => element.getAnimations().length) - ) - .toBe(0) - const withoutPanel = await dialog.boundingBox() - if (!withoutPanel) throw new Error('Templates dialog is not laid out') - - await publishWorkspaceInsetRight( + await expectDialogHoldsSizeWhenPanelDocks( comfyPage.page, - DOCKED_AGENT_PANEL_WIDTH - ) - - await expect(dialog).toHaveBounds( - { - ...withoutPanel, - x: Math.max( - await dialogViewportGutter(comfyPage.page), - (width - DOCKED_AGENT_PANEL_WIDTH - withoutPanel.width) / 2 - ) - }, - { numDigits: 1 } + comfyPage.templatesDialog.root, + width ) }) }) @@ -59,42 +43,31 @@ test.describe('Dialog layout against the docked Agent panel', () => { }) test.describe('a dialog sized by its size variant', () => { - const width = 800 - test.use({ viewport: { width, height: 800 } }) + for (const { room, width } of sizeVariantViewports) { + test.describe(`on a viewport ${room}`, () => { + test.use({ viewport: { width, height: 800 } }) - test('keeps the width its variant asks for', async ({ comfyPage }) => { - await comfyPage.page.evaluate(() => { - window - .app!.extensionManager.dialog.confirm({ - title: 'Confirm', - type: 'default', - message: 'Does this dialog keep its width?' + test('keeps the width its variant asks for', async ({ comfyPage }) => { + await comfyPage.page.evaluate(() => { + window + .app!.extensionManager.dialog.confirm({ + title: 'Confirm', + type: 'default', + message: 'Does this dialog keep its width?' + }) + .catch(() => {}) }) - .catch(() => {}) - }) - const dialog = comfyPage.confirmDialog.root - await expect(dialog).toBeVisible() - await expect - .poll(() => - dialog.evaluate((element) => element.getAnimations().length) - ) - .toBe(0) - const withoutPanel = await dialog.boundingBox() - if (!withoutPanel) throw new Error('Confirm dialog is not laid out') + const dialog = comfyPage.confirmDialog.root + await expect(dialog).toBeVisible() - await publishWorkspaceInsetRight(comfyPage.page, DOCKED_AGENT_PANEL_WIDTH) - - await expect(dialog).toHaveBounds( - { - ...withoutPanel, - x: Math.max( - await dialogViewportGutter(comfyPage.page), - (width - DOCKED_AGENT_PANEL_WIDTH - withoutPanel.width) / 2 + await expectDialogHoldsSizeWhenPanelDocks( + comfyPage.page, + dialog, + width ) - }, - { numDigits: 1 } - ) - }) + }) + }) + } }) }) From 90d8854ea4e895a9714eb9b76cc58feab271e3d0 Mon Sep 17 00:00:00 2001 From: bymyself Date: Sat, 3 Oct 2026 10:33:45 +0000 Subject: [PATCH 03/10] fix(dialog): clamp overridden widths to viewport https://github.com/Comfy-Org/ComfyUI_frontend/pull/20002#discussion_r4172725565 --- src/components/ui/dialog/dialog.variants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ui/dialog/dialog.variants.ts b/src/components/ui/dialog/dialog.variants.ts index db45a173639..a16476b88ee 100644 --- a/src/components/ui/dialog/dialog.variants.ts +++ b/src/components/ui/dialog/dialog.variants.ts @@ -14,7 +14,7 @@ export const dialogContentVariants = cva({ maximized: { true: 'inset-2 top-2 left-2 size-auto max-h-none max-w-none sm:max-w-none', false: - 'top-1/2 left-1/2 max-h-[85vh] w-[calc(100vw-1rem)] translate-x-[max(calc(0.5rem-50vw),calc(-50%-var(--workspace-inset-right,0px)/2))] -translate-y-1/2' + 'top-1/2 left-1/2 max-h-[85vh] w-[calc(100vw-1rem)] translate-x-[max(calc(0.5rem-50%),calc(-50%-var(--workspace-inset-right,0px)/2))] -translate-y-1/2' } }, defaultVariants: { From 902eb431e15580fe96cde22543924301a2b09071 Mon Sep 17 00:00:00 2001 From: bymyself Date: Sat, 3 Oct 2026 10:33:45 +0000 Subject: [PATCH 04/10] test: share the agent panel minimum width Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/20002#discussion_r4172725575 --- browser_tests/fixtures/utils/workspaceInset.ts | 8 +++----- .../extensions/agent/stores/agent/agentPanelConstants.ts | 1 + .../extensions/agent/stores/agent/agentPanelStore.ts | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 src/workbench/extensions/agent/stores/agent/agentPanelConstants.ts diff --git a/browser_tests/fixtures/utils/workspaceInset.ts b/browser_tests/fixtures/utils/workspaceInset.ts index 7aa8463e89e..35ccbaeaee7 100644 --- a/browser_tests/fixtures/utils/workspaceInset.ts +++ b/browser_tests/fixtures/utils/workspaceInset.ts @@ -1,11 +1,9 @@ import type { Locator, Page } from '@playwright/test' import { WORKSPACE_INSET_RIGHT } from '@/composables/useWorkspaceInset' +import { PANEL_MIN_WIDTH } from '@/workbench/extensions/agent/stores/agent/agentPanelConstants' import { comfyExpect } from '@e2e/fixtures/utils/customMatchers' -/** `PANEL_MIN_WIDTH` in `agentPanelStore` — the narrowest docked Agent panel. */ -const DOCKED_AGENT_PANEL_WIDTH = 420 - /** Half of the `1rem` gutter `dialogContentVariants` reserves around a dialog. */ async function dialogViewportGutter(page: Page): Promise { return page.evaluate( @@ -48,14 +46,14 @@ export async function expectDialogHoldsSizeWhenPanelDocks( const withoutPanel = await dialog.boundingBox() if (!withoutPanel) throw new Error('Dialog is not laid out') - await publishWorkspaceInsetRight(page, DOCKED_AGENT_PANEL_WIDTH) + await publishWorkspaceInsetRight(page, PANEL_MIN_WIDTH) await comfyExpect(dialog).toHaveBounds( { ...withoutPanel, x: Math.max( await dialogViewportGutter(page), - (viewportWidth - DOCKED_AGENT_PANEL_WIDTH - withoutPanel.width) / 2 + (viewportWidth - PANEL_MIN_WIDTH - withoutPanel.width) / 2 ) }, { numDigits: 1 } diff --git a/src/workbench/extensions/agent/stores/agent/agentPanelConstants.ts b/src/workbench/extensions/agent/stores/agent/agentPanelConstants.ts new file mode 100644 index 00000000000..bfbd3d84cc0 --- /dev/null +++ b/src/workbench/extensions/agent/stores/agent/agentPanelConstants.ts @@ -0,0 +1 @@ +export const PANEL_MIN_WIDTH = 420 diff --git a/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts b/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts index 83bf627c02a..0fbdb428082 100644 --- a/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts +++ b/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts @@ -16,7 +16,8 @@ import type { ComfyWorkflow } from '@/platform/workflow/management/stores/comfyW import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { api } from '@/scripts/api' -const PANEL_MIN_WIDTH = 420 +import { PANEL_MIN_WIDTH } from './agentPanelConstants' + const PANEL_MAX_WIDTH = 960 const OPEN_STORAGE_KEY = 'Comfy.AgentPanel.open' const DISCOVERED_STORAGE_KEY = 'Comfy.AgentPanel.discovered' From 79bb5fc0096805c1a2d7166663947a4fe86540e8 Mon Sep 17 00:00:00 2001 From: bymyself Date: Sat, 3 Oct 2026 10:34:02 +0000 Subject: [PATCH 05/10] fix(dialog): isolate horizontal inset transform https://github.com/Comfy-Org/ComfyUI_frontend/pull/20002#discussion_r4172725566 --- src/components/ui/dialog/dialog.variants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ui/dialog/dialog.variants.ts b/src/components/ui/dialog/dialog.variants.ts index a16476b88ee..97b5fbfeb16 100644 --- a/src/components/ui/dialog/dialog.variants.ts +++ b/src/components/ui/dialog/dialog.variants.ts @@ -14,7 +14,7 @@ export const dialogContentVariants = cva({ maximized: { true: 'inset-2 top-2 left-2 size-auto max-h-none max-w-none sm:max-w-none', false: - 'top-1/2 left-1/2 max-h-[85vh] w-[calc(100vw-1rem)] translate-x-[max(calc(0.5rem-50%),calc(-50%-var(--workspace-inset-right,0px)/2))] -translate-y-1/2' + 'top-1/2 left-1/2 max-h-[85vh] w-[calc(100vw-1rem)] -translate-y-1/2 transform-[translateX(max(calc(0.5rem-50%),calc(-50%-var(--workspace-inset-right,0px)/2)))]' } }, defaultVariants: { From 2a0cacb0ee094fb3e31629ba3740fd2abc2848ca Mon Sep 17 00:00:00 2001 From: Glary Bot Date: Sat, 3 Oct 2026 13:31:32 +0000 Subject: [PATCH 06/10] fix(dialog): keep the inset offset on translate and cap the gutter Two follow-ups to the review crossed wires. 90d8854 changed the clamp floor to calc(0.5rem-50%). In translate-x a percentage resolves against the dialog, not the viewport, so the floor reduces to -W/2 + 8px and always beats -W/2 - inset/2: the inset term became unreachable and every dialog sat 8px right of centre whether or not a panel was docked. 79bb5fc moved the offset onto transform. The variant's own animate-in zoom keyframes write transform wholesale, so the offset was animated up from zero and a 1296px dialog entered 544px off the right edge before settling. A malformed inset can now invalidate both axes again, which is what that commit set out to avoid, but no publisher can emit one: agentPanelStore derives the width from clamp() over finite numbers. The floor is back on the viewport (50vw) and capped by the slack the dialog leaves, so a dialog exactly as wide as the viewport pins flush at 0 instead of hanging 8px off the right. Adds an entrance test that samples every frame; settled geometry cannot see the transform regression, which is how it got through. --- .../fixtures/utils/workspaceInset.ts | 49 +++++++++++++++++-- .../dialogs/dialogAgentPanelInset.spec.ts | 48 +++++++++++++++++- src/components/ui/dialog/dialog.variants.ts | 2 +- 3 files changed, 94 insertions(+), 5 deletions(-) diff --git a/browser_tests/fixtures/utils/workspaceInset.ts b/browser_tests/fixtures/utils/workspaceInset.ts index 35ccbaeaee7..af6d8cc36fa 100644 --- a/browser_tests/fixtures/utils/workspaceInset.ts +++ b/browser_tests/fixtures/utils/workspaceInset.ts @@ -32,8 +32,9 @@ async function publishWorkspaceInsetRight( /** * Measures an open dialog, docks a panel beside it, and requires the box to * keep every dimension while moving to the one position the layout allows: - * centred in what the panel leaves, or the viewport gutter when that is less - * than nothing. + * centred in what the panel leaves, floored at the gutter, and the gutter + * itself capped by whatever slack the dialog leaves inside the viewport — a + * dialog as wide as the viewport has none to give. */ export async function expectDialogHoldsSizeWhenPanelDocks( page: Page, @@ -48,14 +49,56 @@ export async function expectDialogHoldsSizeWhenPanelDocks( await publishWorkspaceInsetRight(page, PANEL_MIN_WIDTH) + const gutter = await dialogViewportGutter(page) await comfyExpect(dialog).toHaveBounds( { ...withoutPanel, x: Math.max( - await dialogViewportGutter(page), + Math.min(gutter, viewportWidth - withoutPanel.width), (viewportWidth - PANEL_MIN_WIDTH - withoutPanel.width) / 2 ) }, { numDigits: 1 } ) } + +/** + * Opens a dialog and watches every frame of its entrance. Settled geometry + * cannot see this: the zoom keyframes write `transform` wholesale, so a + * horizontal offset parked on that property is animated up from zero and the + * dialog flies in from off-screen before landing in the right place. + */ +export async function expectDialogEntersOnScreen( + page: Page, + contentClass: string +): Promise { + const excursionPx = await page.evaluate(async (cls) => { + const key = 'enter-animation-probe' + window.app!.extensionManager.dialog.showLayoutDialog({ + key, + component: { setup: () => () => null }, + props: {}, + dialogComponentProps: { contentClass: cls } + }) + const startedAt = performance.now() + let worst = 0 + await new Promise((resolve) => { + const sample = () => { + const element = document.querySelector(`[data-dialog-key="${key}"]`) + if (element) { + const { left, right } = element.getBoundingClientRect() + worst = Math.max(worst, -left, right - window.innerWidth) + } + if (performance.now() - startedAt < 300) requestAnimationFrame(sample) + else resolve() + } + requestAnimationFrame(sample) + }) + return worst + }, contentClass) + + comfyExpect( + excursionPx, + 'pixels the dialog left the viewport while opening' + ).toBeLessThanOrEqual(1) +} diff --git a/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts index e4fca4b37f5..c65ffb8f90e 100644 --- a/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts +++ b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts @@ -2,7 +2,10 @@ import { comfyExpect as expect, comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' -import { expectDialogHoldsSizeWhenPanelDocks } from '@e2e/fixtures/utils/workspaceInset' +import { + expectDialogEntersOnScreen, + expectDialogHoldsSizeWhenPanelDocks +} from '@e2e/fixtures/utils/workspaceInset' /** * A docked Agent panel publishes its width as `--workspace-inset-right`, and @@ -70,4 +73,47 @@ test.describe('Dialog layout against the docked Agent panel', () => { }) } }) + + /** + * `useManagerSurveyDialog` ships `w-full` with no unprefixed `max-w-*`, so + * below `sm` it is exactly as wide as the viewport and has no slack to spend + * on the gutter the clamp would otherwise hold back. + */ + test.describe('a dialog as wide as the viewport', () => { + const width = 600 + test.use({ viewport: { width, height: 800 } }) + + test('sits flush rather than hanging off the edge', async ({ + comfyPage + }) => { + await comfyPage.page.evaluate(() => { + window.app!.extensionManager.dialog.showLayoutDialog({ + key: 'viewport-wide-dialog', + component: { setup: () => () => null }, + props: {}, + dialogComponentProps: { + contentClass: 'w-full sm:max-w-lg rounded-2xl overflow-hidden' + } + }) + }) + + const dialog = comfyPage.page.locator( + '[data-dialog-key="viewport-wide-dialog"]' + ) + await expect(dialog).toBeVisible() + + await expectDialogHoldsSizeWhenPanelDocks(comfyPage.page, dialog, width) + }) + }) + + test.describe('every dialog, while it opens', () => { + test.use({ viewport: { width: 1440, height: 900 } }) + + test('never leaves the viewport mid-animation', async ({ comfyPage }) => { + await expectDialogEntersOnScreen( + comfyPage.page, + 'w-[90vw] max-w-[1400px] sm:max-w-[1400px] h-[80vh]' + ) + }) + }) }) diff --git a/src/components/ui/dialog/dialog.variants.ts b/src/components/ui/dialog/dialog.variants.ts index 97b5fbfeb16..d2b942525b8 100644 --- a/src/components/ui/dialog/dialog.variants.ts +++ b/src/components/ui/dialog/dialog.variants.ts @@ -14,7 +14,7 @@ export const dialogContentVariants = cva({ maximized: { true: 'inset-2 top-2 left-2 size-auto max-h-none max-w-none sm:max-w-none', false: - 'top-1/2 left-1/2 max-h-[85vh] w-[calc(100vw-1rem)] -translate-y-1/2 transform-[translateX(max(calc(0.5rem-50%),calc(-50%-var(--workspace-inset-right,0px)/2)))]' + 'top-1/2 left-1/2 max-h-[85vh] w-[calc(100vw-1rem)] translate-x-[max(calc(min(0.5rem,100vw-100%)-50vw),calc(-50%-var(--workspace-inset-right,0px)/2))] -translate-y-1/2' } }, defaultVariants: { From aab99d06c795f4eefc8dfa9bae79efd757f2e632 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 3 Oct 2026 07:55:46 -0700 Subject: [PATCH 07/10] test(dialog): require entrance probe to observe dialog --- browser_tests/fixtures/utils/workspaceInset.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/browser_tests/fixtures/utils/workspaceInset.ts b/browser_tests/fixtures/utils/workspaceInset.ts index af6d8cc36fa..accb04bc727 100644 --- a/browser_tests/fixtures/utils/workspaceInset.ts +++ b/browser_tests/fixtures/utils/workspaceInset.ts @@ -72,7 +72,7 @@ export async function expectDialogEntersOnScreen( page: Page, contentClass: string ): Promise { - const excursionPx = await page.evaluate(async (cls) => { + const { excursionPx, observed } = await page.evaluate(async (cls) => { const key = 'enter-animation-probe' window.app!.extensionManager.dialog.showLayoutDialog({ key, @@ -82,10 +82,12 @@ export async function expectDialogEntersOnScreen( }) const startedAt = performance.now() let worst = 0 + let observed = false await new Promise((resolve) => { const sample = () => { const element = document.querySelector(`[data-dialog-key="${key}"]`) if (element) { + observed = true const { left, right } = element.getBoundingClientRect() worst = Math.max(worst, -left, right - window.innerWidth) } @@ -94,9 +96,12 @@ export async function expectDialogEntersOnScreen( } requestAnimationFrame(sample) }) - return worst + return { excursionPx: worst, observed } }, contentClass) + comfyExpect(observed, 'dialog was mounted during entrance sampling').toBe( + true + ) comfyExpect( excursionPx, 'pixels the dialog left the viewport while opening' From ba2f360dae6c4456d3ed0ea47989ea438270842e Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Sun, 4 Oct 2026 01:59:32 +0000 Subject: [PATCH 08/10] test(dialog): assert literal positions for real dialogs only Drop the synthetic cases that injected copied contentClass strings, the redundant 1280 and 800 rows, and the expectation that re-derived the CSS clamp. Keep the Agent panel width bounds in the store, since the spec no longer needs the extracted minimum. Amp-Thread-ID: https://ampcode.com/threads/T-01a10306-f9ad-7137-a94e-71043d4f059d --- .../fixtures/utils/workspaceInset.ts | 99 ++---------- .../dialogs/dialogAgentPanelInset.spec.ts | 141 +++++------------- .../agent/stores/agent/agentPanelConstants.ts | 1 - .../agent/stores/agent/agentPanelStore.ts | 3 +- 4 files changed, 47 insertions(+), 197 deletions(-) delete mode 100644 src/workbench/extensions/agent/stores/agent/agentPanelConstants.ts diff --git a/browser_tests/fixtures/utils/workspaceInset.ts b/browser_tests/fixtures/utils/workspaceInset.ts index accb04bc727..d3c1f9604ea 100644 --- a/browser_tests/fixtures/utils/workspaceInset.ts +++ b/browser_tests/fixtures/utils/workspaceInset.ts @@ -1,45 +1,12 @@ import type { Locator, Page } from '@playwright/test' import { WORKSPACE_INSET_RIGHT } from '@/composables/useWorkspaceInset' -import { PANEL_MIN_WIDTH } from '@/workbench/extensions/agent/stores/agent/agentPanelConstants' import { comfyExpect } from '@e2e/fixtures/utils/customMatchers' -/** Half of the `1rem` gutter `dialogContentVariants` reserves around a dialog. */ -async function dialogViewportGutter(page: Page): Promise { - return page.evaluate( - () => parseFloat(getComputedStyle(document.documentElement).fontSize) / 2 - ) -} - -/** - * Declares the inset a docked right-hand surface publishes, standing in for the - * Agent panel so layout can be exercised without the feature flags, consent and - * backend a real panel needs. A real panel owns this property and rewrites it - * whenever it resizes, so measure before resizing the viewport or opening one. - */ -async function publishWorkspaceInsetRight( - page: Page, - widthPx: number -): Promise { - await page.evaluate( - ({ property, widthPx }) => { - document.documentElement.style.setProperty(property, `${widthPx}px`) - }, - { property: WORKSPACE_INSET_RIGHT, widthPx } - ) -} - -/** - * Measures an open dialog, docks a panel beside it, and requires the box to - * keep every dimension while moving to the one position the layout allows: - * centred in what the panel leaves, floored at the gutter, and the gutter - * itself capped by whatever slack the dialog leaves inside the viewport — a - * dialog as wide as the viewport has none to give. - */ -export async function expectDialogHoldsSizeWhenPanelDocks( +export async function expectDialogKeepsSizeWithDockedPanel( page: Page, dialog: Locator, - viewportWidth: number + { panelWidth, x }: { panelWidth: number; x: number } ): Promise { await comfyExpect .poll(() => dialog.evaluate((element) => element.getAnimations().length)) @@ -47,63 +14,15 @@ export async function expectDialogHoldsSizeWhenPanelDocks( const withoutPanel = await dialog.boundingBox() if (!withoutPanel) throw new Error('Dialog is not laid out') - await publishWorkspaceInsetRight(page, PANEL_MIN_WIDTH) - - const gutter = await dialogViewportGutter(page) - await comfyExpect(dialog).toHaveBounds( - { - ...withoutPanel, - x: Math.max( - Math.min(gutter, viewportWidth - withoutPanel.width), - (viewportWidth - PANEL_MIN_WIDTH - withoutPanel.width) / 2 - ) + await page.evaluate( + ({ property, panelWidth }) => { + document.documentElement.style.setProperty(property, `${panelWidth}px`) }, - { numDigits: 1 } + { property: WORKSPACE_INSET_RIGHT, panelWidth } ) -} -/** - * Opens a dialog and watches every frame of its entrance. Settled geometry - * cannot see this: the zoom keyframes write `transform` wholesale, so a - * horizontal offset parked on that property is animated up from zero and the - * dialog flies in from off-screen before landing in the right place. - */ -export async function expectDialogEntersOnScreen( - page: Page, - contentClass: string -): Promise { - const { excursionPx, observed } = await page.evaluate(async (cls) => { - const key = 'enter-animation-probe' - window.app!.extensionManager.dialog.showLayoutDialog({ - key, - component: { setup: () => () => null }, - props: {}, - dialogComponentProps: { contentClass: cls } - }) - const startedAt = performance.now() - let worst = 0 - let observed = false - await new Promise((resolve) => { - const sample = () => { - const element = document.querySelector(`[data-dialog-key="${key}"]`) - if (element) { - observed = true - const { left, right } = element.getBoundingClientRect() - worst = Math.max(worst, -left, right - window.innerWidth) - } - if (performance.now() - startedAt < 300) requestAnimationFrame(sample) - else resolve() - } - requestAnimationFrame(sample) - }) - return { excursionPx: worst, observed } - }, contentClass) - - comfyExpect(observed, 'dialog was mounted during entrance sampling').toBe( - true + await comfyExpect(dialog).toHaveBounds( + { ...withoutPanel, x }, + { numDigits: 1 } ) - comfyExpect( - excursionPx, - 'pixels the dialog left the viewport while opening' - ).toBeLessThanOrEqual(1) } diff --git a/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts index c65ffb8f90e..620bdcf8e32 100644 --- a/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts +++ b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts @@ -2,117 +2,50 @@ import { comfyExpect as expect, comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' -import { - expectDialogEntersOnScreen, - expectDialogHoldsSizeWhenPanelDocks -} from '@e2e/fixtures/utils/workspaceInset' - -/** - * A docked Agent panel publishes its width as `--workspace-inset-right`, and - * dialogs shift left to stay beside it. Opening the panel — which happens - * unprompted for first-time users — must not resize a dialog or push it off - * screen, which inset-aware sizing and an unclamped shift used to do (PM-1865). - */ -const templateViewports = [ - { room: 'too narrow for the dialog beside the panel', width: 1280 }, - { room: 'the width PM-1865 was reported at', width: 1440 }, - { room: 'wide enough for both', width: 1920 } -] - -/** `sm:` applies from 640px, which is where the size variants start to bind. */ -const sizeVariantViewports = [ - { room: 'exactly at the sm breakpoint', width: 640 }, - { room: 'above the sm breakpoint', width: 800 } -] - -test.describe('Dialog layout against the docked Agent panel', () => { - test.describe('the Templates browser, which pins its own max-width', () => { - for (const { room, width } of templateViewports) { - test.describe(`on a viewport ${room}`, () => { - test.use({ viewport: { width, height: 800 } }) - - test('keeps its size and stays on screen', async ({ comfyPage }) => { - await comfyPage.command.executeCommand('Comfy.BrowseTemplates') - await expect(comfyPage.templates.content).toBeVisible() - - await expectDialogHoldsSizeWhenPanelDocks( - comfyPage.page, - comfyPage.templatesDialog.root, - width - ) - }) - }) - } - }) - - test.describe('a dialog sized by its size variant', () => { - for (const { room, width } of sizeVariantViewports) { - test.describe(`on a viewport ${room}`, () => { - test.use({ viewport: { width, height: 800 } }) - - test('keeps the width its variant asks for', async ({ comfyPage }) => { - await comfyPage.page.evaluate(() => { - window - .app!.extensionManager.dialog.confirm({ - title: 'Confirm', - type: 'default', - message: 'Does this dialog keep its width?' - }) - .catch(() => {}) - }) - - const dialog = comfyPage.confirmDialog.root - await expect(dialog).toBeVisible() - - await expectDialogHoldsSizeWhenPanelDocks( - comfyPage.page, - dialog, - width - ) - }) +import { expectDialogKeepsSizeWithDockedPanel } from '@e2e/fixtures/utils/workspaceInset' + +test.describe('Dialog layout with a docked Agent panel', () => { + for (const { viewportWidth, x, outcome } of [ + { viewportWidth: 1440, x: 8, outcome: 'covers the panel from the gutter' }, + { viewportWidth: 1920, x: 50, outcome: 'centres beside the panel' } + ]) { + test.describe(`at a ${viewportWidth}px viewport`, () => { + test.use({ viewport: { width: viewportWidth, height: 800 } }) + + test(`Templates browser keeps its size and ${outcome}`, async ({ + comfyPage + }) => { + await comfyPage.command.executeCommand('Comfy.BrowseTemplates') + await expect(comfyPage.templates.content).toBeVisible() + + await expectDialogKeepsSizeWithDockedPanel( + comfyPage.page, + comfyPage.templatesDialog.root, + { panelWidth: 420, x } + ) }) - } - }) + }) + } - /** - * `useManagerSurveyDialog` ships `w-full` with no unprefixed `max-w-*`, so - * below `sm` it is exactly as wide as the viewport and has no slack to spend - * on the gutter the clamp would otherwise hold back. - */ - test.describe('a dialog as wide as the viewport', () => { - const width = 600 - test.use({ viewport: { width, height: 800 } }) + test.describe('at the sm breakpoint', () => { + test.use({ viewport: { width: 640, height: 800 } }) - test('sits flush rather than hanging off the edge', async ({ - comfyPage - }) => { + test('a size-variant dialog keeps its width', async ({ comfyPage }) => { await comfyPage.page.evaluate(() => { - window.app!.extensionManager.dialog.showLayoutDialog({ - key: 'viewport-wide-dialog', - component: { setup: () => () => null }, - props: {}, - dialogComponentProps: { - contentClass: 'w-full sm:max-w-lg rounded-2xl overflow-hidden' - } - }) + window + .app!.extensionManager.dialog.confirm({ + title: 'Confirm', + type: 'default', + message: 'Does this dialog keep its width?' + }) + .catch(() => {}) }) + await expect(comfyPage.confirmDialog.root).toBeVisible() - const dialog = comfyPage.page.locator( - '[data-dialog-key="viewport-wide-dialog"]' - ) - await expect(dialog).toBeVisible() - - await expectDialogHoldsSizeWhenPanelDocks(comfyPage.page, dialog, width) - }) - }) - - test.describe('every dialog, while it opens', () => { - test.use({ viewport: { width: 1440, height: 900 } }) - - test('never leaves the viewport mid-animation', async ({ comfyPage }) => { - await expectDialogEntersOnScreen( + await expectDialogKeepsSizeWithDockedPanel( comfyPage.page, - 'w-[90vw] max-w-[1400px] sm:max-w-[1400px] h-[80vh]' + comfyPage.confirmDialog.root, + { panelWidth: 420, x: 8 } ) }) }) diff --git a/src/workbench/extensions/agent/stores/agent/agentPanelConstants.ts b/src/workbench/extensions/agent/stores/agent/agentPanelConstants.ts deleted file mode 100644 index bfbd3d84cc0..00000000000 --- a/src/workbench/extensions/agent/stores/agent/agentPanelConstants.ts +++ /dev/null @@ -1 +0,0 @@ -export const PANEL_MIN_WIDTH = 420 diff --git a/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts b/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts index 0fbdb428082..83bf627c02a 100644 --- a/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts +++ b/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts @@ -16,8 +16,7 @@ import type { ComfyWorkflow } from '@/platform/workflow/management/stores/comfyW import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { api } from '@/scripts/api' -import { PANEL_MIN_WIDTH } from './agentPanelConstants' - +const PANEL_MIN_WIDTH = 420 const PANEL_MAX_WIDTH = 960 const OPEN_STORAGE_KEY = 'Comfy.AgentPanel.open' const DISCOVERED_STORAGE_KEY = 'Comfy.AgentPanel.discovered' From 74951c9f43821d3f33fd8318f36b537589bdfa45 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Sun, 4 Oct 2026 02:00:06 +0000 Subject: [PATCH 09/10] refactor(dialog): share the self-styled content class and drop redundant overrides The asset browser's contentClass became identical to SELF_STYLED_PANEL_CONTENT_CLASS once the inset term was removed, and the share dialog's sm:max-w-xl repeats the default md size. Move the shared class presets next to dialogContentVariants so consumers can import them without going through the dialog service. Amp-Thread-ID: https://ampcode.com/threads/T-01a10306-f9ad-7137-a94e-71043d4f059d --- src/components/ui/dialog/dialog.variants.ts | 5 +++++ .../composables/useAssetBrowserDialog.ts | 4 ++-- .../sharing/composables/useShareDialog.ts | 2 +- src/services/dialogService.ts | 22 +++++-------------- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/components/ui/dialog/dialog.variants.ts b/src/components/ui/dialog/dialog.variants.ts index d2b942525b8..24c8db53d24 100644 --- a/src/components/ui/dialog/dialog.variants.ts +++ b/src/components/ui/dialog/dialog.variants.ts @@ -36,3 +36,8 @@ const sizes = [ ] as const satisfies Array export const FOR_STORIES = { sizes } as const + +export const HUG_CONTENT_CLASS = + 'w-fit max-w-[calc(100vw-1rem)] sm:max-w-[calc(100vw-1rem)]' + +export const SELF_STYLED_PANEL_CONTENT_CLASS = `${HUG_CONTENT_CLASS} border-none bg-transparent shadow-none` diff --git a/src/platform/assets/composables/useAssetBrowserDialog.ts b/src/platform/assets/composables/useAssetBrowserDialog.ts index 55f78b75327..e945a304278 100644 --- a/src/platform/assets/composables/useAssetBrowserDialog.ts +++ b/src/platform/assets/composables/useAssetBrowserDialog.ts @@ -1,3 +1,4 @@ +import { SELF_STYLED_PANEL_CONTENT_CLASS } from '@/components/ui/dialog/dialog.variants' import AssetBrowserModal from '@/platform/assets/components/AssetBrowserModal.vue' import type { AssetItem } from '@/platform/assets/schemas/assetSchema' import { useDialogService } from '@/services/dialogService' @@ -25,8 +26,7 @@ interface BrowseOptions { const DIALOG_KEY = 'global-asset-browser' const ASSET_BROWSER_DIALOG_PROPS = { - contentClass: - 'w-fit max-w-[calc(100vw-1rem)] sm:max-w-[calc(100vw-1rem)] border-none bg-transparent shadow-none' + contentClass: SELF_STYLED_PANEL_CONTENT_CLASS } satisfies DialogComponentProps export const useAssetBrowserDialog = () => { diff --git a/src/platform/workflow/sharing/composables/useShareDialog.ts b/src/platform/workflow/sharing/composables/useShareDialog.ts index f1850e78df6..c5430f10d0e 100644 --- a/src/platform/workflow/sharing/composables/useShareDialog.ts +++ b/src/platform/workflow/sharing/composables/useShareDialog.ts @@ -66,7 +66,7 @@ export function useShareDialog() { onClose: hide }, dialogComponentProps: { - contentClass: 'sm:max-w-xl rounded-2xl overflow-hidden' + contentClass: 'rounded-2xl overflow-hidden' } }) } diff --git a/src/services/dialogService.ts b/src/services/dialogService.ts index 821936474aa..491b00df816 100644 --- a/src/services/dialogService.ts +++ b/src/services/dialogService.ts @@ -8,6 +8,10 @@ import ConfirmationDialogContent from '@/components/dialog/content/ConfirmationD import ErrorDialogContent from '@/components/dialog/content/ErrorDialogContent.vue' import PromptDialogContent from '@/components/dialog/content/PromptDialogContent.vue' import TopUpCreditsDialogContentLegacy from '@/components/dialog/content/TopUpCreditsDialogContentLegacy.vue' +import { + HUG_CONTENT_CLASS, + SELF_STYLED_PANEL_CONTENT_CLASS +} from '@/components/ui/dialog/dialog.variants' import InsufficientCreditsMemberDialog from '@/platform/workspace/components/InsufficientCreditsMemberDialog.vue' import TopUpCreditsDialogContentWorkspace from '@/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue' import { useBillingCapabilities } from '@/platform/workspace/composables/useBillingCapabilities' @@ -47,20 +51,6 @@ const lazyCloudNotificationContent = () => const lazyPublishDialog = () => import('@/platform/workflow/sharing/components/publish/ComfyHubPublishDialog.vue') -/** - * Shrink-wrap the Reka DialogContent around the content's intrinsic width, - * like the auto-sized PrimeVue root it replaces. - */ -const HUG_CONTENT_CLASS = - 'w-fit max-w-[calc(100vw-1rem)] sm:max-w-[calc(100vw-1rem)]' - -/** - * Reka chrome for headless dialogs whose content draws its own panel - * (background/border/rounding) — neutralize the DialogContent box and - * shrink-wrap it around the content. - */ -const SELF_STYLED_PANEL_CONTENT_CLASS = `${HUG_CONTENT_CLASS} border-none bg-transparent shadow-none` - // A type alias, not an interface: `showDialog`'s props are index-signature // typed, and only object literal types get an implicit index signature. type TopUpCreditsDialogOptions = { @@ -617,8 +607,6 @@ export const useDialogService = () => { dialogComponentProps: { renderer: 'reka', closable: true, - // Contents bring their own width and separators — shrink-wrap the - // chrome and zero the section padding. contentClass: `${HUG_CONTENT_CLASS} border-border-default`, headerClass: 'p-0', bodyClass: 'p-0 overflow-y-hidden', @@ -1043,7 +1031,7 @@ export const useDialogService = () => { dialogComponentProps: { closable: false, contentClass: - 'w-170 max-w-[calc(100vw-1rem)] sm:max-w-[min(42.5rem,calc(100vw-1rem))] rounded-2xl overflow-hidden', + 'w-170 max-w-[calc(100vw-1rem)] sm:max-w-[calc(100vw-1rem)] rounded-2xl overflow-hidden', onRemoved: () => resolve() } }) From 1d3d36d000a907d84d72e2bd28e7be46282ae5a6 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Sun, 4 Oct 2026 02:08:29 +0000 Subject: [PATCH 10/10] test(dialog): name the docked-panel bounds assertion for what it checks --- browser_tests/fixtures/utils/workspaceInset.ts | 2 +- .../tests/dialogs/dialogAgentPanelInset.spec.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/browser_tests/fixtures/utils/workspaceInset.ts b/browser_tests/fixtures/utils/workspaceInset.ts index d3c1f9604ea..3083bbeabbf 100644 --- a/browser_tests/fixtures/utils/workspaceInset.ts +++ b/browser_tests/fixtures/utils/workspaceInset.ts @@ -3,7 +3,7 @@ import type { Locator, Page } from '@playwright/test' import { WORKSPACE_INSET_RIGHT } from '@/composables/useWorkspaceInset' import { comfyExpect } from '@e2e/fixtures/utils/customMatchers' -export async function expectDialogKeepsSizeWithDockedPanel( +export async function expectDialogBoundsWithDockedPanel( page: Page, dialog: Locator, { panelWidth, x }: { panelWidth: number; x: number } diff --git a/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts index 620bdcf8e32..05aa231254a 100644 --- a/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts +++ b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts @@ -2,7 +2,7 @@ import { comfyExpect as expect, comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' -import { expectDialogKeepsSizeWithDockedPanel } from '@e2e/fixtures/utils/workspaceInset' +import { expectDialogBoundsWithDockedPanel } from '@e2e/fixtures/utils/workspaceInset' test.describe('Dialog layout with a docked Agent panel', () => { for (const { viewportWidth, x, outcome } of [ @@ -18,7 +18,7 @@ test.describe('Dialog layout with a docked Agent panel', () => { await comfyPage.command.executeCommand('Comfy.BrowseTemplates') await expect(comfyPage.templates.content).toBeVisible() - await expectDialogKeepsSizeWithDockedPanel( + await expectDialogBoundsWithDockedPanel( comfyPage.page, comfyPage.templatesDialog.root, { panelWidth: 420, x } @@ -30,7 +30,9 @@ test.describe('Dialog layout with a docked Agent panel', () => { test.describe('at the sm breakpoint', () => { test.use({ viewport: { width: 640, height: 800 } }) - test('a size-variant dialog keeps its width', async ({ comfyPage }) => { + test('a size-variant dialog keeps its width and stops at the gutter', async ({ + comfyPage + }) => { await comfyPage.page.evaluate(() => { window .app!.extensionManager.dialog.confirm({ @@ -42,7 +44,7 @@ test.describe('Dialog layout with a docked Agent panel', () => { }) await expect(comfyPage.confirmDialog.root).toBeVisible() - await expectDialogKeepsSizeWithDockedPanel( + await expectDialogBoundsWithDockedPanel( comfyPage.page, comfyPage.confirmDialog.root, { panelWidth: 420, x: 8 }