Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

Merge PR #328 (Creator template browsing and details) into master

Leggettc29d81e030db
diff --cc apps/daemon/test/integration/creator-api.test.ts
index fc7086e0,a9135655..2171dfa8
--- a/apps/daemon/test/integration/creator-api.test.ts
+++ b/apps/daemon/test/integration/creator-api.test.ts
@@@ -308,19 -308,21 +308,21 @@@ describe('creator api', () =>
locale: 'en-US',
catalogHash: expect.stringMatching(/^[a-f0-9]{64}$/)
});
- expect(catalog.json().presets).toContainEqual(expect.objectContaining({
+ const imagePreset = catalog.json().presets.find(
+ (preset: { module: string }) => preset.module === 'image-generation'
+ );
+ expect(imagePreset).toMatchObject({
module: 'image-generation',
- id: 'exploded-food-infographic',
- version: 1,
- title: 'Exploded Food Infographic',
- coverUrl: expect.stringMatching(/^\/creator-presets\/[a-f0-9]{64}\.jpg$/),
- prompt: expect.stringContaining('Create a hyper-realistic exploded vertical infographic'),
- tags: ['Reference template', 'Product visuals', 'Infographics', 'Food and beverage'],
- tagIds: ['reference-template', '产品视觉', '信息图表', '食品饮料'],
- highlights: [
- { text: '1024 × 1024', colors: [] },
- { text: 'High quality', colors: [] },
- { text: '2 images', colors: [] }
- ]
- }));
+ id: expect.any(String),
+ version: expect.any(Number),
+ title: expect.any(String),
+ coverUrl: expect.stringMatching(/^\/creator-presets\/[a-f0-9]{64}\.(?:jpg|png|webp)$/),
+ prompt: expect.any(String),
+ tags: expect.any(Array),
++ tagIds: expect.any(Array),
+ highlights: expect.any(Array)
+ });
++ expect(imagePreset.tagIds).toHaveLength(imagePreset.tags.length);
const fullPreviewPreset = catalog.json().presets.find(
(preset: { id: string }) => preset.id === 'y2k-streetwear-mobile-landing-page'
);
diff --cc apps/daemon/test/unit/creator-preset-registry.test.ts
index cf0538c2,ae3f6081..da3f034c
--- a/apps/daemon/test/unit/creator-preset-registry.test.ts
+++ b/apps/daemon/test/unit/creator-preset-registry.test.ts
@@@ -81,6 -81,6 +81,31 @@@ describe('creator preset registry', ()
for (const identity of removed) expect(sourceIdentities).not.toContain(identity);
});
++ it('ignores macOS metadata while compiling and loading a local preset', async () => {
++ const fixture = setup();
++ copyOfficialPreset({
++ sourceRoot: fixture.sourceRoot,
++ module: 'image-generation',
++ sourceId: 'ecommerce-product'
++ });
++ for (const directory of [
++ fixture.sourceRoot,
++ join(fixture.sourceRoot, 'image-generation'),
++ join(fixture.sourceRoot, 'image-generation', 'ecommerce-product'),
++ join(fixture.sourceRoot, 'image-generation', 'ecommerce-product', '1')
++ ]) {
++ writeFileSync(join(directory, '.DS_Store'), 'macOS metadata');
++ }
++
++ await compileCreatorPresets(fixture);
++ const registry = await loadCreatorPresetCatalog({
++ root: fixture.outputRoot,
++ templates: createDefaultCreatorTemplateRegistry()
++ });
++ expect(registry.listPublished('en-US').map(preset => preset.id))
++ .toEqual(['ecommerce-product']);
++ });
++
it('localizes identifier and source-language tags while preserving unknown tags', () => {
const preset = {
tags: ['camera-motion', '商业广告', 'reference-template', 'custom-tag']
diff --cc apps/web/e2e/creator-prompt-localization.spec.ts
index c312ec9b,c312ec9b..e34e2638
--- a/apps/web/e2e/creator-prompt-localization.spec.ts
+++ b/apps/web/e2e/creator-prompt-localization.spec.ts
@@@ -42,10 -42,10 +42,15 @@@ test('模板提示词在 Browser/Deskto
await runtime.openApp(page);
await page.goto(`${runtime.origin}/#/new`);
await page.getByRole('tab', { name: '视频创作', exact: true }).click();
-- await page.getByRole('button', { name: '查看纽约跑酷与蛛丝摆荡动作模板详情' }).click();
++ const templateCard = page.getByRole('button', { name: '查看纽约跑酷与蛛丝摆荡动作模板详情' });
++ await templateCard.click();
++ await expect(page.getByRole('button', { name: '返回模板列表' })).toBeFocused();
++ await page.keyboard.press('Escape');
++ await expect(templateCard).toBeFocused();
++ await templateCard.click();
const zhCatalog = await runtime.api<CreatorPresetListResponse>('GET', '/creator/presets?locale=zh-CN');
const chinese = zhCatalog.presets.find(preset => preset.id === 'nyc-parkour-web-swing')!;
-- await expect(page.locator('.creator-template-prompt-card')).toHaveText(chinese.prompt!);
++ await expect(page.locator('.creator-template-prompt-card .creator-template-prompt')).toHaveText(chinese.prompt!);
await runtime.api('PATCH', '/settings/ui', { language: 'en-US' });
await page.reload();
@@@ -55,7 -55,7 +60,7 @@@
const english = enCatalog.presets.find(preset => preset.id === chinese.id)!;
expect(english.prompt!.length).toBeGreaterThan(4000);
expect(english.prompt).not.toBe(chinese.prompt);
-- await expect(page.locator('.creator-template-prompt-card')).toHaveText(english.prompt!);
++ await expect(page.locator('.creator-template-prompt-card .creator-template-prompt')).toHaveText(english.prompt!);
await page.screenshot({ path: testInfo.outputPath(`${platform}-english-template.png`), fullPage: true });
const promptBox = await page.locator('.creator-template-prompt-card').boundingBox();
await page.getByRole('button', { name: 'Use this template', exact: true }).click();
diff --cc apps/web/src/app/AppController.tsx
index d20ecf82,3068c762..e76f6e53
--- a/apps/web/src/app/AppController.tsx
+++ b/apps/web/src/app/AppController.tsx
@@@ -39,11 -38,11 +39,8 @@@ import { Timeline, type TimelineHandle
import { eventToTimelineItem, type TimelineItem } from '../components/timeline/timeline-model.js';
import type { CapabilitiesViewProps } from '../features/capabilities/CapabilitiesView.js';
import { ConversationEmptyState } from '../features/conversation/ConversationEmptyState.js';
--import {
-- CreatorDashboard,
-- getCreatorSkillPromptHint,
-- type CreatorSkill
--} from '../features/conversation/CreatorDashboard.js';
++import type { CreatorSkill } from '../features/conversation/CreatorDashboard.js';
++import { getCreatorSkillPromptHint } from '../features/conversation/creator-skill-prompt-hint.js';
import {
creatorWorkspaceForTemplate,
type CreatorSkillLaunch
@@@ -261,6 -249,6 +258,10 @@@ const FilesPage = lazy(() => import('..
const ProjectsPage = lazy(() => import('../features/projects/ProjectsPage.js'));
const PluginsPage = lazy(() => import('../features/plugins/PluginsPage.js'));
const DashboardPage = lazy(() => import('../features/dashboard/DashboardPage.js'));
++const CreatorDashboard = lazy(async () => {
++ const module = await import('../features/conversation/CreatorDashboard.js');
++ return { default: module.CreatorDashboard };
++});
const ScheduleThreadHeader = lazy(async () => {
const module = await import('../features/schedules/ScheduleThreadHeader.js');
return { default: module.ScheduleThreadHeader };
@@@ -4360,14 -4264,14 +4361,16 @@@ export function AppController(props: Ap
item.kind === 'approval' && item.approval.status === 'pending'
));
const creatorDashboard = (
-- <CreatorDashboard
-- presets={creatorPresets}
-- loading={creatorPresetsLoading}
-- error={creatorPresetsError}
-- onRetry={() => setCreatorPresetsReloadKey(value => value + 1)}
-- onSelectPreset={applyDashboardPreset}
-- onSelectSkill={applyDashboardSkill}
-- />
++ <Suspense fallback={<div role="status">{language === 'en-US' ? 'Loading templates...' : '正在加载模板...'}</div>}>
++ <CreatorDashboard
++ presets={creatorPresets}
++ loading={creatorPresetsLoading}
++ error={creatorPresetsError}
++ onRetry={() => setCreatorPresetsReloadKey(value => value + 1)}
++ onSelectPreset={applyDashboardPreset}
++ onSelectSkill={applyDashboardSkill}
++ />
++ </Suspense>
);
const conversationComposer = (
<Composer
diff --cc apps/web/src/features/conversation/CreatorDashboard.css
index 00000000,00000000..13436ddb
new file mode 100644
--- /dev/null
+++ b/apps/web/src/features/conversation/CreatorDashboard.css
@@@ -1,0 -1,0 +1,159 @@@
++.creator-template-tags-filter {
++ position: relative;
++ min-width: 0;
++ margin: 0 0 22px;
++ padding: 2px 0 0;
++}
++
++.creator-template-tags-line,
++.creator-template-tags-measure {
++ display: flex;
++ align-items: center;
++ gap: 5px;
++ white-space: nowrap;
++}
++
++.creator-template-tags-line {
++ width: 100%;
++ min-width: 0;
++ overflow: hidden;
++}
++
++.creator-template-tags-measure {
++ position: absolute;
++ top: 0;
++ left: 0;
++ width: max-content;
++ visibility: hidden;
++ pointer-events: none;
++}
++
++.creator-template-tags-filter button {
++ flex: 0 0 auto;
++ min-height: 34px;
++ padding: 7px 10px;
++ border: 1px solid transparent;
++ border-radius: 999px;
++ background: transparent;
++ color: var(--muted);
++ font-size: 13px;
++ font-weight: 500;
++ line-height: 1.25;
++ white-space: nowrap;
++ cursor: pointer;
++}
++
++.creator-template-tags-filter button:hover {
++ color: var(--text);
++ background: color-mix(in srgb, var(--surface-2) 65%, transparent);
++}
++
++.creator-template-tags-filter button[aria-pressed="true"] {
++ border-color: var(--border);
++ background: var(--surface-2);
++ color: var(--text);
++ font-weight: 600;
++ box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 7%, transparent);
++}
++
++.creator-template-tags-filter .creator-template-tags-more {
++ display: inline-flex;
++ align-items: center;
++ gap: 4px;
++}
++
++.creator-template-tags-more[aria-expanded="true"] svg {
++ transform: rotate(180deg);
++}
++
++.creator-template-tags-overflow {
++ display: flex;
++ flex-wrap: wrap;
++ gap: 4px 5px;
++ margin-top: 4px;
++}
++
++.creator-template-detail-page {
++ width: min(1500px, 94vw);
++ height: min(920px, 94dvh);
++ min-height: 0;
++ display: flex;
++ flex-direction: column;
++ gap: 0;
++ margin: 0;
++ overflow: hidden;
++ border: 1px solid var(--border);
++ border-radius: 8px;
++ background: var(--surface-popover);
++ box-shadow: 0 24px 80px rgb(0 0 0 / 0.25);
++}
++
++.creator-template-detail-backdrop {
++ position: fixed;
++ inset: 0;
++ z-index: 150;
++ display: grid;
++ place-items: center;
++ padding: 12px;
++ background: rgb(12 15 20 / 0.55);
++}
++
++.creator-template-detail-toolbar {
++ min-height: 78px;
++ display: flex;
++ align-items: center;
++ justify-content: space-between;
++ gap: 16px;
++ padding: 14px 24px;
++ border-bottom: 1px solid var(--border);
++}
++
++.creator-template-detail-heading { min-width: 0; }
++.creator-template-detail-heading h1 { margin: 0; font-size: 18px; line-height: 1.3; }
++.creator-template-detail-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
++.creator-template-detail-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
++.creator-template-detail-actions .creator-template-use-button { margin: 0; }
++
++.creator-template-prompt-heading {
++ display: flex;
++ align-items: center;
++ justify-content: space-between;
++ gap: 8px;
++ padding: 14px 16px 0;
++}
++
++.creator-template-prompt-heading h2 { font-size: 12px; letter-spacing: 0; }
++.creator-template-prompt-heading button {
++ display: inline-flex;
++ align-items: center;
++ gap: 6px;
++ padding: 5px 0 5px 6px;
++ border: 0;
++ background: transparent;
++ color: var(--muted);
++ font-size: 12px;
++ cursor: pointer;
++}
++.creator-template-prompt-heading button:hover:not(:disabled) { color: var(--text); }
++.creator-template-prompt-heading button:disabled { opacity: 0.5; cursor: default; }
++.creator-template-prompt-heading button:focus-visible { outline: 2px solid var(--state-focus-ring); }
++
++@media (max-width: 920px) {
++ .creator-template-detail-page { width: min(700px, 96vw); height: 94dvh; }
++}
++
++@media (max-width: 700px) {
++ .creator-template-tags-filter button {
++ padding-right: 10px;
++ padding-left: 10px;
++ font-size: 12px;
++ }
++}
++
++@media (max-width: 600px) {
++ .creator-template-detail-toolbar { padding: 12px 16px; }
++ .creator-template-detail-heading h1 { font-size: 15px; }
++ .creator-template-detail-heading p { display: none; }
++ .creator-template-detail-actions { gap: 4px; }
++ .creator-template-detail-actions .creator-template-use-button { padding: 8px; font-size: 12px; }
++}
diff --cc apps/web/src/features/conversation/CreatorDashboard.test.tsx
index c5a3468e,97cdbe5a..9a409803
--- a/apps/web/src/features/conversation/CreatorDashboard.test.tsx
+++ b/apps/web/src/features/conversation/CreatorDashboard.test.tsx
@@@ -214,6 -225,16 +225,44 @@@ describe('CreatorDashboard', () =>
await waitFor(() => expect(trigger).toHaveFocus());
});
++ it('contains keyboard focus in template details and returns it to the opening card', () => {
++ render(<CreatorDashboard presets={presets} />);
++ const card = screen.getByRole('button', { name: '查看电商商品主图增强版模板详情' });
++ card.focus();
++ fireEvent.click(card);
++
++ const dialog = screen.getByRole('dialog', { name: '电商商品主图增强版' });
++ const close = within(dialog).getByRole('button', { name: '返回模板列表' });
++ expect(close).toHaveFocus();
++ const first = within(dialog).getByRole('button', { name: '使用此模板' });
++ first.focus();
++ fireEvent.keyDown(first, { key: 'Tab', shiftKey: true });
++ const last = within(dialog).getByRole('link', { name: '查看@example_author的原始来源' });
++ expect(last).toHaveFocus();
++ fireEvent.keyDown(last, { key: 'Tab' });
++ expect(first).toHaveFocus();
++ card.focus();
++ fireEvent.keyDown(card, { key: 'Tab' });
++ expect(first).toHaveFocus();
++ fireEvent.keyDown(close, { key: 'Escape' });
++ expect(dialog).not.toBeInTheDocument();
++ expect(card).toHaveFocus();
++
++ fireEvent.click(card);
++ fireEvent.click(screen.getByRole('button', { name: '返回模板列表' }));
++ expect(card).toHaveFocus();
++ });
++
+ it('copies the raw prompt from the detail card', async () => {
+ const writeText = vi.fn().mockResolvedValue(undefined);
+ Object.defineProperty(navigator, 'clipboard', { configurable: true, value: { writeText } });
+ render(<CreatorDashboard presets={presets} />);
+ fireEvent.click(screen.getByRole('button', { name: '查看电商商品主图增强版模板详情' }));
+ fireEvent.click(screen.getByRole('button', { name: '复制 Prompt' }));
+ expect(writeText).toHaveBeenCalledWith(presets[1]!.prompt);
+ expect(await screen.findByRole('button', { name: '已复制' })).toBeInTheDocument();
+ });
+
it('renders video examples with controls and a full preview', async () => {
render(<CreatorDashboard presets={presets} />);
fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
@@@ -263,6 -284,342 +312,337 @@@
.toBeInTheDocument();
});
+ it('omits tag filters on Recent, Recommended and All while keeping search available', () => {
+ render(<CreatorDashboard presets={presets} />);
+
+ for (const category of ['推荐', '全部', '最近']) {
+ fireEvent.click(screen.getByRole('tab', { name: category }));
+ expect(screen.queryByRole('group', { name: '筛选模板' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '搜索模板' })).toBeInTheDocument();
+ }
+
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ expect(screen.getByRole('group', { name: '筛选模板' })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '商品产品' }));
+ fireEvent.click(screen.getByRole('tab', { name: '全部' }));
+ expect(screen.queryByRole('group', { name: '筛选模板' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '查看社交媒体海报模板详情' })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ expect(screen.getByRole('button', { name: '全部' })).toHaveAttribute('aria-pressed', 'true');
+ });
+
+ it('uses one tag at a time and resets with All or a category change', () => {
+ const catalog = [
+ { ...presets[1]!, tags: ['商业广告', '产品视觉', '创意摄影'] },
+ { ...presets[2]!, tags: ['海报设计', '手绘插画', '角色场景'] },
+ { ...presets[3]!, tags: ['商业广告', 'cinematic', '产品视觉'] }
+ ];
+ render(<CreatorDashboard presets={catalog} />);
+
+ expect(screen.queryByRole('group', { name: '筛选模板' })).not.toBeInTheDocument();
+ expect(screen.queryByText('使用场景')).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
+ expect(screen.getByRole('button', { name: '全部' })).toHaveAttribute('aria-pressed', 'true');
+ expect(screen.getByRole('button', { name: '电影短片' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '海报设计' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '电影短片' }));
+ expect(screen.getByRole('tab', { name: '视频创作' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.queryByRole('button', { name: '查看电商商品主图增强版模板详情' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '查看电影感视频预览模板详情' })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '全部' }));
+ expect(screen.getByRole('tab', { name: '视频创作' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.queryByRole('button', { name: '查看电商商品主图增强版模板详情' })).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ fireEvent.click(screen.getByRole('button', { name: '商品产品' }));
+ expect(screen.getByRole('tab', { name: '图像设计' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: '查看电商商品主图增强版模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看社交媒体海报模板详情' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('tab', { name: '全部' }));
+ expect(screen.queryByRole('button', { name: '商品产品' })).not.toBeInTheDocument();
+ expect(screen.queryByRole('group', { name: '筛选模板' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '查看社交媒体海报模板详情' })).toBeInTheDocument();
+ });
+
+ it('keeps one tag row and moves overflow selections into view without changing the category', () => {
+ mockNarrowTagRow();
+ render(<CreatorDashboard presets={[
+ { ...presets[3]!, tags: ['cinematic', 'camera-motion', 'action'] },
+ presets[0]!,
+ { ...presets[1]!, tags: ['产品视觉', '电商视觉', '人像摄影'] },
+ { ...presets[2]!, tags: ['海报设计'] }
+ ]} />);
+
+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
+ const filter = screen.getByRole('group', { name: '筛选模板' });
+ const line = filter.querySelector('.creator-template-tags-line')!;
+ expect(within(line as HTMLElement).getByRole('button', { name: '视频翻译' })).toBeInTheDocument();
+ expect(within(line as HTMLElement).queryByRole('button', { name: '镜头运动' })).not.toBeInTheDocument();
+ const more = within(line as HTMLElement).getByRole('button', { name: '更多' });
+ expect(more).toHaveAttribute('aria-expanded', 'false');
+ expect(filter.querySelectorAll('.creator-template-tags-measure button[tabindex="-1"]')).toHaveLength(
+ filter.querySelectorAll('.creator-template-tags-measure button').length
+ );
+
+ fireEvent.click(more);
+ const overflow = screen.getByRole('group', { name: '更多模板分类' });
+ expect(more).toHaveAttribute('aria-expanded', 'true');
+ expect(more).toHaveTextContent('收起');
+ expect(within(overflow).queryByRole('button', { name: '视频翻译' })).not.toBeInTheDocument();
+ fireEvent.click(more);
+ expect(more).toHaveAttribute('aria-expanded', 'false');
+ expect(more).toHaveTextContent('更多');
+ expect(screen.queryByRole('group', { name: '更多模板分类' })).not.toBeInTheDocument();
+ fireEvent.click(more);
+ fireEvent.click(within(screen.getByRole('group', { name: '更多模板分类' }))
+ .getByRole('button', { name: '镜头运动' }));
+ expect(screen.queryByRole('group', { name: '更多模板分类' })).not.toBeInTheDocument();
+ expect(within(line as HTMLElement).getByRole('button', { name: '镜头运动' }))
+ .toHaveAttribute('aria-pressed', 'true');
+ expect(screen.getByRole('tab', { name: '视频创作' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: '查看电影感视频预览模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看B站双语精翻模板详情' })).not.toBeInTheDocument();
+
+ fireEvent.click(more);
+ fireEvent.keyDown(document, { key: 'Escape' });
+ expect(screen.queryByRole('group', { name: '更多模板分类' })).not.toBeInTheDocument();
+ expect(more).toHaveFocus();
+ fireEvent.click(more);
+ fireEvent.pointerDown(document.body);
+ expect(screen.queryByRole('group', { name: '更多模板分类' })).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ expect(within(line as HTMLElement).getByRole('button', { name: '人像写真' })).toBeInTheDocument();
+ fireEvent.click(within(line as HTMLElement).getByRole('button', { name: '更多' }));
+ fireEvent.click(within(screen.getByRole('group', { name: '更多模板分类' }))
+ .getByRole('button', { name: '商品产品' }));
+ expect(within(line as HTMLElement).getByRole('button', { name: '商品产品' }))
+ .toHaveAttribute('aria-pressed', 'true');
+ expect(screen.getByRole('tab', { name: '图像设计' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: '查看电商商品主图增强版模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看社交媒体海报模板详情' })).not.toBeInTheDocument();
+ });
+
+ it('localizes the overflow control and its options in English', () => {
+ mockNarrowTagRow();
+ render(
+ <LanguageProvider initialPreference="en-US">
+ <CreatorDashboard presets={[{ ...presets[3]!, tags: ['cinematic', 'camera-motion'] }]} />
+ </LanguageProvider>
+ );
+
+ fireEvent.click(screen.getByRole('tab', { name: 'Video Creation' }));
+ const more = screen.getByRole('button', { name: 'More' });
+ fireEvent.click(more);
+ expect(more).toHaveTextContent('Show less');
+ const overflow = screen.getByRole('group', { name: 'More template filters' });
+ fireEvent.click(within(overflow).getByRole('button', { name: 'Camera Motion' }));
+ expect(screen.getByRole('button', { name: 'Camera Motion' })).toHaveAttribute('aria-pressed', 'true');
+ expect(screen.getByRole('tab', { name: 'Video Creation' })).toHaveAttribute('aria-selected', 'true');
+ });
+
+ it('matches localized English tags within the selected category', () => {
+ const catalog = [
+ { ...presets[1]!, title: 'Product Hero', tags: ['Commercial advertising', 'Product visuals'] },
+ { ...presets[2]!, title: 'Illustrated Poster', tags: ['Poster design', 'Hand-drawn illustration'] },
+ { ...presets[3]!, title: 'Cinematic Motion', tags: ['Cinematic storytelling', 'Animation'] }
+ ];
+ render(
+ <LanguageProvider initialPreference="en-US">
+ <CreatorDashboard presets={catalog} />
+ </LanguageProvider>
+ );
+
+ fireEvent.click(screen.getByRole('tab', { name: 'Image Design' }));
+ expect(screen.getByRole('button', { name: 'Brand Ads' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Posters' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Cinematic' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Brand Ads' }));
+ expect(screen.getByRole('tab', { name: 'Image Design' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: 'View Product Hero template details' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'View Illustrated Poster template details' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'All' }));
+ expect(screen.getByRole('tab', { name: 'Image Design' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: 'View Illustrated Poster template details' })).toBeInTheDocument();
+ });
+
+ it('shows video workflows and motion tags separately from image design tags', () => {
+ const catalog = [
+ presets[0]!,
+ presets[4]!,
+ { ...presets[3]!, tags: ['camera-motion', 'action', 'image-to-video'] },
+ { ...presets[1]!, tags: ['产品视觉', '产品摄影'] },
+ { ...presets[2]!, tags: ['海报设计', '手绘插画'] }
+ ];
+ render(<CreatorDashboard presets={catalog} />);
+
+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
+ expect(screen.getByRole('button', { name: '视频翻译' })).toBeInTheDocument();
- expect(screen.getByRole('button', { name: '火柴人动画' })).toBeInTheDocument();
++ expect(screen.queryByRole('button', { name: '火柴人动画' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '视频下载' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '镜头运动' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '运动动作' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '海报设计' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '镜头运动' }));
+ expect(screen.getByRole('button', { name: '查看电影感视频预览模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看B站双语精翻模板详情' })).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ expect(screen.getByRole('button', { name: '海报设计' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '摄影' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '镜头运动' })).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '视频翻译' })).not.toBeInTheDocument();
+ });
+
+ it('shows specific image uses, styles and subjects in one localized filter', () => {
+ const catalog: CreatorPresetSummary[] = [
+ {
+ ...presets[1]!,
+ title: '极简城市海报',
+ tags: ['极简设计', '城市街景', '海报设计'],
+ tagIds: ['minimalist', 'city-street', '海报设计']
+ },
+ {
+ ...presets[2]!,
+ title: '水彩故事分镜',
+ tags: ['水彩', '故事分镜', '手绘插画'],
+ tagIds: ['watercolor', 'storyboard', '手绘插画']
+ },
+ {
+ ...presets[5]!,
+ title: '品牌商品广告',
+ tags: ['商业广告', '产品视觉', '电商'],
+ tagIds: ['商业广告', '产品视觉', 'ecommerce']
+ }
+ ];
+ const view = render(<CreatorDashboard presets={catalog} />);
+ fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
+ const filter = screen.getByRole('group', { name: '筛选模板' });
+ expect(filter.querySelectorAll('button').length).toBeGreaterThan(9);
+ for (const label of ['海报设计', '故事分镜', '电商主图', '品牌广告', '水彩画', '极简设计', '城市街景', '商品产品']) {
+ expect(screen.getByRole('button', { name: label })).toBeInTheDocument();
+ }
+ expect(screen.queryByRole('button', { name: '游戏视觉' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '城市街景' }));
+ expect(screen.getByRole('tab', { name: '图像设计' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: '查看极简城市海报模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看水彩故事分镜模板详情' })).not.toBeInTheDocument();
+
+ view.unmount();
+ render(
+ <LanguageProvider initialPreference="en-US">
+ <CreatorDashboard presets={[
+ { ...catalog[0]!, title: 'Minimal City Poster', tags: ['Minimalist', 'City streets', 'Poster design'] },
+ { ...catalog[1]!, title: 'Watercolor Storyboard', tags: ['Watercolor', 'Storyboard', 'Hand-drawn illustration'] }
+ ]} />
+ </LanguageProvider>
+ );
+ fireEvent.click(screen.getByRole('tab', { name: 'Image Design' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Watercolor' }));
+ expect(screen.getByRole('tab', { name: 'Image Design' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: 'View Watercolor Storyboard template details' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'View Minimal City Poster template details' })).not.toBeInTheDocument();
+ });
+
+ it('shows localized video-specific tags in English', () => {
+ render(
+ <LanguageProvider initialPreference="en-US">
+ <CreatorDashboard presets={[
+ { ...presets[0]!, title: 'Bilingual Translation', tags: ['Bilingual', 'Subtitles'] },
+ { ...presets[3]!, title: 'Moving Camera', tags: ['Camera motion', 'Cinematic'] }
+ ]} />
+ </LanguageProvider>
+ );
+
+ fireEvent.click(screen.getByRole('tab', { name: 'Video Creation' }));
+ expect(screen.getByRole('button', { name: 'Video Translation' })).toBeInTheDocument();
- expect(screen.getByRole('button', { name: 'Stick Figure Animation' })).toBeInTheDocument();
++ expect(screen.queryByRole('button', { name: 'Stick Figure Animation' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Camera Motion' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Cinematic Shorts' })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Camera Motion' }));
+ expect(screen.getByRole('tab', { name: 'Video Creation' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: 'View Moving Camera template details' })).toBeInTheDocument();
+ });
+
- it('shows the complete video tag list in order, including tags awaiting templates', () => {
++ it('shows only video facets with matching templates in their original order', () => {
+ const catalog = [
+ { ...presets[3]!, tags: ['nature-landscape', 'city-street', 'architecture-interior', 'anime-style'] },
+ { ...presets[3]!, id: 'stickman-preview', title: '火柴人动画预览', tags: ['stickman-video'], tagIds: ['stickman-video'] },
+ presets[0]!
+ ];
+ render(<CreatorDashboard presets={catalog} />);
+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
+ expect(Array.from(document.querySelectorAll('.creator-template-tags-line button'), button => button.textContent))
+ .toEqual([
- '全部', '视频翻译', '火柴人动画', '电影短片', '生活 Vlog', '品牌广告', 'UGC 内容', '知识讲解',
- '片头包装', '游戏宣传', '写实电影感', '奇幻冒险', '未来科幻',
- '动漫风格', '复古胶片', '梦境视觉', '定格动画', '手绘动画',
- '人物角色', '运动动作', '自然风光', '建筑空间', '城市街景',
- '美食料理', '产品特写', '镜头运动', '视频配音', '视频下载'
++ '全部', '视频翻译', '火柴人动画', '动漫风格', '自然风光', '建筑空间', '城市街景'
+ ]);
++ expect(screen.queryByRole('button', { name: '片头包装' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '视频翻译' }));
+ expect(screen.getByRole('button', { name: '查看B站双语精翻模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看火柴人动画预览模板详情' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '火柴人动画' }));
+ expect(screen.getByRole('button', { name: '查看火柴人动画预览模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看B站双语精翻模板详情' })).not.toBeInTheDocument();
- fireEvent.click(screen.getByRole('button', { name: '片头包装' }));
- expect(screen.getByText('该标签暂时没有模板。')).toBeInTheDocument();
- expect(screen.getByRole('tab', { name: '视频创作' })).toHaveAttribute('aria-selected', 'true');
+ fireEvent.click(screen.getByRole('button', { name: '城市街景' }));
+ expect(screen.getByRole('button', { name: '查看电影感视频预览模板详情' })).toBeInTheDocument();
+ });
+
+ it('filters localized video presets by stable tag IDs in Chinese and English', () => {
+ const catalog: CreatorPresetSummary[] = [
+ {
+ ...presets[3]!,
+ title: '城市自然镜头',
+ tags: ['电影感', '镜头运动', '自然风光', '城市街景', '建筑空间'],
+ tagIds: ['cinematic', 'camera-motion', 'nature-landscape', 'city-street', 'architecture-interior']
+ },
+ {
+ ...presets[3]!,
+ id: 'anime-action',
+ title: '动漫动作',
+ tags: ['动漫风格', '动作', '怀旧'],
+ tagIds: ['anime-style', 'action', 'nostalgic']
+ },
+ presets[0]!
+ ];
+ const view = render(<CreatorDashboard presets={catalog} />);
+ fireEvent.click(screen.getByRole('tab', { name: '视频创作' }));
+
+ const filter = screen.getByRole('group', { name: '筛选模板' });
+ expect(filter.querySelectorAll('button').length).toBeGreaterThan(5);
- for (const label of ['视频翻译', '火柴人动画', '电影短片', '写实电影感', '镜头运动', '自然风光', '城市街景', '建筑空间', '动漫风格', '运动动作', '复古胶片']) {
++ for (const label of ['视频翻译', '电影短片', '写实电影感', '镜头运动', '自然风光', '城市街景', '建筑空间', '动漫风格', '运动动作', '复古胶片']) {
+ expect(screen.getByRole('button', { name: label })).toBeInTheDocument();
+ }
++ expect(screen.queryByRole('button', { name: '火柴人动画' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '自然风光' }));
+ expect(screen.getByRole('tab', { name: '视频创作' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: '查看城市自然镜头模板详情' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '查看动漫动作模板详情' })).not.toBeInTheDocument();
+
+ view.unmount();
+ render(
+ <LanguageProvider initialPreference="en-US">
+ <CreatorDashboard presets={[
+ {
+ ...catalog[0]!,
+ title: 'City and Nature Camera',
+ tags: ['Cinematic', 'Camera motion', 'Natural landscapes', 'City streets', 'Architecture and interiors']
+ },
+ {
+ ...catalog[1]!,
+ title: 'Anime Action',
+ tags: ['Anime style', 'Action', 'Nostalgic']
+ },
+ catalog[2]!
+ ]} />
+ </LanguageProvider>
+ );
+ fireEvent.click(screen.getByRole('tab', { name: 'Video Creation' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Natural Landscapes' }));
+ expect(screen.getByRole('tab', { name: 'Video Creation' })).toHaveAttribute('aria-selected', 'true');
+ expect(screen.getByRole('button', { name: 'View City and Nature Camera template details' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'View Anime Action template details' })).not.toBeInTheDocument();
+ });
+
it('highlights replaceable prompt variables without styling section headings', () => {
render(<CreatorDashboard presets={presets} />);
fireEvent.click(screen.getByRole('tab', { name: '图像设计' }));
diff --cc apps/web/src/features/conversation/CreatorDashboard.tsx
index 694cd12d,282b5526..e42cffc8
--- a/apps/web/src/features/conversation/CreatorDashboard.tsx
+++ b/apps/web/src/features/conversation/CreatorDashboard.tsx
@@@ -24,8 -25,6 +24,9 @@@ import
import { createPortal } from 'react-dom';
import { useAppLanguage } from '../../i18n/LanguageProvider.js';
import type { CreatorWorkspace } from '../dashboard/creator-workspace.js';
+import { IssueList } from '../issues/IssuePresenter.js';
+import { usePageIssueState } from '../issues/page-issue-state.js';
++import './CreatorDashboard.css';
export type CreatorSkill = {
id: string;
@@@ -41,8 -40,78 +42,79 @@@
enUS: string;
};
};
++export { getCreatorSkillPromptHint } from './creator-skill-prompt-hint.js';
- type CreatorHomeCategory = 'recent' | 'recommended' | 'video' | 'image';
+ type CreatorHomeCategory = 'recent' | 'recommended' | 'all' | 'video' | 'image';
+ type FacetOption = {
+ id: string;
+ zh: string;
+ en: string;
+ tags: string[];
+ modules?: CreatorRuntimeWorkspace[];
+ };
+
+ const videoTagOptions: FacetOption[] = [
+ { id: 'translation', zh: '视频翻译', en: 'Video Translation', tags: [], modules: ['video-translation'] },
+ { id: 'stickman-animation', zh: '火柴人动画', en: 'Stick Figure Animation', tags: ['stickman-video', 'stick-figure-animation', '火柴人动画', 'Stick figure animation'] },
+ { id: 'short-film', zh: '电影短片', en: 'Cinematic Shorts', tags: ['cinematic', 'Cinematic', 'mystery', 'Mystery'] },
+ { id: 'vlog', zh: '生活 Vlog', en: 'Lifestyle Vlogs', tags: ['dv', 'DV', 'ugc', 'UGC'] },
+ { id: 'brand-ad', zh: '品牌广告', en: 'Brand Ads', tags: ['advertising', 'Advertising', 'jewelry', 'Jewelry'] },
+ { id: 'ugc', zh: 'UGC 内容', en: 'UGC Content', tags: ['ugc', 'UGC'] },
+ { id: 'tutorial', zh: '知识讲解', en: 'Explainers', tags: ['cooking', 'Cooking', 'multi-stage', 'Multi-stage'] },
+ { id: 'intro', zh: '片头包装', en: 'Intros / Branding', tags: [] },
+ { id: 'game-promo', zh: '游戏宣传', en: 'Game Promos', tags: [] },
+ { id: 'cinematic-realism', zh: '写实电影感', en: 'Cinematic Realism', tags: ['cinematic', 'Cinematic'] },
+ { id: 'fantasy', zh: '奇幻冒险', en: 'Fantasy Adventures', tags: ['fantasy', 'Fantasy'] },
+ { id: 'scifi', zh: '未来科幻', en: 'Future Sci-fi', tags: ['sci-fi', 'Sci-fi'] },
+ { id: 'anime', zh: '动漫风格', en: 'Anime Style', tags: ['anime-style', 'Anime style'] },
+ { id: 'retro-film', zh: '复古胶片', en: 'Retro Film', tags: ['nostalgic', 'Nostalgic', 'dv', 'DV'] },
+ { id: 'dreamlike', zh: '梦境视觉', en: 'Dreamlike Visuals', tags: [] },
+ { id: 'stop-motion', zh: '定格动画', en: 'Stop Motion', tags: ['stop-motion', 'Stop motion'] },
+ { id: 'drawn-animation', zh: '手绘动画', en: 'Hand-drawn Animation', tags: ['watercolor', 'Watercolor', '手绘插画', 'Hand-drawn illustration'] },
+ { id: 'characters', zh: '人物角色', en: 'People / Characters', tags: ['character-interaction', 'Character interaction', 'first-person', 'First person', '真人贴纸', 'ugc', 'UGC'] },
+ { id: 'motion-action', zh: '运动动作', en: 'Sports / Action', tags: ['action', 'Action', 'martial-arts', 'Martial arts', 'parkour', 'Parkour', 'skateboard', 'Skateboard'] },
+ { id: 'landscape', zh: '自然风光', en: 'Natural Landscapes', tags: ['nature-landscape', 'Natural landscapes'] },
+ { id: 'architecture', zh: '建筑空间', en: 'Architecture / Interiors', tags: ['architecture-interior', 'Architecture and interiors'] },
+ { id: 'city', zh: '城市街景', en: 'City Streets', tags: ['city-street', 'City streets'] },
+ { id: 'food-video', zh: '美食料理', en: 'Food / Cooking', tags: ['cooking', 'Cooking'] },
+ { id: 'product-video', zh: '产品特写', en: 'Product Close-ups', tags: ['advertising', 'Advertising', 'jewelry', 'Jewelry'] },
+ { id: 'camera-video', zh: '镜头运动', en: 'Camera Motion', tags: ['camera-motion', 'Camera motion', 'rack-focus', 'Rack focus', 'drone-orbit', 'Drone orbit', 'dolly-zoom', 'Dolly zoom', 'crane-up', 'Crane up', 'pan-right', 'Pan right', 'aerial', 'Aerial'] },
+ { id: 'dubbing', zh: '视频配音', en: 'Video Dubbing', tags: [], modules: ['smart-dubbing'] },
+ { id: 'download', zh: '视频下载', en: 'Video Downloads', tags: [], modules: ['video-download'] }
+ ];
+
+ const imageTagOptions: FacetOption[] = [
+ { id: 'image-portrait', zh: '人像写真', en: 'Portraits', tags: ['人像摄影', 'Portrait photography', 'portrait', 'Portrait'] },
+ { id: 'image-social', zh: '社交帖子', en: 'Social Posts', tags: ['社交媒体', 'Social media', 'social', 'Social'] },
+ { id: 'image-infographic', zh: '信息图解', en: 'Infographics', tags: ['信息图表', 'Infographics', '教育科普', 'Educational content'] },
+ { id: 'image-thumbnail', zh: '视频封面', en: 'Video Thumbnails', tags: ['视频缩略图', 'Video thumbnails', 'youtube', 'YouTube', 'cover', 'Cover'] },
+ { id: 'image-storyboard', zh: '故事分镜', en: 'Storyboards', tags: ['storyboard', 'Storyboard'] },
+ { id: 'image-ad', zh: '品牌广告', en: 'Brand Ads', tags: ['商业广告', 'Commercial advertising', 'advertising', 'Advertising'] },
+ { id: 'image-ecommerce', zh: '电商主图', en: 'E-commerce', tags: ['电商视觉', 'E-commerce visuals', 'ecommerce', 'E-commerce'] },
+ { id: 'image-game', zh: '游戏视觉', en: 'Game Art', tags: ['游戏视觉', 'Game visuals'] },
+ { id: 'image-poster', zh: '海报设计', en: 'Posters', tags: ['海报设计', 'Poster design', '活动物料', 'Event collateral', 'poster', 'Poster'] },
+ { id: 'image-web', zh: '网页设计', en: 'Web Design', tags: ['网页界面', 'Web interfaces'] },
+ { id: 'image-photography', zh: '摄影', en: 'Photography', tags: ['人像摄影', 'Portrait photography', '创意摄影', 'Creative photography', '产品摄影', 'Product photography'] },
+ { id: 'image-cinematic', zh: '电影感', en: 'Cinematic', tags: ['cinematic', 'Cinematic', '电影感'] },
+ { id: 'image-anime', zh: '动漫插画', en: 'Anime Illustration', tags: ['anime-style', 'Anime style'] },
+ { id: 'image-illustration', zh: '手绘插画', en: 'Hand-drawn Art', tags: ['手绘插画', 'Hand-drawn illustration', '概念艺术', 'Concept art'] },
+ { id: 'image-3d', zh: '三维场景', en: '3D Scenes', tags: ['3d-render', '3D render', '等轴测', 'Isometric', '微缩场景', 'Miniature scenes'] },
+ { id: 'image-collage', zh: '拼贴手作', en: 'Collage / Craft', tags: ['拼贴设计', 'Collage design', '手工材质', 'Handcrafted textures'] },
+ { id: 'image-watercolor', zh: '水彩画', en: 'Watercolor', tags: ['watercolor', 'Watercolor'] },
+ { id: 'image-traditional', zh: '国风美学', en: 'Chinese-inspired', tags: ['传统文化', 'Traditional culture'] },
+ { id: 'image-retro', zh: '复古怀旧', en: 'Retro', tags: ['nostalgic', 'Nostalgic'] },
+ { id: 'image-future', zh: '未来科技', en: 'Futuristic', tags: ['未来科技', 'Future technology'] },
+ { id: 'image-minimal', zh: '极简设计', en: 'Minimalist', tags: ['minimalist', 'Minimalist'] },
+ { id: 'image-people', zh: '人物角色', en: 'People / Characters', tags: ['人像摄影', 'Portrait photography', '角色场景', 'Character scenes', '真人贴纸', 'Real-person stickers'] },
+ { id: 'image-product', zh: '商品产品', en: 'Products', tags: ['产品视觉', 'Product visuals', '产品摄影', 'Product photography', '电商视觉', 'E-commerce visuals', '工业设计', 'Industrial design', 'product', 'Product'] },
+ { id: 'image-food', zh: '美食饮品', en: 'Food / Drink', tags: ['食品饮料', 'Food and beverage'] },
+ { id: 'image-fashion', zh: '时尚穿搭', en: 'Fashion / Beauty', tags: ['时尚美妆', 'Fashion and beauty'] },
+ { id: 'image-architecture', zh: '建筑空间', en: 'Architecture', tags: ['建筑空间', 'Architecture and interiors'] },
+ { id: 'image-city', zh: '城市街景', en: 'City Streets', tags: ['city-street', 'City streets'] },
+ { id: 'image-nature', zh: '自然植物', en: 'Nature / Plants', tags: ['自然植物', 'Nature and botanicals'] },
+ { id: 'image-maps', zh: '地图图表', en: 'Maps / Charts', tags: ['地图视觉', 'Map visuals', '信息图表', 'Infographics'] },
+ { id: 'image-type', zh: '文字排版', en: 'Typography', tags: ['文本排版', 'Text layout', '编辑设计', 'Editorial design'] }
+ ];
const categoryOrder: CreatorHomeCategory[] = [
'recent',
@@@ -85,11 -159,14 +162,16 @@@ export function CreatorDashboard(props
);
const searchInputRef = useRef<HTMLInputElement>(null);
const detailPageRef = useRef<HTMLDivElement>(null);
++ const detailCloseRef = useRef<HTMLButtonElement>(null);
++ const detailTriggerRef = useRef<HTMLButtonElement | null>(null);
const previewTriggerRef = useRef<HTMLButtonElement>(null);
const previewCloseRef = useRef<HTMLButtonElement>(null);
const promptRef = useRef<HTMLParagraphElement>(null);
+ const tagsFilterRef = useRef<HTMLDivElement>(null);
+ const tagsMeasureRef = useRef<HTMLDivElement>(null);
+ const moreTagsButtonRef = useRef<HTMLButtonElement>(null);
const busyIdentitiesRef = useRef(new Set<string>());
- const [actionError, setActionError] = useState<string>();
+ const pageIssues = usePageIssueState('creator-launch');
const presets = props.presets ?? [];
const normalizedQuery = query.trim().toLocaleLowerCase();
const categoryPresets = useMemo(() => {
@@@ -104,12 -182,36 +187,34 @@@
const modules = category === 'video' ? videoModules : imageModules;
return presets.filter(preset => modules.has(preset.module));
}, [category, presets, recentPresetIds]);
+ const categoryTagOptions = category === 'video'
+ ? videoTagOptions
+ : category === 'image'
+ ? imageTagOptions
+ : [];
- const availableTagOptions = category === 'video'
- ? videoTagOptions
- : categoryTagOptions.filter(option => (
- categoryPresets.some(preset => matchesFacet(preset, option))
- ));
++ const availableTagOptions = categoryTagOptions.filter(option => (
++ categoryPresets.some(preset => matchesFacet(preset, option))
++ ));
+ const pinnedTag = availableTagOptions.findIndex(option => option.id === selectedTag) >= visibleTagCount
+ ? selectedTag
+ : undefined;
+ const orderedTagOptions = pinnedTag === undefined
+ ? availableTagOptions
+ : [
+ ...availableTagOptions.filter(option => option.id === pinnedTag),
+ ...availableTagOptions.filter(option => option.id !== pinnedTag)
+ ];
+ const visibleTagOptions = orderedTagOptions.slice(0, visibleTagCount);
+ const overflowTagOptions = orderedTagOptions.slice(visibleTagCount);
+ const availableTagKey = orderedTagOptions.map(option => option.id).join('|');
const visiblePresets = useMemo(() => categoryPresets.filter(preset => (
- normalizedQuery === ''
- || `${preset.title} ${preset.description} ${preset.tags.join(' ')}`
- .toLocaleLowerCase()
- .includes(normalizedQuery)
- )), [categoryPresets, normalizedQuery]);
+ (selectedTag === undefined
+ || categoryTagOptions.some(option => option.id === selectedTag && matchesFacet(preset, option)))
+ && (normalizedQuery === ''
+ || `${preset.title} ${preset.description} ${preset.tags.join(' ')}`
+ .toLocaleLowerCase()
+ .includes(normalizedQuery))
+ )), [categoryPresets, selectedTag, normalizedQuery, category]);
const selectedPreset = selectedPresetIdentity === undefined
? undefined
: presets.find(preset => presetIdentity(preset) === selectedPresetIdentity);
@@@ -166,12 -290,20 +313,51 @@@
useLayoutEffect(() => {
if (selectedPresetIdentity === undefined) return;
- const scrollContainer = detailPageRef.current?.closest<HTMLElement>('.creator-home-wrap');
- if (scrollContainer !== null && scrollContainer !== undefined) {
- scrollContainer.scrollTop = 0;
- }
+ const info = detailPageRef.current?.querySelector<HTMLElement>('.creator-template-detail-info');
+ if (info) info.scrollTop = 0;
}, [selectedPresetIdentity]);
++ useLayoutEffect(() => {
++ if (selectedPresetIdentity === undefined || selectedPreset === undefined) return;
++ const trigger = detailTriggerRef.current;
++ detailCloseRef.current?.focus();
++ return () => {
++ if (trigger?.isConnected) trigger.focus();
++ };
++ }, [selectedPresetIdentity]);
++
+ useEffect(() => {
+ if (selectedPreset === undefined) return;
- const onEscape = (event: KeyboardEvent) => {
- if (event.key !== 'Escape' || previewOpen) return;
- setSelectedPresetIdentity(undefined);
++ const onKeyDown = (event: KeyboardEvent) => {
++ if (previewOpen) return;
++ if (event.key === 'Escape') {
++ event.preventDefault();
++ setSelectedPresetIdentity(undefined);
++ return;
++ }
++ if (event.key !== 'Tab') return;
++ const dialog = detailPageRef.current;
++ if (dialog === null) return;
++ const focusable = Array.from(dialog.querySelectorAll<HTMLElement>(
++ 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
++ )).filter(element => !element.hidden && element.tabIndex >= 0);
++ const first = focusable[0];
++ const last = focusable[focusable.length - 1];
++ if (first === undefined || last === undefined) {
++ event.preventDefault();
++ dialog.focus();
++ } else if (event.shiftKey && (document.activeElement === first || !dialog.contains(document.activeElement))) {
++ event.preventDefault();
++ last.focus();
++ } else if (!event.shiftKey && (document.activeElement === last || !dialog.contains(document.activeElement))) {
++ event.preventDefault();
++ first.focus();
++ }
+ };
- document.addEventListener('keydown', onEscape);
- return () => document.removeEventListener('keydown', onEscape);
++ document.addEventListener('keydown', onKeyDown);
++ return () => document.removeEventListener('keydown', onKeyDown);
+ }, [selectedPreset, previewOpen]);
+
useLayoutEffect(() => {
const prompt = promptRef.current;
if (prompt === null) {
@@@ -189,8 -321,11 +375,10 @@@
function selectCategory(nextCategory: CreatorHomeCategory) {
setCategory(nextCategory);
+ setSelectedTag(undefined);
+ setMoreTagsOpen(false);
setQuery('');
setSearchOpen(false);
- setActionError(undefined);
}
async function selectPreset(preset: CreatorPresetSummary) {
@@@ -229,20 -357,24 +417,27 @@@
const previewUrl = selectedPreset.previewUrl ?? selectedPreset.coverUrl;
return (
<>
- <div ref={detailPageRef} className="creator-dashboard creator-template-detail-page">
+ <div className="creator-template-detail-backdrop" onMouseDown={event => {
- if (event.target === event.currentTarget) setSelectedPresetIdentity(undefined);
++ if (event.target === event.currentTarget) {
++ setPreviewOpen(false);
++ setSelectedPresetIdentity(undefined);
++ }
+ }}>
+ <div ref={detailPageRef} className="creator-dashboard creator-template-detail-page" role="dialog" aria-modal="true" aria-label={selectedPreset.title}>
<header className="creator-template-detail-toolbar">
- <button
- type="button"
- className="creator-template-back"
- onClick={() => {
- setPreviewOpen(false);
- setSelectedPresetIdentity(undefined);
- }}
- >
- <ArrowLeft size={16} aria-hidden="true" />
- {language === 'en-US' ? 'Back to templates' : '返回模板列表'}
- </button>
- <span>{moduleLabel(selectedPreset.module, language === 'zh-CN' ? 'zh-CN' : 'en-US')}</span>
+ <div className="creator-template-detail-heading">
+ <h1>{selectedPreset.title}</h1>
+ <p>{selectedPreset.description}</p>
+ </div>
+ <div className="creator-template-detail-actions">
+ <button className="creator-template-use-button" type="button" disabled={busy} aria-busy={busy} onClick={() => void selectPreset(selectedPreset)}>
+ <WandSparkles size={17} aria-hidden="true" />
+ {busy ? (language === 'en-US' ? 'Creating...' : '正在创建...') : (language === 'en-US' ? 'Use this template' : '使用此模板')}
+ </button>
- <button type="button" className="creator-template-back" aria-label={language === 'en-US' ? 'Back to templates' : '返回模板列表'} title={language === 'en-US' ? 'Back to templates' : '返回模板列表'} onClick={() => { setSelectedPresetIdentity(undefined); setActionError(undefined); }}>
++ <button ref={detailCloseRef} type="button" className="creator-template-back" aria-label={language === 'en-US' ? 'Back to templates' : '返回模板列表'} title={language === 'en-US' ? 'Back to templates' : '返回模板列表'} onClick={() => { setPreviewOpen(false); setSelectedPresetIdentity(undefined); }}>
+ <X size={18} aria-hidden="true" />
+ </button>
+ </div>
</header>
<div className="creator-template-detail-layout">
@@@ -374,54 -519,13 +582,19 @@@
</p>
) : null}
- {actionError ? (
- <p className="creator-template-action-error" role="alert">{actionError}</p>
- ) : null}
+ <IssueList
+ issues={pageIssues.issues}
+ actions={{ retryOperations: {
+ 'creator-launch.load-presets': () => props.onRetry?.(),
+ 'creator-launch.select-preset': () => selectPreset(selectedPreset)
+ } }}
+ onDismiss={pageIssues.dismissIssue}
+ compact
+ />
- <button
- className="creator-template-use-button"
- type="button"
- disabled={busy}
- aria-busy={busy}
- onClick={() => void selectPreset(selectedPreset)}
- >
- <WandSparkles size={17} aria-hidden="true" />
- {busy
- ? (language === 'en-US' ? 'Creating...' : '正在创建...')
- : (language === 'en-US' ? 'Use this template' : '使用此模板')}
- </button>
</aside>
</div>
-
- <section className="creator-template-detail-section creator-template-prompt-section">
- <h2>{language === 'en-US' ? 'Prompt' : '提示词'}</h2>
- <div className={`creator-template-prompt-card${promptHasOverflow
- ? ' is-scrollable'
- : ''}${promptAtEnd ? ' is-at-end' : ''}`}>
- <p
- ref={promptRef}
- onScroll={updatePromptOverflow}
- className={selectedPreset.prompt === null
- ? 'creator-template-detail-empty'
- : 'creator-template-prompt'}
- >
- {selectedPreset.prompt === null
- ? (language === 'en-US'
- ? 'This template uses fixed settings and does not require a preset prompt.'
- : '此模板使用固定配置,无需预设提示词。')
- : renderPromptVariables(selectedPreset.prompt, language === 'zh-CN' ? 'zh-CN' : 'en-US')}
- </p>
- <span className="creator-template-prompt-scroll-cue" aria-hidden="true">
- <ChevronDown size={17} />
- </span>
- </div>
- </section>
+ </div>
</div>
{!previewOpen ? null : createPortal(
<div
@@@ -562,13 -742,18 +811,13 @@@
))}
</div>
) : null}
- <IssueList
- {props.error ? (
- <div className="creator-template-error" role="alert">
- <span>{props.error}</span>
- <button type="button" onClick={props.onRetry}>
- <RefreshCw size={15} aria-hidden="true" />
- {language === 'en-US' ? 'Retry' : '重试'}
- </button>
- </div>
- ) : null}
- {actionError && selectedPreset === undefined ? (
- <p className="creator-template-action-error" role="alert">{actionError}</p>
- ) : null}
++ {selectedPreset === undefined ? <IssueList
+ issues={pageIssues.issues}
+ actions={{ retryOperations: {
+ 'creator-launch.load-presets': () => props.onRetry?.()
+ } }}
+ onDismiss={pageIssues.dismissIssue}
- />
++ /> : null}
{!props.loading && !props.error ? (
<div className="creator-template-grid">
@@@ -580,9 -765,10 +829,10 @@@
type="button"
key={identity}
data-preset-id={identity}
-- onClick={() => {
++ onClick={event => {
++ detailTriggerRef.current = event.currentTarget;
setPreviewOpen(false);
setSelectedPresetIdentity(identity);
- setActionError(undefined);
}}
aria-label={language === 'en-US'
? `View ${preset.title} template details`
@@@ -622,18 -812,18 +876,6 @@@
);
}
--export function getCreatorSkillPromptHint(
-- skill: CreatorSkill,
-- language: 'zh-CN' | 'en-US'
--): string {
-- if (skill.promptHint !== undefined) {
-- return language === 'en-US' ? skill.promptHint.enUS : skill.promptHint.zhCN;
-- }
-- return language === 'en-US'
-- ? `Describe what you want to create with ${skill.title} and any requirements`
-- : `描述你希望用「${skill.title}」完成的内容和要求`;
--}
--
function presetIdentity(preset: CreatorPresetSummary): string {
return `${preset.module}/${preset.id}/${preset.version}`;
}
@@@ -681,21 -872,43 +924,28 @@@ function categoryLabel
return language === 'en-US' ? labels[category].en : labels[category].zh;
}
- function moduleLabel(
- module: CreatorRuntimeWorkspace,
- language: 'zh-CN' | 'en-US'
- ): string {
- const labels: Record<CreatorRuntimeWorkspace, { zh: string; en: string }> = {
- 'video-translation': { zh: '视频翻译', en: 'Video translation' },
- 'video-download': { zh: '视频下载', en: 'Video download' },
- 'image-generation': { zh: '图像生成', en: 'Image generation' },
- 'video-generation': { zh: '视频生成', en: 'Video generation' },
- 'cover-generator': { zh: '封面生成', en: 'Cover generation' },
- 'smart-dubbing': { zh: '智能配音', en: 'Smart dubbing' }
- };
- return language === 'en-US' ? labels[module].en : labels[module].zh;
+ function matchesFacet(preset: CreatorPresetSummary, option: FacetOption): boolean {
+ return option.modules?.includes(preset.module) === true
+ || (preset.tagIds ?? preset.tags).some(tag => option.tags.includes(tag));
+ }
+
+ function fitTagCount(widths: number[], availableWidth: number, gap: number): number {
+ if (widths.length < 2) return 0;
+ const optionWidths = widths.slice(1, -1);
+ const allWidth = widths[0]!;
+ const fullWidth = allWidth + optionWidths.reduce((sum, width) => sum + width + gap, 0);
+ if (fullWidth <= availableWidth) return optionWidths.length;
+
+ let usedWidth = allWidth + widths[widths.length - 1]! + gap;
+ let count = 0;
+ for (const width of optionWidths) {
+ if (usedWidth + width + gap > availableWidth) break;
+ usedWidth += width + gap;
+ count++;
+ }
+ return count;
}
-function moduleLabel(
- module: CreatorRuntimeWorkspace,
- language: 'zh-CN' | 'en-US'
-): string {
- const labels: Record<CreatorRuntimeWorkspace, { zh: string; en: string }> = {
- 'video-translation': { zh: '视频翻译', en: 'Video translation' },
- 'video-download': { zh: '视频下载', en: 'Video download' },
- 'image-generation': { zh: '图像生成', en: 'Image generation' },
- 'video-generation': { zh: '视频生成', en: 'Video generation' },
- 'cover-generator': { zh: '封面生成', en: 'Cover generation' },
- 'smart-dubbing': { zh: '智能配音', en: 'Smart dubbing' }
- };
- return language === 'en-US' ? labels[module].en : labels[module].zh;
-}
-
function readRecentPresetIds(): string[] {
try {
const stored = window.localStorage.getItem(recentPresetStorageKey);
diff --cc apps/web/src/features/conversation/creator-skill-prompt-hint.ts
index 00000000,00000000..f374c9fc
new file mode 100644
--- /dev/null
+++ b/apps/web/src/features/conversation/creator-skill-prompt-hint.ts
@@@ -1,0 -1,0 +1,13 @@@
++import type { CreatorSkill } from './CreatorDashboard.js';
++
++export function getCreatorSkillPromptHint(
++ skill: CreatorSkill,
++ language: 'zh-CN' | 'en-US'
++): string {
++ if (skill.promptHint !== undefined) {
++ return language === 'en-US' ? skill.promptHint.enUS : skill.promptHint.zhCN;
++ }
++ return language === 'en-US'
++ ? `Describe what you want to create with ${skill.title} and any requirements`
++ : `描述你希望用「${skill.title}」完成的内容和要求`;
++}
diff --cc apps/web/src/styles/app.css
index ffab871c,5647982b..9f9f417c
--- a/apps/web/src/styles/app.css
+++ b/apps/web/src/styles/app.css
@@@ -3754,24 -3831,52 +3755,6 @@@ html.is-pane-resizing *
white-space: nowrap;
}
--.creator-template-detail-page {
- width: min(1120px, 100%);
- gap: 16px;
- width: min(1500px, 94vw);
- height: min(920px, 94dvh);
- min-height: 0;
- display: flex;
- flex-direction: column;
- gap: 0;
- margin: 0;
- overflow: hidden;
- border: 1px solid var(--border);
- border-radius: 8px;
- background: var(--surface-popover);
- box-shadow: 0 24px 80px rgb(0 0 0 / 0.25);
-}
-
-.creator-template-detail-backdrop {
- position: fixed;
- inset: 0;
- z-index: 150;
- display: grid;
- place-items: center;
- padding: 12px;
- background: rgb(12 15 20 / 0.55);
--}
--
--.creator-template-detail-toolbar {
- min-height: 36px;
- min-height: 78px;
-- display: flex;
-- align-items: center;
-- justify-content: space-between;
-- gap: 16px;
- padding: 14px 24px;
- border-bottom: 1px solid var(--border);
--}
-
-.creator-template-detail-heading { min-width: 0; }
-.creator-template-detail-heading h1 { margin: 0; font-size: 18px; line-height: 1.3; }
-.creator-template-detail-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
-.creator-template-detail-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
-.creator-template-detail-actions .creator-template-use-button { margin: 0; }
--
--.creator-template-detail-toolbar > span {
-- color: var(--muted);
-- font-size: 12px;
--}
--
.creator-template-back {
min-height: 34px;
display: inline-flex;
@@@ -3949,26 -4082,26 +3960,6 @@@ button.creator-template-outcome-expand:
border-left: 1px solid var(--border-hairline);
}
--.creator-template-detail-intro {
-- display: grid;
-- gap: 8px;
--}
--
--.creator-template-detail-intro h1 {
-- margin: 0;
-- color: var(--text);
-- font-size: 25px;
-- font-weight: 600;
-- line-height: 1.2;
--}
--
--.creator-template-detail-intro p {
-- margin: 0;
-- color: var(--muted);
-- font-size: 13px;
-- line-height: 1.6;
--}
--
.creator-template-author {
min-width: 0;
display: grid;
@@@ -4057,10 -4190,35 +4048,11 @@@
.creator-template-prompt-section {
min-width: 0;
- gap: 12px;
- padding-top: 18px;
+ gap: 0;
+ padding-top: 0;
+ border-top: 0;
}
-.creator-template-prompt-heading {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
- padding: 14px 16px 0;
-}
-
-.creator-template-prompt-heading h2 { font-size: 12px; letter-spacing: 0; }
-.creator-template-prompt-heading button {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- padding: 5px 0 5px 6px;
- border: 0;
- background: transparent;
- color: var(--muted);
- font-size: 12px;
- cursor: pointer;
-}
-.creator-template-prompt-heading button:hover:not(:disabled) { color: var(--text); }
-.creator-template-prompt-heading button:disabled { opacity: 0.5; cursor: default; }
-.creator-template-prompt-heading button:focus-visible { outline: 2px solid var(--state-focus-ring); }
-
.creator-template-prompt-card {
position: relative;
min-width: 0;
@@@ -4245,9 -4406,10 +4240,9 @@@
padding: 44px 16px 40px;
}
- .creator-template-detail-page { width: min(700px, 96vw); height: 94dvh; }
.creator-template-detail-layout {
grid-template-columns: minmax(0, 1fr);
- gap: 22px;
+ grid-template-rows: minmax(210px, 42%) minmax(0, 1fr);
}
.creator-template-detail-info {
@@@ -4255,8 -4417,17 +4250,9 @@@
border-top: 1px solid var(--border-hairline);
border-left: 0;
}
+ .creator-template-outcome { padding: 16px; }
}
-@media (max-width: 600px) {
- .creator-template-detail-toolbar { padding: 12px 16px; }
- .creator-template-detail-heading h1 { font-size: 15px; }
- .creator-template-detail-heading p { display: none; }
- .creator-template-detail-actions { gap: 4px; }
- .creator-template-detail-actions .creator-template-use-button { padding: 8px; font-size: 12px; }
-}
-
@media (max-width: 700px) {
.creator-dashboard {
gap: 20px;