From c2c0375749e6ecf83a87730d3a5286e9d6779901 Mon Sep 17 00:00:00 2001 From: Maanil Verma Date: Tue, 29 Sep 2026 12:12:45 +0530 Subject: [PATCH 1/4] feat(website): lead model page titles with API & Playground --- apps/website/src/i18n/translations.ts | 12 ++++ .../src/lib/workshop/model-title.test.ts | 62 +++++++++++++++++++ apps/website/src/lib/workshop/model-title.ts | 15 +++++ apps/website/src/routes/models/[slug].astro | 3 +- 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 apps/website/src/lib/workshop/model-title.test.ts create mode 100644 apps/website/src/lib/workshop/model-title.ts diff --git a/apps/website/src/i18n/translations.ts b/apps/website/src/i18n/translations.ts index 7e53b6fac9d..cb3cc59cdb5 100644 --- a/apps/website/src/i18n/translations.ts +++ b/apps/website/src/i18n/translations.ts @@ -9755,6 +9755,18 @@ Enterprise` 'workshop.model.tabs.playground': { en: 'Playground', 'zh-CN': 'Playground' }, 'workshop.model.tabs.api': { en: 'API', 'zh-CN': 'API' }, 'workshop.model.tabs.details': { en: 'Details', 'zh-CN': '详情' }, + 'workshop.model.meta.title': { + en: '{name} API & Playground - Comfy', + 'zh-CN': '{name} API 与 Playground - Comfy' + }, + 'workshop.model.meta.titleApi': { + en: '{name} API - Comfy', + 'zh-CN': '{name} API - Comfy' + }, + 'workshop.model.meta.titleName': { + en: '{name} - Comfy', + 'zh-CN': '{name} - Comfy' + }, 'workshop.model.relatedProvider': { en: 'More from {provider}', 'zh-CN': '{provider} 的更多模型' diff --git a/apps/website/src/lib/workshop/model-title.test.ts b/apps/website/src/lib/workshop/model-title.test.ts new file mode 100644 index 00000000000..d25faaba02f --- /dev/null +++ b/apps/website/src/lib/workshop/model-title.test.ts @@ -0,0 +1,62 @@ +import { describe, expect, it } from 'vitest' + +import { workshopPages } from '../../config/workshop-page-content' +import { modelTitle } from './model-title' + +const MAX_LENGTH = 60 +const fullTitle = (name: string) => `${name} API & Playground - Comfy` +const nameOfLength = (length: number) => 'x'.repeat(length) + +describe('modelTitle', () => { + it.for([ + { + name: 'names the API and playground when they fit', + modelName: 'Seedream 4.0', + expected: 'Seedream 4.0 API & Playground - Comfy' + }, + { + name: 'keeps the full title at exactly the limit', + modelName: nameOfLength(35), + expected: `${nameOfLength(35)} API & Playground - Comfy` + }, + { + name: 'drops the playground one character past the limit', + modelName: nameOfLength(36), + expected: `${nameOfLength(36)} API - Comfy` + }, + { + name: 'keeps the API title at exactly the limit', + modelName: nameOfLength(48), + expected: `${nameOfLength(48)} API - Comfy` + }, + { + name: 'falls back to the name alone when nothing else fits', + modelName: nameOfLength(49), + expected: `${nameOfLength(49)} - Comfy` + }, + { + name: 'writes the Chinese title with the Chinese conjunction', + locale: 'zh-CN' as const, + modelName: 'Seedream 4.0', + expected: 'Seedream 4.0 API 与 Playground - Comfy' + } + ])('$name', ({ modelName, locale, expected }) => { + expect(modelTitle({ name: modelName }, locale)).toBe(expected) + }) + + it('gives every model page a short, unique title that leads with its name', () => { + expect(workshopPages.length).toBeGreaterThan(100) + const titles = workshopPages.map((model) => { + const title = modelTitle(model) + expect(title.startsWith(`${model.name} `)).toBe(true) + expect(title.length).toBeLessThanOrEqual(MAX_LENGTH) + expect(title).not.toMatch(/undefined|· Models/) + expect(title.endsWith(' - Comfy')).toBe(true) + expect(title.split(' - Comfy')).toHaveLength(2) + if (title !== fullTitle(model.name)) + expect(fullTitle(model.name).length).toBeGreaterThan(MAX_LENGTH) + return title + }) + expect(new Set(titles).size).toBe(titles.length) + }) +}) diff --git a/apps/website/src/lib/workshop/model-title.ts b/apps/website/src/lib/workshop/model-title.ts new file mode 100644 index 00000000000..1c8dd542f07 --- /dev/null +++ b/apps/website/src/lib/workshop/model-title.ts @@ -0,0 +1,15 @@ +import type { Locale } from '../../i18n/translations' +import { t } from '../../i18n/translations' + +const TITLE_MAX = 60 + +export function modelTitle(model: { name: string }, locale: Locale = 'en') { + const [full, apiOnly, nameOnly] = ( + [ + 'workshop.model.meta.title', + 'workshop.model.meta.titleApi', + 'workshop.model.meta.titleName' + ] as const + ).map((key) => t(key, locale, { name: model.name })) + return [full, apiOnly].find((title) => title.length <= TITLE_MAX) ?? nameOnly +} diff --git a/apps/website/src/routes/models/[slug].astro b/apps/website/src/routes/models/[slug].astro index c54fcaefeba..714bae8c7f6 100644 --- a/apps/website/src/routes/models/[slug].astro +++ b/apps/website/src/routes/models/[slug].astro @@ -5,6 +5,7 @@ import ModelsPage from '../../components/workshop/ModelsPage.vue' import ModelsShowcase from '../../components/models/ModelsShowcase.astro' import { workshopPagePaths } from '../../config/workshop-page-content' import { t } from '../../i18n/translations' +import { modelTitle } from '../../lib/workshop/model-title' import { prepareModelPage } from './model-page' export const getStaticPaths: GetStaticPaths = () => @@ -19,7 +20,7 @@ const { model } = page --- Date: Wed, 30 Sep 2026 00:51:55 +0530 Subject: [PATCH 2/4] fix(website): keep API & Playground in long model titles Drop the brand suffix before the playground phrase, and shorten the name at a word boundary on the last rung so no name length can exceed 60. --- apps/website/src/i18n/translations.ts | 8 +-- .../src/lib/workshop/model-title.test.ts | 67 ++++++++++--------- apps/website/src/lib/workshop/model-title.ts | 25 ++++--- 3 files changed, 58 insertions(+), 42 deletions(-) diff --git a/apps/website/src/i18n/translations.ts b/apps/website/src/i18n/translations.ts index cb3cc59cdb5..ecf788b7333 100644 --- a/apps/website/src/i18n/translations.ts +++ b/apps/website/src/i18n/translations.ts @@ -9759,14 +9759,14 @@ Enterprise` en: '{name} API & Playground - Comfy', 'zh-CN': '{name} API 与 Playground - Comfy' }, + 'workshop.model.meta.titleUnbranded': { + en: '{name} API & Playground', + 'zh-CN': '{name} API 与 Playground' + }, 'workshop.model.meta.titleApi': { en: '{name} API - Comfy', 'zh-CN': '{name} API - Comfy' }, - 'workshop.model.meta.titleName': { - en: '{name} - Comfy', - 'zh-CN': '{name} - Comfy' - }, 'workshop.model.relatedProvider': { en: 'More from {provider}', 'zh-CN': '{provider} 的更多模型' diff --git a/apps/website/src/lib/workshop/model-title.test.ts b/apps/website/src/lib/workshop/model-title.test.ts index d25faaba02f..0048a2680cd 100644 --- a/apps/website/src/lib/workshop/model-title.test.ts +++ b/apps/website/src/lib/workshop/model-title.test.ts @@ -1,62 +1,69 @@ import { describe, expect, it } from 'vitest' -import { workshopPages } from '../../config/workshop-page-content' +import type { Locale } from '../../i18n/translations' +import { t } from '../../i18n/translations' import { modelTitle } from './model-title' -const MAX_LENGTH = 60 -const fullTitle = (name: string) => `${name} API & Playground - Comfy` const nameOfLength = (length: number) => 'x'.repeat(length) +const full = (name: string, locale: Locale = 'en') => + t('workshop.model.meta.title', locale, { name }) +const unbranded = (name: string) => + t('workshop.model.meta.titleUnbranded', 'en', { name }) +const apiOnly = (name: string) => + t('workshop.model.meta.titleApi', 'en', { name }) describe('modelTitle', () => { it.for([ { name: 'names the API and playground when they fit', modelName: 'Seedream 4.0', - expected: 'Seedream 4.0 API & Playground - Comfy' + expected: full('Seedream 4.0') }, { name: 'keeps the full title at exactly the limit', modelName: nameOfLength(35), - expected: `${nameOfLength(35)} API & Playground - Comfy` + expected: full(nameOfLength(35)) }, { - name: 'drops the playground one character past the limit', + name: 'drops the brand before the playground', modelName: nameOfLength(36), - expected: `${nameOfLength(36)} API - Comfy` + expected: unbranded(nameOfLength(36)) }, { - name: 'keeps the API title at exactly the limit', + name: 'keeps the unbranded title at exactly the limit', + modelName: nameOfLength(43), + expected: unbranded(nameOfLength(43)) + }, + { + name: 'falls back to the API title when the playground no longer fits', + modelName: nameOfLength(44), + expected: apiOnly(nameOfLength(44)) + }, + { + name: 'keeps the whole name in the API title at exactly the limit', modelName: nameOfLength(48), - expected: `${nameOfLength(48)} API - Comfy` + expected: apiOnly(nameOfLength(48)) }, { - name: 'falls back to the name alone when nothing else fits', - modelName: nameOfLength(49), - expected: `${nameOfLength(49)} - Comfy` + name: 'shortens a longer name at a word boundary', + modelName: + 'Seed Audio 1.0 Multilingual Text-to-Speech with Voice Cloning Preview', + expected: apiOnly('Seed Audio 1.0 Multilingual Text-to-Speech with…') + }, + { + name: 'cuts a long name with no spaces to fit', + modelName: nameOfLength(70), + expected: apiOnly(`${nameOfLength(47)}…`) }, { name: 'writes the Chinese title with the Chinese conjunction', locale: 'zh-CN' as const, modelName: 'Seedream 4.0', - expected: 'Seedream 4.0 API 与 Playground - Comfy' + expected: full('Seedream 4.0', 'zh-CN') } ])('$name', ({ modelName, locale, expected }) => { - expect(modelTitle({ name: modelName }, locale)).toBe(expected) - }) - - it('gives every model page a short, unique title that leads with its name', () => { - expect(workshopPages.length).toBeGreaterThan(100) - const titles = workshopPages.map((model) => { - const title = modelTitle(model) - expect(title.startsWith(`${model.name} `)).toBe(true) - expect(title.length).toBeLessThanOrEqual(MAX_LENGTH) - expect(title).not.toMatch(/undefined|· Models/) - expect(title.endsWith(' - Comfy')).toBe(true) - expect(title.split(' - Comfy')).toHaveLength(2) - if (title !== fullTitle(model.name)) - expect(fullTitle(model.name).length).toBeGreaterThan(MAX_LENGTH) - return title - }) - expect(new Set(titles).size).toBe(titles.length) + const title = modelTitle({ name: modelName }, locale) + expect(title).toBe(expected) + expect(title.length).toBeLessThanOrEqual(60) }) }) diff --git a/apps/website/src/lib/workshop/model-title.ts b/apps/website/src/lib/workshop/model-title.ts index 1c8dd542f07..884a71853c5 100644 --- a/apps/website/src/lib/workshop/model-title.ts +++ b/apps/website/src/lib/workshop/model-title.ts @@ -2,14 +2,23 @@ import type { Locale } from '../../i18n/translations' import { t } from '../../i18n/translations' const TITLE_MAX = 60 +const ELLIPSIS = '…' + +function shortenAtWord(text: string, max: number) { + if (text.length <= max) return text + const limit = max - ELLIPSIS.length + const wordEnd = text.lastIndexOf(' ', limit) + return `${text.slice(0, wordEnd > 0 ? wordEnd : limit)}${ELLIPSIS}` +} export function modelTitle(model: { name: string }, locale: Locale = 'en') { - const [full, apiOnly, nameOnly] = ( - [ - 'workshop.model.meta.title', - 'workshop.model.meta.titleApi', - 'workshop.model.meta.titleName' - ] as const - ).map((key) => t(key, locale, { name: model.name })) - return [full, apiOnly].find((title) => title.length <= TITLE_MAX) ?? nameOnly + const fitting = ( + ['workshop.model.meta.title', 'workshop.model.meta.titleUnbranded'] as const + ) + .map((key) => t(key, locale, { name: model.name })) + .find((title) => title.length <= TITLE_MAX) + if (fitting) return fitting + const apiKey = 'workshop.model.meta.titleApi' + const nameBudget = TITLE_MAX - t(apiKey, locale, { name: '' }).length + return t(apiKey, locale, { name: shortenAtWord(model.name, nameBudget) }) } From 352b0a799ea67ec880495f1ded0f4343956b738e Mon Sep 17 00:00:00 2001 From: Maanil Verma Date: Wed, 30 Sep 2026 00:53:36 +0530 Subject: [PATCH 3/4] test(website): check display-name uniqueness beside the page catalogue --- apps/website/src/config/workshop-workflow-content.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/website/src/config/workshop-workflow-content.test.ts b/apps/website/src/config/workshop-workflow-content.test.ts index 732e9964555..efc48cc5c10 100644 --- a/apps/website/src/config/workshop-workflow-content.test.ts +++ b/apps/website/src/config/workshop-workflow-content.test.ts @@ -264,3 +264,10 @@ describe('curated workflow pages', () => { } ) }) + +describe('workshop pages', () => { + it('gives every model and workflow page its own display name', () => { + const names = workshopPages.map((model) => model.name) + expect(new Set(names).size).toBe(names.length) + }) +}) From d697ab9b7f3d3a2fbe077ccbc99bc311f97e854b Mon Sep 17 00:00:00 2001 From: Maanil Verma Date: Wed, 30 Sep 2026 01:07:38 +0530 Subject: [PATCH 4/4] test(website): check page title uniqueness instead of display names --- apps/website/src/config/workshop-workflow-content.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/website/src/config/workshop-workflow-content.test.ts b/apps/website/src/config/workshop-workflow-content.test.ts index efc48cc5c10..f5922936a00 100644 --- a/apps/website/src/config/workshop-workflow-content.test.ts +++ b/apps/website/src/config/workshop-workflow-content.test.ts @@ -6,6 +6,7 @@ import { assert, describe, expect, it } from 'vitest' import displayJson from '../content/workshop-display.json' import categories from '../content/workshop-workflow-categories.json' import { workshopDisplayEntriesSchema } from '../content/workshop-display.schema' +import { modelTitle } from '../lib/workshop/model-title' import { workshopExecutionId } from './models-catalogue' import { initialWorkshopPageState } from './workshop-page-state' import { urlUploadField, validateForm } from './workshop-playground' @@ -266,8 +267,8 @@ describe('curated workflow pages', () => { }) describe('workshop pages', () => { - it('gives every model and workflow page its own display name', () => { - const names = workshopPages.map((model) => model.name) - expect(new Set(names).size).toBe(names.length) + it('gives every model and workflow page its own title', () => { + const titles = workshopPages.map((model) => modelTitle(model)) + expect(new Set(titles).size).toBe(titles.length) }) })