Compare commits

...
Author SHA1 Message Date
总工andmultica-agent 48e16ae443 feat(studio): image result deletion and video history click-to-play (HEL-641)
Co-authored-by: multica-agent <github@multica.ai>
2026-09-29 17:48:00 +08:00
施工员andmultica-agent 319c7b049b fix: nine review follow-ups for connections & workflow foundation (HEL-619)
1. .form-col border-box — 384px is the outer width (a6 spec)
2. import preview counts all analyzed inputs, matching inline/studio counts
3. SSRF guard also runs on endpoint save (create + patch)
4. schemeless/garbled URL is a 400 format error, not a DNS-classified probe failure
5. ComfyUI health probe timeout 120s → 5s (matches the test probe)
6. workflow delete refuses (409) while pending/running jobs use it; delete errors surfaced in the UI
7. agent_llm_assignments: per-role incremental merge server-side + single-role delta payloads
8. test_shell_tool now portable (interpreter on PATH; PYTHON+approval instead of ffprobe)
9. test_video_continue pauses the queue singleton via monkeypatch (no leak into test_workbench)

Co-authored-by: multica-agent <github@multica.ai>
2026-09-29 16:13:00 +08:00
总工andmultica-agent e3bfe771af feat(workflows): manual output-node mapping for unknown custom outputs (HEL-638)
Unknown custom output nodes are never auto-typed by class-name semantics;
they stay pending until the user designates the real output node(s) and
media type. Picking a usage alone no longer enables a workflow, reanalyze/
migration/field edits never overwrite a user mapping, generation harvests
only the mapped nodes from ComfyUI history, and media-type mismatches or
missing node results fail for real instead of faking completion.

