Repository navigation
[backport cloud/1.55] fix(dialog): keep modal size independent of the docked Agent panel #20126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<void> { | ||
| 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 } | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 } }) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Nit — A 640px viewport sits exactly on the |
||
|
|
||
| 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 } | ||
| ) | ||
| }) | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Nit — |
||
| md: 'sm:max-w-xl', | ||
| lg: 'sm:max-w-3xl', | ||
| xl: 'sm:max-w-5xl', | ||
| full: 'sm:max-w-[calc(100vw-1rem)]' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium — Dropping the inset from the |
||
| }, | ||
| 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' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟢 Low — Moving the inset offset from |
||
| } | ||
| }, | ||
| defaultVariants: { | ||
|
|
@@ -36,3 +36,8 @@ const sizes = [ | |
| ] as const satisfies Array<DialogContentSize> | ||
|
|
||
| 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` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Low — The fixture sets
--workspace-inset-rightdirectly ondocument.documentElement— the propertypublishCurrentInset()insrc/composables/useWorkspaceInset.tsowns exclusively — and never restores it. Any publisher that mounts, updates, or disposes during thetoHaveBoundsretry window willsetProperty/removePropertyover the simulated value and snap the dialog mid-assertion, and because the real publisher path is never exercised these tests stay green ifDockedAgentPanelstops publishing or publishes a stale width. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max adversarial).