diff --git a/.oxlintrc.json b/.oxlintrc.json index 1a068966ea6..09b223ff419 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -172,7 +172,7 @@ } }, { - "files": ["tools/test-recorder/**/*.ts"], + "files": ["tools/test-recorder/**/*.ts", "apps/*/scripts/**/*.ts"], "rules": { "no-console": "allow" } diff --git a/apps/website/e2e/fixtures/blockExternalMedia.ts b/apps/website/e2e/fixtures/blockExternalMedia.ts index 9d34ee3f906..a04ac0ffb03 100644 --- a/apps/website/e2e/fixtures/blockExternalMedia.ts +++ b/apps/website/e2e/fixtures/blockExternalMedia.ts @@ -27,7 +27,7 @@ const EMBED_HOSTS = new Set([ 'demo.arcade.software' ]) const MEDIA_PATTERN = - /^https:\/\/(media|comfy-hub-assets)\.comfy\.org\/.*\.(webp|webm|mp4|png|jpg|jpeg|gif|avif|vtt)(\?.*)?$/i + /^https:\/\/((media|comfy-hub-assets)\.comfy\.org|raw\.githubusercontent\.com)\/.*\.(webp|webm|mp4|png|jpg|jpeg|gif|avif|vtt)(\?.*)?$/i const NODE_IMAGE_HOSTS = new Set([ 'avatars.githubusercontent.com', 'raw.githubusercontent.com' diff --git a/apps/website/e2e/homepage.spec.ts b/apps/website/e2e/homepage.spec.ts index 8b6330f6ed9..e0c631851c1 100644 --- a/apps/website/e2e/homepage.spec.ts +++ b/apps/website/e2e/homepage.spec.ts @@ -41,7 +41,24 @@ test.describe('Homepage @smoke', () => { await expect(activeSlide.getByText('New Model Release')).toBeVisible() const cta = activeSlide.getByRole('link', { name: 'Explore Seedance 2.5' }) await expect(cta).toBeVisible() - await expect(cta).toHaveAttribute('href', '/seedance-2.5') + await expect(cta).toHaveAttribute('href', '/models/seedance-2/') + }) + + test('ModelDiscoverySection links providers to the Workshop', async ({ + page + }) => { + const section = page.getByTestId('model-discovery') + await expect( + section.getByRole('heading', { name: /ready to run/i }) + ).toBeVisible() + const bytedance = section.getByRole('link', { name: /ByteDance/ }).first() + await expect(bytedance).toHaveAttribute( + 'href', + '/models?provider=ByteDance' + ) + await expect( + section.getByRole('link', { name: 'Browse all models' }) + ).toHaveAttribute('href', '/models') }) test('FeaturedWorkflowsSection carousel is visible', async ({ page }) => { diff --git a/apps/website/e2e/navigation.spec.ts b/apps/website/e2e/navigation.spec.ts index ce0a3ed0823..770ec3aa8be 100644 --- a/apps/website/e2e/navigation.spec.ts +++ b/apps/website/e2e/navigation.spec.ts @@ -8,6 +8,7 @@ const minimaxRoute = '/minimax-h3' const minimaxRouteZh = '/zh-CN/minimax-h3' const TOP_LEVEL_LABELS = [ + 'Models', 'Products', 'Pricing', 'Community', @@ -36,10 +37,18 @@ test.describe('Desktop navigation @smoke', () => { } }) - test('NEW badge shows on Products and Community only', async ({ page }) => { + test('NEW badge shows on Workshop, Products and Community only', async ({ + page + }) => { + await page.setViewportSize({ width: 1600, height: 900 }) const nav = page.getByRole('navigation', { name: 'Main navigation' }) const desktopLinks = nav.getByTestId('desktop-nav-links') + await expect( + desktopLinks + .getByRole('link', { name: 'Models' }) + .getByText('NEW', { exact: true }) + ).toBeVisible() for (const label of ['Products', 'Community']) { await expect( desktopLinks @@ -137,16 +146,23 @@ test.describe('Mobile menu @mobile', () => { const menu = page.getByRole('dialog') await expect(menu).toBeVisible() - for (const label of ['Products', 'Pricing', 'Community']) { + for (const label of ['Models', 'Products', 'Pricing', 'Community']) { await expect(menu.getByText(label, { exact: true }).first()).toBeVisible() } }) - test('NEW badge shows on Products and Community only', async ({ page }) => { + test('NEW badge shows on Workshop, Products and Community only', async ({ + page + }) => { await page.getByRole('button', { name: 'Toggle menu' }).click() const menu = page.getByRole('dialog') + await expect( + menu.getByRole('link', { name: 'Models' }).getByText('NEW', { + exact: true + }) + ).toBeVisible() for (const label of ['Products', 'Community']) { await expect( menu.getByRole('button', { name: label }).getByText('NEW', { diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/about-hero-1-sm-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/about-hero-1-sm-visual-linux.png index 25d1fda66b4..c2bd126ee0a 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/about-hero-1-sm-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/about-hero-1-sm-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/about-hero-2-md-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/about-hero-2-md-visual-linux.png index 29da52b6b9b..bcd302b04e2 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/about-hero-2-md-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/about-hero-2-md-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/contact-form-1-sm-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/contact-form-1-sm-visual-linux.png index 8d7b9645e70..b68a8d2102b 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/contact-form-1-sm-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/contact-form-1-sm-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/contact-form-2-md-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/contact-form-2-md-visual-linux.png index 5ad07f04eaa..25b46c5405e 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/contact-form-2-md-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/contact-form-2-md-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-1-sm-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-1-sm-visual-linux.png index ca89f831394..e092fdee821 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-1-sm-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-1-sm-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-2-md-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-2-md-visual-linux.png index fa3c625eebe..d21d7d0bb5b 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-2-md-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-2-md-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-3-lg-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-3-lg-visual-linux.png index fd681633ae0..dc408631ec7 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-3-lg-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-3-lg-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-4-xl-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-4-xl-visual-linux.png index 65fe7ad8872..0b630dbe893 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-4-xl-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/enterprise-faq-4-xl-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/gallery-grid-1-sm-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/gallery-grid-1-sm-visual-linux.png index ac2fc80fea7..7ad309270f2 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/gallery-grid-1-sm-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/gallery-grid-1-sm-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/gallery-grid-2-md-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/gallery-grid-2-md-visual-linux.png index 2de5bcb9014..5433f6661a0 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/gallery-grid-2-md-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/gallery-grid-2-md-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-1-sm-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-1-sm-visual-linux.png index 08973313b5f..d47d38148cf 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-1-sm-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-1-sm-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-2-md-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-2-md-visual-linux.png index 7fc6c2c8842..f6955a7ac54 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-2-md-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-2-md-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-3-lg-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-3-lg-visual-linux.png index d85731630c2..2e6d4a0c676 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-3-lg-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-3-lg-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-4-xl-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-4-xl-visual-linux.png index fcd7fe5060e..7d660642e9a 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-4-xl-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-get-started-4-xl-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-1-sm-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-1-sm-visual-linux.png index 5e38023903b..7793d57c4d6 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-1-sm-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-1-sm-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-2-md-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-2-md-visual-linux.png index 5674ea39cfa..faa2833b75a 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-2-md-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-2-md-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-3-lg-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-3-lg-visual-linux.png index 7c809c7fc1c..caffe975b1a 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-3-lg-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-3-lg-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-4-xl-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-4-xl-visual-linux.png index 3910ab485f8..242138f1a6f 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-4-xl-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/home-product-cards-4-xl-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-1-sm-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-1-sm-visual-linux.png index bf2aaefc552..6e76eef4dd4 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-1-sm-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-1-sm-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-2-md-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-2-md-visual-linux.png index 3454d8def4e..b0cf2213409 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-2-md-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-2-md-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-3-lg-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-3-lg-visual-linux.png index 5f868fd4fad..6e92b156d5b 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-3-lg-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-3-lg-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-4-xl-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-4-xl-visual-linux.png index 64500b36ba5..669cb829268 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-4-xl-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-faq-4-xl-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-1-sm-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-1-sm-visual-linux.png index 60dc78ca478..89e52248abd 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-1-sm-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-1-sm-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-2-md-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-2-md-visual-linux.png index 51489e13d19..2aa02c72a56 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-2-md-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-2-md-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-3-lg-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-3-lg-visual-linux.png index d84e300eaa4..991629dde41 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-3-lg-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-3-lg-visual-linux.png differ diff --git a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-4-xl-visual-linux.png b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-4-xl-visual-linux.png index 0eb4a7da73a..f61a755e2e3 100644 Binary files a/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-4-xl-visual-linux.png and b/apps/website/e2e/visual-responsive.spec.ts-snapshots/pricing-tiers-4-xl-visual-linux.png differ diff --git a/apps/website/e2e/workshop.spec.ts b/apps/website/e2e/workshop.spec.ts new file mode 100644 index 00000000000..204930b3c0f --- /dev/null +++ b/apps/website/e2e/workshop.spec.ts @@ -0,0 +1,390 @@ +import type { Page } from '@playwright/test' +import { expect } from '@playwright/test' + +import { test } from './fixtures/blockExternalMedia' + +const MODEL_PATH = '/models/openai-dall-e/' + +async function useAccount(page: Page, kind: 'new' | 'existing') { + await page.getByTestId('prototype-tweaks').click() + await page.getByTestId('tweak-session').selectOption(kind) + await page.keyboard.press('Escape') +} + +test.describe('Workshop V2', () => { + test.beforeEach(async ({ page }) => { + await page.addInitScript(() => + localStorage.setItem('comfy-workshop-version', 'v2') + ) + }) + + test('mirrors comfy.org/workflows and links partner models to their page', async ({ + page + }) => { + await page.goto('/models/') + const hub = page.getByTestId('workshop-hub') + await expect(hub.getByTestId('hub-heading')).toContainText('Browse models') + await expect(hub.getByTestId('hub-use-case-generate-images')).toBeVisible() + await expect(hub.getByTestId('hub-card').first()).toBeVisible() + await hub.getByTestId('hub-tab-comfyApps').click() + await expect(hub.getByTestId('hub-card').first()).toHaveAttribute( + 'data-app', + 'true' + ) + await hub.getByTestId('hub-tab-all').click() + await hub.getByTestId('workshop-search').fill('minimax h3') + await expect(hub.getByTestId('hub-card-link').first()).toContainText( + 'MiniMax H3' + ) + await hub.getByTestId('hub-filter').click() + await page.getByTestId('hub-facet-models').click() + await page.getByRole('option', { name: 'Flux', exact: true }).click() + await expect(hub.getByTestId('hub-filter-count')).toHaveText('1') + }) + + test('workflow cards open a detail page with the model playground', async ({ + page + }) => { + await page.goto('/models/?q=minimax%20h3') + const hub = page.getByTestId('workshop-hub') + await hub.getByTestId('hub-card-link').first().click() + await page.waitForURL(/\/models\/workflows\/video_minimax_h3_i2v\/?$/) + await expect(page.getByRole('heading', { level: 1 })).toContainText( + 'MiniMax H3' + ) + await expect(page.getByTestId('playground-tab')).toBeVisible() + await expect(page.getByTestId('clone-button')).toHaveAttribute( + 'href', + /video_minimax_h3_i2v\.json$/ + ) + await page.getByTestId('tab-details').click() + await expect(page.getByTestId('workflow-io')).toContainText('image') + await expect( + page.getByTestId('related-workflows').getByTestId('hub-card') + ).toHaveCount(8) + }) +}) + +test.describe('Workshop catalog', () => { + test('lists partner models by what they do and filters by search', async ({ + page + }) => { + await page.goto('/models/?version=v1.2') + const grid = page.getByTestId('workshop-models-grid') + const cards = grid.getByTestId('workshop-model-card') + await expect(cards.first()).toBeVisible() + await expect(page.getByTestId('workshop-tabs')).toHaveCount(0) + + const all = await cards.count() + await page.getByTestId('use-case-edit-images').click() + await expect(cards.first()).toBeVisible() + expect(await cards.count()).toBeLessThan(all) + await page.getByTestId('use-case-all').click() + await expect(cards).toHaveCount(all) + + await page.getByTestId('workshop-search').fill('kling') + await expect(cards.first()).toContainText('Kling') + + await page.getByTestId('workshop-search').fill('no such model') + await expect(page.getByTestId('workshop-empty')).toBeVisible() + await page.getByRole('button', { name: 'Clear filters' }).click() + await expect(cards.first()).toBeVisible() + }) + + test('the rows listing browses category rows and drills into one', async ({ + page + }) => { + await page.goto('/models/') + const sections = page.getByTestId('workshop-sections') + await expect(sections).toBeVisible() + await expect(page.getByTestId('workshop-use-cases')).toHaveCount(0) + + const videos = page.getByTestId('section-generate-videos') + const rowHeading = await videos + .getByRole('heading', { level: 2 }) + .innerText() + const promisedCount = Number(rowHeading.match(/(\d+)\s*$/)?.[1]) + const rowLabel = rowHeading.replace(/\s*\d+\s*$/, '').trim() + expect(promisedCount).toBeGreaterThan(0) + + await videos.getByTestId('section-generate-videos-open').click() + + const cards = page + .getByTestId('workshop-models-grid') + .getByTestId('workshop-model-card') + await expect(sections).toHaveCount(0) + await expect(cards).toHaveCount(promisedCount) + await expect(page.getByTestId('workshop-use-cases')).toHaveCount(0) + await expect(page.getByTestId('workshop-hero')).toHaveCount(0) + await expect(page.getByRole('heading', { level: 1 })).toContainText( + rowLabel + ) + + await page.getByTestId('section-back').click() + await expect(page.getByTestId('workshop-sections')).toBeVisible() + await expect(page.getByTestId('workshop-hero')).toBeVisible() + }) + + test('the rows listing opens the whole catalogue', async ({ page }) => { + await page.goto('/models/') + await page.getByTestId('browse-all').click() + + await expect(page.getByTestId('workshop-sections')).toHaveCount(0) + const heading = page.getByRole('heading', { level: 1 }) + await expect(heading).toContainText('All models') + const promisedCount = Number( + (await heading.innerText()).match(/(\d+)\s*$/)?.[1] + ) + expect(promisedCount).toBeGreaterThan(0) + await expect( + page + .getByTestId('workshop-models-grid') + .getByTestId('workshop-model-card') + ).toHaveCount(promisedCount) + + await page.getByTestId('section-back').click() + await expect(page.getByTestId('workshop-sections')).toBeVisible() + }) + + test('model cards open the model detail page', async ({ page }) => { + await page.goto('/models/') + await page.getByTestId('workshop-search').fill('kling ai') + await page.getByRole('heading', { level: 1 }).click() + await page.getByTestId('workshop-model-card').first().click() + await expect(page).toHaveURL(/\/models\/kling-ai\/?$/) + await expect(page.getByRole('heading', { level: 1 })).toHaveText('Kling AI') + await expect( + page.getByTestId('related-models').getByTestId('workshop-model-card') + ).toHaveCount(4) + }) + + test('the filter menu drills into a facet and narrows the grid', async ({ + page + }) => { + await page.goto('/models/') + const cards = page + .getByTestId('workshop-models-grid') + .getByTestId('workshop-model-card') + await page.getByTestId('workshop-filter').click() + await page.getByTestId('workshop-facet-capability').click() + await page.getByTestId('filter-capability-Upscale').click() + await expect(cards).toHaveCount(6) + await expect( + page.getByTestId('workshop-facet-capability-count') + ).toHaveText('1') + await expect(page.getByTestId('workshop-filter-count')).toHaveText('1') + await page.getByTestId('workshop-filter-clear').click() + await expect(page.getByTestId('workshop-sections')).toBeVisible() + }) + + test('model tags deep-link into a filtered catalog', async ({ page }) => { + await page.goto('/models/topaz-labs/') + const tag = page + .getByTestId('model-tags') + .getByRole('link', { name: 'Upscale' }) + await expect(tag).toHaveAttribute('href', '/models?capability=Upscale') + await tag.click() + await expect(page).toHaveURL(/\/models\/?\?capability=Upscale$/) + await expect(page.getByTestId('workshop-filter-count')).toHaveText('1') + await expect( + page + .getByTestId('workshop-models-grid') + .getByTestId('workshop-model-card') + ).toHaveCount(6) + }) + + test('the hero medium deep-links into the catalog', async ({ page }) => { + await page.goto('/models/kling-ai/') + await page + .getByTestId('model-hero') + .getByRole('link', { name: 'Video', exact: true }) + .click() + await expect(page).toHaveURL(/\/models\/?\?modality=video$/) + await expect(page.getByTestId('workshop-filter-count')).toHaveText('1') + }) + + test('homepage model releases open their Workshop model', async ({ + page + }) => { + await page.goto('/') + const explore = page.getByRole('link', { name: /Explore Seedance/i }) + await expect(explore).toHaveAttribute('href', /\/models\/seedance-2\//) + }) +}) + +test.describe('Model playground', () => { + test('signs in through the Cloud-style login and returns to the playground', async ({ + page + }) => { + await page.goto(MODEL_PATH) + const run = page.getByTestId('run-button') + await expect(run).toHaveAttribute('data-gate', 'signedOut') + await expect(run).toHaveAttribute('href', /\/models\/sign-in\?return=/) + await expect( + page.getByTestId('desktop-nav-cta').getByTestId('header-sign-in') + ).toHaveAttribute('href', /\/models\/sign-in\?return=/) + + const prompt = 'a capybara in a trench coat' + await page.getByTestId('field-prompt').fill(prompt) + await run.click() + await expect(page).toHaveURL(/\/models\/sign-in/) + await expect(page.getByTestId('workshop-sign-in')).toHaveAttribute( + 'data-return', + MODEL_PATH + ) + await page.getByTestId('sign-in-github').click() + + await expect(page).toHaveURL(new RegExp(`${MODEL_PATH}$`)) + await expect(page.getByTestId('run-button')).toHaveAttribute( + 'data-gate', + 'ready', + { timeout: 15_000 } + ) + await expect(page.getByTestId('field-prompt')).toHaveValue(prompt) + }) + + test('validates the prompt, runs, cancels and completes', async ({ + page + }) => { + await page.goto(MODEL_PATH) + await useAccount(page, 'existing') + + const run = page.getByTestId('run-button') + await expect(run).toHaveAttribute('data-gate', 'ready') + await page.getByTestId('field-prompt').fill('') + await run.click() + await expect(page.getByTestId('error-prompt')).toBeVisible() + + await page + .getByTestId('field-prompt') + .fill('A slow dolly-in on a neon street') + await run.click() + const output = page.getByTestId('playground-output') + await expect(output).toHaveAttribute('data-state', 'running') + await run.click() + await expect(output).toHaveAttribute('data-state', 'cancelled') + + await page.getByRole('button', { name: 'Run again' }).click() + await run.click() + await expect(output).toHaveAttribute('data-state', 'succeeded', { + timeout: 10_000 + }) + await expect(page.getByTestId('output-download')).toBeVisible() + await expect( + page.getByTestId('desktop-nav-cta').getByTestId('header-credits') + ).toContainText('5,832') + }) + + test('a new account starts without credits and is sent to buy them', async ({ + page + }) => { + await page.goto(MODEL_PATH) + await useAccount(page, 'new') + await expect( + page.getByTestId('desktop-nav-cta').getByTestId('header-credits') + ).toHaveText('0') + await expect(page.getByTestId('run-button')).toHaveAttribute( + 'data-gate', + 'noCredits' + ) + await page + .getByTestId('desktop-nav-cta') + .getByTestId('header-account') + .click() + await page.getByTestId('account-plan').click() + await expect(page.getByTestId('buy-credits-dialog')).toBeVisible() + }) + + test('an empty balance is sent to Comfy Platform and the form survives the trip', async ({ + page + }) => { + await page.goto(MODEL_PATH) + await useAccount(page, 'existing') + await page.getByTestId('prototype-tweaks').click() + await page.getByTestId('tweak-zero-balance').click() + await page.keyboard.press('Escape') + + await page.getByTestId('field-prompt').fill('keep me around') + const run = page.getByTestId('run-button') + await expect(run).toHaveAttribute('data-gate', 'noCredits') + await run.click() + await expect(page.getByTestId('buy-credits-url')).toContainText( + 'success_url=%2Fmodels%2Fopenai-dall-e%2F' + ) + await page.getByTestId('buy-credits-continue').click() + await page.getByTestId('buy-credits-pay').click() + await expect(page.getByTestId('buy-credits-done')).toBeVisible() + await page.getByTestId('buy-credits-resume').click() + await expect(run).toHaveAttribute('data-gate', 'ready') + await expect( + page.getByTestId('desktop-nav-cta').getByTestId('header-credits') + ).toHaveText(/[1-9]/) + await page.reload() + await expect(page.getByTestId('field-prompt')).toHaveValue('keep me around') + }) + + test('API tab mirrors the form values', async ({ page }) => { + await page.goto(MODEL_PATH) + await page.getByTestId('field-prompt').fill('neon street at night') + await page.getByTestId('tab-api').click() + await expect(page.getByTestId('snippet')).toContainText( + 'neon street at night' + ) + await expect(page.getByTestId('snippet')).toContainText( + 'openai/openai-dall-e' + ) + await page.getByTestId('snippet-curl').click() + await expect(page.getByTestId('snippet')).toContainText('POST https://') + }) + + test('examples open in the playground with their settings', async ({ + page + }) => { + await page.goto(MODEL_PATH) + await expect(page.getByTestId('playground-output')).toHaveAttribute( + 'data-state', + 'example' + ) + await expect(page.getByTestId('field-prompt')).not.toHaveValue('') + await page.getByTestId('field-prompt').fill('') + await page.getByTestId('example-card').first().click() + await expect(page.getByTestId('playground-tab')).toBeVisible() + await expect(page.getByTestId('field-prompt')).not.toHaveValue('') + }) +}) + +test.describe('Filter sheet @mobile', () => { + test('the handle pulls the sheet up and lets it go', async ({ page }) => { + await page.goto('/models/') + await page.getByTestId('workshop-filter').click() + + const sheet = page.getByTestId('workshop-filter-menu') + await expect(sheet).toBeVisible() + const resting = (await sheet.boundingBox())!.height + + const handle = page.getByTestId('workshop-filter-grabber') + const grip = (await handle.boundingBox())! + const from = { x: grip.x + grip.width / 2, y: grip.y + grip.height / 2 } + + await page.mouse.move(from.x, from.y) + await page.mouse.down() + await page.mouse.move(from.x, from.y - 260, { steps: 8 }) + await page.mouse.up() + + await expect + .poll(async () => (await sheet.boundingBox())!.height) + .toBeGreaterThan(resting) + + const grown = (await handle.boundingBox())! + await page.mouse.move(grown.x + grown.width / 2, grown.y + grown.height / 2) + await page.mouse.down() + await page.mouse.move( + grown.x + grown.width / 2, + grown.y + grown.height / 2 + 500, + { steps: 8 } + ) + await page.mouse.up() + + await expect(sheet).toHaveCount(0) + }) +}) diff --git a/apps/website/package.json b/apps/website/package.json index 6c47ed94129..0187a3dd4ce 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -21,7 +21,11 @@ "generate:workshop-catalog": "tsx ./scripts/generate-workshop-catalog.ts", "validate:jsonld": "tsx ./scripts/validate-jsonld.ts", "check:hreflang": "tsx ./scripts/check-hreflang.ts", - "validate:llms-txt-links": "tsx ./scripts/validate-llms-txt-links.ts" + "validate:llms-txt-links": "tsx ./scripts/validate-llms-txt-links.ts", + "workshop:generate": "tsx ./scripts/generate-workshop-models.ts", + "workshop:generate-versions": "tsx ./scripts/generate-workshop-versions.ts", + "hub:backfill-media-type": "tsx ./scripts/backfill-template-media-type.ts", + "hub:generate-join": "tsx ./scripts/generate-template-model-join.ts" }, "dependencies": { "@astrojs/sitemap": "catalog:", diff --git a/apps/website/public/icons/ai-models/anthropic.svg b/apps/website/public/icons/ai-models/anthropic.svg new file mode 100644 index 00000000000..c917480d325 --- /dev/null +++ b/apps/website/public/icons/ai-models/anthropic.svg @@ -0,0 +1 @@ +Anthropic \ No newline at end of file diff --git a/apps/website/public/icons/ai-models/bfl.svg b/apps/website/public/icons/ai-models/bfl.svg new file mode 100644 index 00000000000..c58c836f645 --- /dev/null +++ b/apps/website/public/icons/ai-models/bfl.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/apps/website/public/icons/ai-models/bria.svg b/apps/website/public/icons/ai-models/bria.svg new file mode 100644 index 00000000000..797bc8118fc --- /dev/null +++ b/apps/website/public/icons/ai-models/bria.svg @@ -0,0 +1 @@ + diff --git a/apps/website/public/icons/ai-models/elevenlabs.svg b/apps/website/public/icons/ai-models/elevenlabs.svg new file mode 100644 index 00000000000..de438ed510e --- /dev/null +++ b/apps/website/public/icons/ai-models/elevenlabs.svg @@ -0,0 +1 @@ +ElevenLabs \ No newline at end of file diff --git a/apps/website/public/icons/ai-models/heygen.svg b/apps/website/public/icons/ai-models/heygen.svg new file mode 100644 index 00000000000..60285c7788e --- /dev/null +++ b/apps/website/public/icons/ai-models/heygen.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/website/public/icons/ai-models/ideogram.svg b/apps/website/public/icons/ai-models/ideogram.svg new file mode 100644 index 00000000000..061d24c3e5b --- /dev/null +++ b/apps/website/public/icons/ai-models/ideogram.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/website/public/icons/ai-models/kling.svg b/apps/website/public/icons/ai-models/kling.svg new file mode 100644 index 00000000000..32dc0f806e8 --- /dev/null +++ b/apps/website/public/icons/ai-models/kling.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/website/public/icons/ai-models/krea.svg b/apps/website/public/icons/ai-models/krea.svg new file mode 100644 index 00000000000..1712240a339 --- /dev/null +++ b/apps/website/public/icons/ai-models/krea.svg @@ -0,0 +1 @@ + diff --git a/apps/website/public/icons/ai-models/ltxv.svg b/apps/website/public/icons/ai-models/ltxv.svg new file mode 100644 index 00000000000..74fc5ca62d3 --- /dev/null +++ b/apps/website/public/icons/ai-models/ltxv.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/apps/website/public/icons/ai-models/luma.svg b/apps/website/public/icons/ai-models/luma.svg new file mode 100644 index 00000000000..a124becca83 --- /dev/null +++ b/apps/website/public/icons/ai-models/luma.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/website/public/icons/ai-models/magnific.svg b/apps/website/public/icons/ai-models/magnific.svg new file mode 100644 index 00000000000..4e944cbaddb --- /dev/null +++ b/apps/website/public/icons/ai-models/magnific.svg @@ -0,0 +1 @@ + diff --git a/apps/website/public/icons/ai-models/meshy.svg b/apps/website/public/icons/ai-models/meshy.svg new file mode 100644 index 00000000000..9aa90f73f1d --- /dev/null +++ b/apps/website/public/icons/ai-models/meshy.svg @@ -0,0 +1 @@ + diff --git a/apps/website/public/icons/ai-models/openrouter.svg b/apps/website/public/icons/ai-models/openrouter.svg new file mode 100644 index 00000000000..83ec807bc9a --- /dev/null +++ b/apps/website/public/icons/ai-models/openrouter.svg @@ -0,0 +1 @@ +OpenRouter \ No newline at end of file diff --git a/apps/website/public/icons/ai-models/pixverse.svg b/apps/website/public/icons/ai-models/pixverse.svg new file mode 100644 index 00000000000..a3d3239cfa0 --- /dev/null +++ b/apps/website/public/icons/ai-models/pixverse.svg @@ -0,0 +1 @@ + diff --git a/apps/website/public/icons/ai-models/recraft.svg b/apps/website/public/icons/ai-models/recraft.svg new file mode 100644 index 00000000000..08742d8d4e1 --- /dev/null +++ b/apps/website/public/icons/ai-models/recraft.svg @@ -0,0 +1 @@ + diff --git a/apps/website/public/icons/ai-models/runway.svg b/apps/website/public/icons/ai-models/runway.svg new file mode 100644 index 00000000000..91a08a3771d --- /dev/null +++ b/apps/website/public/icons/ai-models/runway.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/apps/website/public/icons/ai-models/sonilo.svg b/apps/website/public/icons/ai-models/sonilo.svg new file mode 100644 index 00000000000..f2d0bfe9628 --- /dev/null +++ b/apps/website/public/icons/ai-models/sonilo.svg @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/apps/website/public/icons/ai-models/sync.svg b/apps/website/public/icons/ai-models/sync.svg new file mode 100644 index 00000000000..0eae2d8d8f4 --- /dev/null +++ b/apps/website/public/icons/ai-models/sync.svg @@ -0,0 +1 @@ + diff --git a/apps/website/public/icons/ai-models/tencent.svg b/apps/website/public/icons/ai-models/tencent.svg new file mode 100644 index 00000000000..7eaa2312180 --- /dev/null +++ b/apps/website/public/icons/ai-models/tencent.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/website/public/icons/ai-models/topaz.svg b/apps/website/public/icons/ai-models/topaz.svg new file mode 100644 index 00000000000..03c8afab5a6 --- /dev/null +++ b/apps/website/public/icons/ai-models/topaz.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/apps/website/public/icons/ai-models/tripo.svg b/apps/website/public/icons/ai-models/tripo.svg new file mode 100644 index 00000000000..35a524ca99d --- /dev/null +++ b/apps/website/public/icons/ai-models/tripo.svg @@ -0,0 +1 @@ + diff --git a/apps/website/public/icons/ai-models/vidu.svg b/apps/website/public/icons/ai-models/vidu.svg new file mode 100644 index 00000000000..02db152ede6 --- /dev/null +++ b/apps/website/public/icons/ai-models/vidu.svg @@ -0,0 +1 @@ + diff --git a/apps/website/public/icons/ai-models/wavespeed.svg b/apps/website/public/icons/ai-models/wavespeed.svg new file mode 100644 index 00000000000..cf209d83dd7 --- /dev/null +++ b/apps/website/public/icons/ai-models/wavespeed.svg @@ -0,0 +1,4 @@ + + + + diff --git a/apps/website/public/llms.txt b/apps/website/public/llms.txt index 8b33c303fa0..b8933f994e8 100644 --- a/apps/website/public/llms.txt +++ b/apps/website/public/llms.txt @@ -94,7 +94,7 @@ Languages: comfy.org is published in English and Simplified Chinese, with a Japa ## Models - [Supported Models](https://comfy.org/p/supported-models/): Directory of 380+ models that run in ComfyUI: image, video, audio, 3D, and utility models, each with its own page. Machine-readable catalog at https://comfy.org/p/supported-models/llms.txt. -- [Models Overview](https://comfy.org/models/): Flagship models available on Comfy, with links to each launch page. +- [Models Overview](https://comfy.org/models/showcase/): Flagship models available on Comfy, with links to each launch page. - [Flux 3 (Black Forest Labs, video model)](https://comfy.org/flux-3/): Multimodal model: video with native audio, up to 20 seconds per generation, from text, image, video, or keyframes. - [Gemini Omni 1.1 Flash (Google, video model)](https://comfy.org/gemini-omni/): One node covers text to video, image to video, reference to video, editing, and scene extension, with output up to 4K and audio on every clip. - [LTX 2.5 (Lightricks, video model)](https://comfy.org/ltx-2.5/): Open weights: free to run on your own GPU, or on Comfy Cloud alongside every other model. diff --git a/apps/website/scripts/backfill-template-media-type.ts b/apps/website/scripts/backfill-template-media-type.ts new file mode 100644 index 00000000000..3c762fc4928 --- /dev/null +++ b/apps/website/scripts/backfill-template-media-type.ts @@ -0,0 +1,88 @@ +/** + * The template index records the media type of the *thumbnail*, so 599 of the + * 610 entries claim `image` — including every video workflow. This rewrites + * `mediaType` from what the workflow actually produces: its first declared + * output where the details snapshot has one, and otherwise the medium named by + * its tags. Run it after refreshing either snapshot. + */ +import { readFileSync, writeFileSync } from 'node:fs' +import { join } from 'node:path' + +const DATA = join(import.meta.dirname, '..', 'src', 'data') +const INDEX = join(DATA, 'hubTemplates.json') +const DETAILS = join(DATA, 'hubTemplateDetails.json') + +const MEDIA_TYPES = ['image', 'video', 'audio', '3d'] as const +type MediaType = (typeof MEDIA_TYPES)[number] + +const isMediaType = (value: unknown): value is MediaType => + typeof value === 'string' && + (MEDIA_TYPES as readonly string[]).includes(value) + +// Ordered: the first tag a template carries decides, so a "Video Edit" wins +// over the broad "Video" and both win over the image default. +const TAG_MEDIA: readonly [string, MediaType][] = [ + ['Image to 3D', '3d'], + ['Text to Model', '3d'], + ['Image to Model', '3d'], + ['3D', '3d'], + ['Text to Speech', 'audio'], + ['TTS', 'audio'], + ['Voice Cloning', 'audio'], + ['Text to Music', 'audio'], + ['Text to Audio', 'audio'], + ['Audio Editing', 'audio'], + ['Music', 'audio'], + ['Audio', 'audio'], + ['Image to Video', 'video'], + ['Text to Video', 'video'], + ['Reference to Video', 'video'], + ['Audio to Video', 'video'], + ['FLF2V', 'video'], + ['Lip Sync', 'video'], + ['Video Edit', 'video'], + ['Video to Video', 'video'], + ['Video Extend', 'video'], + ['Video Upscale', 'video'], + ['Frame Interpolation', 'video'], + ['Motion Control', 'video'], + ['Video', 'video'] +] + +interface IndexEntry { + name: string + mediaType: string + tags: string[] +} +interface DetailEntry { + outputs?: { mediaType?: string }[] +} + +const index = JSON.parse(readFileSync(INDEX, 'utf8')) as IndexEntry[] +const details = JSON.parse(readFileSync(DETAILS, 'utf8')) as Record< + string, + DetailEntry +> + +function mediaTypeOf(entry: IndexEntry): MediaType { + const declared = details[entry.name]?.outputs?.[0]?.mediaType + if (isMediaType(declared)) return declared + return TAG_MEDIA.find(([tag]) => entry.tags.includes(tag))?.[1] ?? 'image' +} + +let changed = 0 +for (const entry of index) { + const mediaType = mediaTypeOf(entry) + if (mediaType !== entry.mediaType) changed++ + entry.mediaType = mediaType +} + +writeFileSync(INDEX, `${JSON.stringify(index, null, 2)}\n`) + +const counts = new Map() +for (const entry of index) + counts.set(entry.mediaType, (counts.get(entry.mediaType) ?? 0) + 1) +console.log( + `Rewrote ${changed} of ${index.length} media types:`, + Object.fromEntries([...counts].sort()) +) diff --git a/apps/website/scripts/generate-template-model-join.ts b/apps/website/scripts/generate-template-model-join.ts new file mode 100644 index 00000000000..4693d5d6ef2 --- /dev/null +++ b/apps/website/scripts/generate-template-model-join.ts @@ -0,0 +1,68 @@ +/** + * Which workflow runs on which partner model. + * + * Most API templates name their model in `models[]`, and an exact name match + * resolves those at runtime. The rest only carry it in the file name + * (`api_seedance2_5_t2v`), which the provider map can decode — but decoding a + * prefix guesses, and a guess once sent a FLUX 3 video workflow to the FLUX + * image playground. So every decoded row must agree with the model on what it + * produces; the ones that disagree are dropped rather than shipped wrong. + * + * Run after refreshing the template snapshot: pnpm hub:generate-join + */ +import { readFileSync, writeFileSync } from 'node:fs' +import { join } from 'node:path' + +import { workshopModels } from '../src/config/models-catalogue' +import type { HubTemplate } from '../src/lib/hub/types' +import { modelNamedBy } from '../src/lib/hub/template-use-case' +import { API_PROVIDER_MAP } from './generate-models' + +const DATA = join(import.meta.dirname, '..', 'src', 'data') +const templates = JSON.parse( + readFileSync(join(DATA, 'hubTemplates.json'), 'utf8') +) as HubTemplate[] + +const bySlug = new Map(workshopModels.map((model) => [model.slug, model])) +const prefixes = Object.keys(API_PROVIDER_MAP).sort( + (a, b) => b.length - a.length +) + +function decodeFromName(name: string): string | undefined { + if (!name.startsWith('api_')) return undefined + const stem = name.slice('api_'.length) + const prefix = prefixes.find((key) => stem.startsWith(key)) + return prefix ? API_PROVIDER_MAP[prefix].slug : undefined +} + +const joined: Record = {} +const rejected: string[] = [] + +for (const template of templates) { + if (!template.tags.includes('API')) continue + if (modelNamedBy(template, workshopModels)) continue + + const slug = decodeFromName(template.name) + const model = slug ? bySlug.get(slug) : undefined + if (!model) continue + + if (model.modality === template.mediaType) { + joined[template.name] = model.slug + } else { + rejected.push( + `${template.name} → ${model.slug} (${template.mediaType} workflow, ${model.modality} model)` + ) + } +} + +const sorted = Object.fromEntries( + Object.entries(joined).sort(([a], [b]) => a.localeCompare(b)) +) +writeFileSync( + join(DATA, 'templateModelJoin.json'), + `${JSON.stringify(sorted, null, 2)}\n` +) + +console.log(`Joined ${Object.keys(sorted).length} workflows to a model.`) +console.log(`Dropped ${rejected.length} rows that disagreed on the medium:`) +for (const row of rejected) console.log(` ${row}`) diff --git a/apps/website/scripts/generate-workshop-models.ts b/apps/website/scripts/generate-workshop-models.ts new file mode 100644 index 00000000000..fd3bb1e14b3 --- /dev/null +++ b/apps/website/scripts/generate-workshop-models.ts @@ -0,0 +1,714 @@ +// Builds src/config/workshop-models.generated.json from two sibling checkouts: +// ../../../../workflow_templates (Comfy-Org/workflow_templates) +// ../../../../ComfyUI (Comfy-Org/ComfyUI, comfy_api_nodes/) +// For every partner-node model in generated-models.json it resolves the +// curated templates, the partner node the first template runs, that node's +// input schema straight from its define_schema(), the template's widget +// values as defaults, its price badge and its output modality. +import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs' +import { join } from 'node:path' +import { fileURLToPath } from 'node:url' + +import { API_PROVIDER_MAP } from './generate-models' + +const TEMPLATES_DIR = fileURLToPath( + new URL('../../../../workflow_templates/templates', import.meta.url) +) +const API_NODES_DIR = fileURLToPath( + new URL('../../../../ComfyUI/comfy_api_nodes', import.meta.url) +) +const WORKFLOW_TEMPLATES_BASE = + 'https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/templates' +const OUTPUT = fileURLToPath( + new URL('../src/config/workshop-models.generated.json', import.meta.url) +) +const EXAMPLES_PER_MODEL = 3 + +type Modality = 'image' | 'video' | 'audio' | '3d' | 'text' +type Primitive = string | number | boolean + +type Field = + | { + kind: 'text' + name: string + label: string + hint?: string + multiline: boolean + required: boolean + default?: string + } + | { + kind: 'number' + name: string + label: string + hint?: string + min: number + max: number + step: number + default: number + } + | { + kind: 'select' + name: string + label: string + hint?: string + options: string[] + default: string + } + | { + kind: 'toggle' + name: string + label: string + hint?: string + default: boolean + } + | { + kind: 'file' + name: string + label: string + hint?: string + accept: 'image' | 'video' | 'audio' + required: boolean + } + +// One entry of a node's inputs list. Dynamic combos carry the inputs each +// option reveals, in the order their widget values appear in a workflow. +interface InputDef { + type: string + name: string + args: string + options?: { label: string; children: InputDef[] }[] +} + +interface NodeSchema { + id: string + displayName: string + provider?: string + modality?: Modality + priceUsdFrom?: number + inputs: InputDef[] + sources: string[] +} + +interface TemplateEntry { + name: string + title: string + description?: string + tags?: string[] +} + +interface GeneratedExample { + name: string + title: string + description: string + tags: string[] + thumbnailUrl: string + // Present only when the template runs a different node (or a different + // dynamic-combo path) than the model's default form. + node?: { id: string; displayName: string } + fields?: Field[] + values: Record +} + +interface GeneratedModel { + thumbnailUrl?: string + provider?: string + modality?: Modality + priceUsdFrom?: number + node?: { id: string; displayName: string; template: string } + fields: Field[] + defaults: Record + examples: GeneratedExample[] +} + +// ---------- Python source helpers ---------- + +function sliceBalanced(source: string, openIndex: number): string { + const open = source[openIndex] + const close = open === '(' ? ')' : open === '[' ? ']' : '}' + let depth = 0 + let inString: string | null = null + for (let i = openIndex; i < source.length; i++) { + const ch = source[i] + if (inString) { + if (ch === '\\') i++ + else if (source.startsWith(inString, i)) { + i += inString.length - 1 + inString = null + } + continue + } + if (source.startsWith('"""', i)) { + inString = '"""' + i += 2 + continue + } + if (ch === '"' || ch === "'") { + inString = ch + continue + } + if (ch === open) depth++ + else if (ch === close) { + depth-- + if (depth === 0) return source.slice(openIndex + 1, i) + } + } + return source.slice(openIndex + 1) +} + +function splitTopLevel(body: string): string[] { + const elements: string[] = [] + let depth = 0 + let inString: string | null = null + let start = 0 + for (let i = 0; i < body.length; i++) { + const ch = body[i] + if (inString) { + if (ch === '\\') i++ + else if (body.startsWith(inString, i)) { + i += inString.length - 1 + inString = null + } + continue + } + if (body.startsWith('"""', i)) { + inString = '"""' + i += 2 + continue + } + if (ch === '"' || ch === "'") inString = ch + else if ('([{'.includes(ch)) depth++ + else if (')]}'.includes(ch)) depth-- + else if (ch === ',' && depth === 0) { + elements.push(body.slice(start, i)) + start = i + 1 + } + } + elements.push(body.slice(start)) + return elements.map((e) => e.trim()).filter(Boolean) +} + +function kwarg(args: string, key: string): string | undefined { + for (const element of splitTopLevel(args)) { + const match = new RegExp(`^${key}\\s*=\\s*`).exec(element) + if (match) return element.slice(match[0].length).trim() + } + return undefined +} + +function positional(args: string, index: number): string | undefined { + const element = splitTopLevel(args)[index] + return element && !/^\w+\s*=/.test(element) ? element : undefined +} + +function pyString(literal: string | undefined): string | undefined { + if (!literal) return undefined + const match = + /^(?:f?)(?:"""([\s\S]*?)"""|"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)')$/.exec( + literal + ) + if (!match) return undefined + // Only one of the three quote styles matches; the rest come back undefined + // at runtime, which the regex types deny. + const groups: (string | undefined)[] = [match[1], match[2], match[3]] + const quoted = groups.find((group) => group !== undefined) + return (quoted ?? '').replace(/\\n/g, ' ').trim() +} + +function pyNumber(literal: string | undefined): number | undefined { + if (!literal) return undefined + const value = Number(literal.replace(/_/g, '')) + return Number.isFinite(value) ? value : undefined +} + +function stringItems(listBody: string): string[] { + return [...listBody.matchAll(/"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'/g)].map( + (m: (string | undefined)[]) => m[1] ?? m[2] ?? '' + ) +} + +function resolveOptions( + literal: string | undefined, + sources: string[] +): string[] | undefined { + if (!literal) return undefined + if (literal.startsWith('[')) { + const items = stringItems(sliceBalanced(literal, 0)) + return items.length ? items : undefined + } + const keysCall = /^list\((\w+)\.keys\(\)\)$/.exec(literal) + const name = keysCall ? keysCall[1] : /^(\w+)$/.exec(literal)?.[1] + if (!name) return undefined + for (const source of sources) { + const assignment = new RegExp( + `^${name}\\s*(?::[^=]+)?=\\s*([\\[{(])`, + 'm' + ).exec(source) + if (assignment) { + const body = sliceBalanced( + source, + assignment.index + assignment[0].length - 1 + ) + if (keysCall || assignment[1] === '{') { + const keys = [...body.matchAll(/^\s*"((?:[^"\\]|\\.)*)"\s*:/gm)].map( + (m) => m[1] + ) + if (keys.length) return keys + } + const items = stringItems(body) + if (items.length) return items + } + const enumClass = new RegExp( + `^class ${name}\\((?:str, )?Enum\\):\\n([\\s\\S]*?)(?=^\\S)`, + 'm' + ).exec(source) + if (enumClass) { + const values = [...enumClass[1].matchAll(/=\s*"((?:[^"\\]|\\.)*)"/g)].map( + (m) => m[1] + ) + if (values.length) return values + } + } + return undefined +} + +function humanize(name: string): string { + const text = name.replace(/_/g, ' ').trim() + return text.charAt(0).toUpperCase() + text.slice(1) +} + +// ---------- Schema parsing ---------- + +function parseInputList(listBody: string): InputDef[] { + const defs: InputDef[] = [] + for (const element of splitTopLevel(listBody)) { + const match = /^IO\.(\w+)\.Input\(/.exec(element) + if (!match) continue + const args = sliceBalanced(element, match[0].length - 1) + const name = pyString(positional(args, 0)) + if (!name) continue + const def: InputDef = { type: match[1], name, args } + if (def.type === 'DynamicCombo') { + const optionsLiteral = kwarg(args, 'options') + if (!optionsLiteral?.startsWith('[')) continue + def.options = splitTopLevel(sliceBalanced(optionsLiteral, 0)).flatMap( + (option) => { + const optionMatch = /^IO\.DynamicCombo\.Option\(/.exec(option) + if (!optionMatch) return [] + const optionArgs = sliceBalanced(option, optionMatch[0].length - 1) + const label = pyString(positional(optionArgs, 0)) + const childrenLiteral = positional(optionArgs, 1) + if (!label) return [] + return [ + { + label, + children: childrenLiteral?.startsWith('[') + ? parseInputList(sliceBalanced(childrenLiteral, 0)) + : [] + } + ] + } + ) + if (!def.options.length) continue + } + defs.push(def) + } + return defs +} + +const OUTPUT_MODALITY: Record = { + Video: 'video', + Image: 'image', + Audio: 'audio', + File: '3d', + Mesh: '3d', + String: 'text' +} + +function parseNodeSchemas(): Map { + const schemas = new Map() + const apisDir = join(API_NODES_DIR, 'apis') + const apiSources = existsSync(apisDir) + ? readdirSync(apisDir) + .filter((f) => f.endsWith('.py')) + .map((f) => readFileSync(join(apisDir, f), 'utf8')) + : [] + for (const file of readdirSync(API_NODES_DIR).filter((f) => + f.endsWith('.py') + )) { + const source = readFileSync(join(API_NODES_DIR, file), 'utf8') + const pattern = /IO\.Schema\(/g + let match: RegExpExecArray | null + while ((match = pattern.exec(source))) { + const body = sliceBalanced(source, match.index + match[0].length - 1) + const id = pyString(kwarg(body, 'node_id')) + if (!id) continue + const inputsLiteral = kwarg(body, 'inputs') + const outputsLiteral = kwarg(body, 'outputs') ?? '' + const firstOutput = /IO\.(\w+)\.Output/.exec(outputsLiteral)?.[1] + const modality = firstOutput ? OUTPUT_MODALITY[firstOutput] : undefined + const provider = (pyString(kwarg(body, 'category')) ?? '').split('/')[2] + const usd = [ + ...(kwarg(body, 'price_badge') ?? '').matchAll(/"usd"\s*:\s*([\d.]+)/g) + ] + .map((m) => Number(m[1])) + .filter((n) => Number.isFinite(n) && n > 0) + schemas.set(id, { + id, + displayName: pyString(kwarg(body, 'display_name')) ?? id, + ...(provider ? { provider } : {}), + ...(modality ? { modality } : {}), + ...(usd.length ? { priceUsdFrom: Math.min(...usd) } : {}), + inputs: inputsLiteral?.startsWith('[') + ? parseInputList(sliceBalanced(inputsLiteral, 0)) + : [], + sources: [source, ...apiSources] + }) + } + } + return schemas +} + +function toField(def: InputDef, sources: string[]): Field | undefined { + const { type, name, args } = def + const optional = kwarg(args, 'optional') === 'True' + const hint = pyString(kwarg(args, 'tooltip')) + const label = pyString(kwarg(args, 'display_name')) ?? humanize(name) + const base = { name, label, ...(hint ? { hint } : {}) } + switch (type) { + case 'String': { + const defaultValue = pyString(kwarg(args, 'default')) + return { + ...base, + kind: 'text', + multiline: kwarg(args, 'multiline') === 'True', + required: !optional && name === 'prompt', + ...(defaultValue !== undefined ? { default: defaultValue } : {}) + } + } + case 'Int': + case 'Float': { + const min = pyNumber(kwarg(args, 'min')) + const max = pyNumber(kwarg(args, 'max')) + const defaultValue = pyNumber(kwarg(args, 'default')) + if (min === undefined || max === undefined || defaultValue === undefined) + return undefined + const cap = name === 'seed' ? 999_999 : max + return { + ...base, + kind: 'number', + min, + max: cap, + step: pyNumber(kwarg(args, 'step')) ?? (type === 'Int' ? 1 : 0.1), + default: Math.min(defaultValue, cap) + } + } + case 'Combo': { + const options = resolveOptions(kwarg(args, 'options'), sources) + if (!options) return undefined + const defaultValue = pyString(kwarg(args, 'default')) + return { + ...base, + kind: 'select', + options, + default: + defaultValue && options.includes(defaultValue) + ? defaultValue + : options[0] + } + } + case 'DynamicCombo': + return { + ...base, + kind: 'select', + options: def.options!.map((o) => o.label), + default: def.options![0].label + } + case 'Boolean': + return { + ...base, + kind: 'toggle', + default: kwarg(args, 'default') === 'True' + } + case 'Image': + case 'Video': + case 'Audio': + return { + ...base, + kind: 'file', + accept: type.toLowerCase() as 'image' | 'video' | 'audio', + required: !optional + } + default: + return undefined + } +} + +// Flattens the input tree into the fields a form shows, following the +// dynamic-combo choices in `chosen` (template values) or each combo's first option. +function fieldsFor( + defs: InputDef[], + sources: string[], + chosen: Record +): Field[] { + return defs.flatMap((def) => { + const field = toField(def, sources) + if (!field) return [] + if (!def.options) return [field] + const picked = + def.options.find((o) => o.label === chosen[def.name]) ?? def.options[0] + return [field, ...fieldsFor(picked.children, sources, chosen)] + }) +} + +const WIDGET_TYPES = new Set([ + 'String', + 'Int', + 'Float', + 'Combo', + 'DynamicCombo', + 'Boolean' +]) + +// Walks widgets_values in schema order, descending into the dynamic-combo +// option the workflow selected. Stops at the first value that does not fit. +function alignWidgets( + defs: InputDef[], + sources: string[], + values: unknown[], + cursor: { index: number }, + out: Record +): boolean { + for (const def of defs) { + if (!WIDGET_TYPES.has(def.type)) continue + const value = values[cursor.index] + cursor.index += kwarg(def.args, 'control_after_generate') === 'True' ? 2 : 1 + const field = toField(def, sources) + if (!field) return false + const fits = + (field.kind === 'text' && typeof value === 'string') || + (field.kind === 'number' && typeof value === 'number') || + (field.kind === 'toggle' && typeof value === 'boolean') || + (field.kind === 'select' && + typeof value === 'string' && + field.options.includes(value)) + if (!fits) return false + out[def.name] = + field.kind === 'number' ? Math.min(value as number, field.max) : value + if (def.options) { + const picked = def.options.find((o) => o.label === value) + if ( + !picked || + !alignWidgets(picked.children, sources, values, cursor, out) + ) + return false + } + } + return true +} + +// ---------- Templates ---------- + +interface WorkflowNode { + type: string + widgets_values?: unknown[] +} + +function isWorkflowNode(value: unknown): value is WorkflowNode { + return ( + typeof value === 'object' && + value !== null && + 'type' in value && + typeof value.type === 'string' && + (!('widgets_values' in value) || + value.widgets_values === undefined || + Array.isArray(value.widgets_values)) + ) +} + +function readWorkflow(name: string): WorkflowNode[] { + const raw: unknown = JSON.parse( + readFileSync(join(TEMPLATES_DIR, `${name}.json`), 'utf8') + ) + const nodes = + typeof raw === 'object' && raw !== null && 'nodes' in raw ? raw.nodes : [] + return Array.isArray(nodes) ? nodes.filter(isWorkflowNode) : [] +} + +function templateValues( + schema: NodeSchema, + node: WorkflowNode | undefined +): Record { + const out: Record = {} + if (node) + alignWidgets( + schema.inputs, + schema.sources, + node.widgets_values ?? [], + { index: 0 }, + out + ) + return out +} + +function pickApiNode( + nodes: WorkflowNode[], + schemas: Map +): WorkflowNode | undefined { + const score = (node: WorkflowNode) => { + const schema = schemas.get(node.type)! + const fields = fieldsFor(schema.inputs, schema.sources, {}) + // The subject of the workflow is the node that takes the prompt, not a + // helper that happens to accept a texture_prompt beside it. + const hasPrompt = fields.some( + (f) => f.kind === 'text' && /^(?:positive_)?(?:prompt|text)$/.test(f.name) + ) + // What the visitor hands the model, prompt or file, is what makes a node + // the subject of its workflow; the rest are conversion and export steps. + const takesUpload = fields.some((f) => f.kind === 'file') + return (hasPrompt ? 1000 : 0) + (takesUpload ? 500 : 0) + fields.length + } + return nodes + .filter((node) => schemas.has(node.type)) + .sort((a, b) => score(b) - score(a))[0] +} + +function slugForTemplate(name: string): string | undefined { + if (!name.startsWith('api_')) return undefined + const rest = name.slice(4) + let best: { key: string; slug: string } | undefined + for (const [key, { slug }] of Object.entries(API_PROVIDER_MAP)) { + if ( + (rest === key || rest.startsWith(`${key}_`)) && + (!best || key.length > best.key.length) + ) { + best = { key, slug } + } + } + return best?.slug +} + +function thumbnailFor(name: string): string | undefined { + return existsSync(join(TEMPLATES_DIR, `${name}-1.webp`)) + ? `${WORKFLOW_TEMPLATES_BASE}/${encodeURIComponent(name)}-1.webp` + : undefined +} + +// ---------- Main ---------- + +function run() { + const generated = JSON.parse( + readFileSync( + fileURLToPath( + new URL('../src/config/generated-models.json', import.meta.url) + ), + 'utf8' + ) + ) as { slug: string; directory: string; canonicalSlug?: string }[] + const partnerSlugs = new Set( + generated + .filter((m) => m.directory === 'partner_nodes' && !m.canonicalSlug) + .map((m) => m.slug) + ) + + const index = JSON.parse( + readFileSync(join(TEMPLATES_DIR, 'index.json'), 'utf8') + ) as { templates: TemplateEntry[] }[] + const templatesBySlug = new Map() + for (const category of index) { + for (const template of category.templates) { + const slug = slugForTemplate(template.name) + if (!slug || !partnerSlugs.has(slug)) continue + if (!existsSync(join(TEMPLATES_DIR, `${template.name}.json`))) continue + const list = templatesBySlug.get(slug) ?? [] + if (!list.some((t) => t.name === template.name)) list.push(template) + templatesBySlug.set(slug, list) + } + } + + const schemas = parseNodeSchemas() + const output: Record = {} + let withFields = 0 + let withDefaults = 0 + + for (const slug of [...partnerSlugs].sort()) { + const templates = (templatesBySlug.get(slug) ?? []).filter((t) => + thumbnailFor(t.name) + ) + if (!templates.length) continue + const [first] = templates + const apiNode = pickApiNode(readWorkflow(first.name), schemas) + const schema = apiNode ? schemas.get(apiNode.type) : undefined + const defaults = schema ? templateValues(schema, apiNode) : {} + const fields = schema + ? fieldsFor(schema.inputs, schema.sources, defaults) + : [] + if (fields.length) withFields++ + if (Object.keys(defaults).length) withDefaults++ + + const examples: GeneratedExample[] = templates + .slice(0, EXAMPLES_PER_MODEL) + .map((template) => { + const exampleNode = pickApiNode(readWorkflow(template.name), schemas) + const exampleSchema = exampleNode + ? schemas.get(exampleNode.type) + : undefined + const values = exampleSchema + ? templateValues(exampleSchema, exampleNode) + : {} + const exampleFields = exampleSchema + ? fieldsFor(exampleSchema.inputs, exampleSchema.sources, values) + : [] + const ownForm = + exampleSchema !== undefined && + (exampleSchema.id !== schema?.id || + JSON.stringify(exampleFields) !== JSON.stringify(fields)) + return { + name: template.name, + title: template.title, + description: template.description ?? '', + tags: template.tags ?? [], + thumbnailUrl: thumbnailFor(template.name)!, + ...(ownForm + ? { + node: { + id: exampleSchema.id, + displayName: exampleSchema.displayName + }, + fields: exampleFields + } + : {}), + values + } + }) + + output[slug] = { + thumbnailUrl: thumbnailFor(first.name), + ...(schema?.provider ? { provider: schema.provider } : {}), + ...(schema?.modality ? { modality: schema.modality } : {}), + ...(schema?.priceUsdFrom !== undefined + ? { priceUsdFrom: schema.priceUsdFrom } + : {}), + ...(schema + ? { + node: { + id: schema.id, + displayName: schema.displayName, + template: first.name + } + } + : {}), + fields, + defaults, + examples + } + } + + writeFileSync(OUTPUT, `${JSON.stringify(output, null, 2)}\n`) + process.stdout.write( + `Written ${Object.keys(output).length}/${partnerSlugs.size} partner models ` + + `(${withFields} with fields, ${withDefaults} with template defaults) to ${OUTPUT}\n` + ) +} + +run() diff --git a/apps/website/scripts/generate-workshop-versions.ts b/apps/website/scripts/generate-workshop-versions.ts new file mode 100644 index 00000000000..b960274e2ce --- /dev/null +++ b/apps/website/scripts/generate-workshop-versions.ts @@ -0,0 +1,151 @@ +/** + * The catalogue used to hold one entry per partner *node* — 48 of them — while + * the templates name 97 distinct models: Wan 2.5 through 3.0, Vidu Q1 to Q3, + * four Seedreams. This reads the models the templates actually declare and + * writes the ones the catalogue is missing, each pointing at the node entry + * whose schema, defaults and examples it runs on. + * + * Run after refreshing the template snapshot: pnpm workshop:generate-versions + */ +import { readFileSync, writeFileSync } from 'node:fs' +import { join } from 'node:path' + +import { workshopModels } from '../src/config/models-catalogue' +import type { HubTemplate } from '../src/lib/hub/types' +import { API_PROVIDER_MAP } from './generate-models' + +const DATA = join(import.meta.dirname, '..', 'src', 'data') +const OUTPUT = join( + import.meta.dirname, + '..', + 'src', + 'config', + 'workshop-model-versions.generated.json' +) + +const MEDIA_TYPES = ['image', 'video', 'audio', '3d', 'text'] as const +type Modality = (typeof MEDIA_TYPES)[number] + +interface Version { + readonly name: string + readonly slug: string + readonly baseSlug: string + readonly provider?: string + readonly modality?: Modality + readonly workflowCount: number + readonly thumbnailUrl?: string +} + +const templates = JSON.parse( + readFileSync(join(DATA, 'hubTemplates.json'), 'utf8') +) as HubTemplate[] + +const prefixes = Object.keys(API_PROVIDER_MAP).sort( + (a, b) => b.length - a.length +) + +function baseSlugOf(templateName: string): string | undefined { + if (!templateName.startsWith('api_')) return undefined + const stem = templateName.slice('api_'.length).toLowerCase() + const prefix = prefixes.find( + (key) => stem === key || stem.startsWith(`${key}_`) + ) + return prefix ? API_PROVIDER_MAP[prefix].slug : undefined +} + +const normalize = (value: string) => + value + .toLowerCase() + .replaceAll(/[^a-z0-9]+/g, '') + .replace(/api$/, '') + +function slugify(name: string): string { + return name + .toLowerCase() + .replaceAll(/[^a-z0-9]+/g, '-') + .replace(/^-|-$/g, '') +} + +const catalogued = new Set(workshopModels.map((model) => normalize(model.name))) +const providerNames = new Set( + workshopModels.flatMap((model) => + model.provider ? [normalize(model.provider)] : [] + ) +) +const bySlug = new Map(workshopModels.map((model) => [model.slug, model])) +const takenSlugs = new Set(workshopModels.map((model) => model.slug)) + +interface Draft { + name: string + baseSlug: string + templates: HubTemplate[] +} + +const drafts = new Map() + +for (const template of templates) { + if (!template.tags.includes('API')) continue + const baseSlug = baseSlugOf(template.name) + if (!baseSlug || !bySlug.has(baseSlug)) continue + + for (const declared of template.models) { + const key = normalize(declared) + // A template that names its provider rather than a model, and every model + // the catalogue already lists, stay out. + const baseKey = normalize(bySlug.get(baseSlug)!.name) + if ( + !key || + catalogued.has(key) || + providerNames.has(key) || + // "Grok" next to "Grok Imagine" is the node's own name, not a release. + baseKey.startsWith(key) + ) + continue + const draft = drafts.get(key) ?? { name: declared, baseSlug, templates: [] } + draft.templates.push(template) + drafts.set(key, draft) + } +} + +function majority(values: readonly T[]): T | undefined { + const counts = new Map() + for (const value of values) counts.set(value, (counts.get(value) ?? 0) + 1) + return [...counts].sort((a, b) => b[1] - a[1])[0]?.[0] +} + +const isModality = (value: string): value is Modality => + (MEDIA_TYPES as readonly string[]).includes(value) + +const versions: Version[] = [...drafts.values()] + .map((draft) => { + const base = bySlug.get(draft.baseSlug)! + const busiest = [...draft.templates].sort((a, b) => b.usage - a.usage).at(0) + const declaredModality = majority( + draft.templates.map((template) => template.mediaType) + ) + // A chat model stays text however the workflow around it renders. + const modality = + base.modality === 'text' + ? base.modality + : declaredModality && isModality(declaredModality) + ? declaredModality + : base.modality + let slug = slugify(draft.name) + while (takenSlugs.has(slug)) slug = `${slug}-${draft.baseSlug}` + takenSlugs.add(slug) + return { + name: draft.name, + slug, + baseSlug: draft.baseSlug, + ...(base.provider ? { provider: base.provider } : {}), + ...(modality ? { modality } : {}), + workflowCount: draft.templates.length, + ...(busiest?.thumbnails[0] ? { thumbnailUrl: busiest.thumbnails[0] } : {}) + } + }) + .sort((a, b) => a.slug.localeCompare(b.slug)) + +writeFileSync(OUTPUT, `${JSON.stringify(versions, null, 2)}\n`) +console.log( + `Wrote ${versions.length} models the templates name but the catalogue was missing.` +) diff --git a/apps/website/src/components/common/HeaderMain/HeaderAccount.test.ts b/apps/website/src/components/common/HeaderMain/HeaderAccount.test.ts new file mode 100644 index 00000000000..d3f0b8f4485 --- /dev/null +++ b/apps/website/src/components/common/HeaderMain/HeaderAccount.test.ts @@ -0,0 +1,76 @@ +// @vitest-environment happy-dom +import userEvent from '@testing-library/user-event' +import { render, screen } from '@testing-library/vue' +import { beforeEach, describe, expect, it } from 'vitest' +import { defineComponent, h, nextTick } from 'vue' + +import { useMockSession } from '../../../composables/useMockSession' +import HeaderAccount from './HeaderAccount.vue' + +function mountAccount(kind: 'existing' | 'new') { + let api!: ReturnType + render( + defineComponent({ + setup() { + api = useMockSession() + api.signIn(kind) + return () => h(HeaderAccount) + } + }) + ) + return api +} + +describe('HeaderAccount', () => { + beforeEach(() => { + localStorage.clear() + }) + + it('shows the balance in the header and buys credits from the menu', async () => { + const user = userEvent.setup() + mountAccount('existing') + await nextTick() + + expect(screen.getByTestId('header-credits').textContent).toContain('5,840') + + await user.click(screen.getByTestId('header-account')) + await user.click(await screen.findByTestId('account-plan')) + expect(await screen.findByTestId('buy-credits-dialog')).toBeTruthy() + }) + + it('shows an empty balance as zero and opens the credits flow', async () => { + const user = userEvent.setup() + mountAccount('new') + await nextTick() + + expect(screen.getByTestId('header-credits').textContent.trim()).toBe('0') + + await user.click(screen.getByTestId('header-account')) + await user.click(await screen.findByTestId('account-plan')) + expect(await screen.findByTestId('buy-credits-dialog')).toBeTruthy() + }) + + it('switches workspace from the submenu', async () => { + const user = userEvent.setup() + const api = mountAccount('existing') + await nextTick() + + await user.click(screen.getByTestId('header-account')) + await user.click(await screen.findByTestId('account-workspace')) + await user.click(await screen.findByTestId('account-workspace-Comfy team')) + expect( + api.session.value.status === 'signedIn' && + api.session.value.account.workspace + ).toBe('Comfy team') + }) + + it('signs out back to the sign-in button', async () => { + const user = userEvent.setup() + mountAccount('existing') + await nextTick() + + await user.click(screen.getByTestId('header-account')) + await user.click(await screen.findByTestId('account-sign-out')) + expect(await screen.findByTestId('header-sign-in')).toBeTruthy() + }) +}) diff --git a/apps/website/src/components/common/HeaderMain/HeaderAccount.vue b/apps/website/src/components/common/HeaderMain/HeaderAccount.vue new file mode 100644 index 00000000000..1f9dddc20dd --- /dev/null +++ b/apps/website/src/components/common/HeaderMain/HeaderAccount.vue @@ -0,0 +1,258 @@ + + + diff --git a/apps/website/src/components/common/HeaderMain/HeaderMain.vue b/apps/website/src/components/common/HeaderMain/HeaderMain.vue index 04f81747aeb..ae2077d5398 100644 --- a/apps/website/src/components/common/HeaderMain/HeaderMain.vue +++ b/apps/website/src/components/common/HeaderMain/HeaderMain.vue @@ -6,6 +6,7 @@ import { t } from '../../../i18n/translations.ts' import { externalLinks, getRoutes } from '../../../config/routes.ts' import { useWorkshopAuthFlag } from '../../../scripts/posthog.ts' import GitHubStarBadge from '../GitHubStarBadge.vue' +import PrototypeAccount from './HeaderAccount.vue' import HeaderMainDesktop from './HeaderMainDesktop.vue' import HeaderMainMobile from './HeaderMainMobile.vue' import Button from '@/components/ui/button/Button.vue' @@ -54,7 +55,7 @@ const ctaButtons = [ class="col-span-full row-span-full h-8" />
+
@@ -90,11 +92,12 @@ const ctaButtons = [ :aria-label="cta.ariaLabel" > - - {{ cta.short }} + + {{ cta.short }} + diff --git a/apps/website/src/components/common/HeaderMain/HeaderMainDesktop.test.ts b/apps/website/src/components/common/HeaderMain/HeaderMainDesktop.test.ts new file mode 100644 index 00000000000..a804874136c --- /dev/null +++ b/apps/website/src/components/common/HeaderMain/HeaderMainDesktop.test.ts @@ -0,0 +1,33 @@ +// @vitest-environment happy-dom +import { render, screen } from '@testing-library/vue' +import { describe, expect, it } from 'vitest' +import { nextTick } from 'vue' + +import HeaderMainDesktop from './HeaderMainDesktop.vue' + +async function modelsLink(path: string) { + history.replaceState(null, '', path) + render(HeaderMainDesktop) + await nextTick() + return screen.getByRole('link', { name: /^Models\b/i }) +} + +describe('HeaderMainDesktop', () => { + it('renders the Models leaf link with its NEW badge', async () => { + const link = await modelsLink('/pricing') + expect(link.getAttribute('href')).toBe('/models') + expect(link.textContent).toMatch(/new/i) + expect(link.getAttribute('data-active')).toBeNull() + }) + + it('marks the leaf link active on its own page', async () => { + const link = await modelsLink('/models') + expect(link.getAttribute('data-active')).not.toBeNull() + }) + + it('keeps Products inactive on the Models page it also links to', async () => { + await modelsLink('/models') + const products = screen.getByRole('button', { name: /products/i }) + expect(products.getAttribute('data-active')).toBeNull() + }) +}) diff --git a/apps/website/src/components/common/HeaderMain/HeaderMainDesktop.vue b/apps/website/src/components/common/HeaderMain/HeaderMainDesktop.vue index 74bc6f7baed..27727ff5978 100644 --- a/apps/website/src/components/common/HeaderMain/HeaderMainDesktop.vue +++ b/apps/website/src/components/common/HeaderMain/HeaderMainDesktop.vue @@ -5,6 +5,8 @@ import NavigationMenuItem from '@/components/ui/navigation-menu/NavigationMenuIt import NavigationMenuLink from '@/components/ui/navigation-menu/NavigationMenuLink.vue' import NavigationMenuList from '@/components/ui/navigation-menu/NavigationMenuList.vue' import NavigationMenuTrigger from '@/components/ui/navigation-menu/NavigationMenuTrigger.vue' +import { cn } from '@comfyorg/tailwind-utils' + import { navigationMenuTriggerStyle } from '@/components/ui/navigation-menu/navigationMenuTriggerStyle' import { @@ -24,10 +26,15 @@ const currentPath = useCurrentPath() function isNavItemActive(navItem: NavItem, path: string): boolean { if (navItem.href) return isHrefActive(navItem.href, path) + const onLeafPage = mainNavigation.some( + (item) => item.href && isHrefActive(item.href, path) + ) return ( - navItem.columns?.some((column) => + !onLeafPage && + (navItem.columns?.some((column) => column.items.some((item) => isHrefActive(item.href, path)) - ) ?? false + ) ?? + false) ) } @@ -44,8 +51,8 @@ function isNavItemActive(navItem: NavItem, path: string): boolean { :active="isNavItemActive(navItem, currentPath)" > - {{ navItem.label }} - @@ -70,11 +77,19 @@ function isNavItemActive(navItem: NavItem, path: string): boolean { v-else as-child :active="isNavItemActive(navItem, currentPath)" - :class="navigationMenuTriggerStyle()" + :class=" + cn(navigationMenuTriggerStyle(), 'flex-row gap-1 whitespace-nowrap') + " > - {{ - navItem.label - }} + + {{ navItem.label }} + + diff --git a/apps/website/src/components/common/VideoPlayer.vue b/apps/website/src/components/common/VideoPlayer.vue index ca581c0241f..58092af73a7 100644 --- a/apps/website/src/components/common/VideoPlayer.vue +++ b/apps/website/src/components/common/VideoPlayer.vue @@ -38,6 +38,7 @@ const { muteOnly = false, hideControls = false, hideFullscreen = false, + controlsOnHover = false, playButtonVariant = 'solid', fit = 'cover', ariaLabel, @@ -62,6 +63,10 @@ const { muteOnly?: boolean hideControls?: boolean hideFullscreen?: boolean + /** Where the video is the content rather than something to operate, a + * paused frame should not carry a bar across it: the controls wait for a + * pointer. */ + controlsOnHover?: boolean /** Style of the centered play/pause button in `minimal` mode. */ playButtonVariant?: 'solid' | 'overlay' fit?: 'cover' | 'contain' @@ -105,8 +110,10 @@ watch( const hovering = useElementHover(playerEl) const recentActivity = refAutoReset(false, 800) -const controlsVisible = computed( - () => !playing.value || hovering.value || recentActivity.value +const controlsVisible = computed(() => + controlsOnHover + ? hovering.value || recentActivity.value + : !playing.value || hovering.value || recentActivity.value ) function showControls() { diff --git a/apps/website/src/components/home/ModelDiscoverySection.test.ts b/apps/website/src/components/home/ModelDiscoverySection.test.ts new file mode 100644 index 00000000000..d249e6f9a97 --- /dev/null +++ b/apps/website/src/components/home/ModelDiscoverySection.test.ts @@ -0,0 +1,58 @@ +// @vitest-environment happy-dom +import userEvent from '@testing-library/user-event' +import { render, screen } from '@testing-library/vue' +import { describe, expect, it } from 'vitest' + +import { discoveryProviders } from '../../data/modelDiscovery' +import ModelDiscoverySection from './ModelDiscoverySection.vue' + +describe('ModelDiscoverySection', () => { + it('only lines up providers that run models and have a preview', () => { + expect(discoveryProviders.length).toBeGreaterThan(10) + for (const provider of discoveryProviders) { + expect(provider.modelCount, provider.name).toBeGreaterThan(0) + expect(provider.thumbnailUrl, provider.name).toBeTruthy() + } + }) + + it('sends every provider to the catalog filtered by that provider', () => { + render(ModelDiscoverySection) + + const bytedance = screen.getByRole('link', { name: /ByteDance/ }) + expect(bytedance.getAttribute('href')).toBe('/models?provider=ByteDance') + expect(screen.getByRole('link', { name: /Black Forest Labs/ })).toBeTruthy() + + const browse = screen.getByRole('link', { name: 'Browse all models' }) + expect(browse.getAttribute('href')).toBe('/models') + }) + + it('hides the looping copy of the row from assistive tech', () => { + render(ModelDiscoverySection) + + const visible = screen.getAllByRole('link', { name: /ByteDance/ }) + const all = screen.getAllByRole('link', { + name: /ByteDance/, + hidden: true + }) + expect(visible).toHaveLength(1) + expect(all).toHaveLength(2) + expect(visible[0].getAttribute('tabindex')).toBeNull() + expect(all[1].getAttribute('tabindex')).toBe('-1') + }) + + it('loads a provider preview only once its card is hovered', async () => { + const user = userEvent.setup() + render(ModelDiscoverySection) + + expect(screen.queryByTestId('static-frame')).toBeNull() + await user.hover(screen.getByRole('link', { name: /ByteDance/ })) + expect(screen.getAllByTestId('static-frame').length).toBeGreaterThan(0) + }) + + it('localizes copy while keeping the English-only Workshop route', () => { + render(ModelDiscoverySection, { props: { locale: 'zh-CN' } }) + + const browse = screen.getByRole('link', { name: '浏览全部模型' }) + expect(browse.getAttribute('href')).toBe('/models') + }) +}) diff --git a/apps/website/src/components/home/ModelDiscoverySection.vue b/apps/website/src/components/home/ModelDiscoverySection.vue new file mode 100644 index 00000000000..537ba73a421 --- /dev/null +++ b/apps/website/src/components/home/ModelDiscoverySection.vue @@ -0,0 +1,109 @@ + + + diff --git a/apps/website/src/components/home/ModelReleaseSection.test.ts b/apps/website/src/components/home/ModelReleaseSection.test.ts index baa9685db2d..96475e7300f 100644 --- a/apps/website/src/components/home/ModelReleaseSection.test.ts +++ b/apps/website/src/components/home/ModelReleaseSection.test.ts @@ -16,14 +16,11 @@ describe('ModelReleaseSection', () => { expect(screen.getByText('MiniMax H3', { selector: 'h2' })).toBeTruthy() const explore = screen.getByRole('link', { name: 'Explore Seedance 2.5' }) - expect(explore.getAttribute('href')).toBe('/seedance-2.5') + expect(explore.getAttribute('href')).toBe('/models/seedance-2/') const tryCta = screen.getByRole('link', { name: 'Try Workflow' }) - expect(tryCta.getAttribute('href')).toBe( - 'https://cloud.comfy.org/?template=api_seedance2_5_r2v' - ) - expect(tryCta.getAttribute('target')).toBe('_blank') - expect(tryCta.getAttribute('rel')).toBe('noopener noreferrer') + expect(tryCta.getAttribute('href')).toBe('/models/seedance-2/') + expect(tryCta.getAttribute('target')).toBeNull() expect(screen.getAllByText('Partner Nodes').length).toBeGreaterThan(0) expect(screen.getAllByText('Open Weights').length).toBeGreaterThan(0) @@ -35,7 +32,7 @@ describe('ModelReleaseSection', () => { expect(screen.getAllByText('新模型发布').length).toBeGreaterThan(0) const explore = screen.getByRole('link', { name: '探索 Seedance 2.5' }) - expect(explore.getAttribute('href')).toBe('/zh-CN/seedance-2.5') + expect(explore.getAttribute('href')).toBe('/models/seedance-2/') expect(screen.getByRole('link', { name: '试用工作流' })).toBeTruthy() expect(screen.getAllByText('合作伙伴节点').length).toBeGreaterThan(0) diff --git a/apps/website/src/components/home/ModelReleaseSection.vue b/apps/website/src/components/home/ModelReleaseSection.vue index da04a6f38b4..7c1c1bd44a6 100644 --- a/apps/website/src/components/home/ModelReleaseSection.vue +++ b/apps/website/src/components/home/ModelReleaseSection.vue @@ -1,5 +1,6 @@