From 55f6f81ed4753c6ba251c4137544f16c040b7701 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 20:25:39 +0000 Subject: [PATCH] fix(dialog): keep modal size independent of the docked Agent panel (#20002) *PR Created by the Glary-Bot Agent* --- ## Summary Dialogs no longer resize when the Agent panel is docked, and the panel can no longer push them off the left edge of the screen ([PM-1865](https://linear.app/comfyorg/issue/PM-1865/test-forced-open-agent-panel-overlaps-the-template-pop-up-for-first)). ## Changes - **What**: `dialogContentVariants` read `--workspace-inset-right` in two places: every `size` variant subtracted it from `max-width`, and the `maximized: false` variant shifted the box left by half of it. Large dialogs pin their own `max-width`, so they got the shift without the cap. At 1440px with a 420px panel, Templates rendered at `x = -138`, clipped on the left and still over the panel. - Size variants now resolve against the viewport alone (`sm:max-w-96 / xl / 3xl / 5xl`, the same 24/36/48/64rem), and the four call sites that only used the inset to shrink drop it. - The shift is clamped: `translate-x-[max(calc(min(0.5rem,100vw-100%)-50vw),calc(-50%-var(--workspace-inset-right,0px)/2))]`. A dialog keeps its size. It centres beside the panel when it fits there; otherwise it stops at the viewport gutter and covers the panel. `min(0.5rem,100vw-100%)` lets a viewport-wide dialog sit at `x = 0`. - The offset stays on `translate`: the `zoom-in-95` keyframes write `transform`, so an offset there would animate in from off screen. - `HUG_CONTENT_CLASS` and `SELF_STYLED_PANEL_CONTENT_CLASS` move next to `dialogContentVariants`, because the asset browser's class became identical to the latter. The share dialog drops a `sm:max-w-xl` that repeated the default `md` size. - **Breaking**: no API change; deliberate behaviour change below. ## Review Focus 1. Dialogs may now cover the docked panel instead of shrinking beside it. Keeping a dialog's size and keeping it on screen cannot both clear the panel once `dialogWidth > viewportWidth - panelWidth`. Stacking holds today: the docked panel is `relative` with no z-index, and `DialogContent` is `fixed z-1700`. 2. Two places keep the opposite policy. `load3dViewerDialog.ts` stays inset-aware (#19729; `load3dAgentUpdate.spec.ts` asserts the viewer clears the panel), and its own `max-w` keeps it on the centring branch of the clamp. #19972 would make Settings inset-aware too, and its centering unit test expects an inset-aware `left-*` class that this PR replaces with `left-1/2`, so whichever merges second fails that test. 3. With no panel (inset 0) the clamp resolves to `-50%` for every width the base `w-[calc(100vw-1rem)]` allows, so layout without a panel is unchanged. - Fixes PM-1865 ## Testing `browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts` opens real dialogs, publishes a 420px inset (the seam `toastNotifications.spec.ts` uses), and asserts that the box keeps its size and lands at a literal x: | Dialog | Viewport | x | On `main` | | --- | --- | --- | --- | | Templates | 1440 | 8 (covers the panel from the gutter) | fails, x = -138 | | Templates | 1920 | 50 (centred beside the panel) | passes; fails if the floor always wins | | `md` confirm | 640 | 8, width kept at 576 | fails, width shrinks | Real-dialog coverage for the entrance animation, the viewport-wide survey dialog, and stacking over the real panel is tracked in [FE-3198](https://linear.app/comfyorg/issue/FE-3198/playwright-coverage-of-real-dialogs-under-the-docked-agent-panel). ## Screenshots Simulated 420px docked panel on the right. ![Before, 800px: the md confirm dialog shrinks to 364px beside the panel](https://ampcode.com/user-content/artifacts/1feb3727405cf5cdee49c7a3fee573c63041b807be36abd3d15d423ed83f544e-file.png) ![After, 800px: the md confirm dialog keeps its 576px width and covers the panel](https://ampcode.com/user-content/artifacts/29918fc605682403bae96f34a7d7570b92179509024d5affed316a46876ffa9a-file.png) ![Before, 1440px: Templates is pushed off the left edge while still overlapping the panel](https://pub-1fd11710d4c8405b948c9edc4287a3f2.r2.dev/sessions/9b31e98ca7e309acb186c020df5f79286b2ad7800e7ff65a16b54c3b9b9a5647/pr-images/1791018575552-a0d8ecac-c906-4836-a59a-1f0ce6127b44.png) ![After, 1440px: Templates keeps its size, sits at the 8px gutter, and covers the panel](https://pub-1fd11710d4c8405b948c9edc4287a3f2.r2.dev/sessions/9b31e98ca7e309acb186c020df5f79286b2ad7800e7ff65a16b54c3b9b9a5647/pr-images/1791018575903-2fadafcf-5e68-409d-859e-bf4d98bbdabd.png) ![After, 1920px: Templates keeps its size and centres beside the panel](https://pub-1fd11710d4c8405b948c9edc4287a3f2.r2.dev/sessions/9b31e98ca7e309acb186c020df5f79286b2ad7800e7ff65a16b54c3b9b9a5647/pr-images/1791018576205-5f41a1ee-bf6f-41c8-b753-a553eea441d6.png) --------- Co-authored-by: Glary Bot Co-authored-by: Alexander Brown --- .../fixtures/utils/workspaceInset.ts | 28 ++++++++++ .../dialogs/dialogAgentPanelInset.spec.ts | 54 +++++++++++++++++++ src/components/ui/dialog/dialog.variants.ts | 17 +++--- .../composables/useAssetBrowserDialog.ts | 4 +- .../sharing/composables/useShareDialog.ts | 3 +- src/services/dialogService.ts | 25 +++------ 6 files changed, 102 insertions(+), 29 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..3083bbeabbf --- /dev/null +++ b/browser_tests/fixtures/utils/workspaceInset.ts @@ -0,0 +1,28 @@ +import type { Locator, Page } from '@playwright/test' + +import { WORKSPACE_INSET_RIGHT } from '@/composables/useWorkspaceInset' +import { comfyExpect } from '@e2e/fixtures/utils/customMatchers' + +export async function expectDialogBoundsWithDockedPanel( + page: Page, + dialog: Locator, + { panelWidth, x }: { panelWidth: number; x: 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 page.evaluate( + ({ property, panelWidth }) => { + document.documentElement.style.setProperty(property, `${panelWidth}px`) + }, + { property: WORKSPACE_INSET_RIGHT, panelWidth } + ) + + await comfyExpect(dialog).toHaveBounds( + { ...withoutPanel, x }, + { numDigits: 1 } + ) +} diff --git a/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts new file mode 100644 index 00000000000..05aa231254a --- /dev/null +++ b/browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts @@ -0,0 +1,54 @@ +import { + comfyExpect as expect, + comfyPageFixture as test +} from '@e2e/fixtures/ComfyPage' +import { expectDialogBoundsWithDockedPanel } 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 expectDialogBoundsWithDockedPanel( + comfyPage.page, + comfyPage.templatesDialog.root, + { panelWidth: 420, x } + ) + }) + }) + } + + test.describe('at the sm breakpoint', () => { + test.use({ viewport: { width: 640, height: 800 } }) + + test('a size-variant dialog keeps its width and stops at the gutter', async ({ + comfyPage + }) => { + await comfyPage.page.evaluate(() => { + window + .app!.extensionManager.dialog.confirm({ + title: 'Confirm', + type: 'default', + message: 'Does this dialog keep its width?' + }) + .catch(() => {}) + }) + await expect(comfyPage.confirmDialog.root).toBeVisible() + + await expectDialogBoundsWithDockedPanel( + comfyPage.page, + comfyPage.confirmDialog.root, + { panelWidth: 420, x: 8 } + ) + }) + }) +}) diff --git a/src/components/ui/dialog/dialog.variants.ts b/src/components/ui/dialog/dialog.variants.ts index dbe7ddb99aa..24c8db53d24 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(min(0.5rem,100vw-100%)-50vw),calc(-50%-var(--workspace-inset-right,0px)/2))] -translate-y-1/2' } }, defaultVariants: { @@ -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 44f0b53b7a3..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-var(--workspace-inset-right,0px)-1rem)] sm:max-w-[calc(100vw-var(--workspace-inset-right,0px)-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 4b57e30f52a..c5430f10d0e 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: 'rounded-2xl overflow-hidden' } }) } diff --git a/src/services/dialogService.ts b/src/services/dialogService.ts index cf64b57f3d2..7f08039bdb7 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' @@ -46,20 +50,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 = { @@ -613,10 +603,7 @@ 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: - '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', @@ -982,7 +969,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-[calc(100vw-1rem)] rounded-2xl overflow-hidden', onRemoved: () => resolve() } })