- app.css: HEL-649 §一 tokens (bg/line/accent/status/text/type/space/radius/shadow/motion), legacy names aliased, reduced-motion via prefers-reduced-motion and data-reduce - shared .a-btn/.status-chip/.a-panel/inputs reskinned; new .a-tag/.a-progress/.a-sprocket/.a-stage/.a-float - tailwind colors/radii reference the same CSS variables - ui primitives (StatusChip/ProgressBar/Modal/Button/ConfirmDialog/Skeleton/Switch/Card/Toast) on tokens - running state -> --run, awaiting confirm -> --warn, --cloud purple removed, old palette literals -> tokens Co-authored-by: multica-agent <github@multica.ai>
2761 lines
82 KiB
Svelte
2761 lines
82 KiB
Svelte
<script lang="ts">
|
||
import { createQuery, useQueryClient } from '@tanstack/svelte-query';
|
||
import Button from '$lib/components/ui/Button.svelte';
|
||
import ConfirmDialog from '$lib/components/ui/ConfirmDialog.svelte';
|
||
import Icon from '$lib/components/ui/Icon.svelte';
|
||
import Modal from '$lib/components/ui/Modal.svelte';
|
||
import ImageLightbox from '$lib/components/ImageLightbox.svelte';
|
||
import MediaSlot from '$lib/components/studio/MediaSlot.svelte';
|
||
import RefImageGrid from '$lib/components/studio/RefImageGrid.svelte';
|
||
import { mediaFileProblem } from '$lib/comfy/imageFile';
|
||
import { toStore } from 'svelte/store';
|
||
import { tick } from 'svelte';
|
||
import AppShell from '$lib/components/shell/AppShell.svelte';
|
||
import {
|
||
apiErrorMessage,
|
||
assetUrl,
|
||
comfy,
|
||
jobsApi,
|
||
playgroundApi,
|
||
settings,
|
||
workflows,
|
||
type Job,
|
||
} from '$lib/api';
|
||
import type { ComfyDynamicInput } from '$lib/comfy/types';
|
||
import { USAGE_BY_KIND, type WorkflowUsage } from '$lib/comfy/types';
|
||
import { compactInputValues, isPromptLikeInput } from '$lib/comfy/promptInput';
|
||
import { parseDbTs } from '$lib/dbtime';
|
||
import { normalizeInputRole } from '$lib/comfy/parser';
|
||
import { createUploadManager } from '$lib/comfy/useUpload.svelte';
|
||
import { connectEvents } from '$lib/events';
|
||
import { handleJobEvent, progressFor } from '$lib/jobProgress';
|
||
import { jobStatusInfo } from '$lib/jobStatus';
|
||
import { ratioShort, resolutionSelectorSize } from '$lib/comfy/resolution';
|
||
import { toast } from '$lib/toast';
|
||
import { t } from '$lib/i18n.svelte';
|
||
|
||
/**
|
||
* 独立生图 / 生视频窗口 (spec-v2 §4.1 / §4.2, a3 / a4, HEL-612).
|
||
* Three columns: params (left) · current task + results (center) ·
|
||
* history (right). One component serves both kinds — the differences
|
||
* (mask slot, first/last frame slots, video player, frame progress)
|
||
* are driven by the workflow's declared inputs and the `kind` prop.
|
||
*/
|
||
interface Props {
|
||
kind: 'image' | 'video';
|
||
}
|
||
|
||
let { kind }: Props = $props();
|
||
|
||
const client = useQueryClient();
|
||
const uploads = createUploadManager();
|
||
|
||
// ------------------------------------------------------------------
|
||
// Data
|
||
// ------------------------------------------------------------------
|
||
const settingsQuery = createQuery({ queryKey: ['settings'], queryFn: settings.get });
|
||
const workflowsQuery = createQuery({ queryKey: ['workflows'], queryFn: workflows.list });
|
||
const jobsQuery = createQuery({
|
||
queryKey: ['playground-jobs'],
|
||
queryFn: playgroundApi.jobs,
|
||
refetchInterval: 5_000,
|
||
});
|
||
|
||
const endpoints = $derived($settingsQuery.data?.comfyui_endpoints ?? []);
|
||
const activeId = $derived($settingsQuery.data?.comfyui_active_id ?? endpoints[0]?.id ?? '');
|
||
// HEL-636: the page serves its usages (image → t2i/i2i, video →
|
||
// t2v/i2v/ref2v); pending workflows (usage = null) never appear.
|
||
// HEL-638: workflows with unconfirmed unknown output nodes are also
|
||
// hidden — enabled rows carry a settled output mapping, this is a
|
||
// second guard for stale rows.
|
||
const kindWorkflows = $derived(
|
||
($workflowsQuery.data ?? []).filter(
|
||
(w) =>
|
||
w.is_enabled &&
|
||
(w.usage ?? null) !== null &&
|
||
!w.needs_mapping &&
|
||
USAGE_BY_KIND[kind].includes(w.usage!),
|
||
),
|
||
);
|
||
|
||
const allJobs = $derived.by(() => {
|
||
void $jobsQuery.data;
|
||
return $jobsQuery.data ?? [];
|
||
});
|
||
const kindJobs = $derived(allJobs.filter((j) => j.kind === kind));
|
||
// Jobs are listed newest first; the worker runs the oldest pending job next.
|
||
const activeJob = $derived(
|
||
kindJobs.find((j) => j.status === 'running') ?? kindJobs.findLast((j) => j.status === 'pending') ?? null,
|
||
);
|
||
const jobsAhead = $derived(
|
||
activeJob?.status === 'pending'
|
||
? allJobs.filter((j) => j.status === 'running' || (j.status === 'pending' && j.id < activeJob.id)).length
|
||
: 0,
|
||
);
|
||
const queueCount = $derived(kindJobs.filter((j) => j.status === 'pending' || j.status === 'running').length);
|
||
const doneEntries = $derived(
|
||
kindJobs
|
||
.filter((j) => jobStatusInfo(j).tone === 'ok')
|
||
.flatMap((j) => j.output_paths.map((p) => ({ job: j, path: p, key: `${j.id}:${p}` }))),
|
||
);
|
||
|
||
// Jobs enqueued from this window — a fast failure can land before the
|
||
// jobs list refetch knows about them.
|
||
const submittedIds = new Set<number>();
|
||
|
||
// Live progress via SSE + fallback polling.
|
||
$effect(() => {
|
||
const off = connectEvents((ev) => {
|
||
handleJobEvent(ev);
|
||
if (ev.type === 'job.failed' && !ev.data.cancelled) {
|
||
const id = Number(ev.data.job_id);
|
||
// The SSE backlog replays old failures on every connect.
|
||
const known = kindJobs.find((j) => j.id === id);
|
||
if (submittedIds.has(id) || (known && known.status !== 'failed')) {
|
||
toast.error(t('studio.jobFailedToast', { detail: String(ev.data.error ?? '') }));
|
||
}
|
||
}
|
||
if (ev.type === 'job.completed' && submittedIds.has(Number(ev.data.job_id))) {
|
||
if (ev.data.dry_run) {
|
||
toast.info(t('studio.dryRunToast'));
|
||
} else {
|
||
const outputs = Array.isArray(ev.data.outputs) ? ev.data.outputs.length : 0;
|
||
toast.success(t('studio.doneToast', { n: outputs, id: String(ev.data.comfy_prompt_id ?? '—') }));
|
||
}
|
||
}
|
||
if (ev.type.startsWith('job.') || ev.type === 'events.resync') {
|
||
void client.invalidateQueries({ queryKey: ['playground-jobs'] });
|
||
void client.invalidateQueries({ queryKey: ['jobs'] });
|
||
}
|
||
});
|
||
return off;
|
||
});
|
||
|
||
// ------------------------------------------------------------------
|
||
// Form state
|
||
// ------------------------------------------------------------------
|
||
let endpointTouched = $state(false);
|
||
let endpointId = $state('');
|
||
let workflowId = $state<number | null>(null);
|
||
type FormValue = string | number | string[];
|
||
let values = $state<Record<string, FormValue>>({});
|
||
/** Per-slot rejected picks (format / size) — shown in place, never uploaded. */
|
||
let slotRejects = $state<Record<string, Array<{ name: string; message: string }>>>({});
|
||
/** Byte size of files uploaded here, by server path (for the slot meta line). */
|
||
let fileSizes = $state<Record<string, number>>({});
|
||
/** Reference index being replaced while its upload runs. */
|
||
let replacingIndex = $state(-1);
|
||
let replacingKey = $state('');
|
||
let showErrors = $state(false);
|
||
let submitting = $state(false);
|
||
let lightboxOpen = $state(false);
|
||
let pickerFor = $state<string | null>(null);
|
||
let pickerMode = $state<'slot' | 'send'>('slot');
|
||
let deleteOpen = $state(false);
|
||
let deleteJobId = $state<number | null>(null);
|
||
let retryingId = $state<number | null>(null);
|
||
let cancelling = $state(false);
|
||
let selectedKey = $state<string | null>(null);
|
||
|
||
const currentWorkflow = $derived(kindWorkflows.find((w) => w.id === workflowId) ?? null);
|
||
|
||
// Default endpoint follows the workflow binding, then the active one —
|
||
// unless the user picked one explicitly.
|
||
$effect(() => {
|
||
if (endpointTouched) return;
|
||
const wf = currentWorkflow ?? undefined;
|
||
endpointId = wf?.endpoint_id ?? activeId ?? '';
|
||
});
|
||
|
||
// Default workflow: first of this kind.
|
||
$effect(() => {
|
||
if (workflowId == null || !kindWorkflows.some((w) => w.id === workflowId)) {
|
||
workflowId = kindWorkflows[0]?.id ?? null;
|
||
}
|
||
});
|
||
|
||
// Reset values (with schema defaults) whenever the workflow changes.
|
||
let lastWfId = $state<number | null>(null);
|
||
$effect(() => {
|
||
const wf = currentWorkflow;
|
||
if (!wf) {
|
||
if (lastWfId !== null) values = {};
|
||
lastWfId = null;
|
||
return;
|
||
}
|
||
if (wf.id === lastWfId) return;
|
||
lastWfId = wf.id;
|
||
const next: Record<string, FormValue> = {};
|
||
for (const inp of wf.input_schema ?? []) {
|
||
if (inp.defaultValue !== undefined && inp.defaultValue !== '') {
|
||
next[inp.nodeId] = inp.defaultValue;
|
||
}
|
||
}
|
||
values = next;
|
||
slotRejects = {};
|
||
showErrors = false;
|
||
});
|
||
|
||
// ------------------------------------------------------------------
|
||
// Schema classification — slots and structured params come from what
|
||
// the workflow actually declares, never from hardcoded model names.
|
||
// ------------------------------------------------------------------
|
||
const schema = $derived(currentWorkflow?.input_schema ?? []);
|
||
|
||
function role(inp: ComfyDynamicInput): string | null {
|
||
return normalizeInputRole(inp.role ?? null);
|
||
}
|
||
function hay(inp: ComfyDynamicInput): string {
|
||
return `${inp.role ?? ''} ${inp.label}`.toLowerCase();
|
||
}
|
||
const isMedia = (inp: ComfyDynamicInput) =>
|
||
inp.kind === 'image' ||
|
||
inp.kind === 'image_url' ||
|
||
inp.kind === 'video' ||
|
||
inp.kind === 'audio' ||
|
||
inp.kind === 'image_list' ||
|
||
inp.kind === 'video_list' ||
|
||
inp.kind === 'audio_list';
|
||
// Auto-detected slots carry their role from the wiring; tagged (Input:…)
|
||
// workflows still name frames only in the title.
|
||
const isFirstFrame = (inp: ComfyDynamicInput) =>
|
||
role(inp) === 'first_frame' || (!inp.auto && kind === 'video' && /first|start|首帧/.test(hay(inp)));
|
||
const isLastFrame = (inp: ComfyDynamicInput) =>
|
||
role(inp) === 'last_frame' || (!inp.auto && kind === 'video' && /last|end|尾帧/.test(hay(inp)));
|
||
|
||
/** Autogrow media lists actually wired in this workflow (HEL-643: image /
|
||
* video / audio). No wiring → no entry, whatever the model could do. */
|
||
const listGroups = $derived(
|
||
schema.filter(
|
||
(i) => i.kind === 'image_list' || i.kind === 'video_list' || i.kind === 'audio_list',
|
||
),
|
||
);
|
||
function listKind(entry: ComfyDynamicInput): 'image' | 'video' | 'audio' {
|
||
if (entry.kind === 'video_list') return 'video';
|
||
if (entry.kind === 'audio_list') return 'audio';
|
||
return 'image';
|
||
}
|
||
// ComfyUI Autogrow reference images (H3 ref_images): one ordered 1…max list.
|
||
const refGroup = $derived(listGroups.find((i) => i.kind === 'image_list') ?? null);
|
||
const refMax = $derived(refGroup?.max ?? 9);
|
||
const refPaths = $derived.by(() => {
|
||
const v = refGroup ? values[refGroup.nodeId] : undefined;
|
||
if (Array.isArray(v)) return v;
|
||
return typeof v === 'string' && v ? [v] : [];
|
||
});
|
||
function groupPaths(entry: ComfyDynamicInput): string[] {
|
||
const v = values[entry.nodeId];
|
||
if (Array.isArray(v)) return v;
|
||
return typeof v === 'string' && v ? [v] : [];
|
||
}
|
||
// H3 Ref2VA official limits (soft hint, keyed off the node class only).
|
||
const hasH3Hint = $derived(listGroups.some((e) => e.media_hint === 'minimax_h3_ref2va'));
|
||
const h3SoftWarnings = $derived.by(() => {
|
||
if (!hasH3Hint) return [];
|
||
const warns: string[] = [];
|
||
const counts = { image: 0, video: 0, audio: 0 };
|
||
for (const g of listGroups) counts[listKind(g)] += groupPaths(g).length;
|
||
const total = counts.image + counts.video + counts.audio;
|
||
if (total > 12) warns.push(t('wfMedia.h3TotalOver', { n: total }));
|
||
if (counts.audio > 0 && counts.image === 0 && counts.video === 0)
|
||
warns.push(t('wfMedia.h3AudioAlone'));
|
||
return warns;
|
||
});
|
||
const brokenReasons = $derived(
|
||
(currentWorkflow?.warnings ?? []).filter((w) => w.level === 'error').map((w) => w.message),
|
||
);
|
||
|
||
const promptInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'prompt') ?? null);
|
||
const negInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'negative') ?? null);
|
||
const seedInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'seed') ?? null);
|
||
const widthInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'width') ?? null);
|
||
const heightInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'height') ?? null);
|
||
const resolutionInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'resolution') ?? null);
|
||
const durationInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'duration') ?? null);
|
||
const stepsInp = $derived(schema.find((i) => /步数|steps/.test(hay(i)) && !isMedia(i)) ?? null);
|
||
const cfgInp = $derived(
|
||
schema.find((i) => /\bcfg\b|引导/.test(hay(i)) && !isMedia(i)) ?? null,
|
||
);
|
||
const denoiseInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'denoise') ?? null);
|
||
const batchInp = $derived(schema.find((i) => /批次|batch/.test(hay(i)) && !isMedia(i)) ?? null);
|
||
const fpsInp = $derived(schema.find((i) => /帧率|fps|frame.?rate/.test(hay(i)) && !isMedia(i)) ?? null);
|
||
// ComfyUI ResolutionSelector: the ratio + megapixels pair decides width/height.
|
||
const ratioInp = $derived(
|
||
schema.find((i) => i.kind === 'select' && role(i) === 'aspect_ratio' && i.resolution) ?? null,
|
||
);
|
||
const megapixelsInp = $derived(
|
||
ratioInp ? (schema.find((i) => i.nodeId === ratioInp.resolution!.megapixels) ?? null) : null,
|
||
);
|
||
const outputSize = $derived.by(() => {
|
||
if (!ratioInp?.resolution) return null;
|
||
const mp = Number(values[megapixelsInp?.nodeId ?? ''] ?? megapixelsInp?.defaultValue);
|
||
return resolutionSelectorSize(String(values[ratioInp.nodeId] ?? ratioInp.defaultValue ?? ''), mp, ratioInp.resolution.multiple);
|
||
});
|
||
|
||
interface SlotDef {
|
||
inp: ComfyDynamicInput;
|
||
label: string;
|
||
mediaKind: 'image' | 'video' | 'audio';
|
||
aspect: 'square' | 'wide';
|
||
fromResults: boolean;
|
||
/** Required-slot message when left empty (ref-upload-spec §3). */
|
||
missing: string;
|
||
emptyText?: string;
|
||
}
|
||
|
||
const mediaSlots = $derived.by(() => {
|
||
const media = schema.filter(
|
||
(i) =>
|
||
isMedia(i) && i.kind !== 'image_list' && i.kind !== 'video_list' && i.kind !== 'audio_list',
|
||
);
|
||
const plainImages = media.filter(
|
||
(i) => i.kind === 'image' && role(i) !== 'mask' && !/mask|遮罩/.test(hay(i)) && !isFirstFrame(i) && !isLastFrame(i),
|
||
);
|
||
const editInput = kind === 'image' && plainImages.length === 1 ? plainImages[0] : null;
|
||
const out: SlotDef[] = [];
|
||
let refIdx = 0;
|
||
for (const inp of media) {
|
||
const h = hay(inp);
|
||
const base = { inp, missing: '' };
|
||
if (inp.kind === 'video') {
|
||
out.push({ ...base, label: t('studio.slotRefVideo'), mediaKind: 'video', aspect: 'square', fromResults: false });
|
||
} else if (inp.kind === 'audio') {
|
||
out.push({ ...base, label: t('studio.slotAudio'), mediaKind: 'audio', aspect: 'square', fromResults: false });
|
||
} else if (role(inp) === 'mask' || /mask|遮罩/.test(h)) {
|
||
out.push({ ...base, label: t('studio.slotMask'), mediaKind: 'image', aspect: 'square', fromResults: false });
|
||
} else if (isFirstFrame(inp)) {
|
||
out.push({
|
||
...base,
|
||
label: t('studio.slotFirst'),
|
||
mediaKind: 'image',
|
||
aspect: 'wide',
|
||
fromResults: true,
|
||
missing: t('studio.errNeedFirstFrame'),
|
||
emptyText: t('studio.slotEmptyFirst'),
|
||
});
|
||
} else if (isLastFrame(inp)) {
|
||
out.push({ ...base, label: t('studio.slotLast'), mediaKind: 'image', aspect: 'wide', fromResults: true });
|
||
} else if (inp === editInput) {
|
||
out.push({
|
||
...base,
|
||
label: t('studio.slotInput'),
|
||
mediaKind: 'image',
|
||
aspect: 'square',
|
||
fromResults: false,
|
||
missing: t('studio.errNeedInputImage'),
|
||
emptyText: t('studio.slotEmptyInput'),
|
||
});
|
||
} else {
|
||
refIdx += 1;
|
||
const label = inp.auto
|
||
? inp.label
|
||
: refIdx === 1 && media.length === 1
|
||
? t('studio.slotRef')
|
||
: t('studio.slotRefN', { n: refIdx });
|
||
out.push({
|
||
...base,
|
||
label,
|
||
mediaKind: 'image',
|
||
aspect: kind === 'video' ? 'wide' : 'square',
|
||
fromResults: kind === 'video',
|
||
missing: t('studio.errUpload', { label }),
|
||
});
|
||
}
|
||
}
|
||
return out;
|
||
});
|
||
|
||
/** Mode badge: the stored usage when we have one, else the wiring shape. */
|
||
function usageLabel(u: WorkflowUsage): string {
|
||
return t(`usage.${u}`);
|
||
}
|
||
const modeLabel = $derived.by(() => {
|
||
if (currentWorkflow?.usage) return usageLabel(currentWorkflow.usage);
|
||
if (refGroup) return t('studio.modeRefToVideo');
|
||
if (mediaSlots.some((s) => isFirstFrame(s.inp))) return t('studio.modeImageToVideo');
|
||
if (kind === 'image' && mediaSlots.some((s) => s.mediaKind === 'image' && role(s.inp) !== 'mask'))
|
||
return t('studio.modeImageEdit');
|
||
if (mediaSlots.length) return mediaSlots.map((s) => s.label).join(' · ');
|
||
return kind === 'image' ? t('studio.modeTextToImage') : t('studio.modeTextToVideo');
|
||
});
|
||
|
||
const structuredIds = $derived(
|
||
new Set(
|
||
[
|
||
promptInp,
|
||
negInp,
|
||
seedInp,
|
||
widthInp,
|
||
heightInp,
|
||
resolutionInp,
|
||
durationInp,
|
||
stepsInp,
|
||
cfgInp,
|
||
denoiseInp,
|
||
batchInp,
|
||
fpsInp,
|
||
ratioInp,
|
||
megapixelsInp,
|
||
]
|
||
.filter(Boolean)
|
||
.map((i) => i!.nodeId),
|
||
),
|
||
);
|
||
const restInputs = $derived(schema.filter((i) => !isMedia(i) && !structuredIds.has(i.nodeId)));
|
||
|
||
const promptLen = $derived(((values[promptInp?.nodeId ?? ''] ?? '') as string).length);
|
||
const batchCount = $derived.by(() => {
|
||
if (!batchInp) return 1;
|
||
const n = Number(values[batchInp.nodeId]);
|
||
return Number.isFinite(n) && n > 0 ? Math.floor(n) : 1;
|
||
});
|
||
|
||
// Connection state of the selected target — the same server-side probe
|
||
// (and cache key) the shell footer uses for the active connection.
|
||
const probeQuery = createQuery(
|
||
toStore(() => ({
|
||
queryKey: ['comfy-probe', endpointId || null],
|
||
queryFn: () => comfy.testEndpoint({ endpoint_id: endpointId, timeout_sec: 5 }),
|
||
enabled: !!endpointId,
|
||
staleTime: 60_000,
|
||
refetchInterval: 60_000,
|
||
retry: false,
|
||
})),
|
||
);
|
||
const connRec = $derived.by(() => {
|
||
const data = $probeQuery.data;
|
||
if (!endpointId || !data) return null;
|
||
return { ok: data.ok, ms: data.elapsed_ms, at: $probeQuery.dataUpdatedAt };
|
||
});
|
||
const dryRun = $derived($settingsQuery.data?.dry_run === true);
|
||
const selectedEndpointName = $derived(endpoints.find((e) => e.id === endpointId)?.name ?? '');
|
||
|
||
// ------------------------------------------------------------------
|
||
// Validation (spec §6.2 — exact wording)
|
||
// ------------------------------------------------------------------
|
||
const errors = $derived.by(() => {
|
||
const errs: Record<string, string> = {};
|
||
if (!endpoints.length || !endpointId) errs.conn = t('studio.errNoConn');
|
||
else if (connRec?.ok === false && !dryRun) errs.conn = t('studio.errConnDown', { time: fmtTime(connRec.at) });
|
||
if (promptInp?.required) {
|
||
const v = String(values[promptInp.nodeId] ?? '');
|
||
if (!v.trim()) errs[promptInp.nodeId] = t('studio.errPrompt');
|
||
else if (v.length > 2000) errs[promptInp.nodeId] = t('studio.errPromptLong');
|
||
}
|
||
if (brokenReasons.length) errs.workflow = t('studio.errWfBroken');
|
||
const first = mediaSlots.find((s) => isFirstFrame(s.inp));
|
||
const last = mediaSlots.find((s) => isLastFrame(s.inp));
|
||
if (first && last) {
|
||
const a = String(values[first.inp.nodeId] ?? '');
|
||
const b = String(values[last.inp.nodeId] ?? '');
|
||
if ((!a || !b) && (a || b)) {
|
||
errs[`${first.inp.nodeId}|${last.inp.nodeId}`] = t('studio.errFirstLast');
|
||
if (!a) errs[first.inp.nodeId] = ' ';
|
||
if (!b) errs[last.inp.nodeId] = ' ';
|
||
}
|
||
}
|
||
for (const s of mediaSlots) {
|
||
if (!s.inp.required) continue;
|
||
if (!String(values[s.inp.nodeId] ?? '').trim()) {
|
||
errs[s.inp.nodeId] = s.missing || t('studio.errUpload', { label: s.label });
|
||
}
|
||
}
|
||
for (const g of listGroups) {
|
||
const n = groupPaths(g).length;
|
||
const max = g.max ?? 9;
|
||
if (n < (g.min ?? 1)) {
|
||
errs[g.nodeId] =
|
||
g.kind === 'image_list'
|
||
? t('studio.errNeedRef')
|
||
: t('studio.errNeedRefMedia', { n: g.min ?? 1, label: g.label });
|
||
} else if (n > max) {
|
||
errs[g.nodeId] = t('studio.errRefMax', { max, n, k: n - max });
|
||
}
|
||
}
|
||
for (const inp of restInputs) {
|
||
if (inp.required && !String(values[inp.nodeId] ?? '').trim()) {
|
||
errs[inp.nodeId] = t('studio.errFill', { label: inp.label });
|
||
}
|
||
}
|
||
for (const inp of schema) {
|
||
const raw = values[inp.nodeId];
|
||
if (raw === undefined || Array.isArray(raw) || String(raw).trim() === '' || errs[inp.nodeId]) continue;
|
||
const msg = valueError(inp, raw);
|
||
if (msg) errs[inp.nodeId] = msg;
|
||
}
|
||
return errs;
|
||
});
|
||
|
||
/** Same rules the backend enforces before queueing (comfyui/validate.py). */
|
||
function valueError(inp: ComfyDynamicInput, raw: string | number): string | null {
|
||
const label = inp.label;
|
||
if (inp.kind === 'select') {
|
||
return inp.options?.length && !inp.options.includes(String(raw))
|
||
? t('studio.errOption', { label })
|
||
: null;
|
||
}
|
||
if (inp.kind !== 'number') return null;
|
||
const n = Number(raw);
|
||
if (!Number.isFinite(n)) return t('studio.errNumber', { label });
|
||
if (inp.integer && !Number.isInteger(n)) return t('studio.errInteger', { label });
|
||
if (inp.min != null && n < inp.min) return t('studio.errMin', { label, v: inp.min });
|
||
if (inp.max != null && n > inp.max) return t('studio.errMax', { label, v: inp.max });
|
||
return null;
|
||
}
|
||
|
||
function setVal(nodeId: string, v: FormValue) {
|
||
values = { ...values, [nodeId]: v };
|
||
}
|
||
function numVal(nodeId: string, raw: string) {
|
||
if (raw === '') {
|
||
setVal(nodeId, '');
|
||
return;
|
||
}
|
||
const n = Number(raw);
|
||
setVal(nodeId, Number.isNaN(n) ? raw : n);
|
||
}
|
||
|
||
// ------------------------------------------------------------------
|
||
// Uploads & media slots
|
||
// ------------------------------------------------------------------
|
||
function setRejects(nodeId: string, list: Array<{ name: string; message: string }>) {
|
||
slotRejects = { ...slotRejects, [nodeId]: list };
|
||
}
|
||
|
||
async function uploadImage(nodeId: string, file: File): Promise<string | null> {
|
||
const path = await uploads.uploadSafe(nodeId, file);
|
||
if (path) fileSizes = { ...fileSizes, [path]: file.size };
|
||
return path;
|
||
}
|
||
|
||
async function slotFile(nodeId: string, file: File, mediaKind: 'image' | 'video' | 'audio' = 'image') {
|
||
const problem = mediaFileProblem(mediaKind, file);
|
||
if (problem) {
|
||
setRejects(nodeId, [{ name: file.name, message: problem }]);
|
||
return;
|
||
}
|
||
setRejects(nodeId, []);
|
||
const path = await uploadImage(nodeId, file);
|
||
if (path) setVal(nodeId, path);
|
||
}
|
||
|
||
/** Add picked/dropped files in order; a batch that would pass `max` is refused whole. */
|
||
async function groupAdd(entry: ComfyDynamicInput, files: File[]) {
|
||
const key = entry.nodeId;
|
||
const mk = listKind(entry);
|
||
const max = entry.max ?? 9;
|
||
const paths = groupPaths(entry);
|
||
const ok = files.filter((f) => !mediaFileProblem(mk, f));
|
||
const rejected = files
|
||
.filter((f) => mediaFileProblem(mk, f))
|
||
.map((f) => ({ name: f.name, message: mediaFileProblem(mk, f)! }));
|
||
setRejects(key, rejected);
|
||
if (paths.length + ok.length > max) {
|
||
toast.error(t('studio.errRefMax', { max, n: paths.length, k: ok.length }));
|
||
return;
|
||
}
|
||
for (const f of ok) {
|
||
const path = await uploadImage(key, f);
|
||
if (!path) break;
|
||
setVal(key, [...paths, path]);
|
||
}
|
||
}
|
||
|
||
async function groupReplace(entry: ComfyDynamicInput, index: number, file: File) {
|
||
const key = entry.nodeId;
|
||
const problem = mediaFileProblem(listKind(entry), file);
|
||
if (problem) {
|
||
setRejects(key, [{ name: file.name, message: problem }]);
|
||
return;
|
||
}
|
||
setRejects(key, []);
|
||
replacingKey = key;
|
||
replacingIndex = index;
|
||
try {
|
||
const path = await uploadImage(key, file);
|
||
if (path) setVal(key, groupPaths(entry).map((p, i) => (i === index ? path : p)));
|
||
} finally {
|
||
replacingKey = '';
|
||
replacingIndex = -1;
|
||
}
|
||
}
|
||
|
||
function groupRemove(entry: ComfyDynamicInput, index: number) {
|
||
setVal(entry.nodeId, groupPaths(entry).filter((_, i) => i !== index));
|
||
}
|
||
|
||
const imageResults = $derived(
|
||
allJobs
|
||
.filter((j) => j.kind === 'image' && jobStatusInfo(j).tone === 'ok')
|
||
.flatMap((j) => j.output_paths.map((p) => ({ job: j, path: p }))),
|
||
);
|
||
|
||
function openPicker(nodeId: string) {
|
||
pickerMode = 'slot';
|
||
pickerFor = nodeId;
|
||
}
|
||
function pickImageResult(path: string) {
|
||
if (pickerFor && refGroup && pickerFor === refGroup.nodeId) {
|
||
if (refPaths.length >= refMax) toast.error(t('studio.refFull', { max: refMax }));
|
||
else setVal(pickerFor, [...refPaths, path]);
|
||
} else if (pickerFor) {
|
||
setVal(pickerFor, path);
|
||
}
|
||
pickerFor = null;
|
||
}
|
||
|
||
function sendToImg2Img(path: string) {
|
||
let wf = currentWorkflow;
|
||
let target = mediaSlots.find((s) => s.mediaKind === 'image' && role(s.inp) !== 'mask')?.inp ?? null;
|
||
if (!target) {
|
||
const candidate = ($workflowsQuery.data ?? []).find(
|
||
(w) =>
|
||
w.is_enabled &&
|
||
w.usage === 'image2image' &&
|
||
(w.input_schema ?? []).some(isMedia),
|
||
);
|
||
if (!candidate) {
|
||
toast.error(t('studio.noImg2ImgWf'));
|
||
return;
|
||
}
|
||
wf = candidate;
|
||
workflowId = candidate.id;
|
||
target = (candidate.input_schema ?? []).find(isMedia) ?? null;
|
||
}
|
||
if (target) {
|
||
setVal(target.nodeId, path);
|
||
toast.success(t('studio.sentToImg2ImgToast'));
|
||
}
|
||
}
|
||
|
||
// ------------------------------------------------------------------
|
||
// Submit
|
||
// ------------------------------------------------------------------
|
||
async function submit() {
|
||
if (submitting) return;
|
||
showErrors = true;
|
||
if (!workflowId) {
|
||
toast.error(t('studio.errNoWorkflow'));
|
||
return;
|
||
}
|
||
const blocking = Object.values(errors).find((m) => m.trim());
|
||
if (blocking) {
|
||
toast.error(t('studio.errBlocked', { reason: blocking }));
|
||
await tick();
|
||
document
|
||
.querySelector('.param-col .invalid, .param-col .f-error')
|
||
?.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
||
return;
|
||
}
|
||
submitting = true;
|
||
try {
|
||
const res = await playgroundApi.generate({
|
||
workflow_id: workflowId,
|
||
input_values: compactInputValues(values) as Record<string, unknown>,
|
||
endpoint_id: endpointId || null,
|
||
source: kind === 'image' ? 'studio-image' : 'studio-video',
|
||
});
|
||
submittedIds.add(res.job.id);
|
||
selectedKey = null;
|
||
toast.success(t('studio.queuedToast', { name: selectedEndpointName || '—' }));
|
||
await client.invalidateQueries({ queryKey: ['playground-jobs'] });
|
||
await client.invalidateQueries({ queryKey: ['jobs'] });
|
||
} catch (err) {
|
||
toast.error(t('studio.submitFailedToast', { detail: apiErrorMessage(err) }));
|
||
} finally {
|
||
submitting = false;
|
||
}
|
||
}
|
||
|
||
// ------------------------------------------------------------------
|
||
// Current task card
|
||
// ------------------------------------------------------------------
|
||
let nowMs = $state(Date.now());
|
||
$effect(() => {
|
||
if (!activeJob) return;
|
||
const id = setInterval(() => (nowMs = Date.now()), 1000);
|
||
return () => clearInterval(id);
|
||
});
|
||
|
||
const activeStatus = $derived(activeJob ? jobStatusInfo(activeJob) : null);
|
||
// ComfyUI reports no percent: the bar only moves while ComfyUI is really
|
||
// executing and never fills (job.completed ends the card instead).
|
||
const progress = $derived.by(() => {
|
||
if (!activeJob || activeJob.status !== 'running') return 0;
|
||
const phase = progressFor(activeJob.id)?.phase ?? activeJob.phase;
|
||
if (phase !== 'comfy_running' && phase !== 'saving') return 0;
|
||
return progressFor(activeJob.id)?.progress ?? 3;
|
||
});
|
||
|
||
function elapsedOf(job: Job): string {
|
||
const from = job.started_at ? parseDbTs(job.started_at) : parseDbTs(job.created_at);
|
||
if (!Number.isFinite(from)) return '—';
|
||
const to = job.completed_at ? parseDbTs(job.completed_at) : nowMs;
|
||
return fmtDur(Math.max(0, (to - from) / 1000));
|
||
}
|
||
|
||
const avgSec = $derived.by(() => {
|
||
const done = kindJobs.filter((j) => j.status === 'done' && j.started_at && j.completed_at);
|
||
if (!done.length) return null;
|
||
const total = done.reduce(
|
||
(acc, j) => acc + (parseDbTs(j.completed_at!) - parseDbTs(j.started_at!)) / 1000,
|
||
0,
|
||
);
|
||
return total / done.length;
|
||
});
|
||
const etaSec = $derived.by(() => {
|
||
if (!activeJob || activeJob.status !== 'running' || avgSec == null) return null;
|
||
const used = (nowMs - parseDbTs(activeJob.started_at ?? activeJob.created_at)) / 1000;
|
||
return Math.max(0, avgSec - used);
|
||
});
|
||
|
||
function jobValueByRole(job: Job, ...roles: string[]): string | null {
|
||
const wf = ($workflowsQuery.data ?? []).find((w) => w.id === job.workflow_id);
|
||
if (!wf) return null;
|
||
const vals = (job.payload?.input_values ?? {}) as Record<string, unknown>;
|
||
for (const inp of wf.input_schema ?? []) {
|
||
const r = normalizeInputRole(inp.role ?? null);
|
||
if (r && roles.includes(r)) {
|
||
const v = vals[inp.nodeId];
|
||
if (v !== undefined && v !== null && String(v).trim() !== '') return String(v);
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
const endpointName = $derived(
|
||
((activeJob?.payload?.endpoint as Record<string, unknown> | undefined)?.name as string) ??
|
||
endpoints.find((e) => e.id === endpointId)?.name ??
|
||
'—',
|
||
);
|
||
|
||
async function cancelActive() {
|
||
if (!activeJob || cancelling) return;
|
||
cancelling = true;
|
||
try {
|
||
await jobsApi.cancel(activeJob.id);
|
||
toast.info(t('studio.cancelToast'));
|
||
await client.invalidateQueries({ queryKey: ['playground-jobs'] });
|
||
} catch (err) {
|
||
toast.error(err instanceof Error ? err.message : String(err));
|
||
} finally {
|
||
cancelling = false;
|
||
}
|
||
}
|
||
|
||
// ------------------------------------------------------------------
|
||
// Results & selection
|
||
// ------------------------------------------------------------------
|
||
const selectedEntry = $derived(
|
||
doneEntries.find((e) => e.key === selectedKey) ?? doneEntries[0] ?? null,
|
||
);
|
||
const selectedJobId = $derived(selectedEntry?.job.id ?? null);
|
||
|
||
/**
|
||
* Clicking a history row: a finished job loads into the preview
|
||
* (player / image), anything else just reports its live status —
|
||
* never a silent jump to the newest finished clip.
|
||
*/
|
||
function selectFromHistory(job: Job) {
|
||
const st = jobStatusInfo(job);
|
||
if (st.tone === 'ok' && job.output_paths.length) {
|
||
selectedKey = `${job.id}:${job.output_paths[0]}`;
|
||
return;
|
||
}
|
||
toast.info(st.detail && st.detail !== st.label ? `${st.label} · ${st.detail}` : st.label);
|
||
}
|
||
|
||
function histRowKey(e: KeyboardEvent, job: Job) {
|
||
if (e.key === 'Enter' || e.key === ' ') {
|
||
e.preventDefault();
|
||
selectFromHistory(job);
|
||
}
|
||
}
|
||
|
||
function summaryOf(job: Job): string {
|
||
const parts: string[] = [];
|
||
const wf = ($workflowsQuery.data ?? []).find((x) => x.id === job.workflow_id);
|
||
const w = jobValueByRole(job, 'width');
|
||
const h = jobValueByRole(job, 'height');
|
||
const ratio = (wf?.input_schema ?? []).find((i) => normalizeInputRole(i.role ?? null) === 'aspect_ratio' && i.resolution);
|
||
if (w && h) parts.push(`${w}×${h}`);
|
||
else if (ratio?.resolution) {
|
||
const vals = (job.payload?.input_values ?? {}) as Record<string, unknown>;
|
||
const mpDefault = wf?.input_schema.find((i) => i.nodeId === ratio.resolution!.megapixels)?.defaultValue;
|
||
const size = resolutionSelectorSize(
|
||
String(vals[ratio.nodeId] ?? ratio.defaultValue ?? ''),
|
||
Number(vals[ratio.resolution.megapixels] ?? mpDefault),
|
||
ratio.resolution.multiple,
|
||
);
|
||
if (size) parts.push(`${size.width}×${size.height}`);
|
||
}
|
||
const seed = jobValueByRole(job, 'seed');
|
||
if (seed) parts.push(t('studio.seedLabel') + ' ' + seed);
|
||
const dur = jobValueByRole(job, 'duration');
|
||
if (dur) parts.push(`${dur}s`);
|
||
if (wf) parts.push(wf.name);
|
||
return parts.join(' · ');
|
||
}
|
||
|
||
function promptOf(job: Job): string {
|
||
return jobValueByRole(job, 'prompt') ?? '';
|
||
}
|
||
|
||
async function copyPrompt(job: Job) {
|
||
const text = promptOf(job);
|
||
if (!text) return;
|
||
try {
|
||
await navigator.clipboard.writeText(text);
|
||
toast.success(t('studio.copiedToast'));
|
||
} catch {
|
||
toast.error(t('studio.copyPrompt'));
|
||
}
|
||
}
|
||
|
||
function downloadName(path: string): string {
|
||
return path.split(/[/\\]/).pop() ?? 'download';
|
||
}
|
||
|
||
// Video player state
|
||
let videoEl = $state<HTMLVideoElement | null>(null);
|
||
let playerBox = $state<HTMLDivElement | null>(null);
|
||
let playing = $state(false);
|
||
let curSec = $state(0);
|
||
let durSec = $state(0);
|
||
|
||
// Switching the selected video must stop the old clip and rewind it,
|
||
// never keep playing the previous audio/progress into the new one.
|
||
// Runs BEFORE the DOM swaps the src so the reset cannot clobber the
|
||
// duration/metadata events of the clip being loaded in.
|
||
$effect.pre(() => {
|
||
void selectedEntry?.key;
|
||
const v = videoEl;
|
||
if (v) {
|
||
try {
|
||
v.pause();
|
||
v.currentTime = 0;
|
||
} catch {
|
||
/* no loaded metadata yet — src change already reset it */
|
||
}
|
||
}
|
||
playing = false;
|
||
curSec = 0;
|
||
durSec = 0;
|
||
});
|
||
|
||
function fmtClock(s: number): string {
|
||
if (!Number.isFinite(s)) return '0:00';
|
||
const m = Math.floor(s / 60);
|
||
const r = Math.floor(s % 60);
|
||
return `${m}:${String(r).padStart(2, '0')}`;
|
||
}
|
||
|
||
function togglePlay() {
|
||
const v = videoEl;
|
||
if (!v) return;
|
||
if (v.paused) void v.play();
|
||
else v.pause();
|
||
}
|
||
|
||
function seekTrack(e: MouseEvent) {
|
||
const v = videoEl;
|
||
const el = e.currentTarget as HTMLElement;
|
||
if (!v || !durSec) return;
|
||
const rect = el.getBoundingClientRect();
|
||
v.currentTime = Math.min(durSec, Math.max(0, ((e.clientX - rect.left) / rect.width) * durSec));
|
||
}
|
||
|
||
function fullscreen() {
|
||
if (document.fullscreenElement) void document.exitFullscreen();
|
||
else void playerBox?.requestFullscreen();
|
||
}
|
||
|
||
// First/last frame + reference strip for the selected video job.
|
||
// Ref workflows come in two shapes: an autogrow image_list, or several
|
||
// plain image inputs — both are shown as reference images.
|
||
const selectedFrames = $derived.by(() => {
|
||
if (kind !== 'video' || !selectedEntry) return [];
|
||
const wf = ($workflowsQuery.data ?? []).find((w) => w.id === selectedEntry.job.workflow_id);
|
||
if (!wf) return [];
|
||
const vals = (selectedEntry.job.payload?.input_values ?? {}) as Record<string, unknown>;
|
||
const out: Array<{ label: string; path: string; ref?: boolean }> = [];
|
||
let refIdx = 0;
|
||
for (const inp of wf.input_schema ?? []) {
|
||
const h = `${inp.role ?? ''} ${inp.label}`.toLowerCase();
|
||
const v = vals[inp.nodeId];
|
||
if (inp.kind === 'image_list') {
|
||
const list = Array.isArray(v) ? v : typeof v === 'string' && v ? [v] : [];
|
||
list.forEach((p, i) => {
|
||
if (typeof p === 'string') out.push({ label: t('studio.slotRefN', { n: i + 1 }), path: p, ref: true });
|
||
});
|
||
continue;
|
||
}
|
||
if (typeof v !== 'string' || !v) continue;
|
||
if (/first|start|首帧/.test(h)) out.push({ label: t('studio.slotFirst'), path: v });
|
||
else if (/last|end|尾帧/.test(h)) out.push({ label: t('studio.slotLast'), path: v });
|
||
else if (isMedia(inp) && inp.kind === 'image' && !/mask|遮罩/.test(h)) {
|
||
refIdx += 1;
|
||
out.push({ label: t('studio.slotRefN', { n: refIdx }), path: v, ref: true });
|
||
}
|
||
}
|
||
return out;
|
||
});
|
||
const selectedRefCount = $derived(selectedFrames.filter((f) => f.ref).length);
|
||
|
||
// ------------------------------------------------------------------
|
||
// History actions
|
||
// ------------------------------------------------------------------
|
||
/** Fill the form back with a past job's values (on its own workflow). */
|
||
function reuseParams(job: Job) {
|
||
const wf = kindWorkflows.find((w) => w.id === job.workflow_id);
|
||
if (!wf) {
|
||
toast.error(t('studio.reuseMissingWf'));
|
||
return;
|
||
}
|
||
const next: Record<string, FormValue> = {};
|
||
for (const inp of wf.input_schema ?? []) {
|
||
if (inp.defaultValue !== undefined && inp.defaultValue !== '') next[inp.nodeId] = inp.defaultValue;
|
||
}
|
||
const past = (job.payload?.input_values ?? {}) as Record<string, unknown>;
|
||
for (const [k, v] of Object.entries(past)) {
|
||
if (typeof v === 'string' || typeof v === 'number') next[k] = v;
|
||
else if (Array.isArray(v) && v.every((p) => typeof p === 'string')) next[k] = v as string[];
|
||
}
|
||
slotRejects = {};
|
||
workflowId = wf.id;
|
||
lastWfId = wf.id;
|
||
values = next;
|
||
showErrors = false;
|
||
toast.success(t('studio.reusedToast'));
|
||
}
|
||
|
||
async function retryJob(job: Job) {
|
||
if (retryingId != null) return;
|
||
retryingId = job.id;
|
||
try {
|
||
await jobsApi.retry(job.id);
|
||
toast.success(t('studio.retryQueuedToast'));
|
||
await client.invalidateQueries({ queryKey: ['playground-jobs'] });
|
||
} catch (err) {
|
||
toast.error(t('studio.retryFailedToast', { detail: err instanceof Error ? err.message : String(err) }));
|
||
} finally {
|
||
retryingId = null;
|
||
}
|
||
}
|
||
|
||
const deleteTarget = $derived(kindJobs.find((j) => j.id === deleteJobId) ?? null);
|
||
// The dialog names the exact job and — when it produced several
|
||
// outputs — says plainly that ALL of them go away with it (the
|
||
// backend only deletes whole jobs, never a single output file).
|
||
const deleteTitle = $derived(
|
||
deleteTarget ? t('studio.delTitleJob', { name: wfName(deleteTarget) }) : t('studio.delTitle'),
|
||
);
|
||
const deleteMessage = $derived.by(() => {
|
||
const n = deleteTarget?.output_paths?.length ?? 0;
|
||
return n > 1 ? t('studio.delConfirmMulti', { n }) : t('studio.delConfirm');
|
||
});
|
||
|
||
function askDeleteJob(jobId: number) {
|
||
deleteJobId = jobId;
|
||
deleteOpen = true;
|
||
}
|
||
|
||
async function doDelete() {
|
||
if (!deleteJobId) return;
|
||
try {
|
||
await playgroundApi.deleteJob(deleteJobId);
|
||
submittedIds.delete(deleteJobId);
|
||
if (selectedEntry?.job.id === deleteJobId) selectedKey = null;
|
||
toast.success(t('studio.deletedToast'));
|
||
await client.invalidateQueries({ queryKey: ['playground-jobs'] });
|
||
await client.invalidateQueries({ queryKey: ['jobs'] });
|
||
} catch (err) {
|
||
toast.error(err instanceof Error ? err.message : String(err));
|
||
} finally {
|
||
deleteJobId = null;
|
||
deleteOpen = false;
|
||
}
|
||
}
|
||
|
||
// Video history durations (read from element metadata)
|
||
let durations = $state<Record<string, number>>({});
|
||
function noteDuration(path: string, e: Event) {
|
||
const v = e.currentTarget as HTMLVideoElement;
|
||
if (Number.isFinite(v.duration)) durations = { ...durations, [path]: v.duration };
|
||
}
|
||
|
||
function fmtTime(ms: number): string {
|
||
const d = new Date(ms);
|
||
return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
|
||
}
|
||
function fmtDur(sec: number): string {
|
||
if (sec < 60) return `${Math.floor(sec)}s`;
|
||
const m = Math.floor(sec / 60);
|
||
const s = Math.floor(sec % 60);
|
||
return `${m}m${String(s).padStart(2, '0')}s`;
|
||
}
|
||
|
||
function wfName(job: Job): string {
|
||
return (
|
||
($workflowsQuery.data ?? []).find((w) => w.id === job.workflow_id)?.name ??
|
||
t('studio.jobName', { id: job.id })
|
||
);
|
||
}
|
||
</script>
|
||
|
||
{#snippet fieldError(inp: ComfyDynamicInput)}
|
||
{#if showErrors && errors[inp.nodeId]?.trim()}<span class="f-error">{errors[inp.nodeId]}</span>{/if}
|
||
{/snippet}
|
||
|
||
<AppShell
|
||
active={kind}
|
||
title={kind === 'image' ? t('studio.image.title') : t('studio.video.title')}
|
||
subtitle={kind === 'image' ? t('studio.image.subtitle') : t('studio.video.subtitle')}
|
||
>
|
||
{#snippet actions()}
|
||
{#if endpointId}
|
||
<span class="status-chip">
|
||
<span
|
||
class="status-chip-dot"
|
||
class:ok={connRec?.ok === true}
|
||
class:fail={connRec?.ok === false}
|
||
class:idle={!connRec}
|
||
aria-hidden="true"
|
||
></span>
|
||
{queueCount > 0
|
||
? t('studio.chipBusy', { name: selectedEndpointName, n: queueCount })
|
||
: t('studio.chipIdle', { name: selectedEndpointName })}
|
||
</span>
|
||
{/if}
|
||
{/snippet}
|
||
<div class="studio-page">
|
||
<!-- ---------------- left: parameters ---------------- -->
|
||
<section class="param-col" aria-label={kind === 'image' ? t('studio.image.title') : t('studio.video.title')}>
|
||
{#if !$settingsQuery.isLoading && !endpoints.length}
|
||
<div class="param-empty">
|
||
<Icon name="link" size={18} />
|
||
<p>{t('studio.errNoConn')}</p>
|
||
<a class="link-accent" href="/connections">{t('studio.connManage')}</a>
|
||
</div>
|
||
{:else if !kindWorkflows.length}
|
||
<div class="param-empty">
|
||
<Icon name={kind === 'image' ? 'image' : 'film'} size={18} />
|
||
<p>{t('studio.wfEmptyTitle', { kind: kind === 'image' ? t('studio.kindImageText') : t('studio.kindVideoText') })}</p>
|
||
<a class="link-accent" href="/connections">{t('studio.wfEmptyGo')}</a>
|
||
</div>
|
||
{:else}
|
||
<div class="panel-head">
|
||
<h2>{t('studio.genParams')}</h2>
|
||
{#if currentWorkflow}
|
||
<span class="panel-hint">{modeLabel}</span>
|
||
{/if}
|
||
</div>
|
||
{#if dryRun}
|
||
<p class="missing-note">{t('studio.dryRunNote')}</p>
|
||
{/if}
|
||
<div class="f-field">
|
||
<span class="f-label">
|
||
{t('studio.connLabel')}
|
||
<span class="f-hint-inline">
|
||
{#if connRec?.ok}
|
||
<span class="dot green" aria-hidden="true"></span>
|
||
{t('studio.connOk', { ms: connRec.ms ?? '?' })}
|
||
{:else if connRec?.ok === false}
|
||
<span class="dot red" aria-hidden="true"></span>
|
||
{t('studio.connFail')}
|
||
{:else}
|
||
<span class="dot gray" aria-hidden="true"></span>
|
||
{t('studio.connUntested')}
|
||
{/if}
|
||
· {t('studio.connQueue', { n: queueCount })}
|
||
</span>
|
||
</span>
|
||
<select
|
||
class="f-input"
|
||
class:invalid={showErrors && errors.conn}
|
||
value={endpointId}
|
||
onchange={(e) => {
|
||
endpointTouched = true;
|
||
endpointId = e.currentTarget.value;
|
||
}}
|
||
>
|
||
{#each endpoints as ep (ep.id)}
|
||
<option value={ep.id}>{ep.name}{ep.id === activeId ? ` · ${t('conn.defaultBadge')}` : ''}</option>
|
||
{/each}
|
||
</select>
|
||
{#if showErrors && errors.conn}<span class="f-error">{errors.conn}</span>{/if}
|
||
</div>
|
||
|
||
<div class="f-field">
|
||
<span class="f-label">
|
||
{t('studio.wfLabel')}
|
||
{#if currentWorkflow}
|
||
<span class="f-hint-inline">
|
||
{t('studio.wfParams', { n: currentWorkflow.input_schema?.length ?? 0 })} ·
|
||
{#if currentWorkflow.endpoint_id}
|
||
{t('studio.wfBindTo', {
|
||
name: endpoints.find((e) => e.id === currentWorkflow.endpoint_id)?.name ?? '?',
|
||
})}
|
||
{:else}
|
||
{t('studio.wfFollowActive')}
|
||
{/if}
|
||
</span>
|
||
{/if}
|
||
</span>
|
||
<select
|
||
class="f-input"
|
||
value={workflowId ?? ''}
|
||
onchange={(e) => (workflowId = Number(e.currentTarget.value) || null)}
|
||
>
|
||
{#each kindWorkflows as wf (wf.id)}
|
||
<option value={wf.id}>{wf.name}</option>
|
||
{/each}
|
||
</select>
|
||
{#if currentWorkflow && !schema.length}
|
||
<p class="missing-note">{t('studio.wfNoParamsNote')}</p>
|
||
{:else if schema.some((i) => i.auto)}
|
||
<p class="missing-note">{t('studio.wfAutoParamsNote', { n: schema.length })}</p>
|
||
{/if}
|
||
{#if brokenReasons.length}
|
||
<div class="missing-note" role="alert">
|
||
<span class="f-error">{t('studio.wfBrokenTitle')}</span>
|
||
{#each brokenReasons as reason (reason)}
|
||
<span class="f-error">· {reason}</span>
|
||
{/each}
|
||
<span class="f-error">{t('studio.wfBrokenHint')}</span>
|
||
</div>
|
||
{/if}
|
||
</div>
|
||
|
||
{#if mediaSlots.length}
|
||
{@const pairKey = `${mediaSlots.find((s) => isFirstFrame(s.inp))?.inp.nodeId ?? ''}|${mediaSlots.find((s) => isLastFrame(s.inp))?.inp.nodeId ?? ''}`}
|
||
<div class="slots">
|
||
{#each mediaSlots as s (s.inp.nodeId)}
|
||
{@const reject = slotRejects[s.inp.nodeId]?.[0]}
|
||
{#if s.inp.kind === 'video' || s.inp.kind === 'audio'}
|
||
<div class="slot-span">
|
||
<MediaSlot
|
||
label={s.label}
|
||
value={String(values[s.inp.nodeId] ?? '')}
|
||
kind={s.mediaKind}
|
||
uploading={uploads.isUploading(s.inp.nodeId)}
|
||
uploadName={uploads.uploading[s.inp.nodeId]}
|
||
error={showErrors ? errors[s.inp.nodeId] : undefined}
|
||
onFile={(f) => slotFile(s.inp.nodeId, f, s.mediaKind)}
|
||
onClear={() => setVal(s.inp.nodeId, '')}
|
||
/>
|
||
</div>
|
||
{:else}
|
||
<div class="slot-cell" class:span2={s.aspect === 'wide' || mediaSlots.length === 1}>
|
||
<MediaSlot
|
||
label={s.label}
|
||
required={s.inp.required}
|
||
hint={s.fromResults ? t('studio.slotFromResults') : s.inp.required ? t('studio.slotHintOne') : undefined}
|
||
value={String(values[s.inp.nodeId] ?? '')}
|
||
kind="image"
|
||
aspect={s.aspect}
|
||
emptyText={s.emptyText}
|
||
emptySub={t('studio.slotEmptySub')}
|
||
size={fileSizes[String(values[s.inp.nodeId] ?? '')]}
|
||
uploading={uploads.isUploading(s.inp.nodeId)}
|
||
uploadName={uploads.uploading[s.inp.nodeId]}
|
||
error={reject?.message ?? (showErrors ? errors[s.inp.nodeId] : undefined)}
|
||
allowFromResults={s.fromResults}
|
||
onFile={(f) => slotFile(s.inp.nodeId, f)}
|
||
onFromResults={() => openPicker(s.inp.nodeId)}
|
||
onClear={() => {
|
||
setRejects(s.inp.nodeId, []);
|
||
setVal(s.inp.nodeId, '');
|
||
}}
|
||
/>
|
||
</div>
|
||
{/if}
|
||
{/each}
|
||
</div>
|
||
{#if showErrors && errors[pairKey]}
|
||
<span class="f-error">{errors[pairKey]}</span>
|
||
{/if}
|
||
{/if}
|
||
|
||
{#if listGroups.length}
|
||
<div class="f-field ref-groups">
|
||
{#each listGroups as entry (entry.nodeId)}
|
||
<RefImageGrid
|
||
label={entry.label}
|
||
mediaKind={listKind(entry)}
|
||
paths={groupPaths(entry)}
|
||
max={entry.max ?? 9}
|
||
sizes={fileSizes}
|
||
uploadingName={uploads.uploading[entry.nodeId]}
|
||
uploadingIndex={replacingKey === entry.nodeId ? replacingIndex : -1}
|
||
rejects={slotRejects[entry.nodeId] ?? []}
|
||
error={showErrors ? errors[entry.nodeId] : undefined}
|
||
allowFromResults={entry.kind === 'image_list'}
|
||
onAdd={(files) => groupAdd(entry, files)}
|
||
onReplace={(i, file) => groupReplace(entry, i, file)}
|
||
onRemove={(i) => groupRemove(entry, i)}
|
||
onDismissReject={(i) =>
|
||
setRejects(entry.nodeId, (slotRejects[entry.nodeId] ?? []).filter((_, j) => j !== i))}
|
||
onFromResults={entry.kind === 'image_list' ? () => openPicker(entry.nodeId) : undefined}
|
||
/>
|
||
{/each}
|
||
{#if hasH3Hint}
|
||
<div class="h3-hint" role="note">
|
||
<p>{t('wfMedia.h3Limits')}</p>
|
||
{#each h3SoftWarnings as w (w)}
|
||
<p class="warn">{w}</p>
|
||
{/each}
|
||
</div>
|
||
{/if}
|
||
</div>
|
||
{/if}
|
||
|
||
{#if promptInp}
|
||
<label class="f-field">
|
||
<span class="f-label">
|
||
{t('studio.promptLabel')}<em>*</em>
|
||
<span class="f-hint-inline mono">{t('studio.chars', { n: promptLen })}</span>
|
||
<button type="button" class="style-link" onclick={() => toast.info(t('studio.styleSoon'))}>
|
||
{t('studio.insertStyle')}
|
||
</button>
|
||
</span>
|
||
<textarea
|
||
class="f-input prompt-area"
|
||
class:invalid={showErrors && errors[promptInp.nodeId]}
|
||
rows="5"
|
||
value={String(values[promptInp.nodeId] ?? '')}
|
||
oninput={(e) => setVal(promptInp.nodeId, e.currentTarget.value)}
|
||
placeholder={t('studio.promptPh')}
|
||
></textarea>
|
||
{#if showErrors && errors[promptInp.nodeId]}
|
||
<span class="f-error">{errors[promptInp.nodeId]}</span>
|
||
{/if}
|
||
</label>
|
||
{:else if currentWorkflow}
|
||
<label class="f-field">
|
||
<span class="f-label">{t('studio.promptLabel')}</span>
|
||
<textarea
|
||
class="f-input prompt-area"
|
||
rows="3"
|
||
disabled
|
||
placeholder={t('studio.promptNotDeclared')}
|
||
></textarea>
|
||
</label>
|
||
{/if}
|
||
|
||
<div class="pair-row">
|
||
{#if negInp}
|
||
<label class="f-field">
|
||
<span class="f-label">{t('studio.negLabel')}</span>
|
||
<textarea
|
||
class="f-input"
|
||
rows="2"
|
||
value={String(values[negInp.nodeId] ?? '')}
|
||
oninput={(e) => setVal(negInp.nodeId, e.currentTarget.value)}
|
||
></textarea>
|
||
</label>
|
||
{/if}
|
||
{#if seedInp}
|
||
<label class="f-field">
|
||
<span class="f-label">{t('studio.seedLabel')}</span>
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && errors[seedInp.nodeId]}
|
||
type="text"
|
||
inputmode="numeric"
|
||
value={String(values[seedInp.nodeId] ?? '')}
|
||
oninput={(e) => numVal(seedInp.nodeId, e.currentTarget.value)}
|
||
/>
|
||
{@render fieldError(seedInp)}
|
||
</label>
|
||
{/if}
|
||
</div>
|
||
|
||
{#if ratioInp}
|
||
<div class="pair-row">
|
||
<label class="f-field">
|
||
<span class="f-label">{t('studio.ratioLabel')}</span>
|
||
<select
|
||
class="f-input"
|
||
class:invalid={showErrors && errors[ratioInp.nodeId]}
|
||
value={String(values[ratioInp.nodeId] ?? ratioInp.defaultValue ?? '')}
|
||
onchange={(e) => setVal(ratioInp.nodeId, e.currentTarget.value)}
|
||
>
|
||
{#each ratioInp.options ?? [] as opt (opt)}
|
||
<option value={opt}>{ratioShort(opt)}</option>
|
||
{/each}
|
||
</select>
|
||
{@render fieldError(ratioInp)}
|
||
</label>
|
||
{#if megapixelsInp}
|
||
<label class="f-field">
|
||
<span class="f-label">{t('studio.megapixelsLabel')}</span>
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && errors[megapixelsInp.nodeId]}
|
||
type="number"
|
||
min={megapixelsInp.min}
|
||
max={megapixelsInp.max}
|
||
step={megapixelsInp.step ?? 0.1}
|
||
value={String(values[megapixelsInp.nodeId] ?? '')}
|
||
oninput={(e) => numVal(megapixelsInp.nodeId, e.currentTarget.value)}
|
||
/>
|
||
{#if outputSize}
|
||
<span class="panel-hint mono">
|
||
{t('studio.outputSize', { w: outputSize.width, h: outputSize.height })}
|
||
</span>
|
||
{/if}
|
||
{@render fieldError(megapixelsInp)}
|
||
</label>
|
||
{/if}
|
||
</div>
|
||
{:else if widthInp && heightInp}
|
||
<div class="f-field">
|
||
<span class="f-label">{t('studio.sizeLabel')}</span>
|
||
<div class="size-row">
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && errors[widthInp.nodeId]}
|
||
type="number"
|
||
placeholder="W"
|
||
min={widthInp.min}
|
||
max={widthInp.max}
|
||
step={widthInp.step}
|
||
value={String(values[widthInp.nodeId] ?? '')}
|
||
oninput={(e) => numVal(widthInp.nodeId, e.currentTarget.value)}
|
||
/>
|
||
<span class="size-x">×</span>
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && errors[heightInp.nodeId]}
|
||
type="number"
|
||
placeholder="H"
|
||
min={heightInp.min}
|
||
max={heightInp.max}
|
||
step={heightInp.step}
|
||
value={String(values[heightInp.nodeId] ?? '')}
|
||
oninput={(e) => numVal(heightInp.nodeId, e.currentTarget.value)}
|
||
/>
|
||
</div>
|
||
{@render fieldError(widthInp)}
|
||
{@render fieldError(heightInp)}
|
||
</div>
|
||
{:else if resolutionInp}
|
||
<label class="f-field">
|
||
<span class="f-label">{t('studio.resolutionLabel')}</span>
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && errors[resolutionInp.nodeId]}
|
||
type="number"
|
||
min={resolutionInp.min}
|
||
max={resolutionInp.max}
|
||
step={resolutionInp.step ?? 32}
|
||
value={String(values[resolutionInp.nodeId] ?? '')}
|
||
oninput={(e) => numVal(resolutionInp.nodeId, e.currentTarget.value)}
|
||
/>
|
||
<span class="panel-hint">{t('studio.resolutionHint')}</span>
|
||
{@render fieldError(resolutionInp)}
|
||
</label>
|
||
{/if}
|
||
|
||
{#if stepsInp || cfgInp || denoiseInp || batchInp || durationInp || fpsInp}
|
||
<div class="pair-row">
|
||
{#if durationInp}
|
||
<label class="f-field">
|
||
<span class="f-label">{t('studio.durationLabel')}</span>
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && errors[durationInp.nodeId]}
|
||
type="number"
|
||
min={durationInp.min ?? 0}
|
||
step="0.5"
|
||
value={String(values[durationInp.nodeId] ?? '')}
|
||
oninput={(e) => numVal(durationInp.nodeId, e.currentTarget.value)}
|
||
/>
|
||
{@render fieldError(durationInp)}
|
||
</label>
|
||
{/if}
|
||
{#if fpsInp}
|
||
<label class="f-field">
|
||
<span class="f-label">{t('studio.fpsLabel')}</span>
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && errors[fpsInp.nodeId]}
|
||
type="number"
|
||
min="1"
|
||
value={String(values[fpsInp.nodeId] ?? '')}
|
||
oninput={(e) => numVal(fpsInp.nodeId, e.currentTarget.value)}
|
||
/>
|
||
{@render fieldError(fpsInp)}
|
||
</label>
|
||
{/if}
|
||
{#if batchInp}
|
||
<label class="f-field">
|
||
<span class="f-label">{t('studio.batchLabel')}</span>
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && errors[batchInp.nodeId]}
|
||
type="number"
|
||
min={batchInp.min ?? 1}
|
||
max={batchInp.max}
|
||
step="1"
|
||
value={String(values[batchInp.nodeId] ?? '')}
|
||
oninput={(e) => numVal(batchInp.nodeId, e.currentTarget.value)}
|
||
/>
|
||
{@render fieldError(batchInp)}
|
||
</label>
|
||
{/if}
|
||
{#if stepsInp}
|
||
<label class="f-field">
|
||
<span class="f-label">
|
||
{t('studio.stepsLabel')}
|
||
<span class="f-hint-inline mono">{values[stepsInp.nodeId] ?? '—'}</span>
|
||
</span>
|
||
<input
|
||
class="a-range"
|
||
type="range"
|
||
min={stepsInp.min ?? 1}
|
||
max={Math.max(150, Number(values[stepsInp.nodeId] ?? stepsInp.defaultValue ?? 0))}
|
||
step="1"
|
||
value={Number(values[stepsInp.nodeId] ?? stepsInp.defaultValue ?? 20)}
|
||
oninput={(e) => setVal(stepsInp.nodeId, Number(e.currentTarget.value))}
|
||
/>
|
||
{@render fieldError(stepsInp)}
|
||
</label>
|
||
{/if}
|
||
{#if cfgInp}
|
||
<label class="f-field">
|
||
<span class="f-label">
|
||
{t('studio.cfgLabel')}
|
||
<span class="f-hint-inline mono">{values[cfgInp.nodeId] ?? '—'}</span>
|
||
</span>
|
||
<input
|
||
class="a-range"
|
||
type="range"
|
||
min={cfgInp.min ?? 0}
|
||
max={Math.max(20, Number(values[cfgInp.nodeId] ?? cfgInp.defaultValue ?? 0))}
|
||
step="0.1"
|
||
value={Number(values[cfgInp.nodeId] ?? cfgInp.defaultValue ?? 7)}
|
||
oninput={(e) => setVal(cfgInp.nodeId, Number(e.currentTarget.value))}
|
||
/>
|
||
{@render fieldError(cfgInp)}
|
||
</label>
|
||
{/if}
|
||
{#if denoiseInp}
|
||
<label class="f-field">
|
||
<span class="f-label">
|
||
{t('studio.denoiseLabel')}
|
||
<span class="f-hint-inline mono">{values[denoiseInp.nodeId] ?? '—'}</span>
|
||
</span>
|
||
<input
|
||
class="a-range"
|
||
type="range"
|
||
min={denoiseInp.min ?? 0}
|
||
max={denoiseInp.max ?? 1}
|
||
step={denoiseInp.step ?? 0.01}
|
||
value={Number(values[denoiseInp.nodeId] ?? denoiseInp.defaultValue ?? 1)}
|
||
oninput={(e) => setVal(denoiseInp.nodeId, Number(e.currentTarget.value))}
|
||
/>
|
||
{@render fieldError(denoiseInp)}
|
||
</label>
|
||
{/if}
|
||
</div>
|
||
{/if}
|
||
|
||
{#if restInputs.length}
|
||
<div class="rest-params">
|
||
<div class="rest-title">{t('studio.paramsTitle')}</div>
|
||
{#each restInputs as inp (inp.nodeId)}
|
||
<label class="f-field">
|
||
<span class="f-label">
|
||
{inp.label}{#if inp.required}<em>*</em>{/if}
|
||
</span>
|
||
{#if inp.kind === 'textarea'}
|
||
<textarea
|
||
class="f-input"
|
||
class:invalid={showErrors && errors[inp.nodeId]}
|
||
rows="2"
|
||
value={String(values[inp.nodeId] ?? '')}
|
||
oninput={(e) => setVal(inp.nodeId, e.currentTarget.value)}
|
||
></textarea>
|
||
{:else if inp.kind === 'number'}
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && errors[inp.nodeId]}
|
||
type="number"
|
||
min={inp.min}
|
||
max={inp.max}
|
||
step={inp.step ?? 'any'}
|
||
value={String(values[inp.nodeId] ?? '')}
|
||
oninput={(e) => numVal(inp.nodeId, e.currentTarget.value)}
|
||
/>
|
||
{:else if inp.kind === 'select'}
|
||
<select
|
||
class="f-input"
|
||
class:invalid={showErrors && errors[inp.nodeId]}
|
||
value={String(values[inp.nodeId] ?? inp.defaultValue ?? '')}
|
||
onchange={(e) => setVal(inp.nodeId, e.currentTarget.value)}
|
||
>
|
||
{#each inp.options ?? [] as opt (opt)}
|
||
<option value={opt}>{opt}</option>
|
||
{/each}
|
||
</select>
|
||
{:else}
|
||
<input
|
||
class="f-input"
|
||
class:invalid={showErrors && errors[inp.nodeId]}
|
||
type="text"
|
||
value={String(values[inp.nodeId] ?? '')}
|
||
oninput={(e) => setVal(inp.nodeId, e.currentTarget.value)}
|
||
/>
|
||
{/if}
|
||
{#if showErrors && errors[inp.nodeId]}
|
||
<span class="f-error">{errors[inp.nodeId]}</span>
|
||
{/if}
|
||
</label>
|
||
{/each}
|
||
</div>
|
||
{/if}
|
||
|
||
<div class="action-bar">
|
||
<Button
|
||
block
|
||
variant="primary"
|
||
disabled={!endpoints.length || !kindWorkflows.length}
|
||
loading={submitting}
|
||
onclick={submit}
|
||
>
|
||
{submitting
|
||
? t('studio.submitting')
|
||
: batchCount > 1
|
||
? t('studio.generateN', { n: batchCount })
|
||
: t('studio.generate')}
|
||
</Button>
|
||
<span class="eta">{t('studio.etaHint')}</span>
|
||
</div>
|
||
{/if}
|
||
</section>
|
||
|
||
<!-- ---------------- center: current task + results ---------------- -->
|
||
<section class="center-col">
|
||
{#if !kindWorkflows.length}
|
||
<div class="wf-guide card">
|
||
<h2>{t('studio.wfEmptyTitle', { kind: kind === 'image' ? t('studio.kindImageText') : t('studio.kindVideoText') })}</h2>
|
||
<p>{t('studio.wfEmptyBody', { kind: kind === 'image' ? t('studio.kindImageText') : t('studio.kindVideoText') })}</p>
|
||
<p class="missing-note">
|
||
{kind === 'image' ? t('studio.missingQwen') : t('studio.missingFirstLast')}
|
||
</p>
|
||
<div class="guide-actions">
|
||
<a class="a-btn primary" href="/connections">{t('studio.wfEmptyGo')}</a>
|
||
</div>
|
||
</div>
|
||
{:else}
|
||
<div class="card task-card" class:idle={!activeJob}>
|
||
<div class="task-head">
|
||
<span class="tag" class:info={kind === 'image'} class:cloud={kind === 'video'}>
|
||
{kind === 'image' ? t('studio.kindImageText') : t('studio.kindVideoText')}
|
||
</span>
|
||
<span class="task-name">{activeJob ? wfName(activeJob) : t('studio.noActiveTask')}</span>
|
||
{#if activeJob && (activeJob.status === 'pending' || activeJob.status === 'running')}
|
||
<button type="button" class="link-danger" onclick={cancelActive}>
|
||
{t('studio.taskCancel')}
|
||
</button>
|
||
{/if}
|
||
</div>
|
||
{#if activeJob}
|
||
<div class="task-body">
|
||
{#if activeJob.status === 'pending'}
|
||
<div class="pct">{activeStatus?.label}</div>
|
||
<div class="task-meta mono">
|
||
{activeStatus?.detail} ·
|
||
{t('studio.queuedBehind', { n: jobsAhead })}
|
||
</div>
|
||
{:else}
|
||
<div class="pct">{activeStatus?.label}</div>
|
||
<div class="progress" role="progressbar" aria-valuetext={activeStatus?.detail}>
|
||
<div class="fill" style={`width:${progress}%`}></div>
|
||
</div>
|
||
<div class="task-meta mono">
|
||
{activeStatus?.detail} ·
|
||
{t('studio.usedShort', { v: elapsedOf(activeJob) })}
|
||
{#if etaSec != null} · {t('studio.etaShort', { v: fmtDur(etaSec) })}{/if}
|
||
· {t('studio.targetShort', { name: endpointName })}
|
||
</div>
|
||
{/if}
|
||
</div>
|
||
{/if}
|
||
</div>
|
||
|
||
{#if kind === 'image'}
|
||
<div class="results card">
|
||
<div class="panel-head">
|
||
<h2>{t('studio.resultsTitle')}</h2>
|
||
{#if doneEntries.length}<span class="panel-hint mono">{doneEntries.length}</span>{/if}
|
||
</div>
|
||
{#if doneEntries.length}
|
||
<div class="result-grid">
|
||
{#each doneEntries as entry (entry.key)}
|
||
<button
|
||
type="button"
|
||
class="thumb"
|
||
class:selected={entry.key === selectedEntry?.key}
|
||
onclick={() => (selectedKey = entry.key)}
|
||
>
|
||
<img src={assetUrl(entry.path)} alt={downloadName(entry.path)} loading="lazy" />
|
||
{#if entry.key === selectedEntry?.key}
|
||
<span class="sel-badge">{t('studio.selectHint')}</span>
|
||
{/if}
|
||
</button>
|
||
{/each}
|
||
</div>
|
||
{#if selectedEntry}
|
||
<div class="result-bar">
|
||
<span class="mono summary">{summaryOf(selectedEntry.job)}</span>
|
||
<span class="bar-actions">
|
||
<Button variant="secondary" size="sm" onclick={() => (lightboxOpen = true)}>
|
||
<Icon name="image" size={13} />
|
||
{t('studio.zoom')}
|
||
</Button>
|
||
<Button variant="secondary" size="sm" onclick={() => reuseParams(selectedEntry!.job)}>
|
||
<Icon name="retry" size={13} />
|
||
{t('studio.reuseParams')}
|
||
</Button>
|
||
<Button variant="secondary" size="sm" onclick={() => sendToImg2Img(selectedEntry!.path)}>
|
||
<Icon name="upload" size={13} />
|
||
{t('studio.sendToImg2Img')}
|
||
</Button>
|
||
<a class="a-btn secondary sm" href={assetUrl(selectedEntry.path)} download={downloadName(selectedEntry.path)}>
|
||
<Icon name="download" size={13} />
|
||
{t('studio.download')}
|
||
</a>
|
||
<Button
|
||
variant="danger"
|
||
size="sm"
|
||
title={t('studio.deleteBtn')}
|
||
onclick={() => askDeleteJob(selectedEntry!.job.id)}
|
||
>
|
||
<Icon name="trash" size={13} />
|
||
{t('studio.deleteBtn')}
|
||
</Button>
|
||
</span>
|
||
</div>
|
||
{/if}
|
||
{:else}
|
||
<p class="empty-line">
|
||
{kind === 'image' ? t('studio.historyEmptyImage') : t('studio.historyEmptyVideo')}
|
||
</p>
|
||
{/if}
|
||
</div>
|
||
{:else}
|
||
<div class="results card">
|
||
<div class="panel-head">
|
||
<h2>{t('studio.video.resultsTitle')}</h2>
|
||
{#if selectedEntry}
|
||
<span class="panel-hint">
|
||
{wfName(selectedEntry.job)} ·
|
||
{t('studio.doneAt', {
|
||
time: fmtTime(parseDbTs(selectedEntry.job.completed_at ?? selectedEntry.job.created_at)),
|
||
})}
|
||
</span>
|
||
{/if}
|
||
</div>
|
||
{#if selectedEntry}
|
||
<div class="player" bind:this={playerBox}>
|
||
<video
|
||
bind:this={videoEl}
|
||
src={assetUrl(selectedEntry.path)}
|
||
preload="metadata"
|
||
playsinline
|
||
ontimeupdate={(e) => (curSec = e.currentTarget.currentTime)}
|
||
ondurationchange={(e) => (durSec = e.currentTarget.duration)}
|
||
onplay={() => (playing = true)}
|
||
onpause={() => (playing = false)}
|
||
onended={() => (playing = false)}
|
||
></video>
|
||
{#if !playing}
|
||
<button type="button" class="play-center" onclick={togglePlay} aria-label={t('studio.playAria')}>
|
||
<Icon name="play" size={22} />
|
||
</button>
|
||
{/if}
|
||
{#if durSec}
|
||
<span class="dur-badge mono">{fmtClock(durSec)}</span>
|
||
{/if}
|
||
<div class="ctrl-bar">
|
||
<button type="button" class="ctrl-btn" onclick={togglePlay} aria-label={playing ? t('studio.pauseAria') : t('studio.playAria')}>
|
||
<Icon name={playing ? 'pause' : 'play'} size={14} />
|
||
</button>
|
||
<div class="track" onclick={seekTrack} role="slider" aria-label="progress" tabindex="-1">
|
||
<div class="track-fill" style={`width:${durSec ? (curSec / durSec) * 100 : 0}%`}></div>
|
||
</div>
|
||
<span class="mono timecode">{fmtClock(curSec)} / {fmtClock(durSec)}</span>
|
||
<button type="button" class="ctrl-btn" onclick={fullscreen} aria-label={t('studio.fullscreenAria')}>
|
||
<Icon name="external-link" size={14} />
|
||
</button>
|
||
</div>
|
||
</div>
|
||
{#if selectedFrames.length}
|
||
<div class="frame-strip">
|
||
<span class="strip-label">
|
||
{selectedRefCount ? t('studio.refStrip', { n: selectedRefCount }) : t('studio.videoRefStrip')}
|
||
</span>
|
||
{#each selectedFrames as fr (fr.path)}
|
||
<div class="frame-item">
|
||
<img src={assetUrl(fr.path)} alt={fr.label} />
|
||
<span class="frame-tag">{fr.label}</span>
|
||
</div>
|
||
{/each}
|
||
</div>
|
||
{/if}
|
||
<div class="result-bar">
|
||
<span class="mono summary">{summaryOf(selectedEntry.job)}</span>
|
||
<span class="bar-actions">
|
||
<Button variant="secondary" size="sm" onclick={() => copyPrompt(selectedEntry!.job)}>
|
||
<Icon name="check" size={13} />
|
||
{t('studio.copyPrompt')}
|
||
</Button>
|
||
<Button variant="secondary" size="sm" onclick={() => reuseParams(selectedEntry!.job)}>
|
||
<Icon name="retry" size={13} />
|
||
{t('studio.reuseParams')}
|
||
</Button>
|
||
<Button
|
||
variant="secondary"
|
||
size="sm"
|
||
disabled={selectedEntry.job.status !== 'failed'}
|
||
onclick={() => retryJob(selectedEntry!.job)}
|
||
>
|
||
<Icon name="retry" size={13} />
|
||
{t('studio.retryLink')}
|
||
</Button>
|
||
<a class="a-btn secondary sm" href={assetUrl(selectedEntry.path)} download={downloadName(selectedEntry.path)}>
|
||
<Icon name="download" size={13} />
|
||
{t('studio.downloadMp4')}
|
||
</a>
|
||
<Button
|
||
variant="danger"
|
||
size="sm"
|
||
title={t('studio.deleteBtn')}
|
||
onclick={() => askDeleteJob(selectedEntry!.job.id)}
|
||
>
|
||
<Icon name="trash" size={13} />
|
||
{t('studio.deleteBtn')}
|
||
</Button>
|
||
</span>
|
||
</div>
|
||
{:else}
|
||
<p class="empty-line">{t('studio.historyEmptyVideo')}</p>
|
||
{/if}
|
||
</div>
|
||
{/if}
|
||
{/if}
|
||
</section>
|
||
|
||
<!-- ---------------- right: history ---------------- -->
|
||
<aside class="history-col" aria-label={kind === 'image' ? t('studio.image.historyTitle') : t('studio.video.historyTitle')}>
|
||
<div class="history-head">
|
||
<h2>{kind === 'image' ? t('studio.image.historyTitle') : t('studio.video.historyTitle')}</h2>
|
||
{#if kindJobs.length}<span class="panel-hint">{t('studio.historyCount', { n: kindJobs.length })}</span>{/if}
|
||
</div>
|
||
{#if !kindJobs.length}
|
||
<p class="empty-line">
|
||
{kind === 'image' ? t('studio.historyEmptyImage') : t('studio.historyEmptyVideo')}
|
||
</p>
|
||
{:else}
|
||
<div class="history-list">
|
||
{#each kindJobs as job (job.id)}
|
||
{@const st = jobStatusInfo(job)}
|
||
<div
|
||
class="hist-row"
|
||
class:failed={job.status === 'failed'}
|
||
class:video={kind === 'video'}
|
||
class:selected={selectedJobId === job.id}
|
||
role="button"
|
||
tabindex={0}
|
||
aria-label={`${wfName(job)} · ${st.label}`}
|
||
aria-current={selectedJobId === job.id ? 'true' : undefined}
|
||
onclick={() => selectFromHistory(job)}
|
||
onkeydown={(e) => histRowKey(e, job)}
|
||
>
|
||
<div class="hist-thumb" class:video={kind === 'video'}>
|
||
{#if job.output_paths?.[0]}
|
||
{#if kind === 'image'}
|
||
<img src={assetUrl(job.output_paths[0])} alt={wfName(job)} loading="lazy" />
|
||
{:else}
|
||
<video
|
||
src={assetUrl(job.output_paths[0])}
|
||
preload="metadata"
|
||
muted
|
||
onloadedmetadata={(e) => noteDuration(job.output_paths![0], e)}
|
||
></video>
|
||
{#if durations[job.output_paths[0]]}
|
||
<span class="dur mono">{fmtClock(durations[job.output_paths[0]])}</span>
|
||
{/if}
|
||
{/if}
|
||
{:else if job.status === 'failed'}
|
||
<span class="thumb-fallback failed"><Icon name="alert" size={14} /></span>
|
||
{:else}
|
||
<span class="thumb-fallback"><Icon name={kind === 'image' ? 'image' : 'film'} size={14} /></span>
|
||
{/if}
|
||
</div>
|
||
<div class="hist-body">
|
||
<div class="hist-name" title={wfName(job)}>{wfName(job)}</div>
|
||
<div class="hist-meta mono">{summaryOf(job)}</div>
|
||
<div class="hist-status">
|
||
{#if job.status !== 'failed'}
|
||
<span class="st {st.tone}" title={st.detail}>{st.label}</span>
|
||
{:else}
|
||
<button
|
||
type="button"
|
||
class="st fail-link"
|
||
disabled={retryingId === job.id}
|
||
onclick={(e) => {
|
||
e.stopPropagation();
|
||
retryJob(job);
|
||
}}
|
||
>
|
||
{t('studio.retryLink')}
|
||
</button>
|
||
{/if}
|
||
<button
|
||
type="button"
|
||
class="hist-del"
|
||
title={t('studio.deleteBtn')}
|
||
onclick={(e) => {
|
||
e.stopPropagation();
|
||
askDeleteJob(job.id);
|
||
}}
|
||
>
|
||
<Icon name="trash" size={13} />
|
||
</button>
|
||
</div>
|
||
{#if job.status === 'failed' && job.error}
|
||
<div class="hist-error">{job.error}</div>
|
||
{:else if st.tone === 'fail' || (job.status === 'done' && job.phase === 'dry_run')}
|
||
<div class="hist-error">{st.detail}</div>
|
||
{/if}
|
||
</div>
|
||
</div>
|
||
{/each}
|
||
</div>
|
||
{/if}
|
||
</aside>
|
||
</div>
|
||
</AppShell>
|
||
|
||
<ImageLightbox
|
||
src={lightboxOpen && selectedEntry ? assetUrl(selectedEntry.path) : null}
|
||
alt={selectedEntry ? downloadName(selectedEntry.path) : ''}
|
||
images={doneEntries.map((e) => assetUrl(e.path) ?? '')}
|
||
index={Math.max(0, doneEntries.findIndex((e) => e.key === selectedEntry?.key))}
|
||
onClose={() => (lightboxOpen = false)}
|
||
/>
|
||
|
||
<Modal open={pickerFor != null} title={t('studio.pickerTitle')} onclose={() => (pickerFor = null)}>
|
||
{#if imageResults.length}
|
||
<div class="picker-grid">
|
||
{#each imageResults as entry (entry.path)}
|
||
<button type="button" class="picker-item" onclick={() => pickImageResult(entry.path)}>
|
||
<img src={assetUrl(entry.path)} alt={downloadName(entry.path)} loading="lazy" />
|
||
<span class="picker-use">{t('studio.pickerPick')}</span>
|
||
</button>
|
||
{/each}
|
||
</div>
|
||
{:else}
|
||
<p class="empty-line">{t('studio.pickerEmpty')}</p>
|
||
{/if}
|
||
</Modal>
|
||
|
||
<ConfirmDialog
|
||
bind:open={deleteOpen}
|
||
title={deleteTitle}
|
||
message={deleteMessage}
|
||
confirmLabel={t('studio.deleteBtn')}
|
||
cancelLabel={t('common.cancel')}
|
||
danger
|
||
onconfirm={doDelete}
|
||
oncancel={() => {
|
||
deleteJobId = null;
|
||
deleteOpen = false;
|
||
}}
|
||
/>
|
||
|
||
<style>
|
||
.ref-groups {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 14px;
|
||
}
|
||
.h3-hint {
|
||
padding: 8px 10px;
|
||
border: 1px solid var(--border-strong);
|
||
border-radius: 8px;
|
||
background: var(--surface-2);
|
||
}
|
||
.h3-hint p {
|
||
margin: 0;
|
||
font-size: 11px;
|
||
line-height: 1.6;
|
||
color: var(--text-3);
|
||
}
|
||
.h3-hint p.warn {
|
||
color: var(--accent);
|
||
}
|
||
.studio-page {
|
||
display: grid;
|
||
grid-template-columns: 352px minmax(0, 1fr) 296px;
|
||
gap: 20px;
|
||
padding: 20px 28px 40px;
|
||
max-width: 1720px;
|
||
width: 100%;
|
||
box-sizing: border-box;
|
||
margin: 0 auto;
|
||
align-items: start;
|
||
}
|
||
|
||
.card {
|
||
background: var(--surface);
|
||
border: 1px solid var(--border);
|
||
border-radius: 10px;
|
||
}
|
||
|
||
/* ---------------- params ---------------- */
|
||
.param-col {
|
||
background: var(--surface);
|
||
border: 1px solid var(--border);
|
||
border-radius: 10px;
|
||
padding: 16px 18px 0;
|
||
position: sticky;
|
||
top: 0;
|
||
max-height: calc(100vh - 64px - 40px);
|
||
overflow-y: auto;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
.param-empty {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 10px;
|
||
padding: 36px 12px;
|
||
color: var(--text-3);
|
||
font-size: 12px;
|
||
text-align: center;
|
||
}
|
||
.param-empty p {
|
||
margin: 0;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.f-field {
|
||
display: block;
|
||
margin-bottom: 13px;
|
||
}
|
||
.f-label {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 4px;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
color: var(--text-2);
|
||
margin-bottom: 6px;
|
||
}
|
||
.f-label em {
|
||
color: var(--error);
|
||
font-style: normal;
|
||
}
|
||
.f-hint-inline {
|
||
margin-left: auto;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 5px;
|
||
font-size: 10.5px;
|
||
font-weight: 400;
|
||
color: var(--text-3);
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
.f-input {
|
||
width: 100%;
|
||
box-sizing: border-box;
|
||
background: var(--surface-2);
|
||
border: 1px solid var(--border-strong);
|
||
border-radius: 7px;
|
||
padding: 8px 11px;
|
||
color: var(--text);
|
||
font-family: inherit;
|
||
font-size: 13px;
|
||
}
|
||
.f-input.mono {
|
||
font-size: 12px;
|
||
}
|
||
.f-input:focus {
|
||
outline: none;
|
||
border-color: var(--accent-line);
|
||
}
|
||
.f-input.invalid {
|
||
border-color: var(--err-line);
|
||
}
|
||
.f-error {
|
||
display: block;
|
||
margin-top: 5px;
|
||
font-size: 11.5px;
|
||
color: var(--error);
|
||
}
|
||
.prompt-area {
|
||
resize: vertical;
|
||
min-height: 96px;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.style-link {
|
||
background: none;
|
||
border: none;
|
||
padding: 0;
|
||
margin-left: 8px;
|
||
font-family: inherit;
|
||
font-size: 11px;
|
||
color: var(--accent);
|
||
cursor: pointer;
|
||
white-space: nowrap;
|
||
}
|
||
.style-link:hover {
|
||
text-decoration: underline;
|
||
}
|
||
|
||
.slots {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
gap: 12px;
|
||
margin-bottom: 13px;
|
||
}
|
||
.slot-cell.span2 {
|
||
grid-column: 1 / -1;
|
||
}
|
||
.slot-span {
|
||
grid-column: 1 / -1;
|
||
}
|
||
|
||
.pair-row {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
gap: 12px;
|
||
}
|
||
.size-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
}
|
||
.size-x {
|
||
color: var(--text-3);
|
||
}
|
||
|
||
.a-range {
|
||
width: 100%;
|
||
appearance: none;
|
||
height: 4px;
|
||
border-radius: 999px;
|
||
background: var(--surface-3);
|
||
outline: none;
|
||
}
|
||
.a-range::-webkit-slider-thumb {
|
||
appearance: none;
|
||
width: 12px;
|
||
height: 12px;
|
||
border-radius: 50%;
|
||
background: var(--text);
|
||
cursor: pointer;
|
||
transition: transform 150ms;
|
||
}
|
||
.a-range::-webkit-slider-thumb:hover {
|
||
transform: scale(1.15);
|
||
}
|
||
|
||
.rest-params {
|
||
border-top: 1px dashed var(--border-strong);
|
||
padding-top: 12px;
|
||
margin-top: 2px;
|
||
}
|
||
.rest-title {
|
||
font-size: 11.5px;
|
||
font-weight: 600;
|
||
color: var(--text-3);
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.action-bar {
|
||
position: sticky;
|
||
bottom: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
padding: 12px 0 14px;
|
||
margin-top: auto;
|
||
background: linear-gradient(to top, var(--surface) 70%, transparent);
|
||
border-top: 1px solid var(--border);
|
||
}
|
||
.eta {
|
||
font-size: 11px;
|
||
color: var(--text-3);
|
||
line-height: 1.5;
|
||
text-align: center;
|
||
}
|
||
|
||
/* ---------------- center ---------------- */
|
||
.center-col {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 20px;
|
||
min-width: 0;
|
||
}
|
||
|
||
.task-card {
|
||
padding: 16px 18px;
|
||
}
|
||
.task-card.idle {
|
||
border-style: dashed;
|
||
}
|
||
.task-head {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
min-width: 0;
|
||
}
|
||
.task-name {
|
||
flex: 1;
|
||
min-width: 0;
|
||
font-size: 13.5px;
|
||
font-weight: 600;
|
||
color: var(--text);
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
.tag {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
padding: 2px 9px;
|
||
border-radius: 999px;
|
||
font-size: 10.5px;
|
||
font-weight: 600;
|
||
flex-shrink: 0;
|
||
}
|
||
.tag.info,
|
||
.tag.cloud {
|
||
color: var(--text-2);
|
||
background: var(--bg-4);
|
||
}
|
||
.task-body {
|
||
margin-top: 12px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
}
|
||
.pct {
|
||
font-size: 30px;
|
||
font-weight: 600;
|
||
color: var(--text);
|
||
line-height: 1.1;
|
||
}
|
||
.progress {
|
||
height: 4px;
|
||
border-radius: 999px;
|
||
background: var(--surface-3);
|
||
overflow: hidden;
|
||
}
|
||
.progress .fill {
|
||
height: 100%;
|
||
border-radius: 999px;
|
||
background: var(--run-grad);
|
||
box-shadow: 0 0 8px var(--run-soft);
|
||
transition: width var(--d-progress) linear;
|
||
}
|
||
.task-meta {
|
||
font-size: 11px;
|
||
color: var(--text-3);
|
||
}
|
||
|
||
.link-danger {
|
||
background: none;
|
||
border: none;
|
||
padding: 5px 8px;
|
||
font-family: inherit;
|
||
font-size: 12px;
|
||
color: var(--error);
|
||
cursor: pointer;
|
||
border-radius: 6px;
|
||
opacity: 0.85;
|
||
}
|
||
.link-danger:hover:not(:disabled) {
|
||
opacity: 1;
|
||
background: var(--error-dim);
|
||
}
|
||
|
||
.results {
|
||
padding: 16px 18px;
|
||
}
|
||
.panel-head {
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
margin-bottom: 12px;
|
||
}
|
||
.panel-head h2,
|
||
.history-head h2 {
|
||
margin: 0;
|
||
font-size: 14.5px;
|
||
font-weight: 600;
|
||
color: var(--text);
|
||
}
|
||
.panel-hint {
|
||
font-size: 11px;
|
||
color: var(--text-3);
|
||
}
|
||
|
||
.result-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
|
||
gap: 10px;
|
||
}
|
||
.thumb {
|
||
position: relative;
|
||
border: 1px solid var(--border);
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
padding: 0;
|
||
background: var(--surface-2);
|
||
cursor: pointer;
|
||
aspect-ratio: 1;
|
||
transition: border-color 150ms;
|
||
}
|
||
.thumb img {
|
||
width: 100%;
|
||
height: 100%;
|
||
object-fit: cover;
|
||
display: block;
|
||
}
|
||
.thumb:hover {
|
||
border-color: var(--line-2);
|
||
}
|
||
.thumb.selected {
|
||
border: 2px solid var(--accent);
|
||
box-shadow: 0 0 10px var(--accent-glow);
|
||
}
|
||
.sel-badge {
|
||
position: absolute;
|
||
top: 6px;
|
||
left: 6px;
|
||
padding: 1px 8px;
|
||
border-radius: 999px;
|
||
background: var(--accent-dim);
|
||
color: var(--accent);
|
||
font-size: 10px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.result-bar {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
margin-top: 12px;
|
||
padding-top: 12px;
|
||
border-top: 1px solid var(--border);
|
||
flex-wrap: wrap;
|
||
}
|
||
.summary {
|
||
font-size: 11px;
|
||
color: var(--text-3);
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
.bar-actions {
|
||
display: inline-flex;
|
||
gap: 8px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
/* video player */
|
||
.player {
|
||
position: relative;
|
||
border-radius: 9px;
|
||
overflow: hidden;
|
||
background: #000;
|
||
aspect-ratio: 16 / 9;
|
||
}
|
||
.player video {
|
||
width: 100%;
|
||
height: 100%;
|
||
object-fit: contain;
|
||
display: block;
|
||
}
|
||
.play-center {
|
||
position: absolute;
|
||
top: 50%;
|
||
left: 50%;
|
||
transform: translate(-50%, -50%);
|
||
width: 56px;
|
||
height: 56px;
|
||
border-radius: 50%;
|
||
border: 1px solid rgba(255, 255, 255, 0.35);
|
||
background: rgba(0, 0, 0, 0.6);
|
||
backdrop-filter: blur(4px);
|
||
color: var(--text);
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
cursor: pointer;
|
||
transition: transform 150ms;
|
||
}
|
||
.play-center:hover {
|
||
transform: translate(-50%, -50%) scale(1.06);
|
||
}
|
||
.dur-badge {
|
||
position: absolute;
|
||
top: 10px;
|
||
right: 10px;
|
||
padding: 2px 8px;
|
||
border-radius: 6px;
|
||
background: rgba(0, 0, 0, 0.6);
|
||
color: var(--text);
|
||
font-size: 10.5px;
|
||
}
|
||
.ctrl-bar {
|
||
position: absolute;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
padding: 8px 12px;
|
||
background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
|
||
}
|
||
.ctrl-btn {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 30px;
|
||
height: 30px;
|
||
border: none;
|
||
border-radius: 50%;
|
||
background: rgba(255, 255, 255, 0.08);
|
||
color: var(--text);
|
||
cursor: pointer;
|
||
}
|
||
.ctrl-btn:hover {
|
||
background: rgba(255, 255, 255, 0.18);
|
||
}
|
||
.track {
|
||
flex: 1;
|
||
height: 4px;
|
||
border-radius: 999px;
|
||
background: rgba(255, 255, 255, 0.18);
|
||
overflow: hidden;
|
||
cursor: pointer;
|
||
}
|
||
.track-fill {
|
||
height: 100%;
|
||
border-radius: 999px;
|
||
background: var(--accent);
|
||
}
|
||
.timecode {
|
||
font-size: 10.5px;
|
||
color: var(--text);
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.frame-strip {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
margin-top: 12px;
|
||
flex-wrap: wrap;
|
||
}
|
||
.strip-label {
|
||
font-size: 11px;
|
||
color: var(--text-3);
|
||
}
|
||
.frame-item {
|
||
position: relative;
|
||
width: 96px;
|
||
border-radius: 7px;
|
||
overflow: hidden;
|
||
border: 1px solid var(--border);
|
||
}
|
||
.frame-item img {
|
||
display: block;
|
||
width: 100%;
|
||
aspect-ratio: 16 / 9;
|
||
object-fit: cover;
|
||
}
|
||
.frame-tag {
|
||
position: absolute;
|
||
left: 6px;
|
||
bottom: 4px;
|
||
font-size: 10px;
|
||
color: var(--text);
|
||
background: rgba(0, 0, 0, 0.55);
|
||
border-radius: 4px;
|
||
padding: 0 5px;
|
||
}
|
||
|
||
/* workflow guidance */
|
||
.wf-guide {
|
||
padding: 24px;
|
||
}
|
||
.wf-guide h2 {
|
||
margin: 0 0 10px;
|
||
font-size: 15px;
|
||
font-weight: 600;
|
||
color: var(--text);
|
||
}
|
||
.wf-guide p {
|
||
margin: 0 0 12px;
|
||
font-size: 12.5px;
|
||
color: var(--text-2);
|
||
line-height: 1.7;
|
||
}
|
||
.missing-note {
|
||
border-left: 2px solid var(--accent);
|
||
padding-left: 10px;
|
||
color: var(--text-3);
|
||
font-size: 11.5px;
|
||
}
|
||
.guide-actions {
|
||
display: flex;
|
||
gap: 10px;
|
||
}
|
||
|
||
.empty-line {
|
||
margin: 0;
|
||
padding: 18px 4px;
|
||
font-size: 12px;
|
||
color: var(--text-3);
|
||
line-height: 1.7;
|
||
}
|
||
|
||
/* ---------------- history ---------------- */
|
||
.history-col {
|
||
background: var(--surface);
|
||
border: 1px solid var(--border);
|
||
border-radius: 10px;
|
||
padding: 14px 16px;
|
||
position: sticky;
|
||
top: 0;
|
||
max-height: calc(100vh - 64px - 40px);
|
||
display: flex;
|
||
flex-direction: column;
|
||
min-width: 0;
|
||
}
|
||
.history-head {
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
margin-bottom: 10px;
|
||
}
|
||
.history-list {
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow-y: auto;
|
||
gap: 2px;
|
||
}
|
||
.hist-row {
|
||
display: flex;
|
||
gap: 10px;
|
||
padding: 8px 6px;
|
||
border-radius: 8px;
|
||
min-height: 44px;
|
||
align-items: center;
|
||
cursor: pointer;
|
||
}
|
||
.hist-row:hover {
|
||
background: var(--surface-2);
|
||
}
|
||
.hist-row:focus-visible {
|
||
outline: 1px solid var(--accent);
|
||
outline-offset: -1px;
|
||
}
|
||
/* The row loaded into the preview stays marked, and its delete stays visible. */
|
||
.hist-row.selected {
|
||
background: var(--surface-2);
|
||
box-shadow: inset 2px 0 0 var(--accent);
|
||
}
|
||
.hist-row.selected .hist-del {
|
||
opacity: 1;
|
||
}
|
||
.hist-row.failed {
|
||
background: var(--error-dim);
|
||
}
|
||
.hist-thumb {
|
||
width: 52px;
|
||
height: 52px;
|
||
flex-shrink: 0;
|
||
border-radius: 7px;
|
||
overflow: hidden;
|
||
border: 1px solid var(--border);
|
||
position: relative;
|
||
background: var(--surface-2);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
color: var(--text-3);
|
||
}
|
||
.hist-row.video {
|
||
flex-direction: column;
|
||
align-items: stretch;
|
||
gap: 8px;
|
||
padding: 8px 6px 12px;
|
||
border-bottom: 1px solid var(--border);
|
||
border-radius: 0;
|
||
}
|
||
.hist-thumb.video {
|
||
width: 100%;
|
||
height: auto;
|
||
aspect-ratio: 16 / 9;
|
||
}
|
||
.hist-thumb img,
|
||
.hist-thumb video {
|
||
width: 100%;
|
||
height: 100%;
|
||
object-fit: cover;
|
||
display: block;
|
||
}
|
||
.hist-thumb .dur {
|
||
position: absolute;
|
||
right: 4px;
|
||
bottom: 4px;
|
||
font-size: 9.5px;
|
||
padding: 0 4px;
|
||
border-radius: 4px;
|
||
background: rgba(0, 0, 0, 0.6);
|
||
color: var(--text);
|
||
}
|
||
.thumb-fallback.failed {
|
||
color: var(--error);
|
||
}
|
||
.hist-body {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
.hist-name {
|
||
font-size: 12.5px;
|
||
font-weight: 600;
|
||
color: var(--text);
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
.hist-meta {
|
||
font-size: 10.5px;
|
||
color: var(--text-3);
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
.hist-status {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
margin-top: 2px;
|
||
}
|
||
.st {
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
}
|
||
.st.ok {
|
||
color: var(--success);
|
||
}
|
||
.st.run {
|
||
color: var(--run);
|
||
}
|
||
.st.queue {
|
||
color: var(--text-3);
|
||
font-weight: 400;
|
||
}
|
||
.st.fail {
|
||
color: var(--error);
|
||
}
|
||
.fail-link {
|
||
background: none;
|
||
border: none;
|
||
padding: 0;
|
||
font-family: inherit;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
color: var(--error);
|
||
cursor: pointer;
|
||
text-decoration: underline;
|
||
}
|
||
.fail-link:disabled {
|
||
opacity: 0.5;
|
||
cursor: default;
|
||
}
|
||
.hist-del {
|
||
margin-left: auto;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 22px;
|
||
height: 22px;
|
||
border: none;
|
||
border-radius: 6px;
|
||
background: transparent;
|
||
color: var(--text-3);
|
||
cursor: pointer;
|
||
opacity: 0;
|
||
transition: opacity 150ms;
|
||
}
|
||
.hist-row:hover .hist-del {
|
||
opacity: 1;
|
||
}
|
||
.hist-del:focus-visible {
|
||
opacity: 1;
|
||
}
|
||
/* Touch devices have no hover to reveal the delete affordance. */
|
||
@media (hover: none) {
|
||
.hist-del {
|
||
opacity: 1;
|
||
}
|
||
}
|
||
.hist-del:hover {
|
||
color: var(--error);
|
||
background: var(--error-dim);
|
||
}
|
||
.hist-error {
|
||
margin-top: 3px;
|
||
font-size: 10.5px;
|
||
color: var(--error);
|
||
line-height: 1.5;
|
||
display: -webkit-box;
|
||
-webkit-line-clamp: 2;
|
||
-webkit-box-orient: vertical;
|
||
overflow: hidden;
|
||
}
|
||
|
||
/* picker */
|
||
.picker-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
||
gap: 10px;
|
||
}
|
||
.picker-item {
|
||
position: relative;
|
||
border: 1px solid var(--border);
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
padding: 0;
|
||
background: var(--surface-2);
|
||
cursor: pointer;
|
||
}
|
||
.picker-item img {
|
||
width: 100%;
|
||
aspect-ratio: 1;
|
||
object-fit: cover;
|
||
display: block;
|
||
}
|
||
.picker-use {
|
||
position: absolute;
|
||
inset: auto 0 0 0;
|
||
padding: 3px 0;
|
||
background: rgba(0, 0, 0, 0.6);
|
||
color: var(--text);
|
||
font-size: 10.5px;
|
||
opacity: 0;
|
||
transition: opacity 150ms;
|
||
}
|
||
.picker-item:hover .picker-use {
|
||
opacity: 1;
|
||
}
|
||
|
||
.link-accent {
|
||
background: none;
|
||
border: none;
|
||
padding: 0;
|
||
font-family: inherit;
|
||
font-size: 12px;
|
||
color: var(--accent);
|
||
cursor: pointer;
|
||
text-decoration: none;
|
||
}
|
||
.link-accent:hover {
|
||
text-decoration: underline;
|
||
}
|
||
|
||
/* A-style shared button look for raw <a> */
|
||
.a-btn {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
min-height: 34px;
|
||
padding: 0 16px;
|
||
border-radius: 8px;
|
||
font-family: inherit;
|
||
font-size: 13px;
|
||
font-weight: 600;
|
||
cursor: pointer;
|
||
border: 1px solid transparent;
|
||
text-decoration: none;
|
||
transition:
|
||
background-color 150ms cubic-bezier(0.16, 1, 0.3, 1),
|
||
border-color 150ms,
|
||
transform 100ms;
|
||
}
|
||
.dot {
|
||
width: 7px;
|
||
height: 7px;
|
||
border-radius: 50%;
|
||
flex-shrink: 0;
|
||
}
|
||
.dot.green {
|
||
background: var(--success);
|
||
}
|
||
.dot.red {
|
||
background: var(--error);
|
||
}
|
||
.dot.gray {
|
||
background: var(--text-3);
|
||
}
|
||
/* ---------------- responsive (spec §4.5) ---------------- */
|
||
@media (max-width: 1439px) {
|
||
.studio-page {
|
||
grid-template-columns: 320px minmax(0, 1fr);
|
||
padding: 18px 22px 36px;
|
||
}
|
||
.history-col {
|
||
grid-column: 1 / -1;
|
||
position: static;
|
||
max-height: none;
|
||
}
|
||
.history-list {
|
||
flex-direction: row;
|
||
overflow-x: auto;
|
||
padding-bottom: 6px;
|
||
}
|
||
.hist-row,
|
||
.hist-row.video {
|
||
flex-shrink: 0;
|
||
width: 240px;
|
||
border: 1px solid var(--border);
|
||
border-radius: 8px;
|
||
background: var(--surface-2);
|
||
}
|
||
}
|
||
|
||
@media (max-width: 1023px) {
|
||
.studio-page {
|
||
grid-template-columns: 1fr;
|
||
padding: 14px 16px 32px;
|
||
}
|
||
.param-col {
|
||
position: static;
|
||
max-height: none;
|
||
}
|
||
.slots,
|
||
.pair-row {
|
||
grid-template-columns: 1fr;
|
||
}
|
||
}
|
||
</style>
|