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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions apps/website/e2e/workshop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,57 @@ test.describe('Models catalog', () => {
await expect(page.getByTestId('workshop-hero')).toBeVisible()
})

test('a model page returns to the shelf it was opened from', async ({
page
}) => {
await page.goto('/models/')
await page.getByTestId('section-generate-videos-open').click()
await expect(page.getByRole('heading', { level: 1 })).toContainText(
'Generate videos'
)
await page
.getByTestId('workshop-models-grid')
.getByTestId('workshop-model-card')
.first()
.click()

const back = page.getByTestId('model-back')
await expect(back).toHaveText('Back to Generate videos')
await back.click()
await expect(page.getByRole('heading', { level: 1 })).toContainText(
'Generate videos'
)
await expect(page.getByTestId('workshop-sections')).toHaveCount(0)
})

test('the search field stays put as the results swap under it', async ({
page
}) => {
await page.goto('/models/')
await expect(page.getByTestId('workshop-sections')).toBeVisible()
await page.evaluate(() => window.scrollTo(0, 700))
const search = page.getByTestId('workshop-search')

// Nothing else is clicked between the two measurements: a click scrolls its
// own target into view first, which would move the page under the field.
await search.fill('kling')
await expect(
page
.getByTestId('workshop-models-grid')
.getByTestId('workshop-model-card')
.first()
).toContainText('Kling')
const searching = await search.boundingBox()

await search.fill('')
await expect(page.getByTestId('workshop-sections')).toBeVisible()
const cleared = await search.boundingBox()

if (!searching || !cleared)
throw new Error('the search field was never on screen to measure')
expect(cleared.y).toBeCloseTo(searching.y, 0)
})

