Skip to content
15 changes: 10 additions & 5 deletions apps/website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,17 @@ refresh preserves the last confirmed answer for the same identity; a new
identity never inherits a grant. Disabling it restores the public site:

- The header and homepage retain their existing navigation and model links.
- `/models` shows the existing Models marketing page.
- Model render pages show the public marketing content until enabled.
- `/hub/models/` shows the Models marketing page in place of the catalogue.
The old `/models` address redirects there.
- Router model pages at `/hub/models/<slug>/` render their public content.
Workflow pages show the marketing content until enabled.
- Catalogue and playground markup is absent from public HTML; their components
and page data load after enablement. Homepage islands still serialize public
model and provider summaries. `/models` remains indexable with its marketing content.
- Render pages stay out of sitemaps and markdown exports. `/models/showcase`
model and provider summaries. `/hub/models/` remains indexable with its
marketing content.
- Router model pages are indexable and listed in the sitemap and markdown
exports (`launchedModelPages`). Workflow pages stay out until
`launchedWorkflowPages` is on. `/models/showcase`
is the unlisted public copy of the marketing page: noindex and out of the
sitemap.
- Once enabled, a neutral loading frame replaces the public content while a
Expand All @@ -296,7 +301,7 @@ sign in through the website never join that cohort.
The website identifies signed-in people with their Firebase UID, matching
Cloud's PostHog identity. For a verified `comfy.org` or `drip.art` email it
also sets `comfy_staff: true`; every other account sends nothing beyond the
UID. Give staff `/login/?returnTo=%2Fmodels%2F` so they can sign in before
UID. Give staff `/login/?returnTo=%2Fhub%2Fmodels%2F` so they can sign in before
their Models flag is evaluated. Anyone who signed in before `comfy_staff`
existed must sign out and back in once. Authentication is available before
PostHog answers, including when flags are missing or unavailable; no separate
Expand Down
19 changes: 19 additions & 0 deletions apps/website/e2e/hub-navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,25 @@ test('the mobile menu closes and reopens after its Hub link navigates', async ({
await expect(page.getByRole('heading', { level: 1 })).toBeVisible()
})

test('mobile search suggestions show a video model as a still frame', async ({
page
}) => {
await page.setViewportSize({ width: 390, height: 900 })
await page.goto('/hub/models/')
const open = page.getByTestId('workshop-search-button')
await waitForIsland(page, open)
await open.click()
await page.getByTestId('workshop-search-sheet-input').fill('seedance')
const sheet = page.getByTestId('workshop-search-sheet')
await expect(sheet.getByTestId('workshop-search-model')).toHaveCount(4)
await expect(
sheet.getByTestId('workshop-search-model-video')
).not.toHaveCount(0)
await expect(
sheet.locator('img[src*=".mp4"], img[src*=".webm"], img[src*=".mov"]')
).toHaveCount(0)
})

test('keeps the current listing visible until a cold destination is ready', async ({
page,
context
Expand Down
79 changes: 78 additions & 1 deletion apps/website/src/components/workshop/WorkshopSearchPanel.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import userEvent from '@testing-library/user-event'
import { render, screen } from '@testing-library/vue'
import { fireEvent, render, screen } from '@testing-library/vue'
import { describe, expect, it } from 'vitest'

import type { WorkshopModel } from '@/config/models-catalogue'
import WorkshopSearchPanel from './WorkshopSearchPanel.vue'

type ThumbnailFields = Pick<WorkshopModel, 'thumbnail' | 'thumbnailUrl'>

const models: WorkshopModel[] = [
{
slug: 'zeta',
Expand Down Expand Up @@ -59,6 +61,81 @@ describe('WorkshopSearchPanel', () => {
).toBeTruthy()
})

const clip = 'https://comfy-hub-assets.comfy.org/uploads/3f2a9c'
const still = 'https://media.comfy.org/still.webp'

it.for<[string, ThumbnailFields, string]>([
[
'a declared video',
{ thumbnailUrl: clip, thumbnail: { url: clip, kind: 'video' } },
clip
],
[
'a .mp4 URL with no declared kind',
{ thumbnailUrl: 'https://media.comfy.org/clip.mp4' },
'https://media.comfy.org/clip.mp4'
],
[
'a declared video with no thumbnailUrl',
{ thumbnail: { url: clip, kind: 'video' } },
clip
],
[
'a declared video whose thumbnailUrl names another file',
{ thumbnailUrl: still, thumbnail: { url: clip, kind: 'video' } },
clip
]
])('shows %s as a still frame, not a broken image', ([, fields, src]) => {
render(WorkshopSearchPanel, {
props: { models: [{ ...models[1], ...fields }], query: 'alpha' }
})
expect(
screen.getByTestId('workshop-search-model-video').getAttribute('src')
).toBe(`${src}#t=0.1`)
})

it.for<[string, ThumbnailFields]>([
[
'a declared audio thumbnail',
{
thumbnailUrl: 'https://media.comfy.org/sound',
thumbnail: { url: 'https://media.comfy.org/sound', kind: 'audio' }
}
],
[
'an .mp3 URL with no declared kind',
{ thumbnailUrl: 'https://media.comfy.org/sound.mp3' }
]
])('shows the initial instead of a broken image for %s', ([, fields]) => {
render(WorkshopSearchPanel, {
props: { models: [{ ...models[1], ...fields }], query: 'alpha' }
})
expect(screen.getByText('A')).toBeTruthy()
})

it.for<[string, ThumbnailFields, () => HTMLElement]>([
[
'video',
{ thumbnail: { url: clip, kind: 'video' } },
() => screen.getByTestId('workshop-search-model-video')
],
[
'image',
{ thumbnailUrl: still },
() => screen.getByTestId('workshop-search-model-image')
]
])(
'shows the initial when the %s thumbnail fails to load',
async ([, fields, media]) => {
render(WorkshopSearchPanel, {
props: { models: [{ ...models[1], ...fields }], query: 'alpha' }
})
expect(screen.queryByText('A')).toBeNull()
await fireEvent.error(media())
expect(screen.getByText('A')).toBeTruthy()
}
)

it('shows an empty state for a query without matches', () => {
render(WorkshopSearchPanel, {
props: { models, query: 'missing' }
Expand Down
45 changes: 41 additions & 4 deletions apps/website/src/components/workshop/WorkshopSearchPanel.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed } from 'vue'
import { computed, reactive } from 'vue'

import { cn } from '@comfyorg/tailwind-utils'

Expand All @@ -8,6 +8,11 @@ import {
filterWorkshopModels,
sortWorkshopModels
} from '@/config/models-catalogue'
import {
isAudioUrl,
isVideoUrl,
videoPosterUrl
} from '@/config/workshop-playground'
import type { Locale } from '@/i18n/translations'
import { translationsFor } from '@/i18n/translations'

Expand Down Expand Up @@ -42,6 +47,25 @@ const suggestions = computed(() =>
: []
)

const failedThumbnails = reactive(new Set<string>())

function kindOfUrl(url: string) {
if (isVideoUrl(url)) return 'video'
if (isAudioUrl(url)) return 'audio'
return 'image'
}

function thumbnailOf(model: WorkshopModel) {
const url = model.thumbnail?.url ?? model.thumbnailUrl
if (!url || failedThumbnails.has(url)) return undefined
const kind = model.thumbnail?.kind ?? kindOfUrl(url)
return kind === 'audio' ? undefined : { url, kind }
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
}

const rows = computed(() =>
suggestions.value.map((model) => ({ model, thumbnail: thumbnailOf(model) }))
)

function sourceOf(model: WorkshopModel): string | undefined {
if (model.type === 'APP') return t('workshop.card.comfyApp')
if (model.routerId === undefined) return model.models?.join(', ')
Expand Down Expand Up @@ -75,21 +99,34 @@ function sourceOf(model: WorkshopModel): string | undefined {
<span class="tabular-nums opacity-60">({{ matching.length }})</span>
</p>
<button
v-for="model in suggestions"
v-for="{ model, thumbnail } in rows"
:key="model.slug"
type="button"
class="flex cursor-pointer items-center gap-3 rounded-xl p-2 text-left outline-none hover:bg-transparency-white-t4 focus-visible:bg-transparency-white-t4"
data-testid="workshop-search-model"
@mousedown.prevent
@click="emit('pick', model)"
>
<video
v-if="thumbnail?.kind === 'video'"
:src="videoPosterUrl(thumbnail.url)"
class="size-10 shrink-0 rounded-lg object-cover"
aria-hidden="true"
data-testid="workshop-search-model-video"
muted
playsinline
preload="metadata"
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
@error="failedThumbnails.add(thumbnail.url)"
/>
<img
v-if="model.thumbnailUrl"
:src="model.thumbnailUrl"
v-else-if="thumbnail"
:src="thumbnail.url"
alt=""
class="size-10 shrink-0 rounded-lg object-cover"
data-testid="workshop-search-model-image"
loading="lazy"
decoding="async"
@error="failedThumbnails.add(thumbnail.url)"
/>
<span
v-else
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export const externalLinks = {

/**
* The platform creates a key on arrival and shows this product's onboarding.
* `model` is the website's model page id (`/models/<slug>`), not the Router id.
* `model` is the website's model page id (`/hub/models/<slug>/`), not the Router id.
*/
type ApiKeysOnboarding =
| { onboarding: 'router' | 'comfy_api' }
Expand Down
4 changes: 4 additions & 0 deletions apps/website/src/config/workshop-playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,10 @@ export function isVideoUrl(url: string): boolean {
return /\.(mp4|webm|mov)(?:[?#]|$)/i.test(url)
}

export function isAudioUrl(url: string): boolean {
return /\.(mp3|wav|ogg|m4a|flac)(?:[?#]|$)/i.test(url)
}

/** A video address that makes Safari paint a frame before playback. */
export function videoPosterUrl(url: string): string {
return url.includes('#') ? url : `${url}#t=0.1`
Expand Down
Loading