Publish Seedance 2.5 draft mode and video updates
- Add the 样片模式 flow: 480p draft generation, a linkable draft task ID, and pre-flight verification before the 1080p final request. - Allow reference images and audio in video edit/extend requests, matching the provider's 2.5 contract. - Move 主模型 and 样片模式 ahead of 生成模式, default 主模型 to seedance 2.5, and migrate saved widget values. - Refresh the video panel, asset API response logs, and LLM node handling; cover the new behavior with offline tests.
This commit is contained in:
+3
-2
@@ -2,7 +2,7 @@ import { app } from "../../../scripts/app.js";
|
||||
|
||||
// ─── State ───────────────────────────────────────────────────────────────────
|
||||
const STORAGE_KEY = "o1key-chat-conversations";
|
||||
const DEFAULT_MODEL = "gpt-6-sol";
|
||||
const DEFAULT_MODEL = "claude-opus-5-5";
|
||||
let conversations = [];
|
||||
let activeConvId = null;
|
||||
let currentModel = DEFAULT_MODEL;
|
||||
@@ -55,10 +55,11 @@ function truncateFilename(name, maxLen = 20) {
|
||||
|
||||
const MODELS = [
|
||||
DEFAULT_MODEL,
|
||||
"gpt-6.1-sol",
|
||||
"gpt-6-astra",
|
||||
"gpt-5.6-sol",
|
||||
"gpt-5.5",
|
||||
"claude-fable-5",
|
||||
"gemini-4-argon",
|
||||
"gemini-3.1-pro-preview",
|
||||
"deepseek-v4-pro",
|
||||
"doubao-seed-2.0-pro",
|
||||
|
||||
@@ -55,6 +55,7 @@ const SEEDANCE_AUTO_PASS_ROUTES = new Set(["国内", "海外", "海外HC", "海
|
||||
const SEEDANCE_AUTO_PASS_NODE_TYPES = new Set(["SeedanceAutoPass", "SeedanceAutoPassBatch"]);
|
||||
const SEEDANCE_ASSET_CREATE_TOGGLES = new Set(["关闭", "打开"]);
|
||||
const SEEDANCE_ASSET_CREATE_MODES = new Set(["标准", "高并发", "HC"]);
|
||||
const SEEDANCE_DRAFT_MODES = new Set(["关闭", "生成样片", "按样片生成"]);
|
||||
const SEEDANCE_AUTO_PASS_DEFAULT_MODE = "多模态";
|
||||
const SEEDANCE_AUTO_PASS_MODE_ALIASES = new Map([
|
||||
["多模态参考生视频", "多模态"],
|
||||
@@ -1027,11 +1028,43 @@ const MIGRATIONS = [
|
||||
&& REMOVED_NANO_BANANA_RESOLUTIONS.has(wv[4]),
|
||||
apply: (wv) => { wv[4] = "1K"; },
|
||||
},
|
||||
{
|
||||
type: "SeedanceAutoPass",
|
||||
note: "将主模型与样片模式移到生成模式之前",
|
||||
when: (wv) => wv.length >= 62
|
||||
&& typeof wv[0] === "string"
|
||||
&& _isSeedanceAutoPassMode(wv[1])
|
||||
&& SEEDANCE_AUTO_PASS_MODELS.has(wv[2]),
|
||||
apply: (wv) => {
|
||||
const hasDraft = wv.length >= 65
|
||||
&& SEEDANCE_DRAFT_MODES.has(wv[wv.length - 2])
|
||||
&& typeof wv[wv.length - 1] === "string";
|
||||
const hasOutputFormat = hasDraft || wv.length >= 63;
|
||||
const draftMode = hasDraft ? wv[wv.length - 2] : "关闭";
|
||||
const draftTaskId = hasDraft ? wv[wv.length - 1] : "";
|
||||
const bodyEnd = hasDraft ? wv.length - 2 : wv.length;
|
||||
const body = wv.slice(3, bodyEnd);
|
||||
const [prompt, mode, model] = wv;
|
||||
wv.splice(
|
||||
0,
|
||||
wv.length,
|
||||
prompt,
|
||||
model,
|
||||
draftMode,
|
||||
mode,
|
||||
...body,
|
||||
...(hasOutputFormat ? [] : ["mp4"]),
|
||||
draftTaskId,
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
function _isSeedanceAutoPassMode(value) {
|
||||
return value === "多模态"
|
||||
|| value === "首尾帧"
|
||||
|| value === "视频编辑"
|
||||
|| value === "视频延长"
|
||||
|| value === "多模态参考生视频"
|
||||
|| value === "图生视频-首帧"
|
||||
|| value === "图生视频-首尾帧"
|
||||
|
||||
@@ -35,9 +35,12 @@ const MODE_OPTIONS = [
|
||||
{ value: "first_frame", label: "首帧图生视频", description: "1 张图" },
|
||||
{ value: "first_last_frame", label: "首尾帧生视频", description: "2 张图" },
|
||||
{ value: "multimodal", label: "多模态参考", description: "图/视频/音频" },
|
||||
{ value: "edit", label: "视频编辑", description: "Seedance 2.5" },
|
||||
{ value: "extend", label: "视频延长", description: "Seedance 2.5" },
|
||||
];
|
||||
const ASSET_CREATION_OPTIONS = [
|
||||
{ value: "auto", label: "自动创建", description: "直接上传" },
|
||||
{ value: "direct", label: "直接上传", description: "公网 URL" },
|
||||
{ value: "auto", label: "自动创建", description: "创建素材" },
|
||||
{ value: "manual", label: "手动", description: "填写素材 ID" },
|
||||
];
|
||||
const RATIO_OPTIONS = [
|
||||
@@ -51,8 +54,9 @@ const MODEL_CAPS = {
|
||||
"seedance-2.0": { maxDuration: 15, resolutions: ["480p", "720p", "1080p", "4k"] },
|
||||
"seedance-2.0-fast": { maxDuration: 15, resolutions: ["480p", "720p"] },
|
||||
"seedance-2.0-mini": { maxDuration: 15, resolutions: ["480p", "720p"] },
|
||||
"seedance-2.5": { maxDuration: 30, resolutions: ["480p", "720p", "1080p", "4k"] },
|
||||
"seedance-2.5": { maxDuration: 30, resolutions: ["480p", "720p", "1080p"] },
|
||||
};
|
||||
const VIDEO_ONLY_MODES = new Set(["edit", "extend"]);
|
||||
|
||||
const CSS = `
|
||||
.o1vg-panel{
|
||||
@@ -495,6 +499,8 @@ function makeMultimodalMediaSection(node) {
|
||||
{ key: "reference_audios", title: "参考音频", shortTitle: "音频", hint: "节奏与声音参考", accept: "audio/*,.wav,.mp3,.m4a,.aac,.flac,.ogg", kind: "audio", icon: "♫" },
|
||||
];
|
||||
const section = el("section", "o1vg-assets o1vg-multimodal-assets");
|
||||
// 官方 2.5 的视频编辑/延长接受参考图、参考视频与参考音频,素材区不再按模式裁剪。
|
||||
const visibleSources = () => sources;
|
||||
const header = el("div", "o1vg-asset-header");
|
||||
const meta = el("div", "o1vg-asset-meta");
|
||||
const hintElement = el("span", "o1vg-asset-hint");
|
||||
@@ -555,8 +561,8 @@ function makeMultimodalMediaSection(node) {
|
||||
releaseVideoPreviews(track);
|
||||
track.replaceChildren();
|
||||
const media = ensureMediaState(node);
|
||||
hintElement.textContent = sources.map((source) => `${source.shortTitle} ${(media[source.key] || []).length}`).join(" · ");
|
||||
for (const source of sources) {
|
||||
hintElement.textContent = visibleSources().map((source) => `${source.shortTitle} ${(media[source.key] || []).length}`).join(" · ");
|
||||
for (const source of visibleSources()) {
|
||||
const values = media[source.key] || [];
|
||||
values.forEach((item, index) => {
|
||||
const sortable = values.length > 1;
|
||||
@@ -762,8 +768,8 @@ async function submitNativeJob(source, targets, request, batchId) {
|
||||
function setPanelStatus(node, text = "", kind = "") { if (!node._o1vgStatus) return; node._o1vgStatus.textContent = text; node._o1vgStatus.className = `o1vg-status${text ? " visible" : ""}${kind === "error" ? " error" : ""}`; }
|
||||
function setPromptWriteStatus(node, text = "", kind = "") { if (!node._o1vgPromptWriteStatus) return; node._o1vgPromptWriteStatus.textContent = text; node._o1vgPromptWriteStatus.className = `o1vg-prompt-write-status${text ? " visible" : ""}${kind ? ` ${kind}` : ""}`; }
|
||||
function fitGenerator(node, mode, manualAssets = false) {
|
||||
const automaticHeights = { text: 679, first_frame: 824, first_last_frame: 964, multimodal: 824 };
|
||||
const manualHeights = { text: 679, first_frame: 739, first_last_frame: 739, multimodal: 824 };
|
||||
const automaticHeights = { text: 679, first_frame: 824, first_last_frame: 964, multimodal: 824, edit: 824, extend: 824 };
|
||||
const manualHeights = { text: 679, first_frame: 739, first_last_frame: 739, multimodal: 824, edit: 739, extend: 739 };
|
||||
const heights = manualAssets ? manualHeights : automaticHeights;
|
||||
node.setSize([Math.max(560, Number(node.size?.[0]) || 560), heights[mode] || heights.text]);
|
||||
}
|
||||
@@ -805,7 +811,7 @@ function setupGenerator(node) {
|
||||
const model = makeSelect(MODEL_OPTIONS, widget(node, "model")?.value || "seedance-2.0", "模型");
|
||||
const route = makeSelect(ROUTE_OPTIONS, widget(node, "route")?.value || "domestic", "模型线路");
|
||||
const mode = makeSelect(MODE_OPTIONS, widget(node, "generation_mode")?.value || "multimodal", "生成模式");
|
||||
const assetCreation = makeSelect(ASSET_CREATION_OPTIONS, widget(node, "asset_creation_mode")?.value || "auto", "素材创建");
|
||||
const assetCreation = makeSelect(ASSET_CREATION_OPTIONS, widget(node, "asset_creation_mode")?.value || "direct", "素材创建");
|
||||
const resolution = makeSelect(["480p", "720p", "1080p", "4k"], widget(node, "resolution")?.value || "720p", "分辨率");
|
||||
const ratio = makeSelect(RATIO_OPTIONS, widget(node, "aspect_ratio")?.value || "auto", "宽高比");
|
||||
const duration = makeSelect(["auto", ...Array.from({ length: 27 }, (_, index) => ({ value: String(index + 4), label: `${index + 4}秒` }))], widget(node, "duration")?.value || "5", "时长");
|
||||
@@ -834,21 +840,33 @@ function setupGenerator(node) {
|
||||
const selectedDuration = duration.value === "auto" || Number(duration.value) <= caps.maxDuration ? duration.value : "15";
|
||||
if (duration._options.length !== durationOptions.length) setDropdownOptions(duration, durationOptions, selectedDuration);
|
||||
const activeMode = mode.value;
|
||||
const videoOnly = VIDEO_ONLY_MODES.has(activeMode);
|
||||
if (videoOnly && model.value !== "seedance-2.5") setDropdownValue(mode, "multimodal");
|
||||
const activeModeResolved = mode.value;
|
||||
if (VIDEO_ONLY_MODES.has(activeModeResolved)) {
|
||||
// 2.5 的编辑/延长只支持 adaptive 比例,编辑还要求 -1 时长
|
||||
setDropdownValue(ratio, "auto");
|
||||
if (activeModeResolved === "edit") setDropdownValue(duration, "auto");
|
||||
}
|
||||
const isSeedance = model.value.startsWith("seedance-");
|
||||
const assetModeAvailable = isSeedance && activeMode !== "text";
|
||||
if (!assetModeAvailable && assetCreation.value !== "auto") setDropdownValue(assetCreation, "auto");
|
||||
const manualAssets = assetModeAvailable && assetCreation.value === "manual";
|
||||
const assetModeAvailable = isSeedance && activeModeResolved !== "text";
|
||||
if (!assetModeAvailable && assetCreation.value !== "direct") setDropdownValue(assetCreation, "direct");
|
||||
const assetMode = assetCreation.value;
|
||||
const manualAssets = assetModeAvailable && assetMode === "manual";
|
||||
assetCreationField.style.display = isSeedance ? "grid" : "none";
|
||||
assetCreation._trigger.disabled = !assetModeAvailable;
|
||||
firstSection.style.display = !manualAssets && ["first_frame", "first_last_frame"].includes(activeMode) ? "flex" : "none";
|
||||
lastSection.style.display = !manualAssets && activeMode === "first_last_frame" ? "flex" : "none";
|
||||
multimodalSection.style.display = !manualAssets && activeMode === "multimodal" ? "flex" : "none";
|
||||
imageIdField.style.display = manualAssets ? "grid" : "none";
|
||||
videoIdField.style.display = manualAssets && activeMode === "multimodal" ? "grid" : "none";
|
||||
audioIdField.style.display = manualAssets && activeMode === "multimodal" ? "grid" : "none";
|
||||
setWidget(node, "prompt", prompt.value); setWidget(node, "model", model.value); setWidget(node, "route", route.value); setWidget(node, "generation_mode", activeMode); setWidget(node, "asset_creation_mode", manualAssets ? "manual" : "auto"); setWidget(node, "resolution", resolution.value); setWidget(node, "aspect_ratio", ratio.value); setWidget(node, "duration", duration.value); setWidget(node, "generate_audio", generateAudio.value === "on"); setWidget(node, "return_last_frame", returnLast.value === "on"); setWidget(node, "seed", Math.max(0, Math.floor(Number(seed.value) || 0))); setWidget(node, "filename_prefix", prefix.value); setWidget(node, "save_location", location.value);
|
||||
ratio._trigger.disabled = VIDEO_ONLY_MODES.has(activeModeResolved);
|
||||
duration._trigger.disabled = activeModeResolved === "edit";
|
||||
const showsVideo = activeModeResolved === "multimodal" || VIDEO_ONLY_MODES.has(activeModeResolved);
|
||||
firstSection.style.display = !manualAssets && ["first_frame", "first_last_frame"].includes(activeModeResolved) ? "flex" : "none";
|
||||
lastSection.style.display = !manualAssets && activeModeResolved === "first_last_frame" ? "flex" : "none";
|
||||
multimodalSection.style.display = !manualAssets && showsVideo ? "flex" : "none";
|
||||
imageIdField.style.display = manualAssets && activeModeResolved === "multimodal" ? "grid" : "none";
|
||||
videoIdField.style.display = manualAssets && showsVideo ? "grid" : "none";
|
||||
audioIdField.style.display = manualAssets && activeModeResolved === "multimodal" ? "grid" : "none";
|
||||
setWidget(node, "prompt", prompt.value); setWidget(node, "model", model.value); setWidget(node, "route", route.value); setWidget(node, "generation_mode", activeModeResolved); setWidget(node, "asset_creation_mode", manualAssets ? "manual" : (assetMode === "auto" ? "auto" : "direct")); setWidget(node, "resolution", resolution.value); setWidget(node, "aspect_ratio", ratio.value); setWidget(node, "duration", duration.value); setWidget(node, "generate_audio", generateAudio.value === "on"); setWidget(node, "return_last_frame", returnLast.value === "on"); setWidget(node, "seed", Math.max(0, Math.floor(Number(seed.value) || 0))); setWidget(node, "filename_prefix", prefix.value); setWidget(node, "save_location", location.value);
|
||||
node.properties.o1keyVideoAssets = { images: imageIds.value, videos: videoIds.value, audios: audioIds.value };
|
||||
fitGenerator(node, activeMode, manualAssets); updateNode(node);
|
||||
fitGenerator(node, activeModeResolved, manualAssets); updateNode(node);
|
||||
};
|
||||
const restore = () => {
|
||||
const value = (name, fallback) => widget(node, name)?.value ?? fallback;
|
||||
@@ -856,7 +874,7 @@ function setupGenerator(node) {
|
||||
model.value = value("model", "seedance-2.0");
|
||||
route.value = value("route", "domestic");
|
||||
mode.value = value("generation_mode", "multimodal");
|
||||
assetCreation.value = value("asset_creation_mode", "auto");
|
||||
assetCreation.value = value("asset_creation_mode", "direct");
|
||||
resolution.value = value("resolution", "720p");
|
||||
ratio.value = value("aspect_ratio", "auto");
|
||||
duration.value = value("duration", "5");
|
||||
@@ -941,33 +959,41 @@ function setupGenerator(node) {
|
||||
if (node._o1vgWriting) { setPromptWriteStatus(node, "请等待 AI帮写完成", "error"); return; }
|
||||
if (node._o1vgUploading) { setPanelStatus(node, "请等待参考素材上传完成", "error"); return; }
|
||||
sync(); const media = ensureMediaState(node);
|
||||
const videoOnly = VIDEO_ONLY_MODES.has(mode.value);
|
||||
const manualAssets = mode.value !== "text" && assetCreation.value === "manual";
|
||||
const selectedAssets = {
|
||||
images: parseIds(imageIds.value),
|
||||
videos: parseIds(videoIds.value),
|
||||
audios: parseIds(audioIds.value),
|
||||
};
|
||||
if (videoOnly && !String(prompt.value || "").trim()) return toast("error", "缺少提示词", "视频编辑和视频延长必须填写提示词");
|
||||
if (manualAssets && mode.value === "first_frame" && selectedAssets.images.length !== 1) return toast("error", "素材 ID 数量不正确", "首帧图生视频需要填写一个图片素材 ID");
|
||||
if (manualAssets && mode.value === "first_last_frame" && selectedAssets.images.length !== 2) return toast("error", "素材 ID 数量不正确", "首尾帧生视频需要填写两个图片素材 ID");
|
||||
if (manualAssets && mode.value === "multimodal" && !Object.values(selectedAssets).some((items) => items.length)) return toast("error", "缺少素材 ID", "请至少填写一个图片、视频或音频素材 ID");
|
||||
if (manualAssets && videoOnly && selectedAssets.videos.length !== 1) return toast("error", "素材 ID 数量不正确", "视频编辑和视频延长需要填写一个视频素材 ID");
|
||||
if (!manualAssets && mode.value === "first_frame" && !media.first_frame) return toast("error", "缺少首帧", "请选择一张首帧图片");
|
||||
if (!manualAssets && mode.value === "first_last_frame" && (!media.first_frame || !media.last_frame)) return toast("error", "缺少图片", "请选择首帧和尾帧图片");
|
||||
if (!manualAssets && videoOnly && (media.reference_videos || []).length !== 1) return toast("error", "缺少参考视频", "视频编辑和视频延长需要上传一段参考视频");
|
||||
const automaticMedia = mode.value === "text"
|
||||
? {}
|
||||
: mode.value === "first_frame"
|
||||
? { first_frame: media.first_frame }
|
||||
: mode.value === "first_last_frame"
|
||||
? { first_frame: media.first_frame, last_frame: media.last_frame }
|
||||
: { reference_images: media.reference_images || [], reference_videos: media.reference_videos || [], reference_audios: media.reference_audios || [] };
|
||||
const manualRequestAssets = mode.value === "multimodal"
|
||||
? selectedAssets
|
||||
: { images: selectedAssets.images, videos: [], audios: [] };
|
||||
: videoOnly
|
||||
? { reference_videos: media.reference_videos || [] }
|
||||
: { reference_images: media.reference_images || [], reference_videos: media.reference_videos || [], reference_audios: media.reference_audios || [] };
|
||||
const manualRequestAssets = videoOnly
|
||||
? { images: [], videos: selectedAssets.videos, audios: [] }
|
||||
: mode.value === "multimodal"
|
||||
? selectedAssets
|
||||
: { images: selectedAssets.images, videos: [], audios: [] };
|
||||
const request = {
|
||||
provider: "seedance",
|
||||
model: model.value,
|
||||
route: route.value,
|
||||
generation_mode: mode.value,
|
||||
asset_creation_mode: manualAssets ? "manual" : "auto",
|
||||
asset_creation_mode: manualAssets ? "manual" : (assetCreation.value === "auto" ? "auto" : "direct"),
|
||||
prompt: prompt.value,
|
||||
resolution: resolution.value,
|
||||
aspect_ratio: ratio.value,
|
||||
|
||||
@@ -10,13 +10,24 @@ const LIMITED_RESOLUTION_MODELS = new Set([
|
||||
"seedance 2.0 fast",
|
||||
"seedance 2.0 mini",
|
||||
]);
|
||||
const NO_4K_RESOLUTIONS = ["480p", "720p", "1080p"];
|
||||
const RESOLUTION_FALLBACK = "720p";
|
||||
const DRAFT_OFF = "关闭";
|
||||
const DRAFT_PREVIEW = "生成样片";
|
||||
const DRAFT_FINAL = "按样片生成";
|
||||
const DRAFT_PREVIEW_RESOLUTION = "480p";
|
||||
|
||||
function resolutionsForModel(model) {
|
||||
if (LIMITED_RESOLUTION_MODELS.has(model)) return LIMITED_RESOLUTIONS;
|
||||
if (model === MODEL_25) return NO_4K_RESOLUTIONS;
|
||||
return ALL_RESOLUTIONS;
|
||||
}
|
||||
const ID_WIDGET_GROUPS = [
|
||||
{ prefix: "图片素材ID", maximum: 30 },
|
||||
{ prefix: "视频素材ID", maximum: 10 },
|
||||
{ prefix: "音频素材ID", maximum: 10 },
|
||||
];
|
||||
const UNAVAILABLE_WIDGETS = ["联网搜索", "返回末帧图片"];
|
||||
const UNAVAILABLE_WIDGETS = ["联网搜索"];
|
||||
|
||||
const durationOptions = (maximum) => [
|
||||
"自动",
|
||||
@@ -50,23 +61,32 @@ function inputOptions(input) {
|
||||
function syncModeInputs(node) {
|
||||
const state = node.__o1keyAutoPassModeInputs;
|
||||
if (!state || state.syncing) return;
|
||||
const frameMode = findWidget(node, "生成模式")?.value === "首尾帧";
|
||||
const mode = findWidget(node, "生成模式")?.value;
|
||||
const frameMode = mode === "首尾帧";
|
||||
// 按样片生成不再读取任何素材,隐藏全部媒体插座避免误解。
|
||||
const draftFinal = findWidget(node, "样片模式")?.value === DRAFT_FINAL;
|
||||
const autogrow = node.comfyDynamic.autogrow;
|
||||
state.syncing = true;
|
||||
try {
|
||||
// Suspend native Autogrow before removing its sockets; otherwise a
|
||||
// disconnect callback can recreate an inactive reference input.
|
||||
// 官方 2.5 的视频编辑/延长同样接受参考图和参考音频,只有首尾帧模式需要替换插座。
|
||||
for (const group of REFERENCE_GROUPS) {
|
||||
if (frameMode) delete autogrow[group];
|
||||
else autogrow[group] = state.groups[group];
|
||||
const active = !frameMode && !draftFinal;
|
||||
if (active) autogrow[group] = state.groups[group];
|
||||
else delete autogrow[group];
|
||||
}
|
||||
for (let index = node.inputs.length - 1; index >= 0; index--) {
|
||||
const input = node.inputs[index];
|
||||
if (frameMode ? isReferenceInput(input) : FRAME_INPUTS.includes(input.name)) {
|
||||
node.removeInput(index);
|
||||
let removable = false;
|
||||
if (draftFinal) {
|
||||
removable = isReferenceInput(input) || FRAME_INPUTS.includes(input.name);
|
||||
} else if (frameMode) {
|
||||
removable = isReferenceInput(input);
|
||||
} else {
|
||||
removable = FRAME_INPUTS.includes(input.name);
|
||||
}
|
||||
if (removable) node.removeInput(index);
|
||||
}
|
||||
const templates = frameMode ? state.frames : state.references;
|
||||
const templates = draftFinal ? [] : (frameMode ? state.frames : state.references);
|
||||
for (const template of templates) {
|
||||
const exists = frameMode
|
||||
? node.inputs.some((input) => input.name === template.name)
|
||||
@@ -107,7 +127,7 @@ function guardModeInputs(node) {
|
||||
}
|
||||
|
||||
// 与 SeedanceMultiModal 相同:保留控件和值的序列化顺序,仅渐进显隐单行 ID。
|
||||
function setIdWidgetHidden(widget, hidden) {
|
||||
function setWidgetHidden(widget, hidden) {
|
||||
if (!widget || (widget.__o1keyAutoPassIdHidden === hidden
|
||||
&& widget.hidden === hidden && widget.options?.hidden === hidden)) return;
|
||||
widget.__o1keyAutoPassIdHidden = hidden;
|
||||
@@ -129,7 +149,16 @@ function setIdWidgetHidden(widget, hidden) {
|
||||
function syncIdWidgets(node) {
|
||||
if (node.comfyClass !== "SeedanceAutoPass") return;
|
||||
// Temporarily unavailable controls stay serialized for saved workflows.
|
||||
for (const name of UNAVAILABLE_WIDGETS) setIdWidgetHidden(findWidget(node, name), true);
|
||||
for (const name of UNAVAILABLE_WIDGETS) setWidgetHidden(findWidget(node, name), true);
|
||||
// 样片任务 ID:只有「按样片生成」且没有连线时才需要手填。
|
||||
const draftIdLinked = node.inputs?.some(
|
||||
(input) => input.name === "样片任务ID输入"
|
||||
&& input.link !== null && input.link !== undefined,
|
||||
);
|
||||
setWidgetHidden(
|
||||
findWidget(node, "样片任务ID"),
|
||||
findWidget(node, "样片模式")?.value !== DRAFT_FINAL || Boolean(draftIdLinked),
|
||||
);
|
||||
const assetMode = findAssetModeWidget(node);
|
||||
// 该开关自身始终显示,只控制下方 ID 行。
|
||||
if (assetMode) {
|
||||
@@ -145,7 +174,7 @@ function syncIdWidgets(node) {
|
||||
if (typeof widget?.value === "string" && widget.value.trim()) highestFilled = index;
|
||||
});
|
||||
const visibleCount = manual ? Math.min(maximum, Math.max(1, highestFilled + 2)) : 0;
|
||||
widgets.forEach((widget, index) => setIdWidgetHidden(widget, index >= visibleCount));
|
||||
widgets.forEach((widget, index) => setWidgetHidden(widget, index >= visibleCount));
|
||||
}
|
||||
if (typeof node.computeSize === "function" && typeof node.setSize === "function") {
|
||||
const size = node.computeSize([...node.size]);
|
||||
@@ -173,6 +202,18 @@ function guardIdWidgets(node) {
|
||||
syncIdWidgets(node);
|
||||
}
|
||||
|
||||
// 样片任务 ID 支持连线:连上后隐藏手填框,断开后恢复。
|
||||
function guardDraftIdInput(node) {
|
||||
if (node.comfyClass !== "SeedanceAutoPass" || node.__o1keyDraftIdGuard) return;
|
||||
node.__o1keyDraftIdGuard = true;
|
||||
const originalConnectionsChange = node.onConnectionsChange;
|
||||
node.onConnectionsChange = function () {
|
||||
const result = originalConnectionsChange?.apply(this, arguments);
|
||||
syncIdWidgets(node);
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
function notify(detail) {
|
||||
app.extensionManager?.toast?.add({
|
||||
severity: "info",
|
||||
@@ -193,24 +234,45 @@ function updateDynamicParameters(node, silent = false) {
|
||||
const routeWidget = findWidget(node, "模型线路");
|
||||
const resolutionWidget = findWidget(node, "分辨率");
|
||||
const durationWidget = findWidget(node, "时长");
|
||||
const draftWidget = findWidget(node, "样片模式");
|
||||
if (!modelWidget || !routeWidget || !resolutionWidget || !durationWidget) return;
|
||||
|
||||
const is25 = modelWidget.value === MODEL_25;
|
||||
const hasLimitedResolution = LIMITED_RESOLUTION_MODELS.has(modelWidget.value);
|
||||
|
||||
// 样片模式仅 2.5 可用:其他模型直接隐藏,并强制回到「关闭」。
|
||||
if (draftWidget) {
|
||||
setWidgetHidden(draftWidget, !is25);
|
||||
if (!is25 && draftWidget.value !== DRAFT_OFF) {
|
||||
setWidgetValue(draftWidget, DRAFT_OFF);
|
||||
if (!silent) notify("样片模式仅支持 Seedance 2.5,已关闭样片模式。");
|
||||
}
|
||||
}
|
||||
const draftValue = draftWidget?.value ?? DRAFT_OFF;
|
||||
const draftPreview = draftValue === DRAFT_PREVIEW;
|
||||
|
||||
const allowedResolutions = draftPreview
|
||||
? [DRAFT_PREVIEW_RESOLUTION]
|
||||
: resolutionsForModel(modelWidget.value);
|
||||
const fallbackResolution = draftPreview ? DRAFT_PREVIEW_RESOLUTION : RESOLUTION_FALLBACK;
|
||||
const maximumDuration = is25 ? 30 : 15;
|
||||
durationWidget.options ??= {};
|
||||
durationWidget.options.values = is25 ? DURATIONS_25 : DURATIONS_20;
|
||||
resolutionWidget.options ??= {};
|
||||
resolutionWidget.options.values = hasLimitedResolution ? LIMITED_RESOLUTIONS : ALL_RESOLUTIONS;
|
||||
resolutionWidget.options.values = allowedResolutions;
|
||||
|
||||
if (LEGACY_MODEL_ROUTES.has(routeWidget.value)) {
|
||||
setWidgetValue(routeWidget, OVERSEAS_ROUTE);
|
||||
}
|
||||
|
||||
if (hasLimitedResolution && !LIMITED_RESOLUTIONS.includes(resolutionWidget.value)) {
|
||||
setWidgetValue(resolutionWidget, RESOLUTION_FALLBACK);
|
||||
if (!allowedResolutions.includes(resolutionWidget.value)) {
|
||||
setWidgetValue(resolutionWidget, fallbackResolution);
|
||||
if (!silent) {
|
||||
notify(`${modelWidget.value} 仅支持 480p/720p,已自动切换为 ${RESOLUTION_FALLBACK}。`);
|
||||
notify(
|
||||
draftPreview
|
||||
? "样片模式只输出 480p 预览,已自动切换为 480p。"
|
||||
: `${modelWidget.value} 仅支持 ${allowedResolutions.join(" / ")},`
|
||||
+ `已自动切换为 ${fallbackResolution}。`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +284,9 @@ function updateDynamicParameters(node, silent = false) {
|
||||
}
|
||||
}
|
||||
|
||||
// 样片模式/ID 行隐藏后需要重算节点高度。
|
||||
syncIdWidgets(node);
|
||||
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
|
||||
@@ -254,9 +319,10 @@ function guardNode(node) {
|
||||
|
||||
const originalResolutionCallback = resolutionWidget.callback;
|
||||
resolutionWidget.callback = function (value) {
|
||||
if (LIMITED_RESOLUTION_MODELS.has(modelWidget.value) && !LIMITED_RESOLUTIONS.includes(value)) {
|
||||
const allowedResolutions = resolutionsForModel(modelWidget.value);
|
||||
if (!allowedResolutions.includes(value)) {
|
||||
resolutionWidget.value = RESOLUTION_FALLBACK;
|
||||
notify(`${modelWidget.value} 仅支持 480p/720p。`);
|
||||
notify(`${modelWidget.value} 仅支持 ${allowedResolutions.join(" / ")}。`);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
return originalResolutionCallback?.call(this, RESOLUTION_FALLBACK);
|
||||
}
|
||||
@@ -277,6 +343,21 @@ function guardNode(node) {
|
||||
return originalDurationCallback?.apply(this, arguments);
|
||||
};
|
||||
|
||||
const draftWidget = findWidget(node, "样片模式");
|
||||
if (draftWidget) {
|
||||
const originalDraftCallback = draftWidget.callback;
|
||||
draftWidget.callback = function () {
|
||||
const result = originalDraftCallback?.apply(this, arguments);
|
||||
updateDynamicParameters(node);
|
||||
syncModeInputs(node);
|
||||
syncIdWidgets(node);
|
||||
if (draftWidget.value === DRAFT_FINAL) {
|
||||
notify("按样片生成只提交样片任务 ID,提示词、素材和参数都会复用样片。");
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
updateDynamicParameters(node, true);
|
||||
}
|
||||
|
||||
@@ -287,6 +368,7 @@ app.registerExtension({
|
||||
if (!NODE_TYPES.has(node.comfyClass)) return;
|
||||
guardNode(node);
|
||||
guardIdWidgets(node);
|
||||
guardDraftIdInput(node);
|
||||
guardModeInputs(node);
|
||||
},
|
||||
|
||||
@@ -294,6 +376,7 @@ app.registerExtension({
|
||||
if (!NODE_TYPES.has(node.comfyClass)) return;
|
||||
updateDynamicParameters(node, true);
|
||||
guardIdWidgets(node);
|
||||
guardDraftIdInput(node);
|
||||
guardModeInputs(node);
|
||||
syncModeInputs(node);
|
||||
syncIdWidgets(node);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { app } from "../../../scripts/app.js";
|
||||
|
||||
// ── Seedance 多模态节点参数联动 ───────────────────────────────────────────────
|
||||
//
|
||||
// fast、mini 不支持 1080p / 4k;2.5 支持全部分辨率和最长 30 秒。
|
||||
// fast、mini 不支持 1080p / 4k;2.5 最高 1080p,且支持最长 30 秒。
|
||||
// 当用户切换到受限模型,或选择不支持的分辨率时,
|
||||
// 弹 toast 报错并把分辨率回退到 720p,避免提交后才在后端报错浪费一次调用。
|
||||
//
|
||||
@@ -16,7 +16,14 @@ const isLimitedModel = (v) => LIMITED_MODELS.has(v);
|
||||
const MODEL_25 = "seedance 2.5";
|
||||
const ALL_RESOLUTIONS = ["720p", "1080p", "4k", "480p"];
|
||||
const LIMITED_RESOLUTIONS = ["720p", "480p"];
|
||||
const NO_4K_RESOLUTIONS = ["720p", "1080p", "480p"];
|
||||
const RESOLUTION_FALLBACK = "720p";
|
||||
|
||||
function resolutionsForModel(model) {
|
||||
if (isLimitedModel(model)) return LIMITED_RESOLUTIONS;
|
||||
if (model === MODEL_25) return NO_4K_RESOLUTIONS;
|
||||
return ALL_RESOLUTIONS;
|
||||
}
|
||||
const durationOptions = (maximum) => [
|
||||
"自动",
|
||||
...Array.from({ length: maximum - 3 }, (_, index) => `${index + 4}秒`),
|
||||
@@ -51,17 +58,20 @@ function updateDynamicParameters(node, silent = false) {
|
||||
const durationWidget = findWidget(node, "时长");
|
||||
if (!modelWidget || !resWidget || !durationWidget) return;
|
||||
|
||||
const limited = isLimitedModel(modelWidget.value);
|
||||
const maximumDuration = modelWidget.value === MODEL_25 ? 30 : 15;
|
||||
const allowedResolutions = resolutionsForModel(modelWidget.value);
|
||||
resWidget.options ??= {};
|
||||
resWidget.options.values = limited ? LIMITED_RESOLUTIONS : ALL_RESOLUTIONS;
|
||||
resWidget.options.values = allowedResolutions;
|
||||
durationWidget.options ??= {};
|
||||
durationWidget.options.values = maximumDuration === 30 ? DURATIONS_25 : DURATIONS_20;
|
||||
|
||||
if (limited && !LIMITED_RESOLUTIONS.includes(resWidget.value)) {
|
||||
if (!allowedResolutions.includes(resWidget.value)) {
|
||||
setWidgetValue(resWidget, RESOLUTION_FALLBACK);
|
||||
if (!silent) {
|
||||
notify(`${modelWidget.value} 仅支持 480p/720p,已自动切换为 ${RESOLUTION_FALLBACK}。`);
|
||||
notify(
|
||||
`${modelWidget.value} 仅支持 ${allowedResolutions.join(" / ")},`
|
||||
+ `已自动切换为 ${RESOLUTION_FALLBACK}。`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,9 +104,10 @@ function guardNode(node) {
|
||||
|
||||
const origResCb = resWidget.callback;
|
||||
resWidget.callback = function (value) {
|
||||
if (isLimitedModel(modelWidget.value) && !LIMITED_RESOLUTIONS.includes(value)) {
|
||||
const allowedResolutions = resolutionsForModel(modelWidget.value);
|
||||
if (!allowedResolutions.includes(value)) {
|
||||
resWidget.value = RESOLUTION_FALLBACK;
|
||||
notify(`${modelWidget.value} 仅支持 480p/720p。`);
|
||||
notify(`${modelWidget.value} 仅支持 ${allowedResolutions.join(" / ")}。`);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
return origResCb?.call(this, RESOLUTION_FALLBACK);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user