test('cards open canonical model pages with related models', async ({
page
}) => {
Expand Down
31 changes: 31 additions & 0 deletions apps/website/src/components/workshop/CatalogueBackLink.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// @vitest-environment happy-dom
import { render, screen, waitFor } from '@testing-library/vue'
import { afterEach, describe, expect, it } from 'vitest'

import { rememberShelf } from '../../lib/workshop/shelf-memory'
import CatalogueBackLink from './CatalogueBackLink.vue'

afterEach(() => {
sessionStorage.clear()
})

describe('CatalogueBackLink', () => {
it('offers the whole catalogue when no shelf was left behind', () => {
render(CatalogueBackLink)

const link = screen.getByTestId('model-back')
expect(link.textContent.trim()).toBe('Back to all models')
expect(link.getAttribute('href')).toBe('/models')
})

it('offers the shelf the visitor came from', async () => {
rememberShelf('generate-videos')
render(CatalogueBackLink)

await waitFor(() => {
const link = screen.getByTestId('model-back')
expect(link.textContent.trim()).toBe('Back to Generate videos')
expect(link.getAttribute('href')).toBe('/models?useCase=generate-videos')
})
})
})
42 changes: 42 additions & 0 deletions apps/website/src/components/workshop/CatalogueBackLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { ChevronLeft } from '@lucide/vue'
import { onMounted, ref } from 'vue'

import { catalogSearch } from '../../config/models-catalogue'
import { getRoutes } from '../../config/routes'
import type { Locale } from '../../i18n/translations'
import { t } from '../../i18n/translations'
import { lastShelf } from '../../lib/workshop/shelf-memory'
import { useCaseLabelKey } from '../../lib/workshop/use-case-label'

const { locale = 'en' } = defineProps<{ locale?: Locale }>()

const routes = getRoutes(locale)
const href = ref(routes.workshop)
const category = ref<string>()

// Most visitors reach a model from a shelf, and the way back they want is that
// shelf, not the whole catalogue. Opened in a new tab, or reached from a link
// somebody shared, there is no shelf to return to and the catalogue answers.
onMounted(() => {
const shelf = lastShelf()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Low — Nothing invalidates the stored shelf except WorkshopModelsGrid writing a new one, so a model page reached without passing back through the catalogue — a related-model card on this very page, or a shared link opened in the same tab — still offers "Back to Generate videos" for a shelf the visitor never came from and that may not even contain the model. Stamping the stored value with the slug it was captured for, or clearing it once consumed, would keep the link honest.

Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).

if (!shelf || shelf === 'all') return
href.value = `${routes.workshop}${catalogSearch({ useCase: shelf })}`
category.value = t(useCaseLabelKey[shelf], locale)
})
</script>

<template>
<a
:href
class="hover:text-primary-comfy-yellow focus-visible:ring-primary-comfy-yellow/50 -ml-1 inline-flex items-center gap-1 rounded-lg px-1 text-sm font-medium text-primary-warm-gray opacity-60 transition hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-3"
data-testid="model-back"
>
<ChevronLeft class="size-4" aria-hidden="true" />
{{
category
? t('workshop.model.backTo', locale).replace('{category}', category)
: t('workshop.model.back', locale)
}}
</a>
</template>
13 changes: 8 additions & 5 deletions apps/website/src/components/workshop/ExamplesTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div class="flex flex-col gap-1">
<h2 class="text-sm font-bold text-primary-warm-white">
{{
t(

Check failure on line 46 in apps/website/src/components/workshop/ExamplesTab.vue

View workflow job for this annotation

GitHub Actions / fallow

High cognitive complexity (high)

Function '<template>' is hard to understand (cognitive: 37, threshold: 15). • Severity: high • Cyclomatic: 16 • Cognitive: 37 • Lines: 182 High cognitive complexity means deeply nested or interleaved logic. Consider flattening control flow or extracting helper functions.
samplesOnly
? 'workshop.examples.samples'
: 'workshop.examples.start',
Expand Down Expand Up @@ -73,7 +73,7 @@
they fit in a row of their own. -->
<ul
v-else
class="flex scrollbar-hide snap-x gap-3 overflow-x-auto max-sm:-mx-6 max-sm:-my-1 max-sm:scroll-px-6 max-sm:px-6 max-sm:py-1 sm:grid sm:max-w-2xl sm:grid-cols-3 sm:overflow-visible"
class="flex scrollbar-hide snap-x gap-3 overflow-x-auto max-sm:-mx-6 max-sm:-my-1 max-sm:scroll-px-6 max-sm:px-6 max-sm:py-1 sm:grid sm:max-w-5xl sm:grid-cols-[repeat(auto-fit,minmax(14rem,1fr))] sm:overflow-visible"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

SHOULD FIX: auto-fit collapses the empty tracks and stretches the remaining 1fr ones, and the <li> is sm:w-auto, so a model with a single example renders one card the full max-w-5xl (~64rem wide, ~36rem tall at aspect-video); two examples become ~32rem each. Before this change a lone example was a third of max-w-2xl. One-example models exist (workshop.examples.subtitleOne is right above).

auto-fill keeps the empty tracks so a lone card stays ~16rem while four still fill the row:

Suggested change
class="flex scrollbar-hide snap-x gap-3 overflow-x-auto max-sm:-mx-6 max-sm:-my-1 max-sm:scroll-px-6 max-sm:px-6 max-sm:py-1 sm:grid sm:max-w-5xl sm:grid-cols-[repeat(auto-fit,minmax(14rem,1fr))] sm:overflow-visible"
class="flex scrollbar-hide snap-x gap-3 overflow-x-auto max-sm:-mx-6 max-sm:-my-1 max-sm:scroll-px-6 max-sm:px-6 max-sm:py-1 sm:grid sm:max-w-5xl sm:grid-cols-[repeat(auto-fill,minmax(14rem,1fr))] sm:overflow-visible"

>
<li
v-for="example in examples"
Expand All @@ -82,15 +82,18 @@
>
<button
type="button"
:aria-label="
:aria-label="`${example.title}: ${
example.sampleOnly
? actionFor(example)
: t('workshop.examples.open', locale)
"
}`"
:aria-current="example.id === activeId ? 'true' : undefined"
class="group flex w-full cursor-pointer flex-col gap-2 text-left outline-none"
data-testid="example-card"
:title="actionFor(example, example.id === activeId)"
:title="`${example.title} · ${actionFor(
example,
example.id === activeId
)}`"
@click="emit('open', example)"
>
<span
Expand Down Expand Up @@ -147,7 +150,7 @@
<span
:class="
cn(
'line-clamp-2 text-xs transition-colors',
'line-clamp-1 text-xs transition-colors',
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
example.id === activeId
? 'text-primary-warm-white'
: 'text-primary-comfy-canvas group-hover:text-primary-warm-white'
Expand Down
12 changes: 8 additions & 4 deletions apps/website/src/components/workshop/FeaturedBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

<template>
<section
v-if="active"

Check warning on line 80 in apps/website/src/components/workshop/FeaturedBanner.vue

View workflow job for this annotation

GitHub Actions / fallow

High cognitive complexity (moderate)

Function '<template>' is hard to understand (cognitive: 21, threshold: 15). • Severity: moderate • Cyclomatic: 11 • Cognitive: 21 • Lines: 183 High cognitive complexity means deeply nested or interleaved logic. Consider flattening control flow or extracting helper functions.
ref="banner"
:aria-label="t('workshop.sections.featured', locale)"
class="rounded-4.5xl relative isolate overflow-hidden border border-transparency-white-t8"
Expand Down Expand Up @@ -118,27 +118,31 @@
class="sm:short:gap-3 relative flex h-full flex-col justify-end gap-4 p-6 pb-16 sm:max-w-2xl sm:justify-center lg:p-8 lg:pb-16"
>
<div class="flex flex-wrap items-center gap-2">
<Badge variant="subtle" size="md" class="text-primary-comfy-canvas">
<Badge
variant="subtle"
size="md"
class="text-primary-comfy-canvas backdrop-blur-md"
>
{{ active.task }}
</Badge>
<Badge
v-for="capability in active.capabilities"
:key="capability"
variant="subtle"
size="md"
class="text-content-secondary max-sm:hidden"
class="text-content-secondary backdrop-blur-md max-sm:hidden"
>
{{ capability }}
</Badge>
</div>

<h2 class="text-4xl font-bold text-primary-warm-white">
<h2 class="text-2xl font-bold text-primary-warm-white lg:text-3xl">
{{ active.model.name }}
</h2>

<p
v-if="active.model.summary"
class="text-content-secondary line-clamp-2 max-w-prose"
class="text-content-secondary line-clamp-2 max-w-prose max-sm:line-clamp-1"
>
{{ active.model.summary }}
</p>
Expand Down
7 changes: 3 additions & 4 deletions apps/website/src/components/workshop/FileSourceInput.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ describe('file source selection', () => {
screen.getByLabelText('Images', { selector: 'input' }),
file
)
if (type.startsWith('video/') || type.startsWith('audio/')) {
if (type.startsWith('video/')) {
const preview = screen.getByLabelText(name)
expect(preview).toBeInstanceOf(HTMLMediaElement)
expect(preview).toHaveProperty('controls', true)
expect(preview).toBeInstanceOf(HTMLVideoElement)
expect(preview.getAttribute('src')).toMatch(/^blob:/)
} else {
expect(screen.getByText(label)).toBeTruthy()
expect(screen.getByText('2 KB')).toBeTruthy()
}
expect(screen.getByText('2 KB')).toBeTruthy()
expect(screen.queryByRole('img')).toBeNull()
expect(values.value).toMatchObject([{ file }])
expect(screen.getByText('Choose files or drop them here')).toBeTruthy()
Expand Down
Loading
Loading