HEL-892: expose source-reviewed workflow documentation in shared drawer
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
<script lang="ts">
|
||||
import { toStore } from "svelte/store";
|
||||
import { createQuery } from "@tanstack/svelte-query";
|
||||
import { workflows, apiErrorMessage, type Workflow } from "$lib/api";
|
||||
import Drawer from "./ui/Drawer.svelte";
|
||||
import Button from "./ui/Button.svelte";
|
||||
import Card from "./ui/Card.svelte";
|
||||
import StatusChip from "./ui/StatusChip.svelte";
|
||||
|
||||
let {
|
||||
open = $bindable(false),
|
||||
workflow,
|
||||
}: { open?: boolean; workflow: Workflow | null } = $props();
|
||||
// Keep the list lightweight. Only this read-only GET loads the selected document.
|
||||
const detail = createQuery(
|
||||
toStore(() => {
|
||||
const id = workflow?.id;
|
||||
return {
|
||||
queryKey: ["workflow-document", id],
|
||||
queryFn: () => workflows.get(id!),
|
||||
enabled: open && workflow !== null,
|
||||
staleTime: 0,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const wf = $derived($detail.data);
|
||||
const doc = $derived(wf?.doc_json);
|
||||
const review = $derived(doc?.source_review);
|
||||
const deps = $derived(doc?.dependencies);
|
||||
const categories: Record<string, string> = {
|
||||
runtime_parameter: "有源侧用途依据",
|
||||
frontend_state: "前端状态(非运行参数)",
|
||||
current_value_only: "仅确认现值",
|
||||
semantic_unknown: "语义待确认",
|
||||
};
|
||||
function value(v: unknown): string {
|
||||
if (v === undefined) return "未记录";
|
||||
return typeof v === "string" ? v : JSON.stringify(v, null, 2);
|
||||
}
|
||||
</script>
|
||||
|
||||
<Drawer bind:open title="工作流说明" width={440}>
|
||||
<div class="document-content" aria-live="polite">
|
||||
<h3>{workflow?.name}</h3>
|
||||
{#if $detail.isPending || $detail.isFetching}
|
||||
<p role="status">正在读取说明…</p>
|
||||
{:else if $detail.isError}
|
||||
<p role="alert">说明读取失败:{apiErrorMessage($detail.error)}</p>
|
||||
<Button onclick={() => $detail.refetch()}>重试</Button>
|
||||
{:else if wf}
|
||||
<div class="document-status">
|
||||
<StatusChip status="pending" label="已入库" />
|
||||
<StatusChip
|
||||
status="pending"
|
||||
label={doc?.status?.doc_done && wf.doc_completed_at
|
||||
? "说明已定稿"
|
||||
: "说明未定稿"}
|
||||
/>
|
||||
<StatusChip
|
||||
status="pending"
|
||||
label={doc?.status?.exec_verified && wf.exec_verified_at
|
||||
? "有实跑通过记录"
|
||||
: "未验证实跑"}
|
||||
/>
|
||||
</div>
|
||||
{#if wf.import_state === "needs_conversion"}
|
||||
<Card title="待转换 / 待补材料">
|
||||
<p>此条目尚不可执行,仍可阅读说明。</p>
|
||||
<p>{wf.import_issues?.[0]?.message || "可靠转换尚未完成。"}</p>
|
||||
<details>
|
||||
<summary>全部转换阻碍({wf.import_issues?.length ?? 0})</summary>
|
||||
{#each wf.import_issues ?? [] as issue}<p>{issue.message}</p>{/each}
|
||||
</details>
|
||||
</Card>
|
||||
{/if}
|
||||
<Card title="用途与来源">
|
||||
<p>
|
||||
{doc?.purpose ||
|
||||
wf.description ||
|
||||
"此旧工作流尚无详细说明,保留现有输入输出供核对。"}
|
||||
</p>
|
||||
{#if doc?.source_path || wf.source_repo_path}<p>
|
||||
源文件:{doc?.source_path || wf.source_repo_path}
|
||||
</p>{/if}
|
||||
{#if review?.scope?.length}<p>
|
||||
已审范围:{review.scope.join(";")}
|
||||
</p>{/if}
|
||||
{#each review?.semantic_review?.conclusions ?? [] as conclusion}<p>
|
||||
{conclusion}
|
||||
</p>{/each}
|
||||
</Card>
|
||||
<Card title="素材要求与输入输出">
|
||||
{#each doc?.materials ?? [] as material}
|
||||
<p>
|
||||
素材槽 {material.slot}:{material.desc}({material.required
|
||||
? "必需"
|
||||
: "可选"})
|
||||
</p>
|
||||
{/each}
|
||||
<h4>输入映射</h4>
|
||||
{#each doc?.io?.inputs ?? wf.input_schema ?? [] as input}
|
||||
<p>
|
||||
{input.label} · {input.kind} · 节点 {input.nodeId} / {input.role ??
|
||||
"未标记角色"}({input.required ? "必需" : "可选"})
|
||||
</p>
|
||||
{:else}<p>未记录可靠输入映射;不能据此判定无需素材。</p>{/each}
|
||||
<h4>输出映射</h4>
|
||||
{#each doc?.io?.outputs ?? wf.output_schema ?? [] as output}
|
||||
<p>{output.label} · {output.kind} · 节点 {output.nodeId}</p>
|
||||
{:else}<p>未记录可靠输出映射,实际输出待核对。</p>{/each}
|
||||
{#if review?.semantic_review?.material_requirements}
|
||||
<details>
|
||||
<summary>源文件素材审校</summary>
|
||||
<pre>{value(review.semantic_review.material_requirements)}</pre>
|
||||
</details>
|
||||
{/if}
|
||||
</Card>
|
||||
<Card title="参数与源现值">
|
||||
<p>
|
||||
源现值不代表推荐值。下列审校分类与单位、范围、调整效果的确认分别记录。
|
||||
</p>
|
||||
{#each doc?.params ?? [] as param}
|
||||
{@const fields = (review?.reviewed_named_fields ?? []).filter(
|
||||
(f) => f.node_id === param.node_id && f.field === param.field,
|
||||
)}
|
||||
<details>
|
||||
<summary>节点 {param.node_id} · {param.field}</summary>
|
||||
<p>源现值:</p>
|
||||
<pre>{value(param.default)}</pre>
|
||||
{#each fields as field}
|
||||
<p>
|
||||
{categories[field.category ?? ""] ??
|
||||
"源字段局部审校"}:{field.label}
|
||||
</p>
|
||||
{#if field.scope}<p>{field.scope}</p>{/if}
|
||||
{#if field.operation_check}<p>{field.operation_check}</p>{/if}
|
||||
{#if field.connections}<details>
|
||||
<summary>源连线依据</summary>
|
||||
<pre>{value(field.connections)}</pre>
|
||||
</details>{/if}
|
||||
{:else}<p>已保留源字段与现值;语义待确认。</p>{/each}
|
||||
<p>单位:{param.unit ?? "待确认"}</p>
|
||||
<p>
|
||||
范围:{param.range_source && param.range_source !== "unverified"
|
||||
? `${param.min ?? "未记录下界"} ~ ${param.max ?? "未记录上界"}(${param.range_source})`
|
||||
: "待确认"}
|
||||
</p>
|
||||
{#if param.options}<p>可选值:{value(param.options)}</p>{/if}
|
||||
<p>调整效果:{param.effect || "待确认"}</p>
|
||||
</details>
|
||||
{:else}<p>暂无具名参数说明;位置控件不能按顺序猜测。</p>{/each}
|
||||
</Card>
|
||||
<Card title="模型与节点引用">
|
||||
<p>
|
||||
环境检查:{deps?.check_state === "unchecked" || !deps?.check_state
|
||||
? "未检查"
|
||||
: deps.check_state}。源引用不等于实际加载依赖,未检查不能判定缺失或就位。
|
||||
</p>
|
||||
{#if deps?.checked_at}<p>检查时间:{deps.checked_at}</p>{/if}
|
||||
{#if deps?.source}<p>定义来源:{deps.source}</p>{/if}
|
||||
<p>模型位置:{deps?.model_locations || "未检查"}</p>
|
||||
<details>
|
||||
<summary>模型引用({deps?.models?.length ?? 0})</summary>
|
||||
{#each deps?.models ?? [] as model}<p>{model}</p>{:else}<p>
|
||||
无记录,不代表环境就绪。
|
||||
</p>{/each}
|
||||
</details>
|
||||
<details>
|
||||
<summary>源节点类型({deps?.node_types?.length ?? 0})</summary>
|
||||
{#each deps?.node_types ?? [] as node}<p>{node}</p>{/each}
|
||||
</details>
|
||||
{#if deps?.node_packs?.length}<p>
|
||||
节点包:{deps.node_packs.join(";")}
|
||||
</p>{/if}
|
||||
</Card>
|
||||
<Card title="使用步骤">
|
||||
<ol>
|
||||
{#each doc?.steps ?? [] as step}<li>{step}</li>{:else}<li>
|
||||
此工作流尚未补充使用步骤。
|
||||
</li>{/each}
|
||||
</ol>
|
||||
</Card>
|
||||
<Card title="常见问题与待确认项">
|
||||
{#each doc?.errors ?? [] as error}<details>
|
||||
<summary>{error.symptom}</summary>
|
||||
<p>{error.fix}</p>
|
||||
</details>{/each}
|
||||
{#each review?.unconfirmed ?? [] as item}<p>待确认:{item}</p>{/each}
|
||||
{#if !doc}<p>
|
||||
此旧工作流暂无说明数据,说明定稿、依赖环境和实跑状态均待核对。
|
||||
</p>{/if}
|
||||
</Card>
|
||||
{#if doc?.source_notes?.length}
|
||||
<Card title="源文件注释">
|
||||
{#each doc.source_notes as note}<details>
|
||||
<summary>节点 {note.node_id}</summary>
|
||||
<pre>{value(note.content)}</pre>
|
||||
</details>{/each}
|
||||
</Card>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{#snippet footer()}<Button onclick={() => (open = false)}>关闭</Button
|
||||
>{/snippet}
|
||||
</Drawer>
|
||||
|
||||
<style>
|
||||
.document-content {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.document-content :global(*) {
|
||||
min-width: 0;
|
||||
}
|
||||
.document-status {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
h3,
|
||||
h4,
|
||||
p {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
details {
|
||||
margin: 8px 0;
|
||||
}
|
||||
summary {
|
||||
cursor: pointer;
|
||||
}
|
||||
pre {
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
font: inherit;
|
||||
margin: 8px 0;
|
||||
}
|
||||
ol {
|
||||
margin: 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
li + li {
|
||||
margin-top: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -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<Workflow | null>(null);
|
||||
let documentOpen = $state(false);
|
||||
|
||||
function startWfImport() {
|
||||
wfImportOpen = true;
|
||||
@@ -745,7 +748,7 @@
|
||||
<span class="wf-kind {wf.kind}">
|
||||
<Icon name={wf.kind === 'image' ? 'image' : 'film'} size={14} />
|
||||
</span>
|
||||
<span class="wf-name" title={wf.description ?? wf.name}>{wf.name}</span>
|
||||
<span class="wf-name" title={[wf.name, wf.description].filter(Boolean).join("\n")}>{wf.name}</span>
|
||||
{#if wf.usage}
|
||||
<span
|
||||
class="tag tag-usage"
|
||||
@@ -791,10 +794,12 @@
|
||||
</span>
|
||||
{/if}
|
||||
<span class="wf-params">{t('conn.wfParams', { n: wf.input_schema?.length ?? 0 })}</span>
|
||||
<Button size="sm" variant="ghost" onclick={() => { documentWf = wf; documentOpen = true; }}>说明</Button>
|
||||
<button
|
||||
type="button"
|
||||
class="link-accent wf-test-btn"
|
||||
title={t('wft.title')}
|
||||
disabled={wf.import_state === 'needs_conversion'}
|
||||
title={wf.import_state === 'needs_conversion' ? '待可靠转换,暂不可执行;可打开说明' : t('wft.title')}
|
||||
onclick={() => openTest(wf)}
|
||||
>
|
||||
<Icon name="play" size={13} />
|
||||
@@ -1109,6 +1114,8 @@
|
||||
{endpoints}
|
||||
onchanged={() => client.invalidateQueries({ queryKey: ['workflows'] })}
|
||||
/>
|
||||
<WorkflowDocumentDrawer bind:open={documentOpen} workflow={documentWf} />
|
||||
|
||||
<WorkflowTestDialog
|
||||
bind:open={testOpen}
|
||||
workflow={testWf}
|
||||
@@ -1560,6 +1567,7 @@
|
||||
}
|
||||
.wf-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 10px;
|
||||
@@ -1584,7 +1592,7 @@
|
||||
background: var(--bg-4);
|
||||
}
|
||||
.wf-name {
|
||||
flex: 1;
|
||||
flex: 1 0 160px;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
@@ -1910,9 +1918,6 @@
|
||||
.card-foot {
|
||||
margin-left: 0;
|
||||
}
|
||||
.wf-row {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.wf-name {
|
||||
flex-basis: 100%;
|
||||
order: 5;
|
||||
|
||||
Reference in New Issue
Block a user