Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions browser_tests/fixtures/utils/workspaceInset.ts
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`)

Copy link
Copy Markdown
Contributor

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-right directly on document.documentElement — the property publishCurrentInset() in src/composables/useWorkspaceInset.ts owns exclusively — and never restores it. Any publisher that mounts, updates, or disposes during the toHaveBounds retry window will setProperty/removeProperty over the simulated value and snap the dialog mid-assertion, and because the real publisher path is never exercised these tests stay green if DockedAgentPanel stops publishing or publishes a stale width. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max adversarial).

},
{ property: WORKSPACE_INSET_RIGHT, panelWidth }
)

await comfyExpect(dialog).toHaveBounds(
{ ...withoutPanel, x },
{ numDigits: 1 }
)
}
54 changes: 54 additions & 0 deletions browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts
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 } })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Nit — A 640px viewport sits exactly on the sm breakpoint, and the assertion cannot tell whether the size variant applied: width/height/y come from the pre-change measurement and only x is checked against a literal, which is 8 either way. Pick a width comfortably above 640px so the test actually exercises the sm:max-w-* variant it is named for. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max edge-case).


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 }
)
})
})
})
17 changes: 11 additions & 6 deletions src/components/ui/dialog/dialog.variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Nit — sm:max-w-96 is a numeric spacing token that tailwind-merge v2's max-w group does not recognise (it matches keywords, t-shirt sizes, and arbitrary values only), so a caller's conflicting sm:max-w-* will no longer be deduped against it and CSS source order picks the winner — the old arbitrary value merged correctly. sm:max-w-sm is the same 24rem and keeps the merge working; the other four sizes use t-shirt tokens and are fine. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max adversarial).

md: 'sm:max-w-xl',
lg: 'sm:max-w-3xl',
xl: 'sm:max-w-5xl',
full: 'sm:max-w-[calc(100vw-1rem)]'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — Dropping the inset from the full cap means a full-size dialog is now 100vw - 1rem wide, which is wider than the space left of a docked panel, so the new translate-x clamps it to the 8px gutter and it renders straight over the panel instead of shrinking to fit beside it. The Load3D viewer is the concrete case: LOAD3D_VIEWER_CONTENT_CLASS carries only an unprefixed inset-aware max-w, so above sm this variant's sm:max-w-[calc(100vw-1rem)] wins and the viewer sits at a full 80vw overlapping the panel (≈140px at a 1440px viewport with a 420px panel); its guard test runs at 500px, below sm, so it stays green. Keep calc(100vw-var(--workspace-inset-right,0px)-1rem) for full, or clamp the width rather than only the offset. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max edge-case).

},
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'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — Moving the inset offset from left into translate-x turns the left-1/2 in four untouched call sites (src/services/hdrViewerService.ts, AssetsSidebarTab.vue, JobHistorySidebarTab.vue, ReplyAssetGroup.vue) into a no-op dedupe of the variant's own class — those classes only ever existed to override the old left-[calc(50%-var(--workspace-inset-right,0px)/2)]. Those media viewers now pick up the inset shift and gutter clamp they previously opted out of, and there is no longer any class a caller can pass to opt out. Either delete the dead left-1/2 overrides deliberately or keep an opt-out hook. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).

}
},
defaultVariants: {
Expand All @@ -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`
4 changes: 2 additions & 2 deletions src/platform/assets/composables/useAssetBrowserDialog.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 = () => {
Expand Down
3 changes: 1 addition & 2 deletions src/platform/workflow/sharing/composables/useShareDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
})
}
Expand Down
25 changes: 6 additions & 19 deletions src/services/dialogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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()
}
})
Expand Down
Loading