From d9f332895857a16058e9d0202da4d6f76f4dbb81 Mon Sep 17 00:00:00 2001 From: leefer Date: Wed, 28 Oct 2026 08:23:47 +0800 Subject: [PATCH] HEL-892: expose source-reviewed workflow documentation in shared drawer Co-authored-by: multica-agent --- calliope-web/src/lib/comfy/types.ts | 61 ++++ .../components/WorkflowDocumentDrawer.svelte | 246 ++++++++++++++++ .../src/routes/connections/+page.svelte | 17 +- docs/hel-892/ui-backend-tests.txt | 6 + docs/hel-892/ui-browser.txt | 20 ++ docs/hel-892/ui-build.txt | 267 ++++++++++++++++++ docs/hel-892/ui-check.txt | 34 +++ docs/hel-892/ui-evidence/01-library.png | Bin 0 -> 228087 bytes docs/hel-892/ui-evidence/02-api-parameter.png | Bin 0 -> 254249 bytes docs/hel-892/ui-evidence/03-ui-notes.png | Bin 0 -> 294497 bytes docs/hel-892/ui-evidence/04-narrow-models.png | Bin 0 -> 70946 bytes docs/hel-892/ui-evidence/05-api-overview.png | Bin 0 -> 252846 bytes docs/hel-892/ui-evidence/06-ui-overview.png | Bin 0 -> 295306 bytes docs/hel-892/ui-evidence/browser-results.json | 13 + docs/hel-892/ui-format.txt | 3 + docs/hel-892/ui-harness-lint.txt | 2 + docs/hel-892/ui-import.txt | 1 + docs/hel-892/ui-lint.txt | 15 + docs/hel-892/ui-repo-lint.txt | 76 +++++ docs/hel-892/ui-tests.txt | 51 ++++ docs/hel-892/界面施工与浏览验证.md | 29 ++ e2e/workflow-document-server.py | 58 ++++ e2e/workflow-document.mjs | 70 +++++ 23 files changed, 963 insertions(+), 6 deletions(-) create mode 100644 calliope-web/src/lib/components/WorkflowDocumentDrawer.svelte create mode 100644 docs/hel-892/ui-backend-tests.txt create mode 100644 docs/hel-892/ui-browser.txt create mode 100644 docs/hel-892/ui-build.txt create mode 100644 docs/hel-892/ui-check.txt create mode 100644 docs/hel-892/ui-evidence/01-library.png create mode 100644 docs/hel-892/ui-evidence/02-api-parameter.png create mode 100644 docs/hel-892/ui-evidence/03-ui-notes.png create mode 100644 docs/hel-892/ui-evidence/04-narrow-models.png create mode 100644 docs/hel-892/ui-evidence/05-api-overview.png create mode 100644 docs/hel-892/ui-evidence/06-ui-overview.png create mode 100644 docs/hel-892/ui-evidence/browser-results.json create mode 100644 docs/hel-892/ui-format.txt create mode 100644 docs/hel-892/ui-harness-lint.txt create mode 100644 docs/hel-892/ui-import.txt create mode 100644 docs/hel-892/ui-lint.txt create mode 100644 docs/hel-892/ui-repo-lint.txt create mode 100644 docs/hel-892/ui-tests.txt create mode 100644 docs/hel-892/界面施工与浏览验证.md create mode 100644 e2e/workflow-document-server.py create mode 100644 e2e/workflow-document.mjs diff --git a/calliope-web/src/lib/comfy/types.ts b/calliope-web/src/lib/comfy/types.ts index 10a2c155..c8207e72 100644 --- a/calliope-web/src/lib/comfy/types.ts +++ b/calliope-web/src/lib/comfy/types.ts @@ -150,9 +150,70 @@ export interface WorkflowNode { _meta?: { title?: string }; } +/** Persisted library document; list responses omit doc_json, detail GET includes it. */ +export interface WorkflowDocument { + title?: string; + purpose?: string; + source_path?: string; + materials?: { slot?: string; desc?: string; required?: boolean }[]; + io?: { inputs?: ComfyDynamicInput[]; outputs?: ComfyDynamicOutput[] }; + dependencies?: { + models?: string[]; + node_types?: string[]; + node_packs?: string[]; + check_state?: string; + checked_at?: string | null; + source?: string | null; + model_locations?: string; + missing?: unknown[]; + }; + params?: { + node_id: string; + field: string; + name?: string; + default?: unknown; + unit?: string | null; + min?: number | null; + max?: number | null; + options?: unknown[] | null; + range_source?: string; + effect?: string; + }[]; + steps?: string[]; + errors?: { symptom: string; fix: string }[]; + status?: { imported?: boolean; doc_done?: boolean; exec_verified?: boolean }; + source_notes?: { node_id: string; content: unknown }[]; + source_review?: { + scope?: string[]; + unconfirmed?: string[]; + reviewed_named_fields?: { + node_id: string; + field: string; + label?: string; + category?: string; + source_value?: unknown; + scope?: string; + operation_check?: string; + connections?: unknown; + }[]; + semantic_review?: { + conclusions?: string[]; + material_requirements?: unknown; + [key: string]: unknown; + }; + }; +} + export interface Workflow { id: number; name: string; + doc_json?: WorkflowDocument | null; + import_state?: string | null; + source_format?: string | null; + source_repo_path?: string | null; + import_issues?: { message: string; code?: string; node_id?: string }[] | null; + doc_completed_at?: string | null; + exec_verified_at?: string | null; kind: 'image' | 'video'; /** Five-way usage (HEL-636); null = pending human confirmation. */ usage?: WorkflowUsage | null; diff --git a/calliope-web/src/lib/components/WorkflowDocumentDrawer.svelte b/calliope-web/src/lib/components/WorkflowDocumentDrawer.svelte new file mode 100644 index 00000000..1f5e853e --- /dev/null +++ b/calliope-web/src/lib/components/WorkflowDocumentDrawer.svelte @@ -0,0 +1,246 @@ + + + +
+

{workflow?.name}

+ {#if $detail.isPending || $detail.isFetching} +

正在读取说明…

+ {:else if $detail.isError} +

说明读取失败:{apiErrorMessage($detail.error)}

+ + {:else if wf} +
+ + + +
+ {#if wf.import_state === "needs_conversion"} + +

此条目尚不可执行,仍可阅读说明。

+

{wf.import_issues?.[0]?.message || "可靠转换尚未完成。"}

+
+ 全部转换阻碍({wf.import_issues?.length ?? 0}) + {#each wf.import_issues ?? [] as issue}

{issue.message}

{/each} +
+
+ {/if} + +

+ {doc?.purpose || + wf.description || + "此旧工作流尚无详细说明,保留现有输入输出供核对。"} +

+ {#if doc?.source_path || wf.source_repo_path}

+ 源文件:{doc?.source_path || wf.source_repo_path} +

{/if} + {#if review?.scope?.length}

+ 已审范围:{review.scope.join(";")} +

{/if} + {#each review?.semantic_review?.conclusions ?? [] as conclusion}

+ {conclusion} +

{/each} +
+ + {#each doc?.materials ?? [] as material} +

+ 素材槽 {material.slot}:{material.desc}({material.required + ? "必需" + : "可选"}) +

+ {/each} +

输入映射

+ {#each doc?.io?.inputs ?? wf.input_schema ?? [] as input} +

+ {input.label} · {input.kind} · 节点 {input.nodeId} / {input.role ?? + "未标记角色"}({input.required ? "必需" : "可选"}) +

+ {:else}

未记录可靠输入映射;不能据此判定无需素材。

{/each} +

输出映射

+ {#each doc?.io?.outputs ?? wf.output_schema ?? [] as output} +

{output.label} · {output.kind} · 节点 {output.nodeId}

+ {:else}

未记录可靠输出映射,实际输出待核对。

{/each} + {#if review?.semantic_review?.material_requirements} +
+ 源文件素材审校 +
{value(review.semantic_review.material_requirements)}
+
+ {/if} +
+ +

+ 源现值不代表推荐值。下列审校分类与单位、范围、调整效果的确认分别记录。 +

+ {#each doc?.params ?? [] as param} + {@const fields = (review?.reviewed_named_fields ?? []).filter( + (f) => f.node_id === param.node_id && f.field === param.field, + )} +
+ 节点 {param.node_id} · {param.field} +

源现值:

+
{value(param.default)}
+ {#each fields as field} +

+ {categories[field.category ?? ""] ?? + "源字段局部审校"}:{field.label} +

+ {#if field.scope}

{field.scope}

{/if} + {#if field.operation_check}

{field.operation_check}

{/if} + {#if field.connections}
+ 源连线依据 +
{value(field.connections)}
+
{/if} + {:else}

已保留源字段与现值;语义待确认。

{/each} +

单位:{param.unit ?? "待确认"}

+

+ 范围:{param.range_source && param.range_source !== "unverified" + ? `${param.min ?? "未记录下界"} ~ ${param.max ?? "未记录上界"}(${param.range_source})` + : "待确认"} +

+ {#if param.options}

可选值:{value(param.options)}

{/if} +

调整效果:{param.effect || "待确认"}

+
+ {:else}

暂无具名参数说明;位置控件不能按顺序猜测。

{/each} +
+ +

+ 环境检查:{deps?.check_state === "unchecked" || !deps?.check_state + ? "未检查" + : deps.check_state}。源引用不等于实际加载依赖,未检查不能判定缺失或就位。 +

+ {#if deps?.checked_at}

检查时间:{deps.checked_at}

{/if} + {#if deps?.source}

定义来源:{deps.source}

{/if} +

模型位置:{deps?.model_locations || "未检查"}

+
+ 模型引用({deps?.models?.length ?? 0}) + {#each deps?.models ?? [] as model}

{model}

{:else}

+ 无记录,不代表环境就绪。 +

{/each} +
+
+ 源节点类型({deps?.node_types?.length ?? 0}) + {#each deps?.node_types ?? [] as node}

{node}

{/each} +
+ {#if deps?.node_packs?.length}

+ 节点包:{deps.node_packs.join(";")} +

{/if} +
+ +
    + {#each doc?.steps ?? [] as step}
  1. {step}
  2. {:else}
  3. + 此工作流尚未补充使用步骤。 +
  4. {/each} +
+
+ + {#each doc?.errors ?? [] as error}
+ {error.symptom} +

{error.fix}

+
{/each} + {#each review?.unconfirmed ?? [] as item}

待确认:{item}

{/each} + {#if !doc}

+ 此旧工作流暂无说明数据,说明定稿、依赖环境和实跑状态均待核对。 +

{/if} +
+ {#if doc?.source_notes?.length} + + {#each doc.source_notes as note}
+ 节点 {note.node_id} +
{value(note.content)}
+
{/each} +
+ {/if} + {/if} +
+ {#snippet footer()}{/snippet} +
+ + diff --git a/calliope-web/src/routes/connections/+page.svelte b/calliope-web/src/routes/connections/+page.svelte index d8338c97..08a20316 100644 --- a/calliope-web/src/routes/connections/+page.svelte +++ b/calliope-web/src/routes/connections/+page.svelte @@ -8,6 +8,7 @@ import Icon from '$lib/components/ui/Icon.svelte'; import EmptyState from '$lib/components/ui/EmptyState.svelte'; import WorkflowImportDrawer from '$lib/components/WorkflowImportDrawer.svelte'; + import WorkflowDocumentDrawer from '$lib/components/WorkflowDocumentDrawer.svelte'; import WorkflowTestDialog from '$lib/components/WorkflowTestDialog.svelte'; import { apiErrorMessage, comfy, settings, workflows, type ComfyEndpoint, type Workflow, type WorkflowOutputMapEntry, type WorkflowUsage, type WorkflowConnectionCheck } from '$lib/api'; import { WORKFLOW_USAGES } from '$lib/comfy/types'; @@ -332,6 +333,8 @@ // wizard itself lives in WorkflowImportDrawer (HEL-655 E 批). // ------------------------------------------------------------------ let wfImportOpen = $state(false); + let documentWf = $state(null); + let documentOpen = $state(false); function startWfImport() { wfImportOpen = true; @@ -745,7 +748,7 @@ - {wf.name} + {wf.name} {#if wf.usage} {/if} {t('conn.wfParams', { n: wf.input_schema?.length ?? 0 })} +