HEL-740: restore approved creative desk dock and anchored controls

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
leefer
2026-10-21 21:54:09 +08:00
co-authored by multica-agent
parent 2304ab1538
commit 5cb75d5718
11 changed files with 890 additions and 181 deletions
@@ -59,6 +59,9 @@
onCancel: (job: Job) => void;
onSendToSlot: (path: string) => void;
onDelete: (job: Job) => void;
canAttach?: boolean;
attachBusy?: boolean;
onAttach?: () => void;
}
let {
@@ -80,6 +83,9 @@
onCancel,
onSendToSlot,
onDelete,
canAttach = false,
attachBusy = false,
onAttach,
}: Props = $props();
let detailsOpen = $state(false);
@@ -190,29 +196,6 @@
<div class="result-title">
<span>第 {job?.id} 次生成</span><small>{wf?.name ?? '历史作品'}</small>
</div>
<div class="canvas-actions">
{#if output && !video}<button
class="canvas-btn"
onclick={() => (lightbox = true)}
aria-label="放大查看">⤢</button
>
{#if compareSource && compareSource !== output}<button
class="canvas-btn"
aria-pressed={compare}
onclick={() => (compare = !compare)}
>◫ {compare ? '结束对比' : '对比'}</button
>{/if}
{/if}
{#if output}<a
class="canvas-btn"
href={assetUrl(output)}
download
aria-label="下载生成结果">↓ 下载</a
>{/if}
<button class="canvas-btn" onclick={() => (detailsOpen = true)}
>详情与操作</button
>
</div>
</header>
<div class="stage" class:comparing={compare}>
{#if job && st}{#key mediaKey}
@@ -324,23 +307,64 @@
</div>{/if}
</div>
<footer class="artboard-footer">
{#if job && output}<button
class="canvas-btn"
onclick={() => job && onReuse(job)}>复用到输入区</button
>{/if}
{#if video}<button
class="canvas-btn play-button"
onclick={togglePlayback}
aria-label={paused ? '播放视频' : '暂停视频'}
>{paused ? '▶ 播放' : 'Ⅱ 暂停'}</button
><button
class="canvas-btn"
onclick={() => videoEl?.requestFullscreen().catch(() => {})}
>全屏</button
>{/if}
<span class="result-spec"
>{dims || st?.label} · {job ? fmtDur(elapsedSec(job, nowMs)) : ''}</span
<button
class="canvas-btn"
disabled={!output}
onclick={() =>
video
? videoEl?.requestFullscreen().catch(() => {})
: (lightbox = true)}
aria-label="放大查看"><Icon name="zoom-in" size={14} />放大</button
>
<a
class="canvas-btn"
href={output ? assetUrl(output) : undefined}
aria-disabled={!output}
download
aria-label="下载生成结果"><Icon name="download" size={14} />下载</a
>
<button
class="canvas-btn"
disabled={!job || !output}
onclick={() => job && onReuse(job)}
><Icon name="retry" size={14} />复用参数</button
>
<button
class="canvas-btn"
disabled={!output || video || !canSendToSlot}
title={canSendToSlot
? '放入当前工作流图片输入'
: '当前工作流没有图片输入'}
onclick={() => output && onSendToSlot(output)}
><Icon name="image" size={14} />作为参考图</button
>
<button
class="canvas-btn"
disabled
title="跨工作流送图尚未具备,请选择生视频工作流后从已有结果选取"
><Icon name="film" size={14} />送去生视频</button
>
<button
class="canvas-btn"
disabled={!canAttach || attachBusy}
title={canAttach
? '保存到来源项目'
: '通用选择项目与阶段将在后续批次提供'}
onclick={onAttach}><Icon name="folder" size={14} />存入项目</button
>
<a class="canvas-btn" href="/assets"
><Icon name="assets" size={14} />素材库</a
>
<button class="canvas-btn" onclick={() => (detailsOpen = true)}>更多</button
>
{#if job?.status === 'pending' || job?.status === 'running'}<button
class="canvas-btn"
onclick={() => job && onCancel(job)}>取消生成</button
>{/if}
{#if st?.tone === 'fail'}<button
class="canvas-btn"
onclick={() => job && onRetry(job)}>重试</button
>{/if}
{#if compare && output && !video}<label class="compare-slider"
>参考<input
type="range"
@@ -350,19 +374,41 @@
aria-label="拖动对比画面"
/>结果</label
>{/if}
{#if job?.status === 'pending' || job?.status === 'running'}<button
class="canvas-btn"
onclick={() => job && onCancel(job)}>取消生成</button
>{/if}
{#if st?.tone === 'fail'}<button
class="canvas-btn"
onclick={() => job && onRetry(job)}>重试</button
>{/if}
</footer>
</div>
<Modal bind:open={detailsOpen} size="lg" title="作品详情与操作">
{#if job && st}
<div class="detail-actions">
{#if video}<button
class="canvas-btn play-button"
onclick={togglePlayback}
aria-label={paused ? '播放视频' : '暂停视频'}
>{paused ? '▶ 播放' : 'Ⅱ 暂停'}</button
><button
class="canvas-btn"
onclick={() => videoEl?.requestFullscreen().catch(() => {})}
>全屏</button
>{/if}
<span class="result-spec"
>{dims || st?.label} · {job ? fmtDur(elapsedSec(job, nowMs)) : ''}</span
>
{#if compare && output && !video}<label class="compare-slider"
>参考<input
type="range"
min="0"
max="100"
bind:value={compareAt}
aria-label="拖动对比画面"
/>结果</label
>{/if}
{#if output && !video && compareSource && compareSource !== output}<button
class="canvas-btn"
aria-pressed={compare}
onclick={() => {
compare = !compare;
detailsOpen = false;
}}>◫ {compare ? '结束对比' : '对比'}</button
>{/if}
<button
class="a-btn secondary sm"
onclick={() => {
@@ -458,13 +504,14 @@
<style>
.artboard {
position: relative;
display: grid;
grid-template-rows: 38px minmax(0, 1fr) 32px;
grid-template-rows: 0 minmax(0, 1fr) 40px;
height: 100%;
min-height: 0;
border: 1px solid var(--line);
border-radius: var(--r-md);
background: var(--bg-1);
border: 0;
border-radius: 0;
background: transparent;
overflow: hidden;
}
.artboard-toolbar,
@@ -476,6 +523,17 @@
padding: 0 12px;
min-width: 0;
}
.artboard-toolbar {
position: absolute;
top: 10px;
left: 10px;
z-index: 2;
border-radius: 4px;
background: var(--media-scrim);
color: var(--on-media);
padding: 2px 6px;
max-width: calc(100% - 20px);
}
.result-title {
display: flex;
align-items: center;
@@ -492,22 +550,28 @@
text-overflow: ellipsis;
max-width: 220px;
}
.canvas-actions {
display: flex;
gap: 4px;
flex-shrink: 0;
}
.canvas-btn {
display: inline-flex;
align-items: center;
gap: 6px;
height: 26px;
box-sizing: border-box;
background: var(--bg-2);
color: var(--text-2);
border: 1px solid var(--line);
border-radius: 6px;
padding: 5px 8px;
font-size: 10px;
padding: 0 9px;
font-size: 12px;
font-weight: 500;
cursor: pointer;
text-decoration: none;
white-space: nowrap;
}
.canvas-btn:disabled,
.canvas-btn[aria-disabled='true'] {
opacity: 0.45;
cursor: not-allowed;
}
.canvas-btn:hover {
color: var(--text);
background: var(--bg-3);
@@ -518,6 +582,7 @@
border-color: var(--accent-line);
}
.stage {
grid-row: 2;
min-height: 0;
min-width: 0;
position: relative;
@@ -607,7 +672,10 @@
pointer-events: none;
}
.artboard-footer {
justify-content: flex-start;
grid-row: 3;
justify-content: center;
gap: 6px;
padding: 0;
font-size: 10px;
color: var(--text-3);
}
@@ -17,8 +17,12 @@
onKind,
onDetails,
disabled = false,
historyCollapsed = false,
onToggleHistory,
}: {
disabled?: boolean;
historyCollapsed?: boolean;
onToggleHistory: () => void;
kind: 'image' | 'video';
initialUsage?: string;
metas: WorkflowMeta[];
@@ -114,7 +118,12 @@
<aside class="workflow-rail" aria-label="创作工作流列表">
<header>
<div><strong>创作台</strong><small>选择工作流,开始创作</small></div>
<strong>创作台</strong><button
class="history-toggle a-btn ghost sm"
onclick={onToggleHistory}
aria-label={historyCollapsed ? '展开历史栏' : '收起历史栏'}
aria-expanded={!historyCollapsed}>◫</button
>
</header>
<div class="rail-tools">
<div class="kind-tabs" role="tablist" aria-label="创作类型">
@@ -223,6 +232,7 @@
<style>
.workflow-rail {
box-sizing: border-box;
width: var(--list);
flex-shrink: 0;
display: flex;
@@ -232,45 +242,49 @@
border-right: 1px solid var(--line);
}
.workflow-rail > header {
padding: 21px 18px 16px;
padding: 12px;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid var(--line);
}
header strong {
font-size: 18px;
font-size: 14px;
font-weight: 600;
display: block;
}
header small {
display: block;
font-size: 11px;
color: var(--text-3);
margin-top: 6px;
}
.rail-tools {
padding: 14px 12px 7px;
}
.kind-tabs {
display: flex;
gap: 4px;
gap: 2px;
padding: 3px;
height: 36px;
box-sizing: border-box;
border: 1px solid var(--line);
border-radius: var(--desk-seg-radius);
background: var(--well);
}
.kind-tabs button {
padding: 5px 12px;
border: 1px solid var(--line-2);
border-radius: var(--r-pill);
background: var(--bg-2);
flex: 1;
height: 28px;
padding: 0 12px;
font-size: 12.5px;
border: 0;
border-radius: var(--desk-seg-selected-radius);
background: transparent;
color: var(--tx-2);
cursor: pointer;
}
.kind-tabs [aria-selected='true'] {
border-color: var(--scene);
color: var(--scene);
background: var(--bg-3);
box-shadow: var(--sh-1);
color: var(--tx-1);
}
.kind-tabs button:disabled {
cursor: wait;
}
.kind-tabs button {
flex: 1;
}
.rail-tools input {
width: 100%;
margin-top: 10px;
@@ -8,25 +8,19 @@
selectedId,
onSelect,
onExpand,
collapsed = false,
}: {
collapsed?: boolean;
jobs: Job[];
selectedId: number | null;
onSelect: (job: Job) => void;
onExpand: () => void;
} = $props();
const sorted = $derived([...jobs].sort((a, b) => b.id - a.id));
let collapsed = $state(false);
</script>
<aside class="history-rail" class:collapsed aria-label="生成历史">
<header>
<button
onclick={() => (collapsed = !collapsed)}
aria-expanded={!collapsed}
aria-label={collapsed ? '展开历史栏' : '收起历史栏'}
>{collapsed ? '◷' : '历史'}</button
>
</header>
<header>历史</header>
{#if !collapsed}
<div class="history-list">
{#each sorted as job (job.id)}
@@ -68,6 +62,7 @@
<style>
.history-rail {
box-sizing: border-box;
width: var(--hist);
flex-shrink: 0;
display: flex;
@@ -77,7 +72,10 @@
background: var(--bg-1);
}
.history-rail.collapsed {
width: 34px;
width: 0;
border: 0;
overflow: hidden;
visibility: hidden;
}
header {
height: var(--head);
@@ -265,6 +265,8 @@
let paramEndpoint = $state('');
let paramShowErrors = $state(false);
let historyOpen = $state(false);
let historyCollapsed = $state(false);
let dockAnchor = $state<HTMLElement | null>(null);
let focusMode = $state(false);
let bayActiveId = $state<number | null>(null);
let bay = $state<WorkflowBay | null>(null);
@@ -1188,6 +1190,8 @@
<DeskWorkflowRail
{kind}
initialUsage={mode}
{historyCollapsed}
onToggleHistory={() => (historyCollapsed = !historyCollapsed)}
metas={allMetas.filter((m) => m.kind === kind)}
selectedId={workflowId}
{pendingCount}
@@ -1199,19 +1203,23 @@
<div class="refract-studio">
<header class="studio-heading">
<div class="heading-actions">
<button class="a-btn ghost sm" onclick={() => (historyOpen = true)}
>◷ 生成历史</button
><button id="desk-wf" class="model-selector" onclick={openBay}
<button id="desk-wf" class="model-selector" onclick={openBay}
>{currentWorkflow?.name ?? currentMeta?.name ?? '选择工作流'} ⌄</button
>
</div>
<div class="heading-actions">
{#if selectedJob && workbenchCtxOf(selectedJob) && selectedJob.status === 'done'}<button
class="a-btn secondary sm"
disabled={attachBusyId === selectedJob.id}
onclick={() => selectedJob && attachToProject(selectedJob)}
>保存到来源项目 ↗</button
>{/if}
<span
class="connection-status"
class:failed={connState.state === 'fail'}
>
<i class:connected={connState.state === 'ok'}></i>
{endpoints.find((e) => e.id === endpointId)?.name ?? '未选择连接'} · {connState.state ===
'ok' && connState.ms != null
? `${connState.ms}ms`
: connState.state === 'fail'
? '连接失败'
: '延迟未知'}
</span>
<button class="a-btn secondary sm" onclick={openParams}
>创作设置</button
><button class="a-btn ghost sm" onclick={toggleInspector}
@@ -1251,6 +1259,11 @@
open={true}
inactive={false}
canSendToSlot={!!imageSlotTarget || !!imageList}
canAttach={!!selectedJob &&
!!workbenchCtxOf(selectedJob) &&
selectedJob.status === 'done'}
attachBusy={attachBusyId === selectedJob?.id}
onAttach={() => selectedJob && attachToProject(selectedJob)}
{crossfade}
bind:videoEl
params={paramsTab}
@@ -1280,7 +1293,11 @@
</div>{/if}
</div>
</section>
<aside class="studio-form" aria-label="提示词、素材与参数">
<aside
bind:this={dockAnchor}
class="studio-form"
aria-label="提示词、素材与参数"
>
<Composer
bind:this={composer}
dock
@@ -1314,6 +1331,7 @@
</div>
</div>
<HistoryRail
collapsed={historyCollapsed}
jobs={allJobs.filter((j) => j.kind === kind && !pendingIds.has(j.id))}
selectedId={selectedJob?.id ?? null}
onSelect={selectTake}
@@ -1432,15 +1450,20 @@
</Modal>
<Modal
bind:open={paramsOpen}
anchor={dockAnchor}
size="lg"
title="创作设置"
onclose={() => (paramDraft = null)}
>
{#snippet headerActions()}<button
class="a-btn ghost sm"
onclick={resetParamDraft}>恢复工作流默认</button
>{/snippet}
{#snippet footer()}<div class="param-actions">
<span>保存后应用到当前工作流</span><button
class="a-btn secondary"
onclick={() => (paramsOpen = false)}>取消</button
><button class="a-btn purple" onclick={saveParams}>保存设置</button>
><button class="a-btn primary" onclick={saveParams}>保存设置</button>
</div>{/snippet}
<div class="reference-preferences">
<div class="runtime-setting">
@@ -1517,10 +1540,15 @@
flex-shrink: 0;
padding: 6px 8px;
border: 1px solid var(--info);
border-radius: var(--r-md);
border-radius: var(--r-pill);
color: var(--info);
font-size: 11px;
background: var(--bg-2);
font-size: 12.5px;
background: color-mix(in srgb, var(--bg-2) 92%, transparent);
backdrop-filter: blur(8px);
box-shadow: var(--sh-2);
align-self: center;
max-width: 100%;
box-sizing: border-box;
}
.history-banner span {
margin-right: auto;
@@ -1536,13 +1564,43 @@
background: none;
color: var(--text-2);
padding: 6px 8px;
font-size: 12px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
max-width: 320px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.connection-status {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 12px;
height: 26px;
padding: 0 10px;
border-radius: var(--r-pill);
border: 1px solid var(--line);
background: var(--bg-2);
color: var(--tx-2);
white-space: nowrap;
max-width: 260px;
overflow: hidden;
text-overflow: ellipsis;
}
.connection-status i {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--tx-3);
flex-shrink: 0;
}
.connection-status i.connected {
background: var(--ok);
}
.connection-status.failed i {
background: var(--err);
}
.studio-heading :global(.a-btn) {
min-height: 28px;
font-size: 11px;
@@ -1660,9 +1718,6 @@
grid-template-rows: minmax(0, 1fr) auto;
gap: 10px;
}
.refract-studio {
padding-bottom: 10px;
}
}
@media (max-width: 1100px) {
.refract-studio {
@@ -200,23 +200,26 @@
0,
)}</button
>{/if}
<button class="media-token" onclick={openMedia}
<button class="expand-prompt manage-media" onclick={openMedia}
>{slotBusy ? '正在上传…' : '管理素材'}</button
>
{:else}<small>描述你的画面</small>{/if}
<button
class="expand-prompt"
aria-expanded={expanded}
onclick={() => (expanded = !expanded)}
>{expanded ? '收起提示词' : '展开提示词'}</button
>
{/if}
</div>{/if}
<div class="prompt-pair" class:dual={dock && !!ds.negative}>
{#if ds.prompt}<div class="prompt-field">
<label for="desk-prompt"
>{ds.negative ? '正向提示词' : '提示词'}
{#if ds.prompt.required}<span>必填</span>{/if}</label
><textarea
<div class="prompt-label">
<label for="desk-prompt"
>{ds.negative ? '正向提示词' : '提示词'}
{#if ds.prompt.required}<span>必填</span>{/if}</label
>
<button
class="expand-prompt"
aria-expanded={expanded}
onclick={() => (expanded = !expanded)}
>{expanded ? '收起提示词' : '展开提示词'}</button
>
</div>
<textarea
bind:this={promptEl}
id="desk-prompt"
class="prompt"
@@ -544,16 +547,18 @@
height: auto;
min-height: 0;
border: 1px solid var(--line-2);
border-radius: var(--r-lg);
border-radius: var(--desk-dock-radius);
background: var(--composer-bg);
overflow: hidden;
box-shadow: var(--sh-2);
box-shadow: var(--desk-dock-shadow);
}
.dock .composer:focus-within {
border-color: var(--accent-line);
border-color: color-mix(in srgb, var(--gold) 45%, transparent);
box-shadow: var(--desk-dock-focus);
}
.dock .composer-scroll {
padding: 9px 14px 4px;
scrollbar-gutter: auto;
padding: 0;
overflow: auto;
display: flex;
flex-direction: column;
@@ -574,33 +579,24 @@
display: flex;
align-items: center;
gap: 6px;
min-height: 24px;
margin-bottom: 6px;
min-height: 0;
margin: 0;
flex-shrink: 0;
overflow: auto;
}
.dock .input-section.has-slots {
display: grid;
grid-template-columns: minmax(160px, 32%) minmax(0, 1fr);
gap: 12px;
grid-template-columns: minmax(0, var(--desk-slot-column)) minmax(0, 1fr);
gap: 0;
}
.has-slots .media-summary {
align-self: start;
flex-wrap: wrap;
margin: 0;
padding-right: 10px;
padding: 10px 12px 8px;
border-right: 1px solid var(--line);
}
.has-slots .expand-prompt {
width: 100%;
text-align: right;
}
.media-summary > small {
color: var(--text-3);
font-size: 10px;
white-space: nowrap;
}
.media-token {
display: flex;
align-items: center;
@@ -635,12 +631,13 @@
grid-template-columns: minmax(0, 1fr);
min-height: 0;
flex: 1;
gap: 18px;
gap: 0;
}
.dock .prompt-pair.dual {
grid-template-columns: minmax(0, 1fr) minmax(0, 0.65fr);
grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
}
.dock .prompt-field {
padding: 10px 14px 6px;
display: flex;
flex-direction: column;
min-height: 0;
@@ -648,15 +645,21 @@
}
.dock .negative {
border-left: 1px solid var(--line);
padding-left: 18px;
}
.dock .prompt-field label {
font-size: 10px;
font-size: 11.5px;
height: 20px;
color: var(--text-3);
margin: 0 0 4px;
margin: 0;
display: flex;
gap: 6px;
}
.prompt-label {
display: flex;
align-items: center;
justify-content: space-between;
height: 20px;
}
.dock .prompt-field:first-child label {
color: var(--tx-2);
}
@@ -665,7 +668,7 @@
border: 0;
border-radius: 0;
padding: 0;
font-size: 12px;
font-size: var(--fs-body);
line-height: 1.6;
resize: none;
min-height: 0;
@@ -688,15 +691,18 @@
margin-top: 3px;
}
.dock .prompt-counter {
display: none;
height: 22px;
align-items: center;
font-size: 11px;
margin-top: 4px;
}
.dock .submit {
display: flex;
flex-wrap: nowrap;
align-items: center;
gap: 8px;
padding: 7px 14px;
height: 45px;
padding: 8px 10px 10px 12px;
height: 57px;
box-sizing: border-box;
background: none;
border-top: 1px solid var(--line);
@@ -728,11 +734,13 @@
border-color: var(--line-3);
}
.dock .gen {
width: auto;
min-height: 32px;
font-size: 11px;
padding: 7px 18px;
border-radius: 20px;
width: var(--desk-gen-width);
height: var(--desk-gen-height);
min-height: var(--desk-gen-height);
font-size: 14px;
font-weight: var(--desk-gen-weight);
padding: 0 16px;
border-radius: var(--desk-gen-radius);
margin-left: auto;
flex-shrink: 0;
}
@@ -12,6 +12,9 @@
onclose?: () => void;
footer?: Snippet;
children: Snippet;
/** Open above a dock, retaining the shared dialog focus and keyboard behavior. */
anchor?: HTMLElement | null;
headerActions?: Snippet;
}
let {
@@ -22,6 +25,8 @@
onclose,
footer,
children,
anchor = null,
headerActions,
}: Props = $props();
const FOCUSABLE =
@@ -30,6 +35,28 @@
const titleId = `modal-title-${Math.random().toString(36).slice(2, 9)}`;
let panel = $state<HTMLDivElement | null>(null);
let anchorBox = $state({ left: 0, bottom: 0, width: 620, available: 560 });
$effect(() => {
if (!open || !anchor) return;
const source = anchor;
const place = () => {
const r = source.getBoundingClientRect();
anchorBox = {
left: r.left + 12,
bottom: innerHeight - r.top + 8,
width: r.width - 24,
available: Math.max(100, r.top - 64),
};
};
place();
const observer = new ResizeObserver(place);
observer.observe(source);
window.addEventListener('resize', place);
return () => {
observer.disconnect();
window.removeEventListener('resize', place);
};
});
const layer = Symbol('dialog');
function requestClose() {
@@ -100,10 +127,20 @@
{#if open}
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
<div class="modal-backdrop" onclick={handleBackdropClick}>
<div
class="modal-backdrop"
class:anchored={!!anchor}
onclick={handleBackdropClick}
>
<div
bind:this={panel}
class="modal-panel size-{size}"
style:left={anchor ? `${anchorBox.left}px` : undefined}
style:bottom={anchor ? `${anchorBox.bottom}px` : undefined}
style:width={anchor
? `min(var(--desk-pop-width), ${anchorBox.width}px)`
: undefined}
style:--anchor-available={`${anchorBox.available}px`}
role="dialog"
aria-modal="true"
aria-labelledby={title ? titleId : undefined}
@@ -115,6 +152,7 @@
{#if title}
<h2 class="modal-title" id={titleId}>{title}</h2>
{/if}
{@render headerActions?.()}
{#if dismissible}
<button
type="button"
@@ -168,6 +206,38 @@
.modal-panel.size-xl {
width: min(1180px, 100%);
}
.anchored {
background: transparent;
padding: 0;
}
.anchored .modal-panel {
box-sizing: border-box;
position: absolute;
height: var(--desk-pop-height);
max-height: min(64vh, var(--anchor-available));
border: 1px solid var(--line-2);
border-radius: var(--desk-dock-radius);
background: var(--desk-pop-bg);
box-shadow: var(--desk-pop-shadow);
backdrop-filter: blur(14px);
transform-origin: bottom left;
}
.anchored .modal-header {
padding: 12px 14px;
border-bottom: 1px solid var(--line);
}
.anchored .modal-title {
font-size: var(--fs-body);
}
.anchored .modal-body {
flex: 1;
min-height: 0;
padding: 12px 14px;
}
.anchored .modal-footer {
padding: 10px 14px;
border-top: 1px solid var(--line);
}
.modal-header {
display: flex;
align-items: center;
+18 -16
View File
@@ -92,14 +92,14 @@ Status → color mapping (unknown strings fall back to muted and show the raw st
`import ProgressBar from '$lib/components/ui/ProgressBar.svelte';`
| Prop | Type | Default | Notes |
| --------------- | -------------- | ------- | ----------------------------------------- |
| `value` | `number` | `0` | clamped to 0–100 |
| `indeterminate` | `boolean` | `false` | sliding accent gradient, no % readout |
| `label` | `string` | — | text above the track, also the aria-label |
| `size` | `'sm' \| 'md'` | `'md'` | sm = 4px, md = 6px track |
| `tone` | `'accent' \| 'success' \| 'error'` | `'accent'` | done = success, failed = error (§5) |
| `bare` | `boolean` | `false` | track only, no label / % row |
| Prop | Type | Default | Notes |
| --------------- | ---------------------------------- | ---------- | ----------------------------------------- |
| `value` | `number` | `0` | clamped to 0–100 |
| `indeterminate` | `boolean` | `false` | sliding accent gradient, no % readout |
| `label` | `string` | — | text above the track, also the aria-label |
| `size` | `'sm' \| 'md'` | `'md'` | sm = 4px, md = 6px track |
| `tone` | `'accent' \| 'success' \| 'error'` | `'accent'` | done = success, failed = error (§5) |
| `bare` | `boolean` | `false` | track only, no label / % row |
```svelte
<ProgressBar value={job.progress} label={job.name} />
@@ -126,14 +126,16 @@ Status → color mapping (unknown strings fall back to muted and show the raw st
`import Modal from '$lib/components/ui/Modal.svelte';`
| Prop | Type | Default | Notes |
| ------------- | ------------ | -------- | --------------------------------------------------------------------------- |
| `open` | `boolean` | `false` | **bindable** — use `bind:open` |
| `title` | `string` | — | wired to `aria-labelledby`; falls back to `aria-label="Dialog"` |
| `dismissible` | `boolean` | `true` | gates Esc, backdrop click, and the close button |
| `onclose` | `() => void` | — | fires once when the modal closes (any cause, incl. external `open = false`) |
| `footer` | `Snippet` | — | right-aligned action row |
| `children` | `Snippet` | required | body content |
| Prop | Type | Default | Notes |
| --------------- | --------------------- | -------- | -------------------------------------------------------------------------------------------- |
| `open` | `boolean` | `false` | **bindable** — use `bind:open` |
| `title` | `string` | — | wired to `aria-labelledby`; falls back to `aria-label="Dialog"` |
| `dismissible` | `boolean` | `true` | gates Esc, backdrop click, and the close button |
| `onclose` | `() => void` | — | fires once when the modal closes (any cause, incl. external `open = false`) |
| `anchor` | `HTMLElement \| null` | `null` | Optional dock anchor: opens above it, clamps to viewport, retains the dialog focus behavior. |
| `headerActions` | `Snippet` | — | Optional controls beside the title (for example restore workflow defaults). |
| `footer` | `Snippet` | — | right-aligned action row |
| `children` | `Snippet` | required | body content |
Behavior: Esc and backdrop click close when dismissible; focus is trapped while
open; initial focus goes to the first focusable element (or the panel); focus is
+35 -9
View File
@@ -45,7 +45,28 @@
--fs-small: 12px;
--fs-micro: 11px;
--slot-size: 56px;
--prompt-height: 64px;
--prompt-height: 60px;
--desk-dock-radius: 14px;
--desk-dock-bg: linear-gradient(
180deg,
color-mix(in srgb, var(--bg-3) 92%, transparent),
color-mix(in srgb, var(--bg-2) 96%, transparent)
);
--desk-dock-shadow: var(--sh-2);
--desk-dock-focus:
var(--sh-2), 0 0 0 3px color-mix(in srgb, var(--gold) 8%, transparent),
0 0 40px color-mix(in srgb, var(--gold) 8%, transparent);
--desk-gen-width: 131px;
--desk-gen-radius: 10px;
--desk-gen-height: 38px;
--desk-gen-weight: 700;
--desk-seg-radius: 9px;
--desk-seg-selected-radius: 7px;
--desk-slot-column: 272px;
--desk-pop-width: 620px;
--desk-pop-height: 560px;
--desk-pop-bg: color-mix(in srgb, var(--bg-2) 98%, transparent);
--desk-pop-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
--prompt-expanded: 28vh;
/* space (4 base) */
--s1: 4px;
@@ -248,6 +269,10 @@
--r-sm: 4px;
--r-md: 6px;
--r-lg: 8px;
--desk-dock-radius: 8px;
--desk-gen-radius: 4px;
--desk-seg-radius: 4px;
--desk-seg-selected-radius: 4px;
--r-xl: 10px;
--gold: #d9dde2;
--gold-hi: #f2f4f6;
@@ -324,6 +349,14 @@
--r-sm: 8px;
--r-md: 12px;
--r-lg: 18px;
--desk-dock-radius: 18px;
--desk-gen-radius: 999px;
--desk-gen-width: 139px;
--desk-dock-bg: linear-gradient(
180deg,
rgba(31, 44, 92, 0.82),
rgba(22, 33, 72, 0.9)
);
--r-xl: 26px;
--ink: 214 224 255;
--line: rgb(214 224 255 / 0.07);
@@ -428,7 +461,7 @@
--accent-ring: color-mix(in srgb, var(--gold) 25%, transparent);
--accent-wash: var(--accent-soft);
--btn-glow-hover: var(--sh-gold-hover);
--composer-bg: var(--glass);
--composer-bg: var(--desk-dock-bg);
--composer-focus: var(--bg-2);
--float-bg: var(--bg-2);
--on-media: #fff;
@@ -548,10 +581,3 @@ html {
background: var(--bg-0);
color: var(--tx-1);
}
@media (max-height: 800px) {
:root {
--slot-size: 50px;
--prompt-height: 48px;
}
}
@@ -0,0 +1,27 @@
# HEL-740 · B1 创作台样本返工
继续原 `feat/hel-729-creative-desk`,以前次审核 head `2304ab1538a4fd5f301efbf58f1a28b987b78809` 为起点;PR #3 目标仍为 `feat/hel-728-night-foundation@8e84e4c21f22febe7bd4f20777d06fa1d4914e8e`。未部署、合并或修改生成 API、数据库和正式数据。
## 实现
- `static/themes.css` 统一底座、按钮、输入与弹层 token。夜片场/日光棚按钮 131×38、r10、14px/700;调色间遵样本 r4,蓝调时刻遵样本胶囊。底座渐变、边框、阴影、距两边16/底14恢复,样本浮层圆角随主题变化。
- `Composer` 恢复60px/13px正负提示词、1.35:1比例与计数栏,去掉固定滚动槽占位。1440有媒体输入时正375.3×60、负269.7×60,对原样本375.6/270误差小于1px。长文本内部滚动/展开与真实输入要求保留。
- `Modal` 增加可选底座锚点与头部操作槽,复用原焦点层栈、Tab循环、Escape、外部点击和焦点归还。参数620×560;较小窗口按64vh与顶栏可用空间缩短、内容滚动。恢复默认只改草稿,取消丢弃、保存才应用。
- `Artboard` 恢复媒体下40px行内八入口,放大/下载/复用参数/作为参考图/送去生视频/存入项目/素材库/更多。真实来源项目回流沿用原接口;更多保留详情、对比、尾帧导出等。视频默认暂停、contain完整显示、中央64px播放按钮与仅播放器聚焦空格保留。
- `DeskWorkflowRail`/`HistoryRail` 恢复标题行历史切换、收起归零、247×36分段控件。`StudioDesk` 恢复胶囊历史提示、14px/600工作流名和头部连接状态;连接名/延迟来自真实配置与测试结果,未知显示未知。
## 验证
- `e2e/hel729.cjs` 42项全过,只按恢复后的真实入口更新记录/来源项目选择器;覆盖上传、遮罩、首尾帧、多参考、草稿隔离、历史不改输入、主动/跨媒介复用、旧入口、来源项目回流与手动播放。
- `e2e/hel740.cjs` 69项全过:三档尺寸×四主题逐项尺寸/比例、首屏/contain、八入口、锚定弹层及恢复默认/取消/保存/焦点、历史归零/胶囊、视频暂停播放。附原HTML与实际应用并排图、完整DOM实测JSON和全程WebM,另含悬停、选中、生成中与播放逐帧。
- 隔离FastAPI+假ComfyUI;后端四组相关测试47项全过。`check` 0错误、1条既有ShotStagePanel字幕警告;`test`、`build`、定向格式检查、`git diff --check`通过。全仓lint仍受63个文件基线格式与缺失ESLint配置影响,不扩全仓治理。
复现:下载主卡已确认HTML,通过 `HEL740_SAMPLE` 指定原样本路径;在原隔离栈运行 `HEL729_TESTS=e2e/hel729.cjs,e2e/hel740.cjs python3 e2e/run-hel729.py`,环境按原脚本配置Playwright/Chromium。截图和日志通过任务卡附件交付,不将临时数据提交进仓库。
## 明确边界与剩余事实
- 默认文生图没有媒体输入,样本可选垫图槽位仍待总管组织决定;未新增映射或伪造上传槽。此次同状态尺寸对照使用已支持图片和遮罩的真实工作流类型。
- 参数字段来自工作流声明;隔离夹具仅有种子和一个高级参数,没有伪造样本中的分辨率、步数等能力。实际工作流声明这些字段时沿用动态表单显示。
- 跨工作流送图能力未具备,送去生视频入口禁用并解释;通用项目/阶段选择留B4,存入项目只在真实来源上下文存在时启用。
- 已接受B0的48px顶栏保留,其造成的作品高度差不计作已还原。没有宣称全页逐像素一致或交部署。
- PR head随推送更新;Gitea API `/api/v1/user` 返回401,本运行只有SSH推送身份,不能修改PR标题/正文。任务卡附拟更新文案供总管完成元数据更新,不新建重复请求。
+3 -5
View File
@@ -263,7 +263,7 @@ async function shot(p, name) {
await shot(p, width + "-video");
}
// Cross-medium reuse from the complete history switches the editor kind explicitly.
await p.getByRole("button", { name: "◷ 生成历史", exact: true }).click();
await p.getByRole("button", { name: "全部记录", exact: true }).click();
await p
.locator(".history-full .a-seg")
.getByRole("button", { name: "全部", exact: true })
@@ -477,9 +477,7 @@ async function shot(p, name) {
flow.payload?.workbench_context?.source_id === "b1-source" ||
JSON.stringify(flow.payload).includes("b1-source"),
);
await p
.getByRole("button", { name: "保存到来源项目 ↗", exact: true })
.click();
await p.getByRole("button", { name: "存入项目", exact: true }).click();
await wait(async () =>
JSON.stringify(
await api("/api/workbench/projects/" + f.project),
@@ -578,7 +576,7 @@ async function shot(p, name) {
JSON.stringify({ checks, errors }, null, 2),
);
} catch (e) {
if (p) await shot(p, "failure");
if (p) await shot(p, "failure").catch(() => {});
throw e;
} finally {
if (saved) fs.writeFileSync("e2e/fake_mode.json", saved);
+443
View File
@@ -0,0 +1,443 @@
// HEL-740: same-viewport sample comparisons plus anchored-dialog/state evidence.
const { chromium } = require(
process.env.PLAYWRIGHT_MODULE_PATH || "playwright",
);
const fs = require("node:fs"),
path = require("node:path"),
assert = require("node:assert/strict");
const out = "e2e/shots/hel740";
fs.mkdirSync(out, { recursive: true });
let currentPage;
const checks = [],
measurements = [],
errors = [];
const ok = (name, value) => {
assert(value, name);
checks.push(name);
console.log("PASS", name);
};
const api = async (p) => (await fetch("http://127.0.0.1:8247" + p)).json();
const pause = (ms) => new Promise((r) => setTimeout(r, ms));
async function wait(fn) {
for (let i = 0; i < 160; i++) {
if (await fn()) return;
await pause(100);
}
throw Error("timeout");
}
async function metrics(page, sample = false) {
return page.evaluate((sample) => {
const selectors = sample
? {
button: "#genBtn",
dock: "#dock",
positive: "#posTa",
negative: "#negTa",
segment: "#kindSeg",
name: "#hdName",
history: ".hist",
actions: "#actbar",
pop: "#paramPop",
}
: {
button: ".dock .gen",
dock: ".dock .composer",
positive: "#desk-prompt",
negative: "#desk-negative",
segment: ".kind-tabs",
name: ".model-selector",
history: ".history-rail",
actions: ".artboard-footer",
pop: ".anchored .modal-panel",
};
return Object.fromEntries(
Object.entries(selectors).map(([key, sel]) => {
let e = document.querySelector(sel);
if (!e) return [key, null];
let r = e.getBoundingClientRect(),
s = getComputedStyle(e);
return [
key,
{
x: r.x,
y: r.y,
width: r.width,
height: r.height,
bottom: r.bottom,
radius: s.borderRadius,
font: s.fontSize,
weight: s.fontWeight,
background: s.backgroundImage,
border: s.borderTopWidth,
shadow: s.boxShadow,
},
];
}),
);
}, sample);
}
async function shot(page, name) {
await page.screenshot({ path: out + "/" + name + ".png" });
}
(async () => {
const b = await chromium.launch({
executablePath: process.env.CHROMIUM_EXECUTABLE_PATH,
args: ["--no-sandbox", "--disable-dev-shm-usage"],
});
const saved = fs.existsSync("e2e/fake_mode.json")
? fs.readFileSync("e2e/fake_mode.json")
: null;
try {
const c = await b.newContext({
viewport: { width: 1440, height: 900 },
recordVideo: {
dir: out + "/video",
size: { width: 1440, height: 900 },
},
}),
p = await c.newPage(),
s = await c.newPage();
currentPage = p;
p.on("pageerror", (e) => errors.push(e.message));
p.setDefaultTimeout(12000);
await s.goto(
"file://" +
path.resolve(
process.env.HEL740_SAMPLE ||
"../references/夜片场-多主题交互样本.html",
) +
"?still=1&fill=1#create/image",
);
await s.locator("#posTa").waitFor();
const data = await s.evaluate(async () => {
const img = new Image();
img.src = st.hist.image[0].img;
await img.decode();
const cv = document.createElement("canvas");
cv.width = img.naturalWidth;
cv.height = img.naturalHeight;
cv.getContext("2d").drawImage(img, 0, 0);
return {
img: cv.toDataURL("image/png"),
pos: $("#posTa").value,
neg: $("#negTa").value,
};
});
fs.writeFileSync(
out + "/sample-media.png",
Buffer.from(data.img.split(",")[1], "base64"),
);
const workflows = await api("/api/workflows"),
mask = workflows.find((w) => w.name === "遮罩图生图测试");
assert(mask);
await p.goto("http://127.0.0.1:5173/create?wf=" + mask.id);
await p.locator("#desk-negative").waitFor();
const jobs = await api("/api/playground/jobs"),
job = jobs.find((j) => j.workflow_id === mask.id && j.status === "done");
assert(job);
await p
.locator(".history-take")
.filter({ hasText: "#" + job.id })
.click();
await p.getByRole("button", { name: "复用参数", exact: true }).click();
await p.locator("#desk-prompt").fill(data.pos);
await p.locator("#desk-negative").fill(data.neg);
fs.writeFileSync(
"e2e/fake_mode.json",
JSON.stringify({
mode: "ok",
unique_filename: true,
image_file: path.resolve(out + "/sample-media.png"),
}),
);
const before = Math.max(...jobs.map((j) => j.id));
await p.locator(".gen").click();
await wait(async () =>
(await api("/api/playground/jobs")).some(
(j) => j.id > before && j.status === "done",
),
);
await wait(() =>
p.locator(".print img").evaluate((e) => e.complete && e.naturalWidth > 0),
);
await pause(1000);
for (const [width, height] of [
[1440, 900],
[1366, 768],
[1280, 720],
]) {
await p.setViewportSize({ width, height });
await s.setViewportSize({ width, height });
for (const theme of ["night", "day", "grade", "bluehour"]) {
await p.getByRole("button", { name: "主题", exact: true }).click();
await p
.locator(".choice")
.filter({
hasText: {
night: "夜片场",
day: "日光棚",
grade: "调色间",
bluehour: "蓝调时刻",
}[theme],
})
.click();
await p.keyboard.press("Escape");
await s.evaluate((t) => {
document.documentElement.dataset.theme = t;
renderCreate();
}, theme);
await pause(650);
const actual = await metrics(p),
sample = await metrics(s, true);
measurements.push({ width, height, theme, actual, sample });
ok(
`${width}/${theme} 正负提示词宽度与样本误差不超过1px`,
Math.abs(actual.positive.width - sample.positive.width) <= 1 &&
Math.abs(actual.negative.width - sample.negative.width) <= 1,
);
ok(
`${width}/${theme} 按钮38高、提示词60高13px、操作条40高、分段36高`,
actual.button.height === 38 &&
actual.positive.height === 60 &&
actual.positive.font === "13px" &&
actual.actions.height === 40 &&
actual.segment.height === 36,
);
ok(
`${width}/${theme} 首屏按钮与作品完整`,
actual.button.bottom <= height &&
(await p.locator(".print img").evaluate((e) => {
let r = e.getBoundingClientRect();
return (
r.top >= 48 &&
r.bottom < innerHeight &&
getComputedStyle(e).objectFit === "contain"
);
})),
);
await shot(s, `${width}-${theme}-sample`);
await shot(p, `${width}-${theme}-actual`);
const actions = p.locator(
".artboard-footer > button,.artboard-footer > a",
);
ok(`${width}/${theme} 八入口显式存在`, (await actions.count()) === 8);
}
await p
.getByRole("button", { name: "创作设置", exact: true })
.first()
.click();
await pause(250);
const popup = await metrics(p);
ok(
`${width} 参数锚定底座上方且不遮主按钮`,
popup.pop.bottom <= popup.dock.y - 7 &&
popup.pop.y >= 48 &&
popup.pop.width === 620,
);
await s.evaluate(() => openPop());
await pause(250);
measurements.push({
width,
height,
state: "params",
actual: await metrics(p),
sample: await metrics(s, true),
});
await shot(p, `${width}-params-actual`);
await shot(s, `${width}-params-sample`);
// Focus cycle and draft-only reset.
await p.locator(".anchored input[type=number]").first().fill("333");
await p
.getByRole("button", { name: "恢复工作流默认", exact: true })
.click();
ok(
`${width} 恢复默认只改弹层草稿`,
(await p
.locator(".anchored input[type=number]")
.first()
.inputValue()) === "42",
);
await p.keyboard.press("Escape");
ok(
`${width} Escape归还焦点`,
await p
.getByRole("button", { name: "创作设置", exact: true })
.first()
.evaluate((e) => e === document.activeElement),
);
await s.evaluate(() => $("#paramPop").classList.remove("on"));
}
await p.setViewportSize({ width: 1440, height: 900 });
await p.getByRole("button", { name: "收起历史栏", exact: true }).click();
ok(
"历史收起列宽归零",
(await p
.locator(".history-rail")
.evaluate((e) => e.getBoundingClientRect().width)) === 0,
);
await shot(p, "history-collapsed");
await p.getByRole("button", { name: "展开历史栏", exact: true }).click();
await p
.locator(".history-take")
.filter({ hasText: "#" + job.id })
.click();
await shot(p, "history-banner");
ok(
"历史胶囊999圆角",
(await p
.locator(".history-banner")
.evaluate((e) => getComputedStyle(e).borderRadius)) === "999px",
);
await p.getByRole("button", { name: "返回当前创作", exact: true }).click();
await p
.getByRole("button", { name: "创作设置", exact: true })
.first()
.click();
const dialog = p.locator(".anchored .modal-panel");
await dialog.locator("button").last().focus();
await p.keyboard.press("Tab");
ok(
"参数Tab焦点循环",
await dialog.evaluate((e) => e.contains(document.activeElement)),
);
await p.locator(".anchored input[type=number]").first().fill("234");
await p.getByRole("button", { name: "取消", exact: true }).click();
await p
.getByRole("button", { name: "创作设置", exact: true })
.first()
.click();
ok(
"参数取消丢弃修改",
(await p.locator(".anchored input[type=number]").first().inputValue()) !==
"234",
);
await p.locator(".anchored input[type=number]").first().fill("235");
await p.getByRole("button", { name: "保存设置", exact: true }).click();
await p
.getByRole("button", { name: "创作设置", exact: true })
.first()
.click();
ok(
"参数保存草稿持久化",
(await p.locator(".anchored input[type=number]").first().inputValue()) ===
"235",
);
await p
.getByRole("button", { name: "恢复工作流默认", exact: true })
.click();
await p.getByRole("button", { name: "保存设置", exact: true }).click();
await p
.getByRole("button", { name: "创作设置", exact: true })
.first()
.click();
ok(
"恢复默认可保存",
(await p.locator(".anchored input[type=number]").first().inputValue()) ===
"42",
);
await p.keyboard.press("Escape");
// Actual existing disabled abilities have explanatory titles; no fake success.
ok(
"未具备送视频能力如实禁用",
await p
.getByRole("button", { name: "送去生视频", exact: true })
.isDisabled(),
);
ok(
"无来源时通用存入项目禁用",
await p
.getByRole("button", { name: "存入项目", exact: true })
.isDisabled(),
);
await p.getByRole("button", { name: "放大查看", exact: true }).click();
await shot(p, "zoom");
await p.keyboard.press("Escape");
await p.getByRole("button", { name: "更多", exact: true }).click();
await shot(p, "more-actions");
await p.keyboard.press("Escape");
// Video state evidence across the same three viewports.
await p.getByRole("tab", { name: "视频", exact: true }).click();
await p.locator("#desk-prompt").waitFor();
const videos = (await api("/api/playground/jobs")).filter(
(j) => j.kind === "video" && j.status === "done",
);
const vj = videos.find((j) => j.workflow_id === 4);
assert(vj);
await p
.locator(".history-take")
.filter({ hasText: "#" + vj.id })
.click();
await p.getByRole("button", { name: "复用参数", exact: true }).click();
await p.locator(".print video").waitFor();
await s.evaluate(() => go("create", { kind: "video" }));
for (const [width, height] of [
[1440, 900],
[1366, 768],
[1280, 720],
]) {
await p.setViewportSize({ width, height });
await s.setViewportSize({ width, height });
await pause(350);
await shot(p, `${width}-video-actual`);
await shot(s, `${width}-video-sample`);
ok(
`${width} 视频默认暂停且播放键64`,
(await p.locator(".print video").evaluate((e) => e.paused)) &&
(await p
.locator(".big-play")
.evaluate((e) => e.getBoundingClientRect().width === 64)),
);
}
await p.getByRole("button", { name: "播放此视频", exact: true }).click();
await pause(500);
await shot(p, "video-playing");
await p.locator(".print video").focus();
await p.keyboard.press("Space");
await shot(p, "video-paused");
await p.getByRole("tab", { name: "图片", exact: true }).click();
await p.locator(".workflow-pick").first().hover();
await shot(p, "workflow-hover");
await p.locator(".gen").hover();
await shot(p, "generate-hover");
fs.writeFileSync(
"e2e/fake_mode.json",
JSON.stringify({
mode: "ok",
delay_sec: 10,
unique_filename: true,
image_file: path.resolve(out + "/sample-media.png"),
}),
);
await p.locator(".gen").click();
await p.getByRole("button", { name: "取消生成", exact: true }).waitFor();
await shot(p, "generating");
await p.getByRole("button", { name: "取消生成", exact: true }).click();
ok("无浏览器异常", errors.length === 0);
fs.writeFileSync(
out + "/measurements.json",
JSON.stringify(measurements, null, 2),
);
fs.writeFileSync(
out + "/results.json",
JSON.stringify({ checks, errors }, null, 2),
);
await c.close();
fs.copyFileSync(await p.video().path(), out + "/actual-interactions.webm");
fs.copyFileSync(await s.video().path(), out + "/sample-interactions.webm");
} catch (e) {
fs.writeFileSync(
out + "/measurements.json",
JSON.stringify(measurements, null, 2),
);
if (currentPage) await shot(currentPage, "failure").catch(() => {});
throw e;
} finally {
if (saved) fs.writeFileSync("e2e/fake_mode.json", saved);
else if (fs.existsSync("e2e/fake_mode.json"))
fs.unlinkSync("e2e/fake_mode.json");
await b.close();
}
})().catch((e) => {
console.error(e);
process.exitCode = 1;
});