diff --git a/calliope-web/src/lib/components/ImageLightbox.svelte b/calliope-web/src/lib/components/ImageLightbox.svelte index bb748060..ac1fbd52 100644 --- a/calliope-web/src/lib/components/ImageLightbox.svelte +++ b/calliope-web/src/lib/components/ImageLightbox.svelte @@ -96,8 +96,8 @@ + +
+ {#each sorted as job (job.id)} + {@const path = job.output_paths.find((p) => !missingOutputsOf(job).includes(p))} + {@const status = jobStatusInfo(job)} + + {:else}

生成后,结果会保存在这里。

{/each} +
+ + + diff --git a/calliope-web/src/lib/components/desk/StudioDesk.svelte b/calliope-web/src/lib/components/desk/StudioDesk.svelte index 0a49a9ee..428c4ca2 100644 --- a/calliope-web/src/lib/components/desk/StudioDesk.svelte +++ b/calliope-web/src/lib/components/desk/StudioDesk.svelte @@ -13,6 +13,7 @@ import Inspector from '$lib/components/generate/Inspector.svelte'; import ParamsPanel from '$lib/components/generate/ParamsPanel.svelte'; import TakeFeed from '$lib/components/generate/TakeFeed.svelte'; + import ResultRail from './ResultRail.svelte'; import { createTakeDeleteQueue } from '$lib/components/generate/takeDelete.svelte'; import { readDeskContext, workbenchContextOf } from '$lib/components/generate/context'; import { @@ -57,7 +58,7 @@ import { t } from '$lib/i18n.svelte'; /** Refract creative studio. The large artboard and right composer share - * existing workflow/schema/job logic. Model selection is a modal catalogue; + * existing workflow/schema/job logic. Tool selection stays within the workspace; * project context and explicit result attachment stay server-validated. */ interface Props { kind: DeskKind; @@ -212,8 +213,6 @@ if (ev.type === 'job.completed') { const id = Number(ev.data.job_id); flashTake(id, 950, flashIds); - // 完成:检视区若正选中该条且为视频,自动播放。 - if (selectedJobId === id) playSignal += 1; } if ( ev.type === 'job.completed' && @@ -242,21 +241,20 @@ let bayOpen = $state(false); let paramsOpen = $state(false); + let historyOpen = $state(false); let focusMode = $state(false); let bayActiveId = $state(null); let bay = $state(null); - const modeMetas = $derived( - mode === 'all' ? deskMetas : deskMetas.filter((m) => m.usage === mode), - ); - function openBay() { bayActiveId = workflowId; bayOpen = true; + void tick().then(() => bay?.focusSearch()); } function closeBay() { bayOpen = false; + void tick().then(() => document.querySelector('.model-selector')?.focus()); } function pickWorkflow(id: number) { @@ -276,6 +274,10 @@ } if ($metaQuery.isLoading) return; wfDeepLinkDone = true; + if (restoredWorkflowId && deskMetas.some((m) => m.id === restoredWorkflowId)) { + workflowId = restoredWorkflowId; + return; + } if (deskMetas.some((m) => m.id === raw)) workflowId = raw; }); @@ -294,7 +296,49 @@ // ------------------------------------------------------------------ let endpointTouched = $state(false); let endpointId = $state(''); - let workflowId = $state(null); + const draftContext = untrack(() => readDeskContext(page.url, kind)); + const draftKey = untrack( + () => + 'creative-draft:' + + JSON.stringify([ + kind, + draftContext?.projectId, + draftContext?.stage, + draftContext?.sourceId ?? draftContext?.label, + page.url.searchParams.get('wf'), + ]), + ); + const sourceFingerprint = JSON.stringify([ + draftContext?.prompt, + draftContext?.negative, + draftContext?.durationSec, + ]); + function readDraft(): { workflowId: number; values: FormValues } | null { + try { + const d = JSON.parse(window.sessionStorage.getItem(draftKey) ?? 'null'); + if ( + !d || + d.source !== sourceFingerprint || + !Number.isInteger(d.workflowId) || + !d.values || + typeof d.values !== 'object' + ) + return null; + const clean: FormValues = {}; + for (const [key, value] of Object.entries(d.values)) { + if (typeof value === 'string' || (typeof value === 'number' && Number.isFinite(value))) + clean[key] = value; + else if (Array.isArray(value) && value.every((v) => typeof v === 'string')) + clean[key] = value; + } + return { workflowId: d.workflowId, values: clean }; + } catch { + return null; + } + } + let pendingDraft = untrack(readDraft); + const restoredWorkflowId = pendingDraft?.workflowId ?? null; + let workflowId = $state(pendingDraft?.workflowId ?? null); let values = $state({}); let showErrors = $state(false); let submitting = $state(false); @@ -317,6 +361,7 @@ // Default workflow: this entry's usages in priority order (metadata-side; // error-level warnings surface through the block reason once loaded). $effect(() => { + if ($metaQuery.isLoading) return; if ( workflowId != null && (details.has(workflowId) || deskMetas.some((m) => m.id === workflowId)) @@ -382,11 +427,30 @@ ctxApplied = true; next = applyContext(wf, next); } + if (pendingDraft?.workflowId === wf.id) { + const allowed = new Set((wf.input_schema ?? []).map((i) => i.nodeId)); + for (const [key, value] of Object.entries(pendingDraft.values)) + if (allowed.has(key)) next[key] = value; + } + pendingDraft = null; lastWf = wf; values = next; showErrors = false; }); }); + $effect(() => { + const wf = currentWorkflow, + inputs = values; + if (!wf || lastWf?.id !== wf.id) return; + try { + window.sessionStorage.setItem( + draftKey, + JSON.stringify({ workflowId: wf.id, values: inputs, source: sourceFingerprint }), + ); + } catch { + /* Storage may be unavailable; the current form still works. */ + } + }); function applyContext(wf: Workflow, base: FormValues): FormValues { if (!ctx) return base; @@ -580,7 +644,6 @@ let wide = $state(true); let narrow = $state(false); let crossfade = $state(false); - let playSignal = $state(0); let videoEl = $state(null); $effect(() => { @@ -629,7 +692,6 @@ tab = 'result'; crossfade = via === 'pointer'; if (via === 'pointer') { - playSignal += 1; if (!wide) inspOpen = true; void tick().then(() => feed?.slideFrom(from)); } else { @@ -637,15 +699,6 @@ } } - function moveSelection(delta: number) { - if (!orderedIds.length) return; - let i = orderedIds.indexOf(selectedJob?.id ?? -1); - if (i < 0) i = orderedIds.length - 1; - i = Math.max(0, Math.min(orderedIds.length - 1, i + delta)); - const job = allJobs.find((j) => j.id === orderedIds[i]); - if (job) selectTake(job, 'keyboard'); - } - function openParams() { paramsOpen = true; } @@ -657,12 +710,6 @@ if (focusMode) toggleInspector(); } $effect(() => () => window.dispatchEvent(new CustomEvent('refract-focus', { detail: false }))); - function selectMode(next: TaskMode) { - mode = next; - const choice = next === 'all' ? deskMetas[0] : deskMetas.find((m) => m.usage === next); - if (choice) pickWorkflow(choice.id); - else openBay(); - } function mediumLink(next: DeskKind) { const url = new URL(page.url); url.pathname = '/' + next; @@ -829,22 +876,13 @@ // ------------------------------------------------------------------ // 键盘 (§四.8): Ctrl/⌘+Enter 生成 · / 聚焦搜索/提示词 · ↑↓/J/K 切换 - // (挑选台打开时游走挑选行,否则切换记录)· 空格播放/暂停 · Delete 删 - // 选中 · ] 检视区 · Esc 关挑选台/浮层 + // Ctrl/⌘+Enter 仅在创作输入区提交;Esc 退出选工具。媒体与记录使用显式控件。 // ------------------------------------------------------------------ function typing(target: EventTarget | null): boolean { const el = target as HTMLElement | null; return !!el && (el.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName)); } - /** Focus sits on something that owns the key (button, link, video…). */ - function onInteractive(target: EventTarget | null): boolean { - const el = target instanceof Element ? target : null; - return !!el?.closest( - 'button, a, input, textarea, select, label, video, audio, [contenteditable]', - ); - } - function inLayer(target: EventTarget | null): boolean { const el = target instanceof Element ? target : null; return !!el?.closest('.shell-pop, .modal, [role="dialog"]'); @@ -857,49 +895,13 @@ closeBay(); return; } - // 挑选台开着时,键盘归挑选台(其容器自己处理 ↑↓/Enter/Esc)。 - if (bayOpen) { - if (e.key === '/' && !typing(e.target)) { - e.preventDefault(); - bay?.focusSearch(); - } - return; - } - if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) { + if ( + e.key === 'Enter' && + (e.ctrlKey || e.metaKey) && + (e.target as Element)?.closest('.composer') + ) { e.preventDefault(); void submit(); - return; - } - if (e.ctrlKey || e.metaKey || e.altKey) return; - const key = e.key.toLowerCase(); - if (key === '/' && !typing(e.target)) { - e.preventDefault(); - promptEl?.focus(); - } else if ((e.key === 'ArrowDown' || key === 'j') && !typing(e.target)) { - e.preventDefault(); - moveSelection(1); - } else if ((e.key === 'ArrowUp' || key === 'k') && !typing(e.target)) { - e.preventDefault(); - moveSelection(-1); - } else if (e.key === ' ') { - // 空格播放/暂停:检视区可见且有视频时接管;焦点在控件上时走原生行为。 - if (typing(e.target) || onInteractive(e.target)) return; - if (videoEl && (wide ? !inspOff : inspOpen)) { - e.preventDefault(); - if (videoEl.paused) videoEl.play().catch(() => {}); - else videoEl.pause(); - } - } else if (e.key === ']' && !typing(e.target)) { - e.preventDefault(); - toggleInspector(); - } else if ((e.key === 'Delete' || e.key === 'Backspace') && !typing(e.target)) { - const job = selectedJob; - if (job && job.status !== 'pending' && job.status !== 'running') { - e.preventDefault(); - requestDelete(job); - } - } else if (e.key === 'Escape' && !wide && inspOpen) { - inspOpen = false; } } @@ -909,7 +911,6 @@ const currentMeta = $derived(allMetas.find((m) => m.id === workflowId) ?? null); const previewMeta = $derived(allMetas.find((m) => m.id === bayActiveId) ?? null); const previewFull = $derived(bayActiveId != null ? (details.get(bayActiveId) ?? null) : null); - const picking = $derived(bayOpen && wide); @@ -933,114 +934,52 @@ /> {/snippet} - +{#snippet toolHeader()} +
+ +
+
+

1 · 选择创作工具

+ + {#if currentMeta?.usage}

+ {usageLabel(currentMeta.usage)} · +

{/if} + {#if currentWorkflow?.description}

+ {currentWorkflow.description} +

{/if} + {#if !deskMetas.length && !$metaQuery.isLoading}

+ 还没有可用工具。导入与配置 ↗ +

{/if} +
+{/snippet} + +
-
+
-
MAKE ROOM FOR YOUR IMAGINATION
-

让画面,向前一步。

+

{kind === 'image' ? '图片创作' : '视频创作'}

+

选择工具,准备素材,生成你的作品。

- 云端模型与智能体 ↗工具配置 ↗
-
+ {@render ctxBanner()} -
-
-
- 创作预览{selectedJob ? '第 ' + selectedJob.id + ' 次探索' : '从一个想法开始'} -
- j.kind === 'image' && j.status === 'done' && j.id !== selectedJob?.id, - )?.output_paths[0] ?? null} - bind:tab - job={selectedJob} - wf={selectedJob ? workflowOf(selectedJob) : undefined} - {nowMs} - open={true} - inactive={false} - canSendToSlot={!!imageSlotTarget || !!imageList} - {crossfade} - {playSignal} - bind:videoEl - params={paramsTab} - onClose={closeInspector} - onReuse={reuse} - onRetry={retry} - onSendToSlot={sendToSlot} - onDelete={requestDelete} - /> - {#if selectedJob && workbenchCtxOf(selectedJob) && selectedJob.status === 'done'}{/if} -
- 每一次探索 查看创作记录 ↓ - selectTake(job, 'pointer')} - onReuse={reuse} - onRetry={retry} - onCancel={cancel} - onDelete={requestDelete} - {attachBusyId} - onAttach={attachToProject} - /> -
-
-
- -
- +
+ { + selectTake(job, 'pointer'); + historyOpen = false; + }} + onReuse={(job) => { + void reuse(job); + historyOpen = false; + }} + onRetry={retry} + onCancel={cancel} + onDelete={requestDelete} + {attachBusyId} + onAttach={attachToProject} />
@@ -1103,191 +1169,240 @@ diff --git a/calliope-web/src/lib/components/desk/WorkflowBay.svelte b/calliope-web/src/lib/components/desk/WorkflowBay.svelte index c85beede..df62a8ed 100644 --- a/calliope-web/src/lib/components/desk/WorkflowBay.svelte +++ b/calliope-web/src/lib/components/desk/WorkflowBay.svelte @@ -16,6 +16,8 @@ onPick: (id: number) => void; onClose: () => void; catalogue?: boolean; + localOnly?: boolean; + onPreview?: (id: number) => void; } let { open, @@ -27,6 +29,8 @@ onPick, onClose, catalogue = false, + localOnly = false, + onPreview, }: Props = $props(); const client = useQueryClient(); const modelsQuery = createQuery({ @@ -37,6 +41,7 @@ category = $state('all'), family = $state('all'), source = $state('local'), + usage = $state('all'), favOnly = $state(false), recentOnly = $state(false), visibleCount = $state(48); @@ -62,6 +67,7 @@ .filter( (m) => (category === 'all' || m.category === category) && + (usage === 'all' || m.usage === usage) && (family === 'all' || m.model_family === family) && (!favOnly || m.favorite) && (!recentOnly || m.last_used_at) && @@ -93,6 +99,7 @@ void search; void category; void family; + void usage; void favOnly; void recentOnly; visibleCount = 48; @@ -119,7 +126,8 @@ } } function pick(m: WorkflowMeta) { - if (m.is_enabled && !m.needs_mapping && m.usage) onPick(m.id); + if (onPreview) onPreview(m.id); + else if (m.is_enabled && !m.needs_mapping && m.usage) onPick(m.id); } function move(delta: number) { const i = Math.max( @@ -204,9 +212,13 @@
{#if source === 'local'}{#each [...new Set(metas + .map((m) => m.usage) + .filter(Boolean))] as u}{/each}{/if}{source === 'local' ? filtered.length : cloudModels.length} 个结果 @@ -236,14 +248,15 @@ class="workflow-choice" onclick={() => pick(m)} onfocus={() => (activeId = m.id)} - disabled={!m.is_enabled || m.needs_mapping || !m.usage} - aria-label="使用 {m.name}" + disabled={!onPreview && (!m.is_enabled || m.needs_mapping || !m.usage)} + aria-label="{onPreview ? '查看' : '使用'} {m.name}" aria-current={m.id === selectedId ? 'true' : undefined} >
{m.model_family ?? 'COMFYUI'}本地

{m.name}

+ {#if m.description}

{m.description}

{/if}
{m.usage ? usageLabel(m.usage) : '待映射'} diff --git a/calliope-web/src/lib/components/generate/Inspector.svelte b/calliope-web/src/lib/components/generate/Inspector.svelte index d4313929..b3b5e4c5 100644 --- a/calliope-web/src/lib/components/generate/Inspector.svelte +++ b/calliope-web/src/lib/components/generate/Inspector.svelte @@ -1,5 +1,5 @@ - +{#key page.url.pathname + page.url.search}{/key} diff --git a/calliope-web/src/routes/video/+page.svelte b/calliope-web/src/routes/video/+page.svelte index 6d97f24f..98e6c3e1 100644 --- a/calliope-web/src/routes/video/+page.svelte +++ b/calliope-web/src/routes/video/+page.svelte @@ -1,5 +1,6 @@ - +{#key page.url.pathname + page.url.search}{/key} diff --git a/docs/HEL-665-creative-journey.md b/docs/HEL-665-creative-journey.md new file mode 100644 index 00000000..c667fda4 --- /dev/null +++ b/docs/HEL-665-creative-journey.md @@ -0,0 +1,30 @@ +# HEL-665 创作流程重做(2026-10-13) + +## 本轮范围 + +用户确认按新的操作规则重做 ComfyUI 完整创作路径。前端基于 `feat/hel-665-refract@ac1c0f9`;保留既有工作流解析、输入映射、上传、队列和项目回流接口。 + +- 创作区按「选择工具 → 准备素材 → 开始生成 → 查看结果」组织。 +- 工具选择在工作区内完成,先查看真实输入要求,再确认使用。取消选择保留输入。 +- 左侧表单独立滚动,提交按钮与阻止提交的原因固定可见。常用参数直接展示;高级参数折叠,服务配置另设入口。 +- 右侧完整展示结果,历史改为紧凑记录条;可打开详细任务记录。当前排队/运行任务可显式取消。 +- 视频默认暂停,播放/暂停及全屏按钮显式显示,取消页面级空格/方向键/删除键副作用;其他页面共用的媒体放大窗口也取消自动播放。 +- 媒体网格使用 `minmax(0, 1fr)`,防止视频的固有尺寸撑大网格行、被外框裁掉播放控件。 +- 本标签页草稿按类型、项目来源和入口隔离,恢复工具、描述、参数与已上传文件引用。来源提示改变时使用新来源。入口变化重建编辑器,避免串项目;详情先返回时,迟到的目录不会覆盖恢复选择。 +- 共用壳层去掉刚性最小宽度,创作区按实际窗口剩余高度分配空间。 + +没有改服务端业务和数据库,也没有重新提交测试站用户的任务。 + +## 验证与界限 + +- `npm run check`:0 错误,2 条原有警告;`npm test` 原有四组检查通过;`npm run build` 通过。 +- `e2e/refract.mjs` 使用独立本地数据库及假 ComfyUI,覆盖真实 API 提交、首尾帧独立上传、输入保留、回存和重载、显式播放、工具确认、矮窗口、目录延迟与草稿隔离。 +- 窗口包括 1366×768、1280×720、1100×600、960×540、1920×1080。验证视频完整边界、播放区及生成按钮均在视口内。150% 的等效缩放检查使用 960×540 逻辑视口和 1.5 像素密度,不冒充操作系统缩放实测。 +- 总工独立复核使用浏览器内响应替换模拟 30 项参数与 60 条记录;确认长表单与记录分别滚动、播放可控。 +- 真实 Qwen 工作流来自测试站 `qwen2.1`,完整图及输入映射复制到本地临时数据库,绑定实际 `192.168.200.12:8188`。从新版表单提交 0.3 百万像素、8 步的蓝色陶瓷杯检查,经真实 ComfyUI 生成图片并回存本地来源项目。临时任务与项目清理完成;没有写测试站项目库。此检查证明这条路径跑通,不证明所有工作流或模型的生成质量。 +- H3 两种实际工作流也复制到本地用于输入界面检查;本轮没有再做真实 H3 GPU 生成。 + +## 部署 + +只替换前端构建及对应源码,保留先前 demo。新构建保留旧版不可变脚本,避免正在打开的页面因脚本文件切换而失效。 +部署与回退均不重启后端,避免影响正在执行的生成任务。旧前端、版本记录、回退脚本保存在测试服务器 `/opt/aigc-home/releases`。 diff --git a/e2e/refract.mjs b/e2e/refract.mjs index c97d582e..329c2601 100644 --- a/e2e/refract.mjs +++ b/e2e/refract.mjs @@ -58,6 +58,18 @@ const mode = (videos = false, photo = 'coast') => ); try { mode(); + // Remove only this script's marked local fixtures after an interrupted previous run. + const staleProjects = (await api('/api/projects')).filter( + (p) => p.title === '折光·可删除测试项目', + ); + const staleProjectIds = new Set(staleProjects.map((p) => p.id)); + for (const j of await api('/api/playground/jobs')) + if (staleProjectIds.has(j.payload?.workbench?.project_id)) + await api('/api/playground/jobs/' + j.id, null, 'DELETE'); + for (const p of staleProjects) await api('/api/projects/' + p.id, null, 'DELETE'); + for (const w of await api('/api/workflows?view=meta')) + if (['H3 首尾帧·折光回归', 'H3 首尾帧·首次加载回归'].includes(w.name)) + await api('/api/workflows/' + w.id, null, 'DELETE'); const rows = await api('/api/workflows?view=meta'); ok('more than 100 imported catalogue entries', rows.length > 100); const image = rows.find((w) => w.name === '文生图·回归'); @@ -170,37 +182,53 @@ try { (await page.inputValue('#desk-prompt')) === 'traveler on coast' && (await page.locator('.context-bar a.back').count()) === 1, ); + await page.fill('#desk-prompt', '项目草稿·旅人'); + await page.locator('.sidebar .nav-item[href="/image"]').click(); + await page.waitForURL(WEB + '/image'); + await page.locator('.context-bar').waitFor({ state: 'detached' }); + await page.locator('#desk-prompt').waitFor(); + await page.fill('#desk-prompt', '独立创作草稿'); + await page.goto(desk); + await page.locator('#desk-prompt').waitFor(); + ok( + 'project and standalone drafts stay separate across navigation', + (await page.inputValue('#desk-prompt')) === '项目草稿·旅人', + ); + await page.fill('#desk-prompt', 'traveler on coast'); const preview = await page.locator('.inspector.main .stage').boundingBox(), form = await page.locator('.studio-form').boundingBox(); ok( - 'large preview and compact input panel', - preview.width > 600 && preview.x < form.x && form.width < 330, + 'input and results are adjacent workspace regions', + preview.x > form.x && form.width >= 290 && form.width <= 370, ); await page.locator('.model-selector').click(); - await page.locator('[role="dialog"] .catalogue').waitFor(); - await page.locator('[aria-label="搜索工作流"]').fill('文生图·回归'); - await until(async () => (await page.locator('[role="dialog"] .workflow-card').count()) === 1); - ok('workflow search in modal', true); - await page.getByRole('button', { name: '云端与智能体', exact: true }).click(); - await page.locator('[aria-label="搜索工作流"]').focus(); - await page.keyboard.press('Enter'); + await page.locator('.tool-picker .catalogue').waitFor(); + await page.fill('[aria-label="搜索工作流"]', '文生图·回归'); + await until(async () => (await page.locator('.tool-picker .workflow-card').count()) === 1); + ok('tool search stays in workspace', (await page.locator('[role="dialog"]').count()) === 0); + await page.getByRole('button', { name: '查看 文生图·回归', exact: true }).click(); + await page.locator('.tool-detail h3').waitFor(); ok( - 'cloud search Enter does not choose a hidden local workflow', - (await page.locator('[role="dialog"]').count()) === 1, + 'tool requirements before confirmation', + await page + .locator('.tool-detail') + .innerText() + .then((s) => s.includes('画面描述')), ); await page.keyboard.press('Escape'); ok( - 'Escape restores selector focus', - (await page.locator('[role="dialog"]').count()) === 0 && + 'Escape preserves input and restores tool button', + (await page.inputValue('#desk-prompt')) === 'traveler on coast' && (await page.locator('.model-selector').evaluate((e) => e === document.activeElement)), ); - await page.getByRole('button', { name: '全部参数' }).click(); - await page.getByRole('dialog').waitFor(); ok( - 'parameters do not replace the artboard', - await page.locator('.inspector.main .stage').isVisible(), + 'common parameters visible inline', + await page + .locator('.composer-scroll .input-section') + .last() + .innerText() + .then((s) => s.includes('生成设置')), ); - await page.keyboard.press('Escape'); let submitted = page.waitForRequest( (r) => r.url().endsWith('/api/playground/generate') && r.method() === 'POST', ); @@ -225,12 +253,13 @@ try { ); ok('output flows to source project asset', true); await page.reload(); - await page - .locator(`.take[data-job="${job.id}"] .actions .a-tag`, { - hasText: '已回流', - }) - .waitFor(); - ok('attachment survives reload', true); + await page.locator('.save-project').waitFor(); + ok( + 'attachment survives reload', + !!(await api(`/api/workbench/projects/${project.id}`)).stages.find( + (s) => s.stage_key === 'assets', + ).content.assets[0].job, + ); mode(false, 'arch'); await page.fill('#desk-prompt', 'second variation'); await page.locator('.studio-form .gen').click(); @@ -243,7 +272,7 @@ try { ), ); jobs.push(second.id); - await page.locator(`.take[data-job="${second.id}"] button.hit`).click(); + await page.locator(`.result-item[aria-label^="查看第 ${second.id} 次"]`).click(); await page.getByRole('button', { name: '对比画面 ◫' }).click(); await page.getByRole('slider', { name: '拖动对比画面' }).fill('70'); @@ -277,7 +306,8 @@ try { .evaluateAll((els) => els.map((e) => e.getAttribute('src'))); await page.locator('.model-selector').click(); await page.fill('[aria-label="搜索工作流"]', h3Copy.name); - await page.getByRole('button', { name: '使用 ' + h3Copy.name, exact: true }).click(); + await page.getByRole('button', { name: '查看 ' + h3Copy.name, exact: true }).click(); + await page.getByRole('button', { name: '使用这个工具 →', exact: true }).click(); await page.locator('#desk-prompt').waitFor(); ok( 'first uncached workflow keeps prompt', @@ -291,9 +321,34 @@ try { .evaluateAll((els) => els.map((e) => e.getAttribute('src'))), ) === JSON.stringify(inputSources), ); + await page.route(/\/api\/workflows\?view=meta$/, async (route) => { + const response = await route.fetch(); + await new Promise((r) => setTimeout(r, 1000)); + await route.fulfill({ response }); + }); + const delayedMeta = page.waitForResponse(/\/api\/workflows\?view=meta$/); + await page.reload(); + await delayedMeta; + await page.locator('#desk-prompt').waitFor(); + await page.waitForTimeout(150); + await page.unrouteAll({ behavior: 'wait' }); + ok( + 'reload restores the chosen workflow and prompt', + (await page.inputValue('#desk-prompt')) === '切换后保留提示词与首尾帧' && + (await page.locator('.model-selector').innerText()).includes(h3Copy.name), + ); + ok( + 'reload restores first and last frame inputs', + JSON.stringify( + await page + .locator('.studio-form img') + .evaluateAll((els) => els.map((e) => e.getAttribute('src'))), + ) === JSON.stringify(inputSources), + ); await page.locator('.model-selector').click(); await page.fill('[aria-label="搜索工作流"]', h3.name); - await page.getByRole('button', { name: '使用 ' + h3.name, exact: true }).click(); + await page.getByRole('button', { name: '查看 ' + h3.name, exact: true }).click(); + await page.getByRole('button', { name: '使用这个工具 →', exact: true }).click(); await page.locator('#desk-prompt').waitFor(); submitted = page.waitForRequest( (r) => r.url().endsWith('/api/playground/generate') && r.method() === 'POST', @@ -354,13 +409,77 @@ try { await page.locator('.svelte-flow').waitFor(); ok('canvas opens actual persisted graph', new URL(page.url()).pathname.startsWith('/canvas/')); await page.screenshot({ path: SHOTS + '/canvas.png' }); - for (const width of [1280, 1440, 1920]) { - await page.setViewportSize({ width, height: 960 }); - await page.goto(WEB + '/image?wf=' + image.id); - await page.locator('.studio-form').waitFor(); - const b = await page.locator('.studio-form').boundingBox(); - ok(`desktop ${width}px no horizontal input overflow`, b.x + b.width <= width + 1); + await page.goto(WEB + `/video?wf=${h3.id}`); + await page.locator('.inspector.main video').waitFor(); + await page.waitForTimeout(300); + ok( + 'entering page does not autoplay', + await page.locator('.inspector.main video').evaluate((v) => v.paused), + ); + await page.getByRole('button', { name: '播放视频', exact: true }).click(); + await page.getByRole('button', { name: '暂停视频', exact: true }).waitFor(); + ok( + 'explicit playback changes state', + await page.locator('.inspector.main video').evaluate((v) => !v.paused), + ); + await page.getByRole('button', { name: '暂停视频', exact: true }).click(); + await page.evaluate(() => document.activeElement?.blur()); + await page.keyboard.press('Space'); + ok( + 'space outside player does not change playback', + await page.locator('.inspector.main video').evaluate((v) => v.paused), + ); + for (const [width, height] of [ + [1366, 768], + [1280, 720], + [1100, 600], + [960, 540], + [1920, 1080], + ]) { + await page.setViewportSize({ width, height }); + await page.goto(WEB + `/video?wf=${h3.id}`); + await page.locator('.inspector.main video').waitFor(); + const visible = await page.evaluate(() => { + const v = document.querySelector('.inspector.main video').getBoundingClientRect(), + stage = document.querySelector('.inspector.main .stage').getBoundingClientRect(), + gen = document.querySelector('.studio-form .gen').getBoundingClientRect(), + play = document.querySelector('.playback-bar').getBoundingClientRect(); + return ( + v.bottom <= stage.bottom + 1 && + v.right <= stage.right + 1 && + gen.bottom <= innerHeight && + gen.top >= 0 && + play.bottom <= innerHeight && + document.documentElement.scrollWidth <= innerWidth + ); + }); + ok(`entire video, playback and generate visible at ${width}x${height}`, visible); + await page.screenshot({ path: SHOTS + `/workspace-${width}x${height}.png` }); + await page.locator('.model-selector').click(); + await page.locator('.tool-picker').waitFor(); + const confirm = await page + .getByRole('button', { name: '使用这个工具 →', exact: true }) + .boundingBox(); + ok(`tool confirmation visible at ${width}x${height}`, confirm.y + confirm.height <= height); + await page.keyboard.press('Escape'); } + const zoomContext = await browser.newContext({ + viewport: { width: 960, height: 540 }, + deviceScaleFactor: 1.5, + }); + const zoomPage = await zoomContext.newPage(); + await zoomPage.goto(WEB + `/video?wf=${h3.id}`); + await zoomPage.locator('.inspector.main video').waitFor(); + ok( + '150 percent equivalent desktop viewport keeps primary controls visible', + await zoomPage.evaluate(() => { + const gen = document.querySelector('.studio-form .gen').getBoundingClientRect(), + play = document.querySelector('.playback-bar').getBoundingClientRect(); + return devicePixelRatio === 1.5 && gen.bottom <= innerHeight && play.bottom <= innerHeight; + }), + ); + await zoomPage.screenshot({ path: SHOTS + '/zoom-equivalent-150.png' }); + await zoomContext.close(); await page.emulateMedia({ reducedMotion: 'reduce' }); ok( 'reduced motion disables transitions',