Co-authored-by: multica-agent <github@multica.ai>
2026-09-29 14:44:37 +08:00
32 changed files with 1871 additions and 262 deletions
@@ -13,6 +13,11 @@ from calliope.comfyui.registry import IMAGE_CLASSES, AUDIO_CLASSES, VIDEO_CLASSE
logger = logging.getLogger("calliope.comfyui") logger = logging.getLogger("calliope.comfyui")
# Reachability probe budget (HEL-619): matches the connections-page test
# probe (5s). Without it health() inherits the 120s client default, so a
# bad endpoint hangs every queued job for two minutes before failing.
HEALTH_TIMEOUT_SEC = 5.0
def _surface_error(prefix: str, resp: httpx.Response) -> RuntimeError: def _surface_error(prefix: str, resp: httpx.Response) -> RuntimeError:
"""Raise with ComfyUI's own error body instead of an opaque status line. """Raise with ComfyUI's own error body instead of an opaque status line.
@@ -76,7 +81,9 @@ class ComfyUIClient:
async def health(self) -> bool: async def health(self) -> bool:
try: try:
resp = await self._http.get(f"{self.base_url}/system_stats") resp = await self._http.get(
f"{self.base_url}/system_stats", timeout=HEALTH_TIMEOUT_SEC
)
return resp.status_code == 200 return resp.status_code == 200
except Exception: except Exception:
return False return False
@@ -285,16 +292,46 @@ class ComfyUIClient:
except Exception as exc: except Exception as exc:
logger.warning("ComfyUI interrupt failed: %s", exc) logger.warning("ComfyUI interrupt failed: %s", exc)
def extract_outputs(self, history: dict[str, Any]) -> list[dict[str, str]]: # History items carry no explicit media type — infer from the file
# extension first, then the history key the node reported under.
_VIDEO_EXTS = frozenset({".mp4", ".webm", ".mkv", ".mov", ".gif", ".m4v", ".avi", ".flv"})
_IMAGE_EXTS = frozenset({".png", ".jpg", ".jpeg", ".webp", ".bmp", ".tif", ".tiff"})
@classmethod
def _infer_media_kind(cls, filename: str, history_key: str) -> str | None:
ext = Path(str(filename)).suffix.lower()
if ext in cls._VIDEO_EXTS:
return "video"
if ext in cls._IMAGE_EXTS:
return "image"
if history_key in ("gifs", "videos"):
return "video"
return None
def extract_outputs(
self, history: dict[str, Any], node_kinds: dict[str, str] | None = None
) -> list[dict[str, str]]:
"""Media items in a finished prompt's history.
``node_kinds`` (HEL-638) scopes the harvest to the workflow's
confirmed output nodes — {nodeId: image|video} — so results from
nodes the user never designated are ignored, and each item carries
the node id plus its inferred media kind for mismatch checks.
"""
outputs: list[dict[str, str]] = [] outputs: list[dict[str, str]] = []
for _node_id, node_out in (history.get("outputs") or {}).items(): for node_id, node_out in (history.get("outputs") or {}).items():
if node_kinds is not None and str(node_id) not in node_kinds:
continue
for key in ("images", "gifs", "videos"): for key in ("images", "gifs", "videos"):
for item in node_out.get(key) or []: for item in node_out.get(key) or []:
filename = item.get("filename", "")
outputs.append( outputs.append(
{ {
"filename": item.get("filename", ""), "filename": filename,
"subfolder": item.get("subfolder", ""), "subfolder": item.get("subfolder", ""),
"type": item.get("type", "output"), "type": item.get("type", "output"),
"node_id": str(node_id),
"media_kind": self._infer_media_kind(filename, key) or "",
} }
) )
return outputs return outputs
@@ -83,10 +83,11 @@ def workflow_warnings(workflow: dict[str, Any]) -> list[dict[str, str]]:
} }
) )
# HEL-636: a workflow without any recognizable output node can never # HEL-636/638: a workflow without any recognizable output node can never
# return a result — block it with a readable reason instead of letting # return a result — block it with a readable reason instead of letting
# ComfyUI run blind. Unknown *possible* savers (needs_mapping) don't # ComfyUI run blind. Unknown candidates (needs_mapping) don't trigger
# trigger this: the user confirms those on the import page. # this: the user designates them on the import/connections page, and
# until then the row stays disabled.
from calliope.comfyui.parser import detect_output_nodes from calliope.comfyui.parser import detect_output_nodes
outputs = detect_output_nodes(workflow) outputs = detect_output_nodes(workflow)
@@ -110,7 +111,7 @@ def workflow_warnings(workflow: dict[str, Any]) -> list[dict[str, str]]:
"code": "unknown_output_node", "code": "unknown_output_node",
"node_id": names, "node_id": names,
"message": f"存在无法识别的输出节点({names})," "message": f"存在无法识别的输出节点({names}),"
"导入后需人工确认用途;结果按 ComfyUI 历史的图片/视频输出提取", "需人工指定实际输出节点及其媒体类型(图片/视频)后才能生成",
} }
) )
return found return found
@@ -0,0 +1,148 @@
"""Stored output-node mapping for imported workflows (HEL-638).
Unknown custom output nodes are never auto-typed. The import confirm page
(or the connections table) stores the user's explicit designation — which
node ids are the real outputs and each one's media type — in
``workflows.output_map`` with ``output_map_source='user'``. Everything that
re-derives schemas (reanalyze, migration, plain field edits) must keep that
decision; only a fresh explicit payload replaces it.
Rows without unknown candidates carry an ``auto`` map derived from the
trusted registry/tagged outputs so the generation path always knows which
history nodes to harvest.
"""
from __future__ import annotations
import json
from typing import Any
from calliope.comfyui.parser import parse_dynamic_outputs
from calliope.comfyui.registry import (
IMAGE_OUTPUT_CLASSES,
NUMBER_CLASSES,
TEXT_AREA_CLASSES,
VIDEO_OUTPUT_CLASSES,
)
VALID_OUTPUT_KINDS = ("image", "video")
def _wiring_class(class_type: str) -> bool:
"""Parameter / wiring classes can never be designated as outputs."""
return (
not class_type
or class_type in TEXT_AREA_CLASSES
or class_type in NUMBER_CLASSES
or class_type.startswith("Empty")
or class_type.startswith("Primitive")
)
def _entry_public(entry: dict[str, Any]) -> dict[str, Any]:
out = {
"nodeId": str(entry.get("nodeId") or ""),
"kind": entry.get("kind"),
}
if entry.get("label"):
out["label"] = entry["label"]
if entry.get("class_type"):
out["class_type"] = entry["class_type"]
return out
def auto_output_map(workflow: dict[str, Any]) -> list[dict[str, Any]]:
"""Trusted outputs only (tagged titles / registry classes)."""
if not isinstance(workflow, dict):
return []
return [
_entry_public(o)
for o in parse_dynamic_outputs(workflow)
if o.get("kind") in VALID_OUTPUT_KINDS
]
def needs_user_output_map(workflow: dict[str, Any]) -> bool:
"""True when the graph has unknown output candidates (HEL-638)."""
if not isinstance(workflow, dict):
return False
return any(
o.get("evidence") == "unknown_node" for o in parse_dynamic_outputs(workflow)
)
def validate_output_map(
workflow: dict[str, Any], entries: Any
) -> list[str]:
"""Chinese problems with a user-supplied output map; empty = valid."""
if not isinstance(entries, list) or not entries:
return ["输出节点映射不能为空:请至少指定一个输出节点及其媒体类型"]
seen: set[str] = set()
problems: list[str] = []
for entry in entries:
if not isinstance(entry, dict):
problems.append("输出节点映射格式有误(应为对象数组)")
continue
nid = str(entry.get("nodeId") or "")
node = workflow.get(nid) if isinstance(workflow, dict) else None
if not nid or not isinstance(node, dict):
problems.append(f"输出节点 {nid or '?'} 不存在于该工作流中")
continue
ct = str(node.get("class_type") or "").strip()
if not ct:
problems.append(f"节点 {nid} 缺少节点类型,不能作为输出节点")
elif _wiring_class(ct) and ct not in (IMAGE_OUTPUT_CLASSES | VIDEO_OUTPUT_CLASSES):
problems.append(f"节点 {nid}({ct})是参数/连线节点,不能作为输出节点")
if entry.get("kind") not in VALID_OUTPUT_KINDS:
problems.append(f"输出节点 {nid} 的媒体类型必须是图片或视频")
if nid in seen:
problems.append(f"输出节点 {nid} 重复指定")
seen.add(nid)
return problems
def load_output_map(raw: str | None) -> list[dict[str, Any]]:
if not raw:
return []
try:
data = json.loads(raw)
except (json.JSONDecodeError, TypeError):
return []
return data if isinstance(data, list) else []
def resolve_output_map(
output_map_raw: str | None, source: str | None, workflow: dict[str, Any]
) -> tuple[list[dict[str, Any]], str | None]:
"""The map generation harvests, plus whose decision it is.
A user map wins as long as its node ids still exist in the stored JSON
(defensive pruning — PATCH cannot edit the JSON, but keep it safe);
otherwise the trusted auto map applies. Empty list back means "not
confirmed yet".
"""
if source == "user":
entries = [
e for e in load_output_map(output_map_raw) if str(e.get("nodeId") or "") in
(workflow if isinstance(workflow, dict) else {})
]
if entries:
return entries, "user"
return [], None
auto = auto_output_map(workflow)
return (auto, "auto") if auto else ([], None)
def mapping_problem(
workflow: dict[str, Any], output_map_raw: str | None, source: str | None
) -> str | None:
"""Chinese reason this workflow's outputs are not confirmed, else None."""
if not needs_user_output_map(workflow):
return None
entries, resolved = resolve_output_map(output_map_raw, source, workflow)
if resolved == "user" and entries:
return None
return (
"该工作流含无法识别的自定义输出节点,需在「ComfyUI 连接」页指定"
"实际输出节点及其媒体类型(图片/视频)后才能启用或生成"
)
+127 -39
View File
@@ -12,6 +12,8 @@ from calliope.comfyui.registry import (
IMAGE_CLASSES, IMAGE_CLASSES,
IMAGE_OUTPUT_CLASSES, IMAGE_OUTPUT_CLASSES,
IMAGE_URL_CLASSES, IMAGE_URL_CLASSES,
NUMBER_CLASSES,
TEXT_AREA_CLASSES,
VIDEO_CLASSES, VIDEO_CLASSES,
VIDEO_OUTPUT_CLASSES, VIDEO_OUTPUT_CLASSES,
ComfyOutputKind, ComfyOutputKind,
@@ -707,6 +709,16 @@ def parse_dynamic_outputs(workflow: dict[str, Any]) -> list[dict[str, Any]]:
# Nodes whose output another node consumes are wiring, not results. A node # Nodes whose output another node consumes are wiring, not results. A node
# nothing consumes is a sink; media sinks are the workflow's outputs. # nothing consumes is a sink; media sinks are the workflow's outputs.
_INPUT_ONLY_CLASSES = IMAGE_CLASSES | IMAGE_URL_CLASSES | AUDIO_CLASSES | VIDEO_CLASSES _INPUT_ONLY_CLASSES = IMAGE_CLASSES | IMAGE_URL_CLASSES | AUDIO_CLASSES | VIDEO_CLASSES
# Latent/source shapers (EmptyLatentImage…) are wiring even when nothing
# consumes them — they never carry results out of the graph.
_SOURCE_ONLY_CLASSES = _INPUT_ONLY_CLASSES | TEXT_AREA_CLASSES | NUMBER_CLASSES
# Classes that are known-internal tails: standard decode steps and cache
# cleaners consume media but never emit history outputs, so they can never
# be output candidates (HEL-638: a graph ending in these has no output).
_NON_OUTPUT_CLASSES = frozenset(
{"VAEDecode", "VAEDecodeTiled", "VAEDecodeAudio", "easy cleanGpuUsed"}
)
# Widget names save-style custom nodes carry, and link input names that mark # Widget names save-style custom nodes carry, and link input names that mark
# "consumes rendered media" — used to flag unknown sinks that need mapping. # "consumes rendered media" — used to flag unknown sinks that need mapping.
@@ -743,6 +755,17 @@ def _unknown_sink_looks_like_save(node: dict[str, Any], workflow: dict[str, Any]
return False return False
def _node_has_save_widget(node: dict[str, Any]) -> bool:
"""A concrete save widget (filename/prefix/path) — the only signal that
counts for unknown nodes that something else consumes; media links from
decode steps are meaningless there (every transform has them)."""
inputs = node.get("inputs") or {}
return any(
name in _SAVE_WIDGET_NAMES and isinstance(val, (str, int, float, bool))
for name, val in inputs.items()
)
def _video_semantics(workflow: dict[str, Any]) -> bool: def _video_semantics(workflow: dict[str, Any]) -> bool:
"""Auxiliary evidence the graph renders video (frame counts, video nodes).""" """Auxiliary evidence the graph renders video (frame counts, video nodes)."""
for node in workflow.values(): for node in workflow.values():
@@ -757,52 +780,78 @@ def _video_semantics(workflow: dict[str, Any]) -> bool:
return False return False
def _suggest_output_kind(class_type: str, videoish: bool) -> str | None:
"""Best-guess media type for an unknown candidate — UI default only."""
lower = class_type.lower()
if "video" in lower or "animatediff" in lower:
return "video"
if "image" in lower or "save" in lower:
return "image"
return "video" if videoish else None
def _unknown_output_entry(
nid: str, node: dict[str, Any], workflow: dict[str, Any], videoish: bool
) -> dict[str, Any]:
ct = str(node.get("class_type") or "")
return {
"nodeId": nid,
"label": _title_of(node) or ct,
"role": None,
# HEL-638: unknown custom nodes are never auto-typed — the user
# picks the media type; `suggested_kind` is only a form default.
"kind": None,
"class_type": ct,
"evidence": "unknown_node",
"suggested_kind": _suggest_output_kind(ct, videoish),
}
def detect_output_nodes(workflow: dict[str, Any]) -> list[dict[str, Any]]: def detect_output_nodes(workflow: dict[str, Any]) -> list[dict[str, Any]]:
"""Infer output nodes of an untagged workflow from its sinks. """Infer output nodes of an untagged workflow from its sinks.
Exact registry classes (SaveImage, VHS_VideoCombine…) count whether or Exact registry classes (SaveImage, VHS_VideoCombine…) count whether or
not something downstream consumes them (a SaveVideo feeding a not something downstream consumes them (a SaveVideo feeding a
cache-cleanup tail is still the output). Fuzzy class-name matches only cache-cleanup tail is still the output). Every OTHER class at an output
count at a sink. Unknown sink classes that look like savers become position is an *unknown candidate*: kind stays null, the import page
``other`` + ``unknown_node`` evidence — the import page then asks the asks the user to designate the real output node(s) and their media
user to map them. type, and the workflow stays pending until then (HEL-638). Sinks with
no save features only become candidates when the graph has no trusted
output at all — next to a real saver they are utility tails.
""" """
if not isinstance(workflow, dict): if not isinstance(workflow, dict):
return [] return []
consumers = _consumers(workflow) consumers = _consumers(workflow)
videoish = _video_semantics(workflow) videoish = _video_semantics(workflow)
results: list[dict[str, Any]] = [] registry_outputs: list[dict[str, Any]] = []
candidates: list[dict[str, Any]] = []
seen: set[str] = set()
def _is_wiring(ct: str) -> bool:
return (
not ct
or ct in _SOURCE_ONLY_CLASSES
or ct in _NON_OUTPUT_CLASSES
or ct.startswith("Empty")
)
# 1) Trusted registry outputs at sink positions.
for nid, node in _sinks(workflow, consumers): for nid, node in _sinks(workflow, consumers):
ct = str(node.get("class_type") or "") ct = str(node.get("class_type") or "")
if not ct or ct in _INPUT_ONLY_CLASSES:
continue
title = _title_of(node)
if ct in IMAGE_OUTPUT_CLASSES or ct in VIDEO_OUTPUT_CLASSES: if ct in IMAGE_OUTPUT_CLASSES or ct in VIDEO_OUTPUT_CLASSES:
kind: ComfyOutputKind = "video" if ct in VIDEO_OUTPUT_CLASSES else "image" registry_outputs.append(
evidence = "registry" {
else: "nodeId": nid,
kind = class_to_output_kind(ct) "label": _title_of(node) or ct,
if kind in ("image", "video"): "role": None,
evidence = "class_name_match" "kind": "video" if ct in VIDEO_OUTPUT_CLASSES else "image",
elif _unknown_sink_looks_like_save(node, workflow): "class_type": ct,
# A custom saver we cannot type: with video evidence in the "evidence": "registry",
# graph it most likely saves video, but the user decides. }
kind = "video" if videoish else "other" )
evidence = "unknown_node" seen.add(nid)
else:
continue # utility/primitive sink — not an output # 2) Registry output classes consumed by other nodes are outputs too.
results.append(
{
"nodeId": nid,
"label": title or ct,
"role": None,
"kind": kind,
"class_type": ct,
"evidence": evidence,
}
)
# Registry output classes consumed by other nodes are outputs too.
seen = {r["nodeId"] for r in results}
for nid, node in sorted( for nid, node in sorted(
((str(k), v) for k, v in workflow.items() if isinstance(v, dict)), ((str(k), v) for k, v in workflow.items() if isinstance(v, dict)),
key=lambda kv: _node_sort_key(kv[0]), key=lambda kv: _node_sort_key(kv[0]),
@@ -810,7 +859,7 @@ def detect_output_nodes(workflow: dict[str, Any]) -> list[dict[str, Any]]:
ct = str(node.get("class_type") or "") ct = str(node.get("class_type") or "")
if nid in seen or ct not in (IMAGE_OUTPUT_CLASSES | VIDEO_OUTPUT_CLASSES): if nid in seen or ct not in (IMAGE_OUTPUT_CLASSES | VIDEO_OUTPUT_CLASSES):
continue continue
results.append( registry_outputs.append(
{ {
"nodeId": nid, "nodeId": nid,
"label": _title_of(node) or ct, "label": _title_of(node) or ct,
@@ -820,6 +869,37 @@ def detect_output_nodes(workflow: dict[str, Any]) -> list[dict[str, Any]]:
"evidence": "registry", "evidence": "registry",
} }
) )
seen.add(nid)
# 3) Unknown sink candidates. Save-looking sinks always need mapping;
# feature-less sinks only when nothing trusted exists (utility tails
# next to a real saver stay invisible).
has_trusted = bool(registry_outputs)
for nid, node in _sinks(workflow, consumers):
ct = str(node.get("class_type") or "")
if nid in seen or _is_wiring(ct) or ct in (IMAGE_OUTPUT_CLASSES | VIDEO_OUTPUT_CLASSES):
continue
if _unknown_sink_looks_like_save(node, workflow) or not has_trusted:
candidates.append(_unknown_output_entry(nid, node, workflow, videoish))
seen.add(nid)
# 4) Unknown save-looking nodes that something consumes (a custom saver
# feeding a cleanup tail is still an output candidate). Only concrete
# save widgets count here — decode-fed media links are ubiquitous among
# mid-graph transforms (CreateVideo & co.) and never mark an output.
for nid, node in sorted(
((str(k), v) for k, v in workflow.items() if isinstance(v, dict)),
key=lambda kv: _node_sort_key(kv[0]),
):
ct = str(node.get("class_type") or "")
if nid in seen or _is_wiring(ct) or ct in (IMAGE_OUTPUT_CLASSES | VIDEO_OUTPUT_CLASSES):
continue
if _node_has_save_widget(node):
candidates.append(_unknown_output_entry(nid, node, workflow, videoish))
seen.add(nid)
results = registry_outputs + candidates
results.sort(key=lambda r: _node_sort_key(r["nodeId"]))
return results return results
@@ -899,7 +979,7 @@ def classify_usage(workflow: dict[str, Any]) -> dict[str, Any]:
names = "、".join( names = "、".join(
f"节点 {o['nodeId']}({o.get('class_type') or '?'})" for o in unknown_outputs[:4] f"节点 {o['nodeId']}({o.get('class_type') or '?'})" for o in unknown_outputs[:4]
) )
summary.append(f"存在无法识别的输出节点:{names},需人工确认") summary.append(f"存在无法识别的输出节点:{names},需人工指定输出节点及媒体类型")
for s in image_slots: for s in image_slots:
if s["role"] != "mask": if s["role"] != "mask":
summary.append(f"图片输入:节点 {s['nodeId']}({s['label']})") summary.append(f"图片输入:节点 {s['nodeId']}({s['label']})")
@@ -914,6 +994,18 @@ def classify_usage(workflow: dict[str, Any]) -> dict[str, Any]:
"未在图中找到输出节点(SaveImage / 视频合成等)," "未在图中找到输出节点(SaveImage / 视频合成等),"
"请确认导出的是 API 格式且包含保存节点" "请确认导出的是 API 格式且包含保存节点"
) )
elif unknown_outputs:
# HEL-638: any unknown custom output node keeps the workflow
# pending — no name-based guessing, and picking a usage alone must
# not bypass the output-node designation.
names = "、".join(
f"节点 {o['nodeId']}({o.get('class_type') or '?'})" for o in unknown_outputs[:4]
)
ambiguous = True
problem = (
f"存在无法识别的输出节点({names}),"
"需人工指定实际输出节点及其媒体类型(图片/视频)后才能保存启用"
)
elif len(out_kinds) > 1: elif len(out_kinds) > 1:
ambiguous = True ambiguous = True
problem = "同一工作流同时输出图片和视频,需人工选择主用途" problem = "同一工作流同时输出图片和视频,需人工选择主用途"
@@ -929,10 +1021,6 @@ def classify_usage(workflow: dict[str, Any]) -> dict[str, Any]:
else: else:
ambiguous = True ambiguous = True
problem = "视频工作流中的单张图片输入无法判定是首帧还是参考图,需人工确认" problem = "视频工作流中的单张图片输入无法判定是首帧还是参考图,需人工确认"
else:
# only unknown outputs — the user must map them before it is usable
ambiguous = True
problem = "输出节点的媒体类型无法识别,需人工确认用途后才能生成"
return { return {
"usage": usage, "usage": usage,
@@ -30,7 +30,8 @@ VIDEO_OUTPUT_CLASSES = frozenset(
{"VHS_VideoCombine", "SaveVideo", "VideoOutput", "AnimateDiffCombine"} {"VHS_VideoCombine", "SaveVideo", "VideoOutput", "AnimateDiffCombine"}
) )
IMAGE_OUTPUT_CLASSES = frozenset( IMAGE_OUTPUT_CLASSES = frozenset(
{"SaveImage", "PreviewImage", "SaveImageWebsocket", "ETN_SendImageWebSocket"} {"SaveImage", "PreviewImage", "SaveImageWebsocket", "ETN_SendImageWebSocket",
"SaveImageAdvanced"}
) )
+49 -1
View File
@@ -121,7 +121,11 @@ CREATE TABLE IF NOT EXISTS workflows (
description TEXT, description TEXT,
prompt_profile TEXT NOT NULL DEFAULT 'prose', prompt_profile TEXT NOT NULL DEFAULT 'prose',
is_enabled INTEGER NOT NULL DEFAULT 1, is_enabled INTEGER NOT NULL DEFAULT 1,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
usage TEXT,
usage_source TEXT,
output_map TEXT,
output_map_source TEXT
); );
CREATE TABLE IF NOT EXISTS jobs ( CREATE TABLE IF NOT EXISTS jobs (
@@ -370,6 +374,42 @@ def _backfill_workflow_usage(conn: sqlite3.Connection) -> None:
) )
def _backfill_workflow_output_map(conn: sqlite3.Connection) -> None:
"""HEL-638: settle the output-node mapping for existing rows.
Rows the user already mapped (output_map_source='user') are never
touched. Determinate graphs get the trusted ``auto`` map. Rows whose
graph now contains unknown custom output candidates get no auto map and
are parked disabled — the usage decision survives, but until the user
designates the output nodes the workflow must not generate.
"""
from calliope.comfyui.output_map import auto_output_map, needs_user_output_map
rows = conn.execute(
"SELECT id, workflow_json FROM workflows"
" WHERE output_map_source IS NULL OR output_map_source != 'user'"
).fetchall()
for row in rows:
try:
workflow = json.loads(row[1])
except (json.JSONDecodeError, TypeError):
workflow = None
if not isinstance(workflow, dict):
continue
if needs_user_output_map(workflow):
conn.execute(
"UPDATE workflows SET output_map = NULL, output_map_source = NULL,"
" is_enabled = 0 WHERE id = ?",
(row[0],),
)
else:
conn.execute(
"UPDATE workflows SET output_map = ?, output_map_source = 'auto'"
" WHERE id = ?",
(json.dumps(auto_output_map(workflow)), row[0]),
)
async def migrate_db(db_path: Path) -> None: async def migrate_db(db_path: Path) -> None:
db_path.parent.mkdir(parents=True, exist_ok=True) db_path.parent.mkdir(parents=True, exist_ok=True)
conn = sqlite3.connect(db_path) conn = sqlite3.connect(db_path)
@@ -421,9 +461,17 @@ async def migrate_db(db_path: Path) -> None:
conn.execute("ALTER TABLE workflows ADD COLUMN usage TEXT") conn.execute("ALTER TABLE workflows ADD COLUMN usage TEXT")
if "usage_source" not in cols: if "usage_source" not in cols:
conn.execute("ALTER TABLE workflows ADD COLUMN usage_source TEXT") conn.execute("ALTER TABLE workflows ADD COLUMN usage_source TEXT")
# HEL-638: explicit output-node designation for unknown custom output
# nodes ({nodeId, kind} JSON + 'user'|'auto'). Idempotent backfill
# below parks unmapped unknown-output rows (disabled) like usage does.
if "output_map" not in cols:
conn.execute("ALTER TABLE workflows ADD COLUMN output_map TEXT")
if "output_map_source" not in cols:
conn.execute("ALTER TABLE workflows ADD COLUMN output_map_source TEXT")
# Idempotent backfill: pending rows are re-judged on every boot (parser # Idempotent backfill: pending rows are re-judged on every boot (parser
# upgrades can settle them); confirmed rows are never touched. # upgrades can settle them); confirmed rows are never touched.
_backfill_workflow_usage(conn) _backfill_workflow_usage(conn)
_backfill_workflow_output_map(conn)
scene_cols = {r[1] for r in conn.execute("PRAGMA table_info(scenes)").fetchall()} scene_cols = {r[1] for r in conn.execute("PRAGMA table_info(scenes)").fetchall()}
if "location_id" not in scene_cols: if "location_id" not in scene_cols:
conn.execute("ALTER TABLE scenes ADD COLUMN location_id INTEGER") conn.execute("ALTER TABLE scenes ADD COLUMN location_id INTEGER")
@@ -222,6 +222,11 @@ class WorkflowCreate(BaseModel):
usage_source: Literal["auto", "user"] | None = None usage_source: Literal["auto", "user"] | None = None
# Schema corrected on the confirm page (manual role overrides included). # Schema corrected on the confirm page (manual role overrides included).
input_schema: list[dict[str, Any]] | None = None input_schema: list[dict[str, Any]] | None = None
# HEL-638: explicit output-node designation for unknown custom output
# nodes — [{nodeId, kind: image|video}]. Required before a workflow
# with unknown outputs can be enabled or generated.
output_map: list[dict[str, Any]] | None = None
output_map_source: Literal["auto", "user"] | None = None
class WorkflowUpdate(BaseModel): class WorkflowUpdate(BaseModel):
@@ -234,6 +239,10 @@ class WorkflowUpdate(BaseModel):
usage: WorkflowUsageKind | None = None usage: WorkflowUsageKind | None = None
usage_source: Literal["auto", "user"] | None = None usage_source: Literal["auto", "user"] | None = None
input_schema: list[dict[str, Any]] | None = None input_schema: list[dict[str, Any]] | None = None
# HEL-638: set/replace the user output mapping; an explicit empty list
# resets the workflow to pending confirmation.
output_map: list[dict[str, Any]] | None = None
output_map_source: Literal["auto", "user"] | None = None
class WorkflowAnalyze(BaseModel): class WorkflowAnalyze(BaseModel):
+60 -7
View File
@@ -196,15 +196,25 @@ class QueueWorker:
) )
workflow_id = job.get("workflow_id") or payload.get("workflow_id") workflow_id = job.get("workflow_id") or payload.get("workflow_id")
workflow = self._load_workflow(workflow_id) workflow_row = self._load_workflow_row(workflow_id)
if not workflow: if not workflow_row:
raise RuntimeError( raise RuntimeError(
"找不到该任务使用的工作流(可能已被删除),请重新选择工作流后再生成" "找不到该任务使用的工作流(可能已被删除),请重新选择工作流后再生成"
) )
workflow = workflow_row["workflow_json"]
broken = blocking_problem(workflow) broken = blocking_problem(workflow)
if broken: if broken:
raise RuntimeError(broken) raise RuntimeError(broken)
# HEL-638: harvest only the confirmed output nodes. A workflow
# with unknown custom outputs and no user mapping must not run.
node_kinds = self._output_node_kinds(workflow_row)
if node_kinds is None:
raise RuntimeError(
"该工作流含无法识别的自定义输出节点,尚未指定输出节点及媒体类型,"
"请到「ComfyUI 连接」页确认后再生成"
)
input_values = payload.get("input_values") or {} input_values = payload.get("input_values") or {}
if payload.get("continue_source") and kind == "video": if payload.get("continue_source") and kind == "video":
input_values = await self._resolve_continue_source( input_values = await self._resolve_continue_source(
@@ -240,13 +250,31 @@ class QueueWorker:
f"ComfyUI 执行出错(任务 ID {prompt_id}):{_comfy_messages(messages)}" f"ComfyUI 执行出错(任务 ID {prompt_id}):{_comfy_messages(messages)}"
) )
outputs_meta = client.extract_outputs(history) outputs_meta = client.extract_outputs(history, node_kinds=node_kinds)
saved = [m for m in outputs_meta if m.get("type") == "output"] saved = [m for m in outputs_meta if m.get("type") == "output"]
outputs_meta = saved or outputs_meta outputs_meta = saved or outputs_meta
if not outputs_meta: if not outputs_meta:
checked = "、".join(sorted(node_kinds))
raise RuntimeError( raise RuntimeError(
f"ComfyUI 显示任务已结束(任务 ID {prompt_id}),但没有返回任何图片或视频," f"ComfyUI 显示任务已结束(任务 ID {prompt_id}),但没有返回任何图片或视频,"
"不算生成完成。请确认工作流带有保存/预览节点,并到 ComfyUI 历史中核对该任务。" "不算生成完成。已按输出映射检查节点:" f"{checked};"
"请到 ComfyUI 历史中核对该任务,并确认所指定的输出节点正确。"
)
mismatch = next(
(
m
for m in outputs_meta
if m.get("media_kind") and m["media_kind"] != node_kinds.get(m["node_id"])
),
None,
)
if mismatch:
want = node_kinds.get(mismatch["node_id"])
raise RuntimeError(
f"输出节点 {mismatch['node_id']} 的媒体类型与映射不符"
f"(映射为{'视频' if want == 'video' else '图片'},"
f"实际返回 {mismatch['filename']}),任务不算生成完成。"
"请到「ComfyUI 连接」页修正该节点的媒体类型。"
) )
queue_manager.set_phase(job["id"], "saving") queue_manager.set_phase(job["id"], "saving")
dest_dir = config.settings.assets_dir / str(project_id) / kind dest_dir = config.settings.assets_dir / str(project_id) / kind
@@ -476,20 +504,45 @@ class QueueWorker:
finally: finally:
conn.close() conn.close()
def _load_workflow(self, workflow_id: int | None) -> dict[str, Any] | None: def _load_workflow_row(self, workflow_id: int | None) -> dict[str, Any] | None:
if not workflow_id: if not workflow_id:
return None return None
conn = get_db(config.settings.db_path) conn = get_db(config.settings.db_path)
try: try:
row = conn.execute( row = conn.execute(
"SELECT workflow_json FROM workflows WHERE id = ?", (workflow_id,) "SELECT workflow_json, output_map, output_map_source FROM workflows"
" WHERE id = ?",
(workflow_id,),
).fetchone() ).fetchone()
if not row: if not row:
return None return None
return json.loads(row["workflow_json"]) return {
"workflow_json": json.loads(row["workflow_json"]),
"output_map": row["output_map"],
"output_map_source": row["output_map_source"],
}
finally: finally:
conn.close() conn.close()
@staticmethod
def _output_node_kinds(workflow_row: dict[str, Any]) -> dict[str, str] | None:
"""Confirmed {nodeId: image|video} for this workflow, or None when
the outputs are not confirmed (unknown nodes, no user mapping)."""
from calliope.comfyui.output_map import mapping_problem, resolve_output_map
workflow = workflow_row["workflow_json"]
problem = mapping_problem(
workflow, workflow_row.get("output_map"), workflow_row.get("output_map_source")
)
if problem:
return None
entries, _source = resolve_output_map(
workflow_row.get("output_map"),
workflow_row.get("output_map_source"),
workflow,
)
return {str(e["nodeId"]): str(e["kind"]) for e in entries} or None
def _job_label(self, job: dict[str, Any]) -> str: def _job_label(self, job: dict[str, Any]) -> str:
payload = json.loads(job.get("payload_json") or "{}") payload = json.loads(job.get("payload_json") or "{}")
kind = job.get("kind") or "job" kind = job.get("kind") or "job"
@@ -77,8 +77,11 @@ def _parsed_url(base_url: str) -> tuple[str, str]:
url = (base_url or "").strip() url = (base_url or "").strip()
if not url: if not url:
raise HTTPException(status_code=400, detail="API 地址不能为空") raise HTTPException(status_code=400, detail="API 地址不能为空")
if "://" not in url: # HEL-619: the server validates format as strictly as the UI already
url = f"http://{url}" # does. A schemeless garbled string used to be silently prefixed with
# http:// and then reported as a DNS failure; it is a 400 format error.
if "://" not in url or any(ch.isspace() for ch in url):
raise HTTPException(status_code=400, detail="地址必须是 http:// 或 https:// 开头的有效 URL")
parsed = urlparse(url) parsed = urlparse(url)
if parsed.scheme not in ("http", "https") or not parsed.hostname: if parsed.scheme not in ("http", "https") or not parsed.hostname:
raise HTTPException(status_code=400, detail="地址必须是 http:// 或 https:// 开头的有效 URL") raise HTTPException(status_code=400, detail="地址必须是 http:// 或 https:// 开头的有效 URL")
@@ -135,7 +138,12 @@ async def list_endpoints() -> dict[str, Any]:
@router.post("/endpoints") @router.post("/endpoints")
async def create_endpoint(payload: EndpointIn) -> dict[str, Any]: async def create_endpoint(payload: EndpointIn) -> dict[str, Any]:
base_url, _host = _parsed_url(payload.base_url) base_url, host = _parsed_url(payload.base_url)
# HEL-619: the same SSRF guard as the connectivity test applies on
# save — otherwise a blocked address can be stored and later probed by
# the worker path. Unresolvable hosts still pass (resolution happens
# again at probe time).
_assert_not_ssrf(host)
incoming = [ep for ep in settings.comfyui_endpoints or []] incoming = [ep for ep in settings.comfyui_endpoints or []]
incoming.append(payload.model_dump() | {"base_url": base_url}) incoming.append(payload.model_dump() | {"base_url": base_url})
try: try:
@@ -151,7 +159,8 @@ async def update_endpoint(endpoint_id: str, payload: EndpointPatch) -> dict[str,
_stored_endpoint(endpoint_id) _stored_endpoint(endpoint_id)
base_url = payload.base_url base_url = payload.base_url
if base_url is not None: if base_url is not None:
base_url, _host = _parsed_url(base_url) base_url, host = _parsed_url(base_url)
_assert_not_ssrf(host) # same save-time guard as create (HEL-619)
patch = payload.model_dump(exclude_unset=True) patch = payload.model_dump(exclude_unset=True)
if base_url is not None: if base_url is not None:
patch["base_url"] = base_url patch["base_url"] = base_url
@@ -14,6 +14,7 @@ from pydantic import BaseModel, Field
from calliope import config from calliope import config
from calliope.agent.prompts import item_reference_prompt from calliope.agent.prompts import item_reference_prompt
from calliope.comfyui.lint import blocking_problem from calliope.comfyui.lint import blocking_problem
from calliope.comfyui.output_map import mapping_problem
from calliope.comfyui.parser import effective_input_schema from calliope.comfyui.parser import effective_input_schema
from calliope.comfyui.validate import validate_input_values from calliope.comfyui.validate import validate_input_values
from calliope.db import get_db, row_to_dict from calliope.db import get_db, row_to_dict
@@ -335,7 +336,8 @@ async def generate(payload: PlaygroundGenerate) -> dict[str, Any]:
try: try:
pid = ensure_playground_project(conn) pid = ensure_playground_project(conn)
wf = conn.execute( wf = conn.execute(
"SELECT id, kind, is_enabled, workflow_json, input_schema FROM workflows WHERE id = ?", "SELECT id, kind, is_enabled, workflow_json, input_schema, output_map,"
" output_map_source FROM workflows WHERE id = ?",
(payload.workflow_id,), (payload.workflow_id,),
).fetchone() ).fetchone()
if not wf: if not wf:
@@ -348,6 +350,11 @@ async def generate(payload: PlaygroundGenerate) -> dict[str, Any]:
) )
kind = wf["kind"] kind = wf["kind"]
workflow_json = json.loads(wf["workflow_json"]) workflow_json = json.loads(wf["workflow_json"])
# HEL-638: a workflow with unknown custom output nodes must have a
# confirmed output mapping before anything is queued.
map_problem = mapping_problem(workflow_json, wf["output_map"], wf["output_map_source"])
if map_problem:
raise HTTPException(status_code=400, detail=map_problem)
schema = effective_input_schema( schema = effective_input_schema(
json.loads(wf["input_schema"]) if wf["input_schema"] else [], workflow_json json.loads(wf["input_schema"]) if wf["input_schema"] else [], workflow_json
) )
@@ -107,7 +107,11 @@ async def update_settings(payload: SettingsUpdate) -> dict[str, Any]:
if assignments_in is not None: if assignments_in is not None:
settings.ensure_llm_profiles() settings.ensure_llm_profiles()
ids = {p["id"] for p in settings.llm_profiles} ids = {p["id"] for p in settings.llm_profiles}
cleaned: dict[str, str | None] = {} # HEL-619: per-role INCREMENTAL update. Rapid dropdown switches used
# to send whole cached snapshots that fully overwrote the map, so a
# stale snapshot could wipe a newer choice. Roles absent from the
# payload keep their stored value; a role sent as null is cleared.
cleaned: dict[str, str | None] = dict(settings.agent_llm_assignments or {})
for role, pid in assignments_in.items(): for role, pid in assignments_in.items():
if role not in AGENT_LLM_ROLES: if role not in AGENT_LLM_ROLES:
continue continue
@@ -6,6 +6,13 @@ from typing import Any
from fastapi import APIRouter, HTTPException from fastapi import APIRouter, HTTPException
from calliope.comfyui.lint import workflow_warnings from calliope.comfyui.lint import workflow_warnings
from calliope.comfyui.output_map import (
auto_output_map,
load_output_map,
mapping_problem,
needs_user_output_map,
validate_output_map,
)
from calliope.comfyui.parser import ( from calliope.comfyui.parser import (
classify_usage, classify_usage,
effective_input_schema, effective_input_schema,
@@ -26,9 +33,17 @@ def _serialize_workflow(row: Any) -> dict[str, Any]:
data["workflow_json"] = json.loads(data["workflow_json"]) data["workflow_json"] = json.loads(data["workflow_json"])
stored = json.loads(data["input_schema"]) if data.get("input_schema") else [] stored = json.loads(data["input_schema"]) if data.get("input_schema") else []
data["input_schema"] = effective_input_schema(stored, data["workflow_json"]) data["input_schema"] = effective_input_schema(stored, data["workflow_json"])
data["output_schema"] = json.loads(data["output_schema"]) if data.get("output_schema") else [] # Outputs are pure graph derivation (no manual overrides) — always fresh,
# so parser upgrades reach old rows without a re-import.
data["output_schema"] = parse_dynamic_outputs(data["workflow_json"])
data["is_enabled"] = bool(data.get("is_enabled")) data["is_enabled"] = bool(data.get("is_enabled"))
data["warnings"] = workflow_warnings(data["workflow_json"]) data["warnings"] = workflow_warnings(data["workflow_json"])
raw_map = data.get("output_map")
data["output_map"] = load_output_map(raw_map)
# Pending flag: unknown output candidates the user has not mapped yet.
data["needs_mapping"] = (
mapping_problem(data["workflow_json"], raw_map, data.get("output_map_source")) is not None
)
return data return data
@@ -63,9 +78,9 @@ async def reanalyze_workflow(workflow_id: int) -> dict[str, Any]:
"""Recompute usage and input/output schemas from the stored workflow JSON. """Recompute usage and input/output schemas from the stored workflow JSON.
Workflows imported before a parser upgrade keep stale (often empty) Workflows imported before a parser upgrade keep stale (often empty)
schemas — this refreshes them without re-importing. A usage the user schemas — this refreshes them without re-importing. A usage or output
set by hand is never overwritten; only ``auto`` (and pending NULL) mapping the user set by hand is never overwritten; only ``auto`` (and
rows get the new judgment. pending NULL) rows get the new judgment.
""" """
conn = get_db(settings.db_path) conn = get_db(settings.db_path)
try: try:
@@ -83,10 +98,31 @@ async def reanalyze_workflow(workflow_id: int) -> dict[str, Any]:
stored = json.loads(data["input_schema"]) if data["input_schema"] else [] stored = json.loads(data["input_schema"]) if data["input_schema"] else []
schema = effective_input_schema(stored, workflow) schema = effective_input_schema(stored, workflow)
outputs = parse_dynamic_outputs(workflow) outputs = parse_dynamic_outputs(workflow)
if data["output_map_source"] == "user":
output_map, output_map_source = data["output_map"], "user"
elif needs_user_output_map(workflow):
# Unknown output candidates: no auto map, and the row must not
# generate until the user designates the output nodes.
output_map, output_map_source = None, None
else:
output_map, output_map_source = json.dumps(auto_output_map(workflow)), "auto"
is_enabled = data["is_enabled"]
if output_map_source is None or usage is None:
is_enabled = 0
conn.execute( conn.execute(
"UPDATE workflows SET input_schema = ?, output_schema = ?," "UPDATE workflows SET input_schema = ?, output_schema = ?,"
" usage = ?, usage_source = ? WHERE id = ?", " usage = ?, usage_source = ?, output_map = ?, output_map_source = ?,"
(json.dumps(schema), json.dumps(outputs), usage, usage_source, workflow_id), " is_enabled = ? WHERE id = ?",
(
json.dumps(schema),
json.dumps(outputs),
usage,
usage_source,
output_map,
output_map_source,
is_enabled,
workflow_id,
),
) )
conn.commit() conn.commit()
fresh = conn.execute( fresh = conn.execute(
@@ -158,6 +194,20 @@ async def create_workflow(payload: WorkflowCreate) -> dict[str, Any]:
} }
kind = "video" if out_kinds == {"video"} else "image" kind = "video" if out_kinds == {"video"} else "image"
profile = payload.prompt_profile or detect_prompt_profile(payload.workflow_json) profile = payload.prompt_profile or detect_prompt_profile(payload.workflow_json)
# HEL-638: an explicit user output map wins; otherwise the trusted auto
# map. Either way a graph with unknown output candidates is unusable
# until the user designates the output nodes.
if payload.output_map:
problems = validate_output_map(payload.workflow_json, payload.output_map)
if problems:
raise HTTPException(status_code=422, detail=";".join(problems))
output_map = json.dumps(payload.output_map)
output_map_source = payload.output_map_source or "user"
else:
auto_map = auto_output_map(payload.workflow_json)
output_map = json.dumps(auto_map) if auto_map else None
output_map_source = "auto" if auto_map else None
mapping_ok = not needs_user_output_map(payload.workflow_json) or bool(payload.output_map)
conn = get_db(settings.db_path) conn = get_db(settings.db_path)
try: try:
# Byte-identical re-imports are the main way the library fills up with # Byte-identical re-imports are the main way the library fills up with
@@ -174,16 +224,18 @@ async def create_workflow(payload: WorkflowCreate) -> dict[str, Any]:
f" “{existing['name']}”)." f" “{existing['name']}”)."
), ),
) )
# Unconfirmed workflows (ambiguous / unknown outputs) are stored but # Unconfirmed workflows (ambiguous usage / unknown outputs without a
# disabled: they must not reach the generate pages until the user # user mapping) are stored but disabled: they must not reach the
# confirms a usage on the connections page (PATCH sets it back on). # generate pages until the user confirms usage AND, for unknown
is_enabled = 1 if usage else 0 # output nodes, designates the outputs on the connections page.
is_enabled = 1 if (usage and mapping_ok) else 0
cur = conn.execute( cur = conn.execute(
""" """
INSERT INTO workflows (name, kind, workflow_json, input_schema, INSERT INTO workflows (name, kind, workflow_json, input_schema,
output_schema, description, prompt_profile, output_schema, description, prompt_profile,
endpoint_id, is_enabled, usage, usage_source) endpoint_id, is_enabled, usage, usage_source,
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) output_map, output_map_source)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""", """,
( (
payload.name, payload.name,
@@ -197,6 +249,8 @@ async def create_workflow(payload: WorkflowCreate) -> dict[str, Any]:
is_enabled, is_enabled,
usage, usage,
usage_source, usage_source,
output_map,
output_map_source,
), ),
) )
conn.commit() conn.commit()
@@ -228,20 +282,54 @@ async def update_workflow(workflow_id: int, payload: WorkflowUpdate) -> dict[str
data = payload.model_dump(exclude_unset=True) data = payload.model_dump(exclude_unset=True)
if "is_enabled" in data and data["is_enabled"] is not None: if "is_enabled" in data and data["is_enabled"] is not None:
data["is_enabled"] = 1 if data["is_enabled"] else 0 data["is_enabled"] = 1 if data["is_enabled"] else 0
workflow_json = json.loads(existing["workflow_json"])
# HEL-638: output_map payload. A non-empty list validates against the
# stored JSON and becomes the user decision; an explicit empty list
# resets the row to pending (disabled).
if "output_map" in data:
if data["output_map"]:
problems = validate_output_map(workflow_json, data["output_map"])
if problems:
raise HTTPException(status_code=422, detail=";".join(problems))
data["output_map"] = json.dumps(data["output_map"])
data.setdefault("output_map_source", "user")
else:
data["output_map"] = None
data["output_map_source"] = None
data["is_enabled"] = 0
if data.get("usage"): if data.get("usage"):
# Confirming / correcting the usage is an explicit user decision: # Confirming / correcting the usage is an explicit user decision:
# it re-enables the workflow and keeps kind (output media) in sync. # kind (output media) follows the usage. Whether it re-enables is
# decided by the gate below — with unknown output nodes the user
# must also designate the output nodes (HEL-638).
data.setdefault("usage_source", "user") data.setdefault("usage_source", "user")
data["kind"] = usage_to_kind(data["usage"]) or existing["kind"] data["kind"] = usage_to_kind(data["usage"]) or existing["kind"]
if "is_enabled" not in data:
data["is_enabled"] = 1
if "input_schema" in data and data["input_schema"] is not None: if "input_schema" in data and data["input_schema"] is not None:
if not all(isinstance(e, dict) for e in data["input_schema"]): if not all(isinstance(e, dict) for e in data["input_schema"]):
raise HTTPException(status_code=422, detail="input_schema 必须是参数对象数组") raise HTTPException(status_code=422, detail="input_schema 必须是参数对象数组")
data["input_schema"] = json.dumps(data["input_schema"]) data["input_schema"] = json.dumps(data["input_schema"])
# endpoint_id: explicit null clears the binding; other Nones are skips. # endpoint_id: explicit null clears the binding; other Nones are skips
explicit_null = {"endpoint_id"} & {k for k, v in data.items() if v is None} # (an output_map reset keeps its explicit NULLs).
explicit_null = {"endpoint_id", "output_map", "output_map_source"} & {
k for k, v in data.items() if v is None
}
data = {k: v for k, v in data.items() if v is not None or k in explicit_null} data = {k: v for k, v in data.items() if v is not None or k in explicit_null}
# Enable gate: usage must be settled and, when the graph carries
# unknown custom output nodes, a user output mapping must exist.
usage_ok = bool(data.get("usage") or existing["usage"])
map_raw = data.get("output_map", existing["output_map"])
map_source = data.get("output_map_source", existing["output_map_source"])
map_problem = mapping_problem(workflow_json, map_raw, map_source)
if data.get("is_enabled"):
if not usage_ok:
raise HTTPException(status_code=400, detail="请先选择工作流用途,再启用该工作流")
if map_problem:
raise HTTPException(status_code=400, detail=map_problem)
elif (data.get("usage") or data.get("output_map")) and "is_enabled" not in data:
# A usage-confirm or output-map-confirm path: enabled only when
# both decisions are settled.
data["is_enabled"] = 1 if (usage_ok and not map_problem) else 0
if data: if data:
fields = ", ".join(f"{k} = :{k}" for k in data) fields = ", ".join(f"{k} = :{k}" for k in data)
data["id"] = workflow_id data["id"] = workflow_id
@@ -257,10 +345,29 @@ async def update_workflow(workflow_id: int, payload: WorkflowUpdate) -> dict[str
async def delete_workflow(workflow_id: int) -> dict[str, bool]: async def delete_workflow(workflow_id: int) -> dict[str, bool]:
conn = get_db(settings.db_path) conn = get_db(settings.db_path)
try: try:
cur = conn.execute("DELETE FROM workflows WHERE id = ?", (workflow_id,)) # HEL-619: refuse to delete while queued/running jobs still use the
conn.commit() # workflow — deleting sets their workflow_id NULL and the job dies
if cur.rowcount == 0: # with "工作流已被删除" only after the user waits for it.
row = conn.execute(
"SELECT id FROM workflows WHERE id = ?", (workflow_id,)
).fetchone()
if not row:
raise HTTPException(status_code=404, detail="Workflow not found") raise HTTPException(status_code=404, detail="Workflow not found")
pending = conn.execute(
"SELECT COUNT(*) AS n FROM jobs"
" WHERE workflow_id = ? AND status IN ('pending', 'running')",
(workflow_id,),
).fetchone()["n"]
if pending:
raise HTTPException(
status_code=409,
detail=(
f"该工作流还有 {pending} 个排队或执行中的任务,"
"请先等任务完成或取消任务,再删除该工作流"
),
)
conn.execute("DELETE FROM workflows WHERE id = ?", (workflow_id,))
conn.commit()
return {"ok": True} return {"ok": True}
finally: finally:
conn.close() conn.close()
+4
View File
@@ -10,6 +10,10 @@ from fastapi.testclient import TestClient
from calliope.db import migrate_db from calliope.db import migrate_db
from calliope.main import create_app from calliope.main import create_app
# Shared fake-ComfyUI HTTP server (defined in test_studio_generation,
# reused by the generation / status / unknown-output-mapping suites).
from tests.test_studio_generation import fake_comfy # noqa: F401,E402
@pytest.fixture @pytest.fixture
def client(monkeypatch): def client(monkeypatch):
@@ -374,6 +374,61 @@ def test_comfy_test_requires_url(client):
assert r.status_code == 400 assert r.status_code == 400
def test_schemeless_url_is_format_error_everywhere(client):
"""HEL-619: a schemeless/garbled address is a 400 format error on every
entry point (probe + save), not a silent http:// prefix that later
surfaces as a DNS-classified probe failure."""
prev = _snapshot_settings()
try:
for url in ("192.168.0.1:8188", "http:192.168.0.1", "ht!tp://x", "http://a b.test/"):
r = client.post(
"/api/comfyui/endpoints/test", json={"base_url": url, "timeout_sec": 2}
)
assert r.status_code == 400, url
assert "http://" in r.json()["detail"] or "https://" in r.json()["detail"]
r = client.post(
"/api/comfyui/endpoints", json={"name": "无协议", "base_url": url}
)
assert r.status_code == 400, url
assert "无协议" not in [ep.get("name") for ep in settings.comfyui_endpoints or []]
finally:
for key, value in prev.items():
setattr(settings, key, value)
def test_save_endpoint_runs_ssrf_guard(client):
"""HEL-619: the SSRF guard applies on save (create + edit), not only on
the connectivity probe; loopback stays allowed."""
prev = _snapshot_settings()
try:
_clear_endpoints()
r = client.post(
"/api/comfyui/endpoints",
json={"name": "元数据", "base_url": "http://169.254.169.254/latest"},
)
assert r.status_code == 400
assert "禁止" in r.json()["detail"]
r = client.post(
"/api/comfyui/endpoints",
json={"name": "本机", "base_url": "http://127.0.0.1:8188"},
)
assert r.status_code == 200
eid = r.json()["endpoints"][-1]["id"]
r = client.patch(
f"/api/comfyui/endpoints/{eid}",
json={"base_url": "http://169.254.169.254/latest"},
)
assert r.status_code == 400
# the stored endpoint is untouched
stored = next(ep for ep in settings.comfyui_endpoints if ep["id"] == eid)
assert stored["base_url"] == "http://127.0.0.1:8188"
finally:
for key, value in prev.items():
setattr(settings, key, value)
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# workflow binding + job snapshots # workflow binding + job snapshots
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
@@ -542,6 +597,41 @@ def test_queue_enqueue_stamps_all_paths(client):
setattr(settings, key, value) setattr(settings, key, value)
def test_workflow_delete_blocked_while_jobs_pending(client):
"""HEL-619: deleting a workflow with pending/running jobs is refused
with 409 instead of silently nulling the jobs' workflow_id."""
from calliope.db import get_db
from calliope.queue.manager import queue_manager
wf = _import_workflow(client).json()
project = client.post(
"/api/projects", json={"title": "删除保护测试", "idea": "x"}
).json()
# Pause the lifespan-started worker so the pending job STAYS pending.
queue_manager.paused = True
try:
queue_manager.enqueue(
project_id=project["id"], kind="video", workflow_id=wf["id"], payload={}
)
r = client.delete(f"/api/workflows/{wf['id']}")
assert r.status_code == 409
assert "排队" in r.json()["detail"]
finally:
queue_manager.paused = False
# job finished → deletion allowed again
conn = get_db(settings.db_path)
try:
conn.execute("UPDATE jobs SET status = 'done' WHERE project_id = ?", (project["id"],))
conn.commit()
finally:
conn.close()
r = client.delete(f"/api/workflows/{wf['id']}")
assert r.status_code == 200
assert r.json() == {"ok": True}
def test_settings_public_dict_masks_endpoint_tokens(client): def test_settings_public_dict_masks_endpoint_tokens(client):
prev = _snapshot_settings() prev = _snapshot_settings()
try: try:
@@ -216,6 +216,18 @@ def test_settings_accepts_agent_llm_assignments(client):
# Unknown role keys are dropped, known roles stored (incl. explicit None) # Unknown role keys are dropped, known roles stored (incl. explicit None)
assert body["agent_llm_assignments"] == {"video": a_id, "story": None} assert body["agent_llm_assignments"] == {"video": a_id, "story": None}
# HEL-619: updates are per-role incremental — a partial payload must
# not wipe roles it does not mention (rapid-switch race).
r = client.post(
"/api/settings",
json={"agent_llm_assignments": {"main": a_id}},
)
assert r.status_code == 200
body = r.json()
assert body["agent_llm_assignments"]["main"] == a_id
assert body["agent_llm_assignments"]["video"] == a_id
assert body["agent_llm_assignments"]["story"] is None
r = client.post( r = client.post(
"/api/settings", "/api/settings",
json={"agent_llm_assignments": {"video": "no-such-profile"}}, json={"agent_llm_assignments": {"video": "no-such-profile"}},
+54 -15
View File
@@ -13,6 +13,7 @@ The shell is default-OFF; every guard branch here is a security contract:
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
import os
import sys import sys
from pathlib import Path from pathlib import Path
@@ -25,6 +26,23 @@ from calliope.agent.harness.registry import ToolContext
PYTHON = Path(sys.executable).stem # bare name ("python") — the tool refuses paths PYTHON = Path(sys.executable).stem # bare name ("python") — the tool refuses paths
@pytest.fixture(autouse=True, scope="module")
def _interpreter_on_path():
"""Make the bare interpreter name resolvable via PATH (HEL-619).
The guard resolves the command with ``shutil.which`` against PATH —
running pytest as ``path/to/.venv/bin/python -m pytest`` (or on a box
with no ``python`` alias) leaves the stem unresolvable and every
exec-path test fails for environmental reasons only. Prepending the
interpreter's own bin dir (restored afterwards) pins the lookup to the
interpreter actually running the suite, on every OS.
"""
prev = os.environ.get("PATH", "")
os.environ["PATH"] = f"{Path(sys.executable).parent}{os.pathsep}{prev}"
yield
os.environ["PATH"] = prev
@pytest.fixture(autouse=True, scope="module") @pytest.fixture(autouse=True, scope="module")
def _never_touch_real_db(): def _never_touch_real_db():
"""Redirect data_dir before ANY write in this module (repo test rule).""" """Redirect data_dir before ANY write in this module (repo test rule)."""
@@ -210,12 +228,19 @@ def test_structured_shell_approval_allows(enabled):
def test_cwd_outside_workspace_denied(enabled): def test_cwd_outside_workspace_denied(enabled):
"""Guard denial tests use PYTHON + a structured approval card (not
ffprobe): the interpreter resolves on every machine, and the card
clears the approval gate so the LATER containment check is what fires
(HEL-619 — ffprobe-absent boxes used to fail these for environmental
reasons)."""
registry, _ = build_harness() registry, _ = build_harness()
sid = _session()
_answer_card(sid, "Yes, run it")
out = asyncio.run( out = asyncio.run(
registry.execute( registry.execute(
_ctx(), ToolContext(session_id=sid, project_id=None),
"run_command", "run_command",
{"command": "ffprobe", "cwd": str(Path(settings_data_dir_home()))}, {"command": PYTHON, "cwd": str(settings_data_dir_home())},
) )
) )
assert out["reason_code"] == "guard_shell_outside_workspace" assert out["reason_code"] == "guard_shell_outside_workspace"
@@ -230,11 +255,13 @@ def test_sensitive_arg_denied(enabled, tmp_path):
registry, _ = build_harness() registry, _ = build_harness()
secret = tmp_path / "calliope_config.json" secret = tmp_path / "calliope_config.json"
secret.write_text("{}", encoding="utf-8") secret.write_text("{}", encoding="utf-8")
sid = _session()
_answer_card(sid, "Yes, run it")
out = asyncio.run( out = asyncio.run(
registry.execute( registry.execute(
_ctx(), ToolContext(session_id=sid, project_id=None),
"run_command", "run_command",
{"command": "ffprobe", "args": [str(secret)]}, {"command": PYTHON, "args": ["-c", "print('x')", str(secret)]},
) )
) )
assert out["reason_code"] == "guard_shell_denied_path" assert out["reason_code"] == "guard_shell_denied_path"
@@ -244,11 +271,13 @@ def test_db_arg_denied(enabled, tmp_path):
registry, _ = build_harness() registry, _ = build_harness()
db = tmp_path / "calliope.db" db = tmp_path / "calliope.db"
db.write_bytes(b"") db.write_bytes(b"")
sid = _session()
_answer_card(sid, "Yes, run it")
out = asyncio.run( out = asyncio.run(
registry.execute( registry.execute(
_ctx(), ToolContext(session_id=sid, project_id=None),
"run_command", "run_command",
{"command": "ffprobe", "args": [str(db)]}, {"command": PYTHON, "args": ["-c", "print('x')", str(db)]},
) )
) )
assert out["reason_code"] == "guard_shell_denied_path" assert out["reason_code"] == "guard_shell_denied_path"
@@ -256,11 +285,13 @@ def test_db_arg_denied(enabled, tmp_path):
def test_env_file_arg_denied(enabled): def test_env_file_arg_denied(enabled):
registry, _ = build_harness() registry, _ = build_harness()
sid = _session()
_answer_card(sid, "Yes, run it")
out = asyncio.run( out = asyncio.run(
registry.execute( registry.execute(
_ctx(), ToolContext(session_id=sid, project_id=None),
"run_command", "run_command",
{"command": "ffprobe", "args": ["--", ".env"]}, {"command": PYTHON, "args": ["-c", "print('x')", "--", ".env"]},
) )
) )
assert out["reason_code"] == "guard_shell_denied_path" assert out["reason_code"] == "guard_shell_denied_path"
@@ -270,11 +301,13 @@ def test_outside_absolute_arg_denied(enabled, tmp_path):
registry, _ = build_harness() registry, _ = build_harness()
outside = tmp_path / "movie.mp4" outside = tmp_path / "movie.mp4"
outside.write_bytes(b"00") outside.write_bytes(b"00")
sid = _session()
_answer_card(sid, "Yes, run it")
out = asyncio.run( out = asyncio.run(
registry.execute( registry.execute(
_ctx(), ToolContext(session_id=sid, project_id=None),
"run_command", "run_command",
{"command": "ffprobe", "args": [str(outside)]}, {"command": PYTHON, "args": ["-c", "print('x')", str(outside)]},
) )
) )
assert out["reason_code"] == "guard_shell_outside_workspace" assert out["reason_code"] == "guard_shell_outside_workspace"
@@ -287,16 +320,22 @@ def test_inside_asset_arg_allowed(enabled):
registry, _ = build_harness() registry, _ = build_harness()
ref = settings.assets_dir / "ref.mp4" ref = settings.assets_dir / "ref.mp4"
ref.write_bytes(b"00") ref.write_bytes(b"00")
sid = _session()
_answer_card(sid, "Yes, run it")
out = asyncio.run( out = asyncio.run(
registry.execute( registry.execute(
_ctx(), ToolContext(session_id=sid, project_id=None),
"run_command", "run_command",
{"command": "ffprobe", "args": ["-v", "error", str(ref)]}, {
# The asset path is a real argv entry the guard must allow
# (and the interpreter actually reads it).
"command": PYTHON,
"args": ["-c", "import sys; print(open(sys.argv[1]).read())", str(ref)],
},
) )
) )
# Not a real mp4 — ffprobe fails, but the GUARD must not have denied it. assert out["ok"] is True, out
assert out.get("reason_code") is None assert "00" in out["stdout"]
assert out.get("exit_code") != 0 or out.get("ok") is False or out["ok"] is True
def test_workspace_relative_cwd_allowed(enabled, tmp_path): def test_workspace_relative_cwd_allowed(enabled, tmp_path):
@@ -25,9 +25,19 @@ PNG_1PX = bytes.fromhex(
class _FakeComfyHandler(BaseHTTPRequestHandler): class _FakeComfyHandler(BaseHTTPRequestHandler):
"""Minimal ComfyUI: /system_stats, /prompt, /history/{id}, /view, /upload/image.""" """Minimal ComfyUI: /system_stats, /prompt, /history/{id}, /view, /upload/image.
History outputs are keyed by the prompt's real output node id (what
ComfyUI does); a known output class that is absent falls back to
``server.forced_output_node`` (default "9"). Scripted tests can pin
``server.forced_output_node`` or drop entries via ``server.drop_outputs``.
"""
server_version = "FakeComfy/1.0" server_version = "FakeComfy/1.0"
KNOWN_OUTPUT_CLASSES = {
"SaveImage", "PreviewImage", "SaveImageAdvanced", "SaveImageWebsocket",
"SaveVideo", "VideoOutput", "VHS_VideoCombine", "AnimateDiffCombine",
}
def do_GET(self): def do_GET(self):
self.server.requests.append(self.path) self.server.requests.append(self.path)
@@ -64,11 +74,13 @@ class _FakeComfyHandler(BaseHTTPRequestHandler):
prompt_id = uuid.uuid4().hex prompt_id = uuid.uuid4().hex
outputs_key = self.server.outputs_key outputs_key = self.server.outputs_key
out_entry = { out_entry = {
outputs_key: [{"filename": self.server.out_name, "subfolder": "", "type": "output"}] outputs_key: [
{"filename": self.server.out_name, "subfolder": "", "type": "output"}
]
} }
self.server.history[prompt_id] = { self.server.history[prompt_id] = {
"status": {"status_str": "success", "completed": True}, "status": {"status_str": "success", "completed": True},
"outputs": {"9": out_entry}, "outputs": {self._output_node(body): out_entry},
"prompt": [], "prompt": [],
} }
self.server.prompts.append(json.loads(body.decode("utf-8") or "{}")) self.server.prompts.append(json.loads(body.decode("utf-8") or "{}"))
@@ -80,6 +92,19 @@ class _FakeComfyHandler(BaseHTTPRequestHandler):
return return
self._json(404, {"error": "not found"}) self._json(404, {"error": "not found"})
def _output_node(self, body: bytes) -> str:
forced = getattr(self.server, "forced_output_node", None)
if forced:
return forced
try:
prompt = json.loads(body.decode("utf-8") or "{}").get("prompt") or {}
except json.JSONDecodeError:
prompt = {}
for nid, node in prompt.items():
if isinstance(node, dict) and node.get("class_type") in self.KNOWN_OUTPUT_CLASSES:
return str(nid)
return "9"
def _json(self, status: int, payload: dict) -> None: def _json(self, status: int, payload: dict) -> None:
data = json.dumps(payload).encode("utf-8") data = json.dumps(payload).encode("utf-8")
self.send_response(status) self.send_response(status)
@@ -109,6 +134,7 @@ def fake_comfy():
server.fail_prompt = False server.fail_prompt = False
server.out_name = "out-1.png" server.out_name = "out-1.png"
server.outputs_key = "images" server.outputs_key = "images"
server.forced_output_node = None
thread = threading.Thread(target=server.serve_forever, daemon=True) thread = threading.Thread(target=server.serve_forever, daemon=True)
thread.start() thread.start()
try: try:
@@ -0,0 +1,371 @@
"""HEL-638: unknown custom output nodes close the loop — no name-based
auto-typing, feature-less sinks become mappable candidates, a usage choice
alone never bypasses the output designation, and generation harvests (and
checks) exactly the nodes the user mapped.
Two brand-new class names drive the cases:
* ``NebulaGlaxVideoVault`` — screams "video" in its name and carries a
filename_prefix; before HEL-638 the fuzzy name match auto-typed it video
and enabled the workflow.
* ``QuarkMuffinDisplay`` — no save widget, no media link name; before
HEL-638 such a graph only reported ``no_output`` with no way to map.
"""
from __future__ import annotations
import json
from pathlib import Path
from calliope.config import settings
from calliope.db import get_db, migrate_db
from tests.test_studio_generation import _real_run, _wait_done
FIXTURES = Path(__file__).parent / "fixtures" / "comfy_native"
def _vault_workflow() -> dict:
return {
"1": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "p"}},
"7": {
"class_type": "GlaxSamplerNode",
"inputs": {"prompt": ["1", 0], "length": 121},
},
"12": {
"class_type": "NebulaGlaxVideoVault",
"inputs": {"filename_prefix": "anim", "frames": ["7", 0]},
},
}
def _muffin_workflow() -> dict:
return {
"1": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "p"}},
"7": {
"class_type": "GlaxSamplerNode",
"inputs": {"prompt": ["1", 0], "length": 121},
},
"15": {"class_type": "QuarkMuffinDisplay", "inputs": {"payload": ["7", 0]}},
}
def _analyze(client, wf: dict) -> dict:
r = client.post("/api/workflows/analyze", json={"workflow_json": wf})
assert r.status_code == 200, r.text
return r.json()
# ---------------------------------------------------------------------------
# 1. Unknown outputs stay pending — names never decide (gap 1)
# ---------------------------------------------------------------------------
def test_video_semantic_unknown_node_is_never_auto_typed(client):
body = _analyze(client, _vault_workflow())
entry = next(o for o in body["usage_evidence"]["outputs"] if o["nodeId"] == "12")
assert entry["evidence"] == "unknown_node"
assert entry["kind"] is None # the user picks the media type
assert entry["suggested_kind"] == "video" # only a form default
assert body["needs_mapping"] is True
assert body["usage"] is None and body["usage_ambiguous"] is True
assert "指定实际输出节点" in body["usage_problem"]
codes = {(w["level"], w["code"]) for w in body["warnings"]}
assert ("warning", "unknown_output_node") in codes
assert ("error", "no_output") not in codes
def test_choosing_a_usage_alone_does_not_bypass_output_mapping(client):
"""create/PATCH with a usage but no output map keeps the row disabled."""
r = client.post(
"/api/workflows",
json={"name": "未知·视频语义", "workflow_json": _vault_workflow(),
"usage": "text2video", "usage_source": "user"},
)
assert r.status_code == 200, r.text
wf = r.json()
assert wf["usage"] == "text2video" and wf["usage_source"] == "user"
assert wf["is_enabled"] is False # usage set, outputs still unconfirmed
assert wf["needs_mapping"] is True and not wf["output_map"]
gen = client.post(
"/api/playground/generate",
json={"workflow_id": wf["id"], "input_values": {"1": "x"}},
)
assert gen.status_code == 400
# forcing the switch on is refused with the mapping reason
r = client.patch(f"/api/workflows/{wf['id']}", json={"is_enabled": True})
assert r.status_code == 400
assert "指定" in r.json()["detail"] and "输出节点" in r.json()["detail"]
# ---------------------------------------------------------------------------
# 2. Feature-less unknown sinks become mappable candidates (gap 2)
# ---------------------------------------------------------------------------
def test_featureless_unknown_node_is_a_candidate_not_a_hard_error(client):
body = _analyze(client, _muffin_workflow())
entry = next(o for o in body["usage_evidence"]["outputs"] if o["nodeId"] == "15")
assert entry["evidence"] == "unknown_node" and entry["kind"] is None
assert body["needs_mapping"] is True
codes = {(w["level"], w["code"]) for w in body["warnings"]}
assert ("warning", "unknown_output_node") in codes
assert ("error", "no_output") not in codes
def test_truly_outputless_graph_still_reports_the_chinese_error(client):
wf = {
"1": {"class_type": "CLIPTextEncode", "inputs": {"text": "p"}},
"2": {"class_type": "VAEDecode", "inputs": {"samples": ["1", 0]}},
}
body = _analyze(client, wf)
assert body["usage"] is None and body["needs_mapping"] is False
assert "未在图中找到输出节点" in body["usage_problem"]
# ---------------------------------------------------------------------------
# 3. Manual mapping → enable → scoped generation (fake ComfyUI round trip)
# ---------------------------------------------------------------------------
def test_manual_mapping_enables_and_extracts_from_the_mapped_node(client, fake_comfy):
fake_comfy.outputs_key = "gifs"
fake_comfy.out_name = "clip.mp4"
fake_comfy.forced_output_node = "12" # the mapped node reports results
with _real_run(client, fake_comfy):
r = client.post(
"/api/workflows",
json={
"name": "映射·视频库",
"workflow_json": _vault_workflow(),
"usage": "text2video",
"usage_source": "user",
"output_map": [{"nodeId": "12", "kind": "video"}],
"output_map_source": "user",
},
)
assert r.status_code == 200, r.text
wf = r.json()
assert wf["is_enabled"] is True
assert wf["output_map"] == [{"nodeId": "12", "kind": "video"}]
assert wf["output_map_source"] == "user"
r = client.post(
"/api/playground/generate",
json={"workflow_id": wf["id"], "input_values": {"1": "星空延时"},
"source": "studio-video"},
)
assert r.status_code == 200, r.text
job = _wait_done(client, r.json()["job"]["id"])
assert job["status"] == "done", job.get("error")
assert job["output_paths"][0].endswith(".mp4")
def test_mapped_node_returning_nothing_fails_for_real(client, fake_comfy):
"""Results that only land on an unmapped node are NOT a completion."""
fake_comfy.forced_output_node = "7" # something else reports results
with _real_run(client, fake_comfy):
r = client.post(
"/api/workflows",
json={
"name": "映射·空手而归",
"workflow_json": _muffin_workflow(),
"usage": "text2image",
"usage_source": "user",
"output_map": [{"nodeId": "15", "kind": "image"}],
},
)
assert r.status_code == 200 and r.json()["is_enabled"] is True
r = client.post(
"/api/playground/generate",
json={"workflow_id": r.json()["id"], "input_values": {"1": "x"}},
)
assert r.status_code == 200, r.text
job = _wait_done(client, r.json()["job"]["id"])
assert job["status"] == "failed"
assert "没有返回任何图片或视频" in job["error"]
assert "15" in job["error"] # names the node it waited on
assert job["output_paths"] == []
def test_media_type_mismatch_fails_for_real(client, fake_comfy):
"""A video mapping that only yields a png is a real failure."""
fake_comfy.outputs_key = "images"
fake_comfy.out_name = "still.png"
fake_comfy.forced_output_node = "12"
with _real_run(client, fake_comfy):
r = client.post(
"/api/workflows",
json={
"name": "映射·类型不符",
"workflow_json": _vault_workflow(),
"usage": "text2video",
"usage_source": "user",
"output_map": [{"nodeId": "12", "kind": "video"}],
},
)
wid = r.json()["id"]
r = client.post(
"/api/playground/generate",
json={"workflow_id": wid, "input_values": {"1": "x"}},
)
job = _wait_done(client, r.json()["job"]["id"])
assert job["status"] == "failed"
assert "媒体类型与映射不符" in job["error"]
assert job["output_paths"] == []
# ---------------------------------------------------------------------------
# 4. Bad / cancelled mappings
# ---------------------------------------------------------------------------
def test_invalid_mappings_are_rejected_in_chinese(client):
r = client.post(
"/api/workflows",
json={"name": "坏映射", "workflow_json": _vault_workflow(),
"usage": "text2video",
"output_map": [{"nodeId": "999", "kind": "video"}]},
)
assert r.status_code == 422 and "不存在" in r.json()["detail"]
r = client.post(
"/api/workflows",
json={"name": "坏映射2", "workflow_json": _vault_workflow(),
"usage": "text2video",
"output_map": [{"nodeId": "12", "kind": "audio"}]},
)
assert r.status_code == 422 and "媒体类型" in r.json()["detail"]
# a prompt/parameter node can never be an output
r = client.post(
"/api/workflows",
json={"name": "坏映射3", "workflow_json": _vault_workflow(),
"usage": "text2video",
"output_map": [{"nodeId": "1", "kind": "video"}]},
)
assert r.status_code == 422 and "不能作为输出节点" in r.json()["detail"]
wid = client.post(
"/api/workflows",
json={"name": "先好后坏", "workflow_json": _vault_workflow(),
"usage": "text2video",
"output_map": [{"nodeId": "12", "kind": "video"}]},
).json()["id"]
r = client.patch(
f"/api/workflows/{wid}", json={"output_map": [{"nodeId": "42", "kind": "image"}]}
)
assert r.status_code == 422 and "不存在" in r.json()["detail"]
def test_clearing_the_mapping_resets_to_pending(client):
wid = client.post(
"/api/workflows",
json={"name": "映射后清空", "workflow_json": _vault_workflow(),
"usage": "text2video",
"output_map": [{"nodeId": "12", "kind": "video"}]},
).json()["id"]
wf = client.get(f"/api/workflows/{wid}").json()
assert wf["is_enabled"] is True
r = client.patch(f"/api/workflows/{wid}", json={"output_map": []})
assert r.status_code == 200
wf = r.json()
assert wf["is_enabled"] is False and not wf["output_map"]
assert wf["usage"] == "text2video" # the usage decision survives
gen = client.post(
"/api/playground/generate",
json={"workflow_id": wid, "input_values": {"1": "x"}},
)
assert gen.status_code == 400
# ---------------------------------------------------------------------------
# 5. Saved mappings survive reanalyze / field edits / migration
# ---------------------------------------------------------------------------
def test_saved_mapping_survives_reanalyze_and_field_edits(client):
r = client.post(
"/api/workflows",
json={"name": "重分析·保映射", "workflow_json": _vault_workflow(),
"usage": "text2video",
"output_map": [{"nodeId": "12", "kind": "video"}]},
)
wid = r.json()["id"]
r = client.patch(f"/api/workflows/{wid}", json={"name": "改名不影响映射",
"description": "编辑其他字段"})
wf = r.json()
assert wf["output_map"] == [{"nodeId": "12", "kind": "video"}]
assert wf["output_map_source"] == "user" and wf["is_enabled"] is True
r = client.post(f"/api/workflows/{wid}/reanalyze")
assert r.status_code == 200
wf = r.json()
assert wf["output_map"] == [{"nodeId": "12", "kind": "video"}]
assert wf["output_map_source"] == "user"
assert wf["usage"] == "text2video" and wf["usage_source"] == "user"
assert wf["is_enabled"] is True
def test_sql_forced_enabled_row_without_mapping_is_blocked(client):
"""Backend-direct generation on an unconfirmed row is refused."""
wid = client.post(
"/api/workflows",
json={"name": "强开", "workflow_json": _vault_workflow(),
"usage": "text2video"},
).json()["id"]
conn = get_db(settings.db_path)
try:
conn.execute("UPDATE workflows SET is_enabled = 1 WHERE id = ?", (wid,))
conn.commit()
finally:
conn.close()
gen = client.post(
"/api/playground/generate",
json={"workflow_id": wid, "input_values": {"1": "x"}},
)
assert gen.status_code == 400
assert "输出节点" in gen.json()["detail"]
def test_migration_parks_unknown_output_rows_and_keeps_trusted_ones(client):
import asyncio
conn = get_db(settings.db_path)
try:
# Pre-HEL-638 shape: user confirmed a usage on an unknown-output
# graph and the old PATCH re-enabled it.
conn.execute(
"INSERT INTO workflows (name, kind, workflow_json, input_schema,"
" output_schema, is_enabled, usage, usage_source)"
" VALUES (?, 'video', ?, '[]', '[]', 1, 'text2video', 'user')",
("存量·未知输出", json.dumps(_vault_workflow())),
)
conn.commit()
finally:
conn.close()
asyncio.run(migrate_db(settings.db_path)) # idempotent re-run
wfs = {w["name"]: w for w in client.get("/api/workflows").json()}
parked = wfs["存量·未知输出"]
assert parked["is_enabled"] is False
assert parked["usage"] == "text2video" # decision preserved
assert not parked["output_map"] and parked["needs_mapping"] is True
# A trusted five-type import keeps working untouched.
r = client.post(
"/api/workflows",
json={"name": "存量·可信", "kind": "image",
"workflow_json": json.loads(
(FIXTURES / "qwen_image_t2i_API.json").read_text(encoding="utf-8")
)},
)
assert r.status_code == 200
trusted = next(w for w in client.get("/api/workflows").json() if w["id"] == r.json()["id"])
assert trusted["is_enabled"] is True
assert trusted["output_map_source"] == "auto"
assert any(e["nodeId"] == "60" and e["kind"] == "image" for e in trusted["output_map"])
+10 -4
View File
@@ -268,12 +268,14 @@ def _scene_ids(pid: int) -> list[int]:
async def _fake_history(_client, _prompt_id, *_args): async def _fake_history(_client, _prompt_id, *_args):
"""A successful ComfyUI history with one video output named out.mp4. """A successful ComfyUI history with one video output named out.mp4,
Extra positional args (job_id) are accepted for the cancel-check wiring.""" reported under the workflow's real output node (30 = the tagged
VHS_VideoCombine). Extra positional args (job_id) are accepted for the
cancel-check wiring."""
return { return {
"status": {"status_str": "success", "completed": True}, "status": {"status_str": "success", "completed": True},
"outputs": { "outputs": {
"99": {"videos": [{"filename": "out.mp4", "subfolder": "", "type": "output"}]} "30": {"videos": [{"filename": "out.mp4", "subfolder": "", "type": "output"}]}
}, },
} }
@@ -287,7 +289,11 @@ def _stub_comfy(monkeypatch, captured: dict) -> list[str]:
prepare_media_inputs handed it; download_image writes out.mp4. Returns prepare_media_inputs handed it; download_image writes out.mp4. Returns
the list that collects uploaded local paths. the list that collects uploaded local paths.
""" """
queue_manager.paused = True # monkeypatch (not bare assignment): queue_manager is a process-level
# singleton — a bare `paused = True` leaks into every later test and
# stalls e.g. test_workbench's worker (HEL-619). monkeypatch restores
# the previous value at teardown.
monkeypatch.setattr(queue_manager, "paused", True)
uploads: list[str] = [] uploads: list[str] = []
async def fake_upload_video(self, path, subfolder="calliope"): async def fake_upload_video(self, path, subfolder="calliope"):
+6
View File
@@ -137,6 +137,7 @@ import type {
WorkflowAnalyzeResult, WorkflowAnalyzeResult,
ComfyDynamicInput, ComfyDynamicInput,
ComfyDynamicOutput, ComfyDynamicOutput,
WorkflowOutputMapEntry,
} from "./comfy/types"; } from "./comfy/types";
export type { export type {
Job, Job,
@@ -148,6 +149,7 @@ export type {
WorkflowAnalyzeResult, WorkflowAnalyzeResult,
ComfyDynamicInput, ComfyDynamicInput,
ComfyDynamicOutput, ComfyDynamicOutput,
WorkflowOutputMapEntry,
}; };
async function api<T>(path: string, init?: RequestInit): Promise<T> { async function api<T>(path: string, init?: RequestInit): Promise<T> {
@@ -470,6 +472,8 @@ export const workflows = {
usage?: WorkflowUsage; usage?: WorkflowUsage;
usage_source?: "auto" | "user"; usage_source?: "auto" | "user";
input_schema?: ComfyDynamicInput[]; input_schema?: ComfyDynamicInput[];
output_map?: WorkflowOutputMapEntry[];
output_map_source?: "auto" | "user";
description?: string; description?: string;
prompt_profile?: string; prompt_profile?: string;
endpoint_id?: string | null; endpoint_id?: string | null;
@@ -490,6 +494,8 @@ export const workflows = {
usage: WorkflowUsage; usage: WorkflowUsage;
usage_source: "auto" | "user"; usage_source: "auto" | "user";
input_schema: ComfyDynamicInput[]; input_schema: ComfyDynamicInput[];
output_map: WorkflowOutputMapEntry[];
output_map_source: "auto" | "user";
}>, }>,
) => ) =>
api<Workflow>(`/api/workflows/${id}`, { api<Workflow>(`/api/workflows/${id}`, {
+17 -1
View File
@@ -45,10 +45,21 @@ export interface ComfyDynamicOutput {
label: string; label: string;
/** Role from title tag, e.g. (Output:image). */ /** Role from title tag, e.g. (Output:image). */
role?: string | null; role?: string | null;
kind: ComfyOutputKind; /** Null while an unknown custom node awaits the user's media-type pick. */
kind: ComfyOutputKind | null;
/** Untagged detection: node class + which rule typed it. */ /** Untagged detection: node class + which rule typed it. */
class_type?: string; class_type?: string;
evidence?: 'registry' | 'class_name_match' | 'unknown_node'; evidence?: 'registry' | 'class_name_match' | 'unknown_node';
/** Form default for unknown candidates — never auto-applied. */
suggested_kind?: 'image' | 'video' | null;
}
/** One entry of a workflow's confirmed output mapping (HEL-638). */
export interface WorkflowOutputMapEntry {
nodeId: string;
kind: 'image' | 'video';
label?: string;
class_type?: string;
} }
/** The five workflow usages the studio distinguishes (HEL-636). */ /** The five workflow usages the studio distinguishes (HEL-636). */
@@ -114,6 +125,11 @@ export interface Workflow {
/** Bound ComfyUI connection id (settings.comfyui_endpoints); null = active. */ /** Bound ComfyUI connection id (settings.comfyui_endpoints); null = active. */
endpoint_id?: string | null; endpoint_id?: string | null;
warnings?: WorkflowWarning[]; warnings?: WorkflowWarning[];
/** HEL-638: confirmed output mapping ({nodeId, kind}); null/empty = pending. */
output_map?: WorkflowOutputMapEntry[] | null;
output_map_source?: 'auto' | 'user' | null;
/** True when the graph has unknown output nodes needing designation. */
needs_mapping?: boolean;
} }
export interface Job { export interface Job {
@@ -63,13 +63,20 @@
const endpoints = $derived($settingsQuery.data?.comfyui_endpoints ?? []); const endpoints = $derived($settingsQuery.data?.comfyui_endpoints ?? []);
const activeId = $derived($settingsQuery.data?.comfyui_active_id ?? endpoints[0]?.id ?? ''); const activeId = $derived($settingsQuery.data?.comfyui_active_id ?? endpoints[0]?.id ?? '');
// HEL-636: the page serves its usages (image → t2i/i2i, video → // HEL-636: the page serves its usages (image → t2i/i2i, video →
// t2v/i2v/ref2v); pending workflows (usage = null) never appear. // t2v/i2v/ref2v); pending workflows (usage = null) never appear.
const kindWorkflows = $derived( // HEL-638: workflows with unconfirmed unknown output nodes are also
($workflowsQuery.data ?? []).filter( // hidden — enabled rows carry a settled output mapping, this is a
(w) => w.is_enabled && (w.usage ?? null) !== null && USAGE_BY_KIND[kind].includes(w.usage!), // 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(() => { const allJobs = $derived.by(() => {
void $jobsQuery.data; void $jobsQuery.data;
@@ -699,6 +706,28 @@
const selectedEntry = $derived( const selectedEntry = $derived(
doneEntries.find((e) => e.key === selectedKey) ?? doneEntries[0] ?? null, 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 { function summaryOf(job: Job): string {
const parts: string[] = []; const parts: string[] = [];
@@ -751,6 +780,26 @@
let curSec = $state(0); let curSec = $state(0);
let durSec = $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 { function fmtClock(s: number): string {
if (!Number.isFinite(s)) return '0:00'; if (!Number.isFinite(s)) return '0:00';
const m = Math.floor(s / 60); const m = Math.floor(s / 60);
@@ -778,13 +827,16 @@
else void playerBox?.requestFullscreen(); else void playerBox?.requestFullscreen();
} }
// First/last frame strip for the selected video job // 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(() => { const selectedFrames = $derived.by(() => {
if (kind !== 'video' || !selectedEntry) return []; if (kind !== 'video' || !selectedEntry) return [];
const wf = ($workflowsQuery.data ?? []).find((w) => w.id === selectedEntry.job.workflow_id); const wf = ($workflowsQuery.data ?? []).find((w) => w.id === selectedEntry.job.workflow_id);
if (!wf) return []; if (!wf) return [];
const vals = (selectedEntry.job.payload?.input_values ?? {}) as Record<string, unknown>; const vals = (selectedEntry.job.payload?.input_values ?? {}) as Record<string, unknown>;
const out: Array<{ label: string; path: string; ref?: boolean }> = []; const out: Array<{ label: string; path: string; ref?: boolean }> = [];
let refIdx = 0;
for (const inp of wf.input_schema ?? []) { for (const inp of wf.input_schema ?? []) {
const h = `${inp.role ?? ''} ${inp.label}`.toLowerCase(); const h = `${inp.role ?? ''} ${inp.label}`.toLowerCase();
const v = vals[inp.nodeId]; const v = vals[inp.nodeId];
@@ -798,6 +850,10 @@
if (typeof v !== 'string' || !v) continue; if (typeof v !== 'string' || !v) continue;
if (/first|start|首帧/.test(h)) out.push({ label: t('studio.slotFirst'), path: v }); 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 (/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; return out;
}); });
@@ -845,12 +901,31 @@
} }
const deleteTarget = $derived(kindJobs.find((j) => j.id === deleteJobId) ?? 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() { async function doDelete() {
if (!deleteJobId) return; if (!deleteJobId) return;
try { try {
await playgroundApi.deleteJob(deleteJobId); await playgroundApi.deleteJob(deleteJobId);
submittedIds.delete(deleteJobId);
if (selectedEntry?.job.id === deleteJobId) selectedKey = null; if (selectedEntry?.job.id === deleteJobId) selectedKey = null;
toast.success(t('studio.deletedToast'));
await client.invalidateQueries({ queryKey: ['playground-jobs'] }); await client.invalidateQueries({ queryKey: ['playground-jobs'] });
await client.invalidateQueries({ queryKey: ['jobs'] });
} catch (err) { } catch (err) {
toast.error(err instanceof Error ? err.message : String(err)); toast.error(err instanceof Error ? err.message : String(err));
} finally { } finally {
@@ -1495,11 +1570,20 @@
<Icon name="upload" size={13} /> <Icon name="upload" size={13} />
{t('studio.sendToImg2Img')} {t('studio.sendToImg2Img')}
</Button> </Button>
<a class="a-btn secondary sm" href={assetUrl(selectedEntry.path)} download={downloadName(selectedEntry.path)}> <a class="a-btn secondary sm" href={assetUrl(selectedEntry.path)} download={downloadName(selectedEntry.path)}>
<Icon name="download" size={13} /> <Icon name="download" size={13} />
{t('studio.download')} {t('studio.download')}
</a> </a>
</span> <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> </div>
{/if} {/if}
{:else} {:else}
@@ -1514,7 +1598,8 @@
<h2>{t('studio.video.resultsTitle')}</h2> <h2>{t('studio.video.resultsTitle')}</h2>
{#if selectedEntry} {#if selectedEntry}
<span class="panel-hint"> <span class="panel-hint">
{t('studio.lastDone', { {wfName(selectedEntry.job)} ·
{t('studio.doneAt', {
time: fmtTime(parseDbTs(selectedEntry.job.completed_at ?? selectedEntry.job.created_at)), time: fmtTime(parseDbTs(selectedEntry.job.completed_at ?? selectedEntry.job.created_at)),
})} })}
</span> </span>
@@ -1587,11 +1672,20 @@
<Icon name="retry" size={13} /> <Icon name="retry" size={13} />
{t('studio.retryLink')} {t('studio.retryLink')}
</Button> </Button>
<a class="a-btn secondary sm" href={assetUrl(selectedEntry.path)} download={downloadName(selectedEntry.path)}> <a class="a-btn secondary sm" href={assetUrl(selectedEntry.path)} download={downloadName(selectedEntry.path)}>
<Icon name="download" size={13} /> <Icon name="download" size={13} />
{t('studio.downloadMp4')} {t('studio.downloadMp4')}
</a> </a>
</span> <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> </div>
{:else} {:else}
<p class="empty-line">{t('studio.historyEmptyVideo')}</p> <p class="empty-line">{t('studio.historyEmptyVideo')}</p>
@@ -1612,59 +1706,73 @@
{kind === 'image' ? t('studio.historyEmptyImage') : t('studio.historyEmptyVideo')} {kind === 'image' ? t('studio.historyEmptyImage') : t('studio.historyEmptyVideo')}
</p> </p>
{:else} {:else}
<div class="history-list"> <div class="history-list">
{#each kindJobs as job (job.id)} {#each kindJobs as job (job.id)}
{@const st = jobStatusInfo(job)} {@const st = jobStatusInfo(job)}
<div class="hist-row" class:failed={job.status === 'failed'} class:video={kind === 'video'}> <div
<div class="hist-thumb" class:video={kind === 'video'}> class="hist-row"
{#if job.output_paths?.[0]} class:failed={job.status === 'failed'}
{#if kind === 'image'} class:video={kind === 'video'}
<img src={assetUrl(job.output_paths[0])} alt={wfName(job)} loading="lazy" /> class:selected={selectedJobId === job.id}
{:else} role="button"
<video tabindex={0}
src={assetUrl(job.output_paths[0])} aria-label={`${wfName(job)} · ${st.label}`}
preload="metadata" aria-current={selectedJobId === job.id ? 'true' : undefined}
muted onclick={() => selectFromHistory(job)}
onloadedmetadata={(e) => noteDuration(job.output_paths![0], e)} onkeydown={(e) => histRowKey(e, job)}
></video> >
{#if durations[job.output_paths[0]]} <div class="hist-thumb" class:video={kind === 'video'}>
<span class="dur mono">{fmtClock(durations[job.output_paths[0]])}</span> {#if job.output_paths?.[0]}
{/if} {#if kind === 'image'}
{/if} <img src={assetUrl(job.output_paths[0])} alt={wfName(job)} loading="lazy" />
{:else if job.status === 'failed'}
<span class="thumb-fallback failed"><Icon name="alert" size={14} /></span>
{:else} {:else}
<span class="thumb-fallback"><Icon name={kind === 'image' ? 'image' : 'film'} size={14} /></span> <video
{/if} src={assetUrl(job.output_paths[0])}
</div> preload="metadata"
<div class="hist-body"> muted
<div class="hist-name" title={wfName(job)}>{wfName(job)}</div> onloadedmetadata={(e) => noteDuration(job.output_paths![0], e)}
<div class="hist-meta mono">{summaryOf(job)}</div> ></video>
<div class="hist-status"> {#if durations[job.output_paths[0]]}
{#if job.status !== 'failed'} <span class="dur mono">{fmtClock(durations[job.output_paths[0]])}</span>
<span class="st {st.tone}" title={st.detail}>{st.label}</span>
{:else}
<button
type="button"
class="st fail-link"
disabled={retryingId === job.id}
onclick={() => retryJob(job)}
>
{t('studio.retryLink')}
</button>
{/if} {/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 <button
type="button" type="button"
class="hist-del" class="st fail-link"
title={t('studio.deleteBtn')} disabled={retryingId === job.id}
onclick={() => { onclick={(e) => {
deleteJobId = job.id; e.stopPropagation();
deleteOpen = true; retryJob(job);
}} }}
> >
<Icon name="trash" size={13} /> {t('studio.retryLink')}
</button> </button>
</div> {/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} {#if job.status === 'failed' && job.error}
<div class="hist-error">{job.error}</div> <div class="hist-error">{job.error}</div>
{:else if st.tone === 'fail' || (job.status === 'done' && job.phase === 'dry_run')} {:else if st.tone === 'fail' || (job.status === 'done' && job.phase === 'dry_run')}
@@ -1704,9 +1812,10 @@
<ConfirmDialog <ConfirmDialog
bind:open={deleteOpen} bind:open={deleteOpen}
title={t('studio.delTitle')} title={deleteTitle}
message={t('studio.delConfirm')} message={deleteMessage}
confirmLabel={t('studio.deleteBtn')} confirmLabel={t('studio.deleteBtn')}
cancelLabel={t('common.cancel')}
danger danger
onconfirm={doDelete} onconfirm={doDelete}
oncancel={() => { oncancel={() => {
@@ -2288,10 +2397,23 @@
border-radius: 8px; border-radius: 8px;
min-height: 44px; min-height: 44px;
align-items: center; align-items: center;
cursor: pointer;
} }
.hist-row:hover { .hist-row:hover {
background: var(--surface-2); 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 { .hist-row.failed {
background: var(--error-dim); background: var(--error-dim);
} }
@@ -2417,6 +2539,15 @@
.hist-row:hover .hist-del { .hist-row:hover .hist-del {
opacity: 1; 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 { .hist-del:hover {
color: var(--error); color: var(--error);
background: var(--error-dim); background: var(--error-dim);
+16 -2
View File
@@ -1435,6 +1435,17 @@ export const de: Dict = {
'conn.wfSourceAuto': 'Usage auto-detected', 'conn.wfSourceAuto': 'Usage auto-detected',
'conn.wfDisabledBadge': 'Disabled', 'conn.wfDisabledBadge': 'Disabled',
'conn.wfConfirmAria': 'Confirm workflow usage', 'conn.wfConfirmAria': 'Confirm workflow usage',
'conn.wfOutputLabel': 'Ausgabeknoten',
'conn.wfOutputNeedPick': 'Unbekannte benutzerdefinierte Ausgabeknoten — bitte zuordnen',
'conn.wfOutputHint': 'Markieren Sie die Knoten, die tatsächlich Ergebnisse liefern, und wählen Sie je den Medientyp; die Generierung sammelt Bilder/Videos nur aus diesen Knoten.',
'conn.wfOutputPick': 'Mindestens einen Ausgabeknoten markieren',
'conn.wfOutputKindAria': 'Medientyp des Ausgabeknotens',
'conn.wfOutputPendingBadge': 'Ausgabe offen',
'conn.wfOutputNeedMap': 'Dieser Workflow enthält nicht erkannte Ausgabeknoten; ordnen Sie sie samt Medientyp zu, um ihn zu aktivieren',
'conn.wfOutputApply': 'Ausgabezuordnung speichern',
'conn.wfMapCancel': 'Abbrechen',
'conn.wfOutputApplied': 'Ausgabezuordnung gespeichert: Knoten {nodes}',
'conn.wfOutputCleared': 'Ausgabezuordnung gelöscht — der Workflow ist wieder ausstehend',
'conn.missingMaterial': 'Ein dediziertes Qwen Image 2.1-Workflow-JSON fehlt noch im Repo: aus ComfyUI exportieren und hier importieren — der generische Importweg steht bereit.', 'conn.missingMaterial': 'Ein dediziertes Qwen Image 2.1-Workflow-JSON fehlt noch im Repo: aus ComfyUI exportieren und hier importieren — der generische Importweg steht bereit.',
// --- Eigenständige Bild-/Videogenerierung (a3/a4, HEL-612) --- // --- Eigenständige Bild-/Videogenerierung (a3/a4, HEL-612) ---
@@ -1451,7 +1462,7 @@ export const de: Dict = {
'studio.image.historyTitle': 'Bildverlauf', 'studio.image.historyTitle': 'Bildverlauf',
'studio.video.historyTitle': 'Videoverlauf', 'studio.video.historyTitle': 'Videoverlauf',
'studio.historyCount': '{n} gesamt', 'studio.historyCount': '{n} gesamt',
'studio.lastDone': 'Zuletzt fertig · {time}', 'studio.doneAt': 'Fertiggestellt um {time}',
'studio.kindImageText': 'Bild', 'studio.kindImageText': 'Bild',
'studio.kindVideoText': 'Video', 'studio.kindVideoText': 'Video',
'studio.loading': 'Lädt…', 'studio.loading': 'Lädt…',
@@ -1567,7 +1578,10 @@ export const de: Dict = {
'studio.cancelToast': 'Abbruch angefordert', 'studio.cancelToast': 'Abbruch angefordert',
'studio.deleteBtn': 'Löschen', 'studio.deleteBtn': 'Löschen',
'studio.delTitle': 'Aufgabeneintrag löschen', 'studio.delTitle': 'Aufgabeneintrag löschen',
'studio.delConfirm': 'Die Ergebnisdateien werden mitgelöscht. Löschen?', 'studio.delConfirm': 'Beim Löschen werden auch die Ergebnisdateien dieses Auftrags entfernt; der Verlauf ist nicht wiederherstellbar. Löschen?',
'studio.delTitleJob': 'Auftrag „{name}“ löschen',
'studio.delConfirmMulti': 'Dieser Auftrag hat {n} Ergebnisse. Beim Löschen werden der gesamte Auftragsdatensatz und alle {n} Ergebnisdateien entfernt; dies ist unwiderruflich. Löschen?',
'studio.deletedToast': 'Auftrag und zugehörige Ergebnisdateien gelöscht',
'studio.wfEmptyTitle': 'Noch keine {kind}-Workflows', 'studio.wfEmptyTitle': 'Noch keine {kind}-Workflows',
'studio.wfEmptyBody': 'Entwicklermodus in ComfyUI aktivieren, Workflow als API-JSON exportieren und auf der Seite ComfyUI-Verbindungen als {kind} importieren.', 'studio.wfEmptyBody': 'Entwicklermodus in ComfyUI aktivieren, Workflow als API-JSON exportieren und auf der Seite ComfyUI-Verbindungen als {kind} importieren.',
'studio.wfEmptyGo': 'In ComfyUI-Verbindungen importieren', 'studio.wfEmptyGo': 'In ComfyUI-Verbindungen importieren',
+16 -2
View File
@@ -1435,6 +1435,17 @@ export const en = {
'conn.wfSourceAuto': 'Usage auto-detected', 'conn.wfSourceAuto': 'Usage auto-detected',
'conn.wfDisabledBadge': 'Disabled', 'conn.wfDisabledBadge': 'Disabled',
'conn.wfConfirmAria': 'Confirm workflow usage', 'conn.wfConfirmAria': 'Confirm workflow usage',
'conn.wfOutputLabel': 'Output nodes',
'conn.wfOutputNeedPick': 'Unrecognized custom output nodes — designate them',
'conn.wfOutputHint': 'Check the nodes that actually produce results and pick each one’s media type; generation harvests images/videos only from these nodes.',
'conn.wfOutputPick': 'Check at least one output node',
'conn.wfOutputKindAria': 'Output node media type',
'conn.wfOutputPendingBadge': 'Outputs unset',
'conn.wfOutputNeedMap': 'This workflow has unrecognized output nodes; designate them and their media type to enable it',
'conn.wfOutputApply': 'Save output mapping',
'conn.wfMapCancel': 'Cancel',
'conn.wfOutputApplied': 'Output mapping saved: node {nodes}',
'conn.wfOutputCleared': 'Output mapping cleared — the workflow is pending again',
'conn.missingMaterial': 'A dedicated Qwen Image 2.1 workflow JSON is not in the repo yet: export it from ComfyUI and import it here — the generic import path is ready.', 'conn.missingMaterial': 'A dedicated Qwen Image 2.1 workflow JSON is not in the repo yet: export it from ComfyUI and import it here — the generic import path is ready.',
// --- Standalone image / video generation (a3/a4, HEL-612) --- // --- Standalone image / video generation (a3/a4, HEL-612) ---
'studio.image.title': 'Image', 'studio.image.title': 'Image',
@@ -1450,7 +1461,7 @@ export const en = {
'studio.image.historyTitle': 'Image history', 'studio.image.historyTitle': 'Image history',
'studio.video.historyTitle': 'Video history', 'studio.video.historyTitle': 'Video history',
'studio.historyCount': '{n} total', 'studio.historyCount': '{n} total',
'studio.lastDone': 'Last done · {time}', 'studio.doneAt': 'Done at {time}',
'studio.kindImageText': 'image', 'studio.kindImageText': 'image',
'studio.kindVideoText': 'video', 'studio.kindVideoText': 'video',
'studio.loading': 'Loading…', 'studio.loading': 'Loading…',
@@ -1566,7 +1577,10 @@ export const en = {
'studio.cancelToast': 'Cancel requested', 'studio.cancelToast': 'Cancel requested',
'studio.deleteBtn': 'Delete', 'studio.deleteBtn': 'Delete',
'studio.delTitle': 'Delete task record', 'studio.delTitle': 'Delete task record',
'studio.delConfirm': 'The result files will be removed together with the record. Delete it?', 'studio.delConfirm': 'Deleting also removes this job’s result files; the history cannot be restored. Delete?',
'studio.delTitleJob': 'Delete job “{name}”',
'studio.delConfirmMulti': 'This job produced {n} results. Deleting removes the whole job record and all {n} result files; this cannot be undone. Delete?',
'studio.deletedToast': 'Job deleted together with its result files',
'studio.wfEmptyTitle': 'No {kind} workflows yet', 'studio.wfEmptyTitle': 'No {kind} workflows yet',
'studio.wfEmptyBody': "Enable ComfyUI's developer mode, export the workflow as API JSON, then import it on the ComfyUI Connections page as {kind}.", 'studio.wfEmptyBody': "Enable ComfyUI's developer mode, export the workflow as API JSON, then import it on the ComfyUI Connections page as {kind}.",
'studio.wfEmptyGo': 'Import in ComfyUI Connections', 'studio.wfEmptyGo': 'Import in ComfyUI Connections',
+16 -2
View File
@@ -1435,6 +1435,17 @@ export const es: Dict = {
'conn.wfSourceAuto': 'Usage auto-detected', 'conn.wfSourceAuto': 'Usage auto-detected',
'conn.wfDisabledBadge': 'Disabled', 'conn.wfDisabledBadge': 'Disabled',
'conn.wfConfirmAria': 'Confirm workflow usage', 'conn.wfConfirmAria': 'Confirm workflow usage',
'conn.wfOutputLabel': 'Nodos de salida',
'conn.wfOutputNeedPick': 'Nodos de salida personalizados no reconocidos: asígnalos',
'conn.wfOutputHint': 'Marca los nodos que realmente producen resultados y elige el tipo de medio de cada uno; la generación solo extrae imágenes/vídeos de estos nodos.',
'conn.wfOutputPick': 'Marca al menos un nodo de salida',
'conn.wfOutputKindAria': 'Tipo de medio del nodo de salida',
'conn.wfOutputPendingBadge': 'Salida pendiente',
'conn.wfOutputNeedMap': 'Este flujo tiene nodos de salida no reconocidos; asígnalos y su tipo de medio para activarlo',
'conn.wfOutputApply': 'Guardar mapeo de salida',
'conn.wfMapCancel': 'Cancelar',
'conn.wfOutputApplied': 'Mapeo de salida guardado: nodo {nodes}',
'conn.wfOutputCleared': 'Mapeo de salida borrado: el flujo vuelve a estar pendiente',
'conn.missingMaterial': 'Aún falta en el repo un JSON dedicado de Qwen Image 2.1: expórtalo desde ComfyUI e impórtalo aquí; la vía genérica ya está lista.', 'conn.missingMaterial': 'Aún falta en el repo un JSON dedicado de Qwen Image 2.1: expórtalo desde ComfyUI e impórtalo aquí; la vía genérica ya está lista.',
// --- Generación independiente de imagen / vídeo (a3/a4, HEL-612) --- // --- Generación independiente de imagen / vídeo (a3/a4, HEL-612) ---
@@ -1451,7 +1462,7 @@ export const es: Dict = {
'studio.image.historyTitle': 'Historial de imágenes', 'studio.image.historyTitle': 'Historial de imágenes',
'studio.video.historyTitle': 'Historial de vídeos', 'studio.video.historyTitle': 'Historial de vídeos',
'studio.historyCount': '{n} en total', 'studio.historyCount': '{n} en total',
'studio.lastDone': 'Último · {time}', 'studio.doneAt': 'Completado a las {time}',
'studio.kindImageText': 'imagen', 'studio.kindImageText': 'imagen',
'studio.kindVideoText': 'vídeo', 'studio.kindVideoText': 'vídeo',
'studio.loading': 'Cargando…', 'studio.loading': 'Cargando…',
@@ -1567,7 +1578,10 @@ export const es: Dict = {
'studio.cancelToast': 'Cancelación solicitada', 'studio.cancelToast': 'Cancelación solicitada',
'studio.deleteBtn': 'Eliminar', 'studio.deleteBtn': 'Eliminar',
'studio.delTitle': 'Eliminar registro de tarea', 'studio.delTitle': 'Eliminar registro de tarea',
'studio.delConfirm': 'Los archivos de resultados se eliminarán junto con el registro. ¿Eliminar?', 'studio.delConfirm': 'Al eliminar también se quitan los archivos de resultados de esta tarea; el historial no se puede restaurar. ¿Eliminar?',
'studio.delTitleJob': 'Eliminar tarea «{name}»',
'studio.delConfirmMulti': 'Esta tarea produjo {n} resultados. Al eliminarla se quita el registro completo y los {n} archivos de resultados; no se puede deshacer. ¿Eliminar?',
'studio.deletedToast': 'Tarea eliminada junto con sus archivos de resultados',
'studio.wfEmptyTitle': 'Aún no hay flujos de {kind}', 'studio.wfEmptyTitle': 'Aún no hay flujos de {kind}',
'studio.wfEmptyBody': 'Activa el modo desarrollador de ComfyUI, exporta el flujo como JSON API e impórtalo en Conexiones ComfyUI como {kind}.', 'studio.wfEmptyBody': 'Activa el modo desarrollador de ComfyUI, exporta el flujo como JSON API e impórtalo en Conexiones ComfyUI como {kind}.',
'studio.wfEmptyGo': 'Importar en Conexiones ComfyUI', 'studio.wfEmptyGo': 'Importar en Conexiones ComfyUI',
+16 -2
View File
@@ -1435,6 +1435,17 @@ export const fr: Dict = {
'conn.wfSourceAuto': 'Usage auto-detected', 'conn.wfSourceAuto': 'Usage auto-detected',
'conn.wfDisabledBadge': 'Disabled', 'conn.wfDisabledBadge': 'Disabled',
'conn.wfConfirmAria': 'Confirm workflow usage', 'conn.wfConfirmAria': 'Confirm workflow usage',
'conn.wfOutputLabel': 'Nœuds de sortie',
'conn.wfOutputNeedPick': 'Nœuds de sortie personnalisés non reconnus — à désigner',
'conn.wfOutputHint': 'Cochez les nœuds qui produisent réellement les résultats et choisissez leur type de média ; la génération ne collecte les images/vidéos que sur ces nœuds.',
'conn.wfOutputPick': 'Cochez au moins un nœud de sortie',
'conn.wfOutputKindAria': 'Type de média du nœud de sortie',
'conn.wfOutputPendingBadge': 'Sortie à définir',
'conn.wfOutputNeedMap': 'Ce workflow contient des nœuds de sortie non reconnus ; désignez-les avec leur type de média pour l’activer',
'conn.wfOutputApply': 'Enregistrer le mapping de sortie',
'conn.wfMapCancel': 'Annuler',
'conn.wfOutputApplied': 'Mapping de sortie enregistré : nœud {nodes}',
'conn.wfOutputCleared': 'Mapping de sortie effacé — le workflow est de nouveau en attente',
'conn.missingMaterial': 'Un JSON de workflow Qwen Image 2.1 dédié manque encore au dépôt : exportez-le depuis ComfyUI et importez-le ici — le chemin d\'import générique est prêt.', 'conn.missingMaterial': 'Un JSON de workflow Qwen Image 2.1 dédié manque encore au dépôt : exportez-le depuis ComfyUI et importez-le ici — le chemin d\'import générique est prêt.',
// --- Génération indépendante image / vidéo (a3/a4, HEL-612) --- // --- Génération indépendante image / vidéo (a3/a4, HEL-612) ---
@@ -1451,7 +1462,7 @@ export const fr: Dict = {
'studio.image.historyTitle': 'Historique images', 'studio.image.historyTitle': 'Historique images',
'studio.video.historyTitle': 'Historique vidéos', 'studio.video.historyTitle': 'Historique vidéos',
'studio.historyCount': '{n} au total', 'studio.historyCount': '{n} au total',
'studio.lastDone': 'Dernier · {time}', 'studio.doneAt': 'Terminé à {time}',
'studio.kindImageText': 'image', 'studio.kindImageText': 'image',
'studio.kindVideoText': 'vidéo', 'studio.kindVideoText': 'vidéo',
'studio.loading': 'Chargement…', 'studio.loading': 'Chargement…',
@@ -1567,7 +1578,10 @@ export const fr: Dict = {
'studio.cancelToast': 'Annulation demandée', 'studio.cancelToast': 'Annulation demandée',
'studio.deleteBtn': 'Supprimer', 'studio.deleteBtn': 'Supprimer',
'studio.delTitle': 'Supprimer la tâche', 'studio.delTitle': 'Supprimer la tâche',
'studio.delConfirm': 'Les fichiers de résultats seront supprimés avec la tâche. Supprimer ?', 'studio.delConfirm': 'La suppression retire aussi les fichiers de résultats de cette tâche ; l’historique est irrécupérable. Supprimer ?',
'studio.delTitleJob': 'Supprimer la tâche « {name} »',
'studio.delConfirmMulti': 'Cette tâche a produit {n} résultats. La suppression retire la tâche entière et ses {n} fichiers de résultats ; action irréversible. Supprimer ?',
'studio.deletedToast': 'Tâche supprimée avec ses fichiers de résultats',
'studio.wfEmptyTitle': 'Pas encore de workflows {kind}', 'studio.wfEmptyTitle': 'Pas encore de workflows {kind}',
'studio.wfEmptyBody': 'Activez le mode développeur de ComfyUI, exportez le workflow en JSON API, puis importez-le dans Connexions ComfyUI comme {kind}.', 'studio.wfEmptyBody': 'Activez le mode développeur de ComfyUI, exportez le workflow en JSON API, puis importez-le dans Connexions ComfyUI comme {kind}.',
'studio.wfEmptyGo': 'Importer dans Connexions ComfyUI', 'studio.wfEmptyGo': 'Importer dans Connexions ComfyUI',
+16 -2
View File
@@ -1435,6 +1435,17 @@ export const ja: Dict = {
'conn.wfSourceAuto': 'Usage auto-detected', 'conn.wfSourceAuto': 'Usage auto-detected',
'conn.wfDisabledBadge': 'Disabled', 'conn.wfDisabledBadge': 'Disabled',
'conn.wfConfirmAria': 'Confirm workflow usage', 'conn.wfConfirmAria': 'Confirm workflow usage',
'conn.wfOutputLabel': '出力ノード',
'conn.wfOutputNeedPick': '認識できないカスタム出力ノードがあります。手動で指定してください',
'conn.wfOutputHint': '実際に結果を出すノードにチェックし、それぞれのメディア種別を選んでください。生成時にこれらのノードからのみ画像/動画を取り出します。',
'conn.wfOutputPick': '出力ノードを1つ以上チェックしてください',
'conn.wfOutputKindAria': '出力ノードのメディア種別',
'conn.wfOutputPendingBadge': '出力未指定',
'conn.wfOutputNeedMap': '認識できない出力ノードを含みます。ノードとメディア種別を指定すると有効化できます',
'conn.wfOutputApply': '出力マッピングを保存',
'conn.wfMapCancel': 'キャンセル',
'conn.wfOutputApplied': '出力マッピングを保存しました:ノード {nodes}',
'conn.wfOutputCleared': '出力マッピングを解除しました。ワークフローは保留に戻ります',
'conn.missingMaterial': 'Qwen Image 2.1 専用のワークフロー JSON はまだリポジトリにありません。ComfyUI から書き出してここで取り込んでください。汎用の取り込み経路は用意済みです。', 'conn.missingMaterial': 'Qwen Image 2.1 専用のワークフロー JSON はまだリポジトリにありません。ComfyUI から書き出してここで取り込んでください。汎用の取り込み経路は用意済みです。',
// --- 独立画像/動画生成(a3/a4、HEL-612)--- // --- 独立画像/動画生成(a3/a4、HEL-612)---
@@ -1451,7 +1462,7 @@ export const ja: Dict = {
'studio.image.historyTitle': '画像生成履歴', 'studio.image.historyTitle': '画像生成履歴',
'studio.video.historyTitle': '動画生成履歴', 'studio.video.historyTitle': '動画生成履歴',
'studio.historyCount': '計 {n} 回', 'studio.historyCount': '計 {n} 回',
'studio.lastDone': '最終完了 · {time}', 'studio.doneAt': '完了 {time}',
'studio.kindImageText': '画像', 'studio.kindImageText': '画像',
'studio.kindVideoText': '動画', 'studio.kindVideoText': '動画',
'studio.loading': '読み込み中…', 'studio.loading': '読み込み中…',
@@ -1567,7 +1578,10 @@ export const ja: Dict = {
'studio.cancelToast': 'キャンセルを要求しました', 'studio.cancelToast': 'キャンセルを要求しました',
'studio.deleteBtn': '削除', 'studio.deleteBtn': '削除',
'studio.delTitle': 'タスク記録を削除', 'studio.delTitle': 'タスク記録を削除',
'studio.delConfirm': '結果ファイルも一緒に削除され、履歴は復元できません。削除しますか?', 'studio.delConfirm': '削除するとこのタスクの結果ファイルも削除され、履歴は元に戻せません。削除しますか?',
'studio.delTitleJob': 'タスク「{name}」を削除',
'studio.delConfirmMulti': 'このタスクには結果が {n} 件あります。削除するとタスク記録と {n} 件すべての結果ファイルが失われ、元に戻せません。削除しますか?',
'studio.deletedToast': 'タスクと結果ファイルを削除しました',
'studio.wfEmptyTitle': '{kind}ワークフローがまだありません', 'studio.wfEmptyTitle': '{kind}ワークフローがまだありません',
'studio.wfEmptyBody': 'ComfyUI の開発者モードで API 形式 JSON を書き出し、「ComfyUI 接続」ページで{kind}として取り込んでください。', 'studio.wfEmptyBody': 'ComfyUI の開発者モードで API 形式 JSON を書き出し、「ComfyUI 接続」ページで{kind}として取り込んでください。',
'studio.wfEmptyGo': '「ComfyUI 接続」で取り込む', 'studio.wfEmptyGo': '「ComfyUI 接続」で取り込む',
+16 -2
View File
@@ -1435,6 +1435,17 @@ export const ko: Dict = {
'conn.wfSourceAuto': 'Usage auto-detected', 'conn.wfSourceAuto': 'Usage auto-detected',
'conn.wfDisabledBadge': 'Disabled', 'conn.wfDisabledBadge': 'Disabled',
'conn.wfConfirmAria': 'Confirm workflow usage', 'conn.wfConfirmAria': 'Confirm workflow usage',
'conn.wfOutputLabel': '출력 노드',
'conn.wfOutputNeedPick': '인식할 수 없는 사용자 지정 출력 노드가 있습니다. 직접 지정하세요',
'conn.wfOutputHint': '실제 결과를 내는 노드를 체크하고 각각의 미디어 유형을 선택하세요. 생성 시 이 노드에서만 이미지/동영상을 수집합니다.',
'conn.wfOutputPick': '출력 노드를 하나 이상 체크하세요',
'conn.wfOutputKindAria': '출력 노드 미디어 유형',
'conn.wfOutputPendingBadge': '출력 미지정',
'conn.wfOutputNeedMap': '인식할 수 없는 출력 노드가 포함되어 있습니다. 노드와 미디어 유형을 지정하면 활성화됩니다',
'conn.wfOutputApply': '출력 매핑 저장',
'conn.wfMapCancel': '취소',
'conn.wfOutputApplied': '출력 매핑 저장됨: 노드 {nodes}',
'conn.wfOutputCleared': '출력 매핑이 삭제되었습니다. 워크플로가 다시 대기 상태가 됩니다',
'conn.missingMaterial': 'Qwen Image 2.1 전용 워크플로 JSON이 아직 저장소에 없습니다. ComfyUI에서 내보내 여기서 가져오세요. 범용 가져오기 경로는 준비되어 있습니다.', 'conn.missingMaterial': 'Qwen Image 2.1 전용 워크플로 JSON이 아직 저장소에 없습니다. ComfyUI에서 내보내 여기서 가져오세요. 범용 가져오기 경로는 준비되어 있습니다.',
// --- 독립 이미지/비디오 생성 (a3/a4, HEL-612) --- // --- 독립 이미지/비디오 생성 (a3/a4, HEL-612) ---
@@ -1451,7 +1462,7 @@ export const ko: Dict = {
'studio.image.historyTitle': '이미지 생성 기록', 'studio.image.historyTitle': '이미지 생성 기록',
'studio.video.historyTitle': '영상 생성 기록', 'studio.video.historyTitle': '영상 생성 기록',
'studio.historyCount': '총 {n}회', 'studio.historyCount': '총 {n}회',
'studio.lastDone': '최근 완료 · {time}', 'studio.doneAt': '완료 {time}',
'studio.kindImageText': '이미지', 'studio.kindImageText': '이미지',
'studio.kindVideoText': '비디오', 'studio.kindVideoText': '비디오',
'studio.loading': '불러오는 중…', 'studio.loading': '불러오는 중…',
@@ -1567,7 +1578,10 @@ export const ko: Dict = {
'studio.cancelToast': '취소를 요청했습니다', 'studio.cancelToast': '취소를 요청했습니다',
'studio.deleteBtn': '삭제', 'studio.deleteBtn': '삭제',
'studio.delTitle': '작업 기록 삭제', 'studio.delTitle': '작업 기록 삭제',
'studio.delConfirm': '결과 파일도 함께 삭제되며 기록은 복구할 수 없습니다. 삭제할까요?', 'studio.delConfirm': '삭제 시 이 작업의 결과 파일도 함께 제거되며 기록은 복구할 수 없습니다. 삭제할까요?',
'studio.delTitleJob': '작업 «{name}» 삭제',
'studio.delConfirmMulti': '이 작업에는 결과가 {n}개 있습니다. 삭제하면 작업 기록과 결과 파일 {n}개 모두 제거되며 복구할 수 없습니다. 삭제할까요?',
'studio.deletedToast': '작업과 결과 파일을 삭제했습니다',
'studio.wfEmptyTitle': '{kind} 워크플로가 아직 없습니다', 'studio.wfEmptyTitle': '{kind} 워크플로가 아직 없습니다',
'studio.wfEmptyBody': 'ComfyUI 개발자 모드를 켜고 API 형식 JSON으로 내보낸 뒤, ComfyUI 연결 페이지에서 {kind}(으)로 가져오세요.', 'studio.wfEmptyBody': 'ComfyUI 개발자 모드를 켜고 API 형식 JSON으로 내보낸 뒤, ComfyUI 연결 페이지에서 {kind}(으)로 가져오세요.',
'studio.wfEmptyGo': 'ComfyUI 연결에서 가져오기', 'studio.wfEmptyGo': 'ComfyUI 연결에서 가져오기',
+15 -1
View File
@@ -1435,6 +1435,17 @@ export const zh: Dict = {
'conn.wfSourceAuto': '用途为自动判定', 'conn.wfSourceAuto': '用途为自动判定',
'conn.wfDisabledBadge': '已停用', 'conn.wfDisabledBadge': '已停用',
'conn.wfConfirmAria': '确认工作流用途', 'conn.wfConfirmAria': '确认工作流用途',
'conn.wfOutputLabel': '输出节点',
'conn.wfOutputNeedPick': '存在无法识别的自定义输出节点,需人工指定',
'conn.wfOutputHint': '勾选实际产生结果的节点,并为每个节点选择媒体类型;生成时只从这些节点提取图片/视频。',
'conn.wfOutputPick': '请至少勾选一个输出节点',
'conn.wfOutputKindAria': '输出节点媒体类型',
'conn.wfOutputPendingBadge': '待指定输出',
'conn.wfOutputNeedMap': '该工作流含无法识别的输出节点,指定输出节点及媒体类型后才能启用',
'conn.wfOutputApply': '保存输出映射',
'conn.wfMapCancel': '取消',
'conn.wfOutputApplied': '已保存输出映射:节点 {nodes}',
'conn.wfOutputCleared': '已清除输出映射,工作流回到待确认状态',
'conn.missingMaterial': 'Qwen Image 2.1 的专用工作流 JSON 仓库中暂缺:请从 ComfyUI 导出后在此导入,通用导入通道已就绪。', 'conn.missingMaterial': 'Qwen Image 2.1 的专用工作流 JSON 仓库中暂缺:请从 ComfyUI 导出后在此导入,通用导入通道已就绪。',
// --- 独立生图 / 生视频(a3/a4,HEL-612)--- // --- 独立生图 / 生视频(a3/a4,HEL-612)---
'studio.image.title': '生图', 'studio.image.title': '生图',
@@ -1450,7 +1461,7 @@ export const zh: Dict = {
'studio.image.historyTitle': '生图历史', 'studio.image.historyTitle': '生图历史',
'studio.video.historyTitle': '生视频历史', 'studio.video.historyTitle': '生视频历史',
'studio.historyCount': '共 {n} 次', 'studio.historyCount': '共 {n} 次',
'studio.lastDone': '最近完成 · {time}', 'studio.doneAt': '完成于 {time}',
'studio.kindImageText': '图片', 'studio.kindImageText': '图片',
'studio.kindVideoText': '视频', 'studio.kindVideoText': '视频',
'studio.loading': '正在加载…', 'studio.loading': '正在加载…',
@@ -1568,6 +1579,9 @@ export const zh: Dict = {
'studio.deleteBtn': '删除', 'studio.deleteBtn': '删除',
'studio.delTitle': '删除任务记录', 'studio.delTitle': '删除任务记录',
'studio.delConfirm': '删除后该任务的结果文件会一并移除,历史不可恢复。确定删除?', 'studio.delConfirm': '删除后该任务的结果文件会一并移除,历史不可恢复。确定删除?',
'studio.delTitleJob': '删除任务「{name}」',
'studio.delConfirmMulti': '该任务共生成 {n} 个结果,删除将移除整条任务记录及其全部 {n} 个结果文件,历史不可恢复。确定删除?',
'studio.deletedToast': '已删除该任务及其结果文件',
'studio.wfEmptyTitle': '还没有{kind}工作流', 'studio.wfEmptyTitle': '还没有{kind}工作流',
'studio.wfEmptyBody': '在 ComfyUI 里启用开发者模式,用「导出(API 格式)」得到 JSON,再到「ComfyUI 连接」页导入并分类为{kind}。', 'studio.wfEmptyBody': '在 ComfyUI 里启用开发者模式,用「导出(API 格式)」得到 JSON,再到「ComfyUI 连接」页导入并分类为{kind}。',
'studio.wfEmptyGo': '去「ComfyUI 连接」导入', 'studio.wfEmptyGo': '去「ComfyUI 连接」导入',
+5 -6
View File
@@ -18,7 +18,6 @@
type NamedAgent, type NamedAgent,
type SkillAdminEntry, type SkillAdminEntry,
type SkillVersion, type SkillVersion,
type Settings,
canvasApi, canvasApi,
} from '$lib/api'; } from '$lib/api';
import { AGENT_TASK_PROMPTS, AGENT_TASK_TITLE_KEYS, isAgentTaskKind } from '$lib/agentTasks'; import { AGENT_TASK_PROMPTS, AGENT_TASK_TITLE_KEYS, isAgentTaskKind } from '$lib/agentTasks';
@@ -378,10 +377,10 @@
}, },
}); });
function setAgentModel(s: Settings, role: string, value: string) { function setAgentModel(role: string, value: string) {
const merged: Record<string, string | null> = { ...(s.agent_llm_assignments ?? {}) }; // Single-role delta only (HEL-619): the whole-snapshot replay races
merged[role] = value === '' ? null : value; // concurrent switches; the server merges per role.
$assignMutation.mutate(merged); $assignMutation.mutate({ [role]: value === '' ? null : value });
} }
// ───────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────
@@ -718,7 +717,7 @@
<select <select
class="a-select" class="a-select"
value={s.agent_llm_assignments?.[activeAgent.llm_role] ?? ''} value={s.agent_llm_assignments?.[activeAgent.llm_role] ?? ''}
onchange={(e) => setAgentModel(s, activeAgent.llm_role, e.currentTarget.value)} onchange={(e) => setAgentModel(activeAgent.llm_role, e.currentTarget.value)}
> >
<option value="">{t('agentsPage.modelDefault')}</option> <option value="">{t('agentsPage.modelDefault')}</option>
{#each s.llm_profiles as p (p.id)} {#each s.llm_profiles as p (p.id)}
+361 -66
View File
@@ -7,7 +7,7 @@
import ConfirmDialog from '$lib/components/ui/ConfirmDialog.svelte'; import ConfirmDialog from '$lib/components/ui/ConfirmDialog.svelte';
import Icon from '$lib/components/ui/Icon.svelte'; import Icon from '$lib/components/ui/Icon.svelte';
import EmptyState from '$lib/components/ui/EmptyState.svelte'; import EmptyState from '$lib/components/ui/EmptyState.svelte';
import { apiErrorMessage, comfy, settings, workflows, type ComfyEndpoint, type Workflow, type WorkflowUsage, type WorkflowAnalyzeResult } from '$lib/api'; import { apiErrorMessage, comfy, settings, workflows, type ComfyEndpoint, type Workflow, type WorkflowOutputMapEntry, type WorkflowUsage, type WorkflowAnalyzeResult } from '$lib/api';
import { WORKFLOW_USAGES } from '$lib/comfy/types'; import { WORKFLOW_USAGES } from '$lib/comfy/types';
import { toast } from '$lib/toast'; import { toast } from '$lib/toast';
import { t } from '$lib/i18n.svelte'; import { t } from '$lib/i18n.svelte';
@@ -337,6 +337,9 @@
let wfAnalysis = $state<WorkflowAnalyzeResult | null>(null); let wfAnalysis = $state<WorkflowAnalyzeResult | null>(null);
let wfUsage = $state<WorkflowUsage | null>(null); let wfUsage = $state<WorkflowUsage | null>(null);
let wfRoleOverrides = $state<Record<string, string>>({}); let wfRoleOverrides = $state<Record<string, string>>({});
// HEL-638: explicit output-node designation for unknown custom nodes.
let wfOutputPicked = $state<Record<string, boolean>>({});
let wfOutputKind = $state<Record<string, 'image' | 'video'>>({});
let wfAnalyzing = $state(false); let wfAnalyzing = $state(false);
let wfAnalyzeError = $state(''); let wfAnalyzeError = $state('');
@@ -374,6 +377,8 @@
wfAnalysis = null; wfAnalysis = null;
wfUsage = null; wfUsage = null;
wfRoleOverrides = {}; wfRoleOverrides = {};
wfOutputPicked = {};
wfOutputKind = {};
wfAnalyzeError = ''; wfAnalyzeError = '';
} }
@@ -390,6 +395,19 @@
wfAnalysis = res; wfAnalysis = res;
wfUsage = res.usage ?? null; wfUsage = res.usage ?? null;
wfRoleOverrides = {}; wfRoleOverrides = {};
// Unknown output candidates: preselect only when there is exactly
// one — with several the user must decide (HEL-638).
const candidates = (res.usage_evidence.outputs ?? []).filter(
(o) => o.evidence === 'unknown_node',
);
const picked: Record<string, boolean> = {};
const kinds: Record<string, 'image' | 'video'> = {};
for (const c of candidates) {
kinds[c.nodeId] = c.suggested_kind ?? 'image';
}
if (candidates.length === 1) picked[candidates[0].nodeId] = true;
wfOutputPicked = picked;
wfOutputKind = kinds;
wfStep = 'confirm'; wfStep = 'confirm';
} catch (err) { } catch (err) {
wfAnalyzeError = apiErrorMessage(err); wfAnalyzeError = apiErrorMessage(err);
@@ -402,6 +420,22 @@
const wfFatal = $derived( const wfFatal = $derived(
wfStep === 'confirm' && wfAnalysis !== null && (wfAnalysis.outputs?.length ?? 0) === 0, wfStep === 'confirm' && wfAnalysis !== null && (wfAnalysis.outputs?.length ?? 0) === 0,
); );
/** Unknown custom output nodes the user must designate (HEL-638). */
const wfOutputCandidates = $derived(
wfStep === 'confirm' && wfAnalysis !== null
? (wfAnalysis.usage_evidence.outputs ?? []).filter((o) => o.evidence === 'unknown_node')
: [],
);
const wfOutputRows = $derived(
wfOutputCandidates.map((o) => ({
...o,
picked: wfOutputPicked[o.nodeId] ?? false,
kind: wfOutputKind[o.nodeId] ?? o.suggested_kind ?? 'image',
})),
);
const wfOutputPickedCount = $derived(
Object.values(wfOutputPicked).filter(Boolean).length,
);
const wfMustPick = $derived( const wfMustPick = $derived(
wfStep === 'confirm' && wfStep === 'confirm' &&
wfAnalysis !== null && wfAnalysis !== null &&
@@ -409,7 +443,12 @@
(wfAnalysis.usage_ambiguous || wfAnalysis.needs_mapping) && (wfAnalysis.usage_ambiguous || wfAnalysis.needs_mapping) &&
wfUsage === null, wfUsage === null,
); );
const wfSaveable = $derived(wfStep === 'confirm' && wfUsage !== null && !wfFatal); const wfSaveable = $derived(
wfStep === 'confirm' &&
wfUsage !== null &&
!wfFatal &&
(wfOutputCandidates.length === 0 || wfOutputPickedCount > 0),
);
/** Media slots the confirm page lets the user re-role. */ /** Media slots the confirm page lets the user re-role. */
const wfSlotRows = $derived.by(() => { const wfSlotRows = $derived.by(() => {
if (wfStep !== 'confirm' || !wfAnalysis) return []; if (wfStep !== 'confirm' || !wfAnalysis) return [];
@@ -421,27 +460,39 @@
}); });
const wfParamPreview = $derived.by(() => { const wfParamPreview = $derived.by(() => {
if (!wfAnalysis) return []; if (!wfAnalysis) return [];
return wfAnalysis.inputs // Count EVERY analyzed input (media slots included) so the preview
.filter((i) => !['image', 'image_list', 'image_url', 'video', 'audio'].includes(i.kind)) // matches the inline count shown after import (input_schema.length)
.map((i) => i.label); // and in the studio — HEL-619.
return wfAnalysis.inputs.map((i) => i.label);
}); });
const wfImportMutation = createMutation({ const wfImportMutation = createMutation({
mutationFn: async () => { mutationFn: async () => {
if (!wfParsed.valid || !wfParsed.json || !wfAnalysis || !wfUsage) if (!wfParsed.valid || !wfParsed.json || !wfAnalysis || !wfUsage)
throw new Error(t('conn.wfPickUsage')); throw new Error(t('conn.wfPickUsage'));
if (wfOutputCandidates.length > 0 && wfOutputPickedCount === 0)
throw new Error(t('conn.wfOutputPick'));
const corrected = Object.keys(wfRoleOverrides).length > 0; const corrected = Object.keys(wfRoleOverrides).length > 0;
const schema = wfAnalysis.inputs.map((e) => const schema = wfAnalysis.inputs.map((e) =>
wfRoleOverrides[e.nodeId] wfRoleOverrides[e.nodeId]
? { ...e, role: wfRoleOverrides[e.nodeId], manual: true } ? { ...e, role: wfRoleOverrides[e.nodeId], manual: true }
: e, : e,
); );
const outputMap = wfOutputRows
.filter((r) => r.picked)
.map((r) => ({
nodeId: r.nodeId,
kind: r.kind,
label: r.label,
...(r.class_type ? { class_type: r.class_type } : {}),
}));
return workflows.create({ return workflows.create({
name: wfImportName.trim(), name: wfImportName.trim(),
workflow_json: wfParsed.json, workflow_json: wfParsed.json,
usage: wfUsage, usage: wfUsage,
usage_source: wfUsage !== wfAnalysis.usage || corrected ? 'user' : 'auto', usage_source: wfUsage !== wfAnalysis.usage || corrected ? 'user' : 'auto',
input_schema: schema, input_schema: schema,
...(outputMap.length ? { output_map: outputMap, output_map_source: 'user' } : {}),
...(wfImportEndpoint ? { endpoint_id: wfImportEndpoint } : {}), ...(wfImportEndpoint ? { endpoint_id: wfImportEndpoint } : {}),
}); });
}, },
@@ -488,6 +539,80 @@
}, },
}); });
// ------------------------------------------------------------------
// HEL-638: per-row output-node designation for pending workflows with
// unknown custom output nodes (imported earlier or parked by migration).
// ------------------------------------------------------------------
let wfMapEditId = $state<number | null>(null);
let wfMapPicked = $state<Record<string, boolean>>({});
let wfMapKind = $state<Record<string, 'image' | 'video'>>({});
function rowOutputCandidates(wf: Workflow) {
return (wf.output_schema ?? []).filter((o) => o.evidence === 'unknown_node');
}
function rowNeedsOutputMap(wf: Workflow): boolean {
return Boolean(wf.needs_mapping) && !(wf.output_map ?? []).length;
}
function toggleWfMapEdit(wf: Workflow) {
if (wfMapEditId === wf.id) {
wfMapEditId = null;
return;
}
const picked: Record<string, boolean> = {};
const kinds: Record<string, 'image' | 'video'> = {};
const mapped = new Map((wf.output_map ?? []).map((e) => [e.nodeId, e.kind]));
for (const c of rowOutputCandidates(wf)) {
const known = mapped.get(c.nodeId);
if (known) picked[c.nodeId] = true;
kinds[c.nodeId] = known ?? c.suggested_kind ?? 'image';
}
wfMapPicked = picked;
wfMapKind = kinds;
wfMapEditId = wf.id;
}
const wfMapMutation = createMutation({
mutationFn: ({ id, outputMap }: { id: number; outputMap: WorkflowOutputMapEntry[] }) =>
workflows.update(
id,
outputMap.length
? { output_map: outputMap, output_map_source: 'user' }
: { output_map: [] },
),
onSuccess: (wf) => {
client.invalidateQueries({ queryKey: ['workflows'] });
wfMapEditId = null;
const nodes = (wf.output_map ?? []).map((e) => e.nodeId).join('、');
toast.success(
wf.output_map?.length
? t('conn.wfOutputApplied', { nodes })
: t('conn.wfOutputCleared'),
);
},
onError: (err) => {
toast.error(
t('conn.wfImportFailed', {
detail: err instanceof Error ? err.message : String(err),
}),
);
},
});
function submitWfMap(wf: Workflow) {
if ($wfMapMutation.isPending) return;
const outputMap = rowOutputCandidates(wf)
.filter((c) => wfMapPicked[c.nodeId])
.map((c) => ({
nodeId: c.nodeId,
kind: wfMapKind[c.nodeId] ?? c.suggested_kind ?? 'image',
label: c.label,
...(c.class_type ? { class_type: c.class_type } : {}),
}));
$wfMapMutation.mutate({ id: wf.id, outputMap });
}
const wfBindMutation = createMutation({ const wfBindMutation = createMutation({
mutationFn: ({ id, endpointId }: { id: number; endpointId: string | null }) => mutationFn: ({ id, endpointId }: { id: number; endpointId: string | null }) =>
workflows.update(id, { endpoint_id: endpointId }), workflows.update(id, { endpoint_id: endpointId }),
@@ -511,6 +636,10 @@
client.invalidateQueries({ queryKey: ['workflows'] }); client.invalidateQueries({ queryKey: ['workflows'] });
toast.success(t('conn.wfDeleted')); toast.success(t('conn.wfDeleted'));
}, },
onError: (err) => {
// e.g. 409 "该工作流还有 N 个排队或执行中的任务…" (HEL-619)
toast.error(apiErrorMessage(err));
},
}); });
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@@ -856,10 +985,56 @@
</button> </button>
{/each} {/each}
</div> </div>
{#if wfMustPick}<span class="f-error">{t('conn.wfPickUsage')}</span>{/if} {#if wfMustPick}<span class="f-error">{t('conn.wfPickUsage')}</span>{/if}
</div> </div>
{#if wfSlotRows.length} {#if wfOutputRows.length}
<div class="f-field">
<span class="f-label">
{t('conn.wfOutputLabel')}<em>*</em>
<span class="f-hint-inline">{t('conn.wfOutputNeedPick')}</span>
</span>
<div class="wf-slot-rows">
{#each wfOutputRows as row (row.nodeId)}
<div class="wf-slot-row" class:off={!row.picked}>
<label class="wf-out-check">
<input
type="checkbox"
checked={row.picked}
onchange={(e) =>
(wfOutputPicked = {
...wfOutputPicked,
[row.nodeId]: e.currentTarget.checked,
})}
/>
<span class="wf-slot-id mono">{row.nodeId}</span>
<span class="wf-slot-name" title={row.class_type}>{row.label}</span>
</label>
<select
class="a-select"
aria-label={t('conn.wfOutputKindAria')}
disabled={!row.picked}
value={row.kind}
onchange={(e) =>
(wfOutputKind = {
...wfOutputKind,
[row.nodeId]: e.currentTarget.value as 'image' | 'video',
})}
>
<option value="image">{t('conn.wfKindImage')}</option>
<option value="video">{t('conn.wfKindVideo')}</option>
</select>
</div>
{/each}
</div>
<span class="f-hint">{t('conn.wfOutputHint')}</span>
{#if wfOutputPickedCount === 0}
<span class="f-error">{t('conn.wfOutputPick')}</span>
{/if}
</div>
{/if}
{#if wfSlotRows.length}
<div class="f-field"> <div class="f-field">
<span class="f-label">{t('conn.wfSlotsLabel')}</span> <span class="f-label">{t('conn.wfSlotsLabel')}</span>
<div class="wf-slot-rows"> <div class="wf-slot-rows">
@@ -916,7 +1091,11 @@
{t('conn.wfBack')} {t('conn.wfBack')}
</Button> </Button>
<span class="need-test" class:passed={wfSaveable && wfImportName.trim() !== ''}> <span class="need-test" class:passed={wfSaveable && wfImportName.trim() !== ''}>
{wfSaveable ? usageLabel(wfUsage) : t('conn.wfUsageNeedPick')} {wfUsage
? wfOutputCandidates.length && wfOutputPickedCount === 0
? t('conn.wfOutputPick')
: usageLabel(wfUsage)
: t('conn.wfUsageNeedPick')}
</span> </span>
<Button <Button
variant="primary" variant="primary"
@@ -948,71 +1127,139 @@
<span class="wf-pending-note">· {t('conn.wfPendingCount', { n: pending })}</span> <span class="wf-pending-note">· {t('conn.wfPendingCount', { n: pending })}</span>
{/if} {/if}
</p> </p>
<div class="wf-table"> <div class="wf-table">
{#each wfs as wf (wf.id)} {#each wfs as wf (wf.id)}
<div class="wf-row" class:pending={!wf.usage}> <div class="wf-row" class:pending={!wf.usage}>
<span class="wf-kind {wf.kind}"> <span class="wf-kind {wf.kind}">
<Icon name={wf.kind === 'image' ? 'image' : 'film'} size={14} /> <Icon name={wf.kind === 'image' ? 'image' : 'film'} size={14} />
</span> </span>
<span class="wf-name" title={wf.description ?? wf.name}>{wf.name}</span> <span class="wf-name" title={wf.description ?? wf.name}>{wf.name}</span>
{#if wf.usage} {#if wf.usage}
<span <span
class="tag tag-usage" class="tag tag-usage"
title={wf.usage_source === 'user' ? t('conn.wfSourceUser') : t('conn.wfSourceAuto')} title={wf.usage_source === 'user' ? t('conn.wfSourceUser') : t('conn.wfSourceAuto')}
>
{usageLabel(wf.usage)}
</span>
{:else}
<select
class="a-select wf-confirm-select"
aria-label={t('conn.wfConfirmAria')}
disabled={$wfConfirmMutation.isPending}
onchange={(e) => {
const usage = e.currentTarget.value as WorkflowUsage;
if (usage) $wfConfirmMutation.mutate({ id: wf.id, usage });
e.currentTarget.value = '';
}}
>
<option value="">{t('usage.pending')}…</option>
{#each WORKFLOW_USAGES as u (u)}
<option value={u}>{usageLabel(u)}</option>
{/each}
</select>
{/if}
{#if !wf.is_enabled && wf.usage}
<span class="tag tag-disabled">{t('conn.wfDisabledBadge')}</span>
{/if}
{#if wfProblems(wf).length}
<span class="tag tag-error" title={wfProblems(wf).join('\n')}>
{t('conn.wfBrokenBadge')}
</span>
{/if}
<span class="wf-params">{t('conn.wfParams', { n: wf.input_schema?.length ?? 0 })}</span>
<select
class="a-select"
value={wf.endpoint_id ?? ''}
onchange={(e) =>
$wfBindMutation.mutate({
id: wf.id,
endpointId: e.currentTarget.value || null,
})}
> >
<option value="">{t('conn.wfConnectionActive')}</option> {usageLabel(wf.usage)}
{#each endpoints as ep (ep.id)} </span>
<option value={ep.id}>{ep.name}</option> {:else}
<select
class="a-select wf-confirm-select"
aria-label={t('conn.wfConfirmAria')}
disabled={$wfConfirmMutation.isPending}
onchange={(e) => {
const usage = e.currentTarget.value as WorkflowUsage;
if (usage) $wfConfirmMutation.mutate({ id: wf.id, usage });
e.currentTarget.value = '';
}}
>
<option value="">{t('usage.pending')}…</option>
{#each WORKFLOW_USAGES as u (u)}
<option value={u}>{usageLabel(u)}</option>
{/each} {/each}
</select> </select>
{/if}
{#if rowNeedsOutputMap(wf)}
<button <button
type="button" type="button"
class="link-danger" class="tag tag-mapbtn"
title={t('conn.delete')} class:open={wfMapEditId === wf.id}
onclick={() => $wfDeleteMutation.mutate(wf.id)} title={t('conn.wfOutputNeedMap')}
onclick={() => toggleWfMapEdit(wf)}
> >
<Icon name="trash" size={14} /> <Icon name="alert" size={12} />
{t('conn.wfOutputPendingBadge')}
</button> </button>
{/if}
{#if !wf.is_enabled && wf.usage && !rowNeedsOutputMap(wf)}
<span class="tag tag-disabled">{t('conn.wfDisabledBadge')}</span>
{/if}
{#if wfProblems(wf).length}
<span class="tag tag-error" title={wfProblems(wf).join('\n')}>
{t('conn.wfBrokenBadge')}
</span>
{/if}
<span class="wf-params">{t('conn.wfParams', { n: wf.input_schema?.length ?? 0 })}</span>
<select
class="a-select"
value={wf.endpoint_id ?? ''}
onchange={(e) =>
$wfBindMutation.mutate({
id: wf.id,
endpointId: e.currentTarget.value || null,
})}
>
<option value="">{t('conn.wfConnectionActive')}</option>
{#each endpoints as ep (ep.id)}
<option value={ep.id}>{ep.name}</option>
{/each}
</select>
<button
type="button"
class="link-danger"
title={t('conn.delete')}
onclick={() => $wfDeleteMutation.mutate(wf.id)}
>
<Icon name="trash" size={14} />
</button>
</div>
{#if wfMapEditId === wf.id}
<div class="wf-map-editor">
<p class="wf-map-hint">{t('conn.wfOutputHint')}</p>
<div class="wf-slot-rows">
{#each rowOutputCandidates(wf) as c (c.nodeId)}
<div class="wf-slot-row" class:off={!wfMapPicked[c.nodeId]}>
<label class="wf-out-check">
<input
type="checkbox"
checked={wfMapPicked[c.nodeId] ?? false}
onchange={(e) =>
(wfMapPicked = {
...wfMapPicked,
[c.nodeId]: e.currentTarget.checked,
})}
/>
<span class="wf-slot-id mono">{c.nodeId}</span>
<span class="wf-slot-name" title={c.class_type}>{c.label}</span>
</label>
<select
class="a-select"
aria-label={t('conn.wfOutputKindAria')}
disabled={!wfMapPicked[c.nodeId]}
value={wfMapKind[c.nodeId] ?? c.suggested_kind ?? 'image'}
onchange={(e) =>
(wfMapKind = {
...wfMapKind,
[c.nodeId]: e.currentTarget.value as 'image' | 'video',
})}
>
<option value="image">{t('conn.wfKindImage')}</option>
<option value="video">{t('conn.wfKindVideo')}</option>
</select>
</div>
{/each}
</div>
<div class="form-actions">
<Button
variant="secondary"
size="sm"
onclick={() => (wfMapEditId = null)}
>
{t('conn.wfMapCancel')}
</Button>
<Button
variant="primary"
size="sm"
disabled={!Object.values(wfMapPicked).some(Boolean)}
loading={$wfMapMutation.isPending}
onclick={() => submitWfMap(wf)}
>
{t('conn.wfOutputApply')}
</Button>
</div>
</div> </div>
{/each} {/if}
</div> {/each}
</div>
{/if} {/if}
</section> </section>
</section> </section>
@@ -1606,6 +1853,52 @@
.wf-slot-row .a-select { .wf-slot-row .a-select {
width: 130px; width: 130px;
} }
.wf-slot-row.off {
opacity: 0.55;
}
.wf-out-check {
display: flex;
align-items: center;
gap: 8px;
flex: 1;
min-width: 0;
cursor: pointer;
}
.wf-out-check input[type='checkbox'] {
accent-color: var(--accent);
}
.tag-mapbtn {
display: inline-flex;
align-items: center;
gap: 4px;
cursor: pointer;
color: var(--error);
background: var(--error-dim);
border: 1px solid transparent;
}
.tag-mapbtn.open {
color: var(--accent);
background: var(--accent-dim);
border-color: var(--accent);
}
.wf-map-editor {
display: flex;
flex-direction: column;
gap: 8px;
padding: 10px 12px;
margin: 2px 0 6px;
border-radius: 7px;
border: 1px dashed var(--border);
background: var(--surface);
}
.wf-map-hint {
margin: 0;
font-size: 11.5px;
color: var(--text-3);
}
.wf-map-editor .form-actions {
justify-content: flex-end;
}
.wf-params { .wf-params {
margin: 0 0 10px; margin: 0 0 10px;
font-size: 11.5px; font-size: 11.5px;
@@ -1779,6 +2072,8 @@
border: 1px solid var(--border); border: 1px solid var(--border);
border-radius: 10px; border-radius: 10px;
padding: 18px 20px 20px; padding: 18px 20px 20px;
/* keep the 384px side-col the OUTER width (HEL-619) */
box-sizing: border-box;
} }
.layout:not(.form-open) .form-col { .layout:not(.form-open) .form-col {
display: none; display: none;
+9 -5
View File
@@ -420,10 +420,11 @@
}, },
}); });
function setAssignment(s: Settings, role: string, value: string) { function setAssignment(role: string, value: string) {
const merged: Record<string, string | null> = { ...(s.agent_llm_assignments ?? {}) }; // Single-role delta only (HEL-619): replaying the whole cached
merged[role] = value === '' ? null : value; // snapshot races concurrent dropdown switches — an older snapshot
$assignMutation.mutate(merged); // could overwrite a newer choice. The server merges per role.
$assignMutation.mutate({ [role]: value === '' ? null : value });
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@@ -630,7 +631,7 @@
<select <select
class="a-select" class="a-select"
value={s.agent_llm_assignments?.[agent.role] ?? ''} value={s.agent_llm_assignments?.[agent.role] ?? ''}
onchange={(e) => setAssignment(s, agent.role, e.currentTarget.value)} onchange={(e) => setAssignment(agent.role, e.currentTarget.value)}
> >
<option value="">{t('models.agentDefault')}</option> <option value="">{t('models.agentDefault')}</option>
{#each profiles as p (p.id)} {#each profiles as p (p.id)}
@@ -1195,6 +1196,9 @@
padding: 18px 20px 20px; padding: 18px 20px 20px;
position: sticky; position: sticky;
top: 24px; top: 24px;
/* 384px must be the OUTER width per the a6 spec — without
border-box padding+border inflate it to 426px (HEL-619). */
box-sizing: border-box;
} }
.form-idle { .form-idle {
display: flex; display: flex;