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:
Jony
2026-10-21 20:13:55 +08:00
parent 532d4a9541
commit ff1cf830fa
27 changed files with 1810 additions and 341 deletions
+102 -19
View File
@@ -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);