fix(combine): 继承态提示词把上游文案与参考图交给组合/连接节点
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 33s

组合节点的拼接逻辑不变。断点在「来源判定」:batchSrcText/isBatchSrc 只看节点自身
data.text,而提示词/文本节点在「继承 · 来自 上一级」时 data.text 为空 —— 组合读不到
这一路、nodeRefsOf(combine) 也把它过滤掉(组合→文本/分层节点的参考图随之丢失);
出图侧 resolveNodeTaskValues 走 own||上游,一直是通的,所以出现「能出图、组合是空的」。

- canvas-text: batchSrcText/isBatchSrc 增加可选 (edges, nodes);自身无文案时按
  inheritedTextOf 同一套排序取上游第一条(提示词不拼合多路,与节点体显示一致),
  只穿透 prompt/textout/relay/batch,组合/LLM/插件节点不越过;不传参保持旧行为
- 组合/连接/端口定位/画布渲染等调用点补传 edges/nodes
- 测试:canvas-text 补继承态断言(多路取第一条/接管/停用/环)、plugin-style-node
  补组合端到端、iwb-inherit-text 补 DOM 用例(组合行出现并跟随上游)
This commit is contained in:
qiqi committed 2026-11-23 11:22:43 +08:00
1 parent 01c922d7e4
commit 9225a76895
9 files changed
+159 -27

No files matched your search

+4 -4
View File
@@ -6891,9 +6891,9 @@ const tbCenterSeed = (type, refs) => {
}
continue
}
const bsrcs = edges.filter((e) => e.to === bn.id).map((e) => nodes.find((n) => n.id === e.from)).filter((n) => isBatchSrc(n) && !(n.data && n.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const bsrcs = edges.filter((e) => e.to === bn.id).map((e) => nodes.find((n) => n.id === e.from)).filter((n) => isBatchSrc(n, edges, nodes) && !(n.data && n.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
if (!bsrcs.length) continue
const textOf = (src) => batchJoinedText(bn.data, batchSrcText(src))
const textOf = (src) => batchJoinedText(bn.data, batchSrcText(src, edges, nodes))
for (const e of edges) {
if (e.from !== bn.id) continue
const dst = nodes.find((n) => n.id === e.to)
@@ -7809,7 +7809,7 @@ const tbCenterSeed = (type, refs) => {
if (!e || !e.to) continue
const dst = refs.nodeMap.get(e.to)
const src = refs.nodeMap.get(e.from)
if (!dst || !src || dst.type !== 'batch' || !isBatchSrc(src)) continue
if (!dst || !src || dst.type !== 'batch' || !isBatchSrc(src, edges, nodes)) continue
if (!m.has(dst.id)) m.set(dst.id, [])
if (!m.get(dst.id).some((n) => n.id === src.id)) m.get(dst.id).push(src)
}
@@ -8075,7 +8075,7 @@ const tbCenterSeed = (type, refs) => {
const node = refs.nodes.find((n) => n.id === id)
if (node) {
if (batchSrcId) {
const bsrcs = refs.edges.filter((e) => e.to === id).map((e) => refs.nodes.find((n) => n.id === e.from)).filter((n) => isBatchSrc(n)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const bsrcs = refs.edges.filter((e) => e.to === id).map((e) => refs.nodes.find((n) => n.id === e.from)).filter((n) => isBatchSrc(n, refs.edges, refs.nodes)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const idx = bsrcs.findIndex((s) => s.id === batchSrcId)
if (idx >= 0) portPos = { x: node.x + nodeWidth(node), y: node.y + batchPortTop(idx, Math.max(1, bsrcs.length), hOf(node)) }
} else {
+2 -2
View File
@@ -120,12 +120,12 @@
let x1 = src.x + nodeWidth(src), y1 = src.y + hOf(src) / 2
let x2 = dst.x, y2 = dst.y + inY
if (src.type === 'batch' && ed.batchSrcId) {
const bsrcs = ((graph && graph.incomingByNode.get(src.id)) || []).map((e) => graph && graph.byId.get(e.from)).filter((n) => isBatchSrc(n)).slice().sort(compareCanvasTextOrder)
const bsrcs = ((graph && graph.incomingByNode.get(src.id)) || []).map((e) => graph && graph.byId.get(e.from)).filter((n) => isBatchSrc(n, graph && graph.edges, graph && graph.nodes)).slice().sort(compareCanvasTextOrder)
const idx = bsrcs.findIndex((s) => s.id === ed.batchSrcId)
if (idx >= 0) y1 = src.y + batchPortTop(idx, Math.max(1, bsrcs.length), hOf(src))
}
if (dst.type === 'batch') {
const bsrcs = ((graph && graph.incomingByNode.get(dst.id)) || []).map((e) => graph && graph.byId.get(e.from)).filter((n) => isBatchSrc(n)).slice().sort(compareCanvasTextOrder)
const bsrcs = ((graph && graph.incomingByNode.get(dst.id)) || []).map((e) => graph && graph.byId.get(e.from)).filter((n) => isBatchSrc(n, graph && graph.edges, graph && graph.nodes)).slice().sort(compareCanvasTextOrder)
const idx = bsrcs.findIndex((s) => s.id === ed.from)
if (idx >= 0) y2 = dst.y + batchPortTop(idx, Math.max(1, bsrcs.length), hOf(dst))
}
+41 -10
View File
@@ -11,18 +11,49 @@
function compareCanvasTextOrder(a, b) { return (Number(a.y) - Number(b.y)) || (Number(a.x) - Number(b.x)) || String(a.id).localeCompare(String(b.id)) }
function batchSrcText(n) {
// 节点**自身**文案(不看上游):组合取 combined/extra,LLM 取 result.text,其余取 data.text
function selfTextOf(n) {
if (!n || !n.data) return ''
if (n.type === 'combine') return ((n.data.combined || n.data.extra) || '').trim()
if (n.type === 'relay') return ((n.data.text || '')).trim()
if (n.type === 'llm') return ((n.data.result && n.data.result.text) || '').trim()
return (n.data.text || '').trim()
}
function isBatchSrc(n) {
// 继承态(2026-11-23):提示词 / 文本节点自己没写字时,它对外输出的就是「节点体显示的那一条上游文案」。
// 产品规则:提示词节点本身不拼合多路文案(一个提示词只承接一条上游),所以这里只取第一条,
// 排序与 inheritedTextOf / 节点体「继承 · 来自 上一级」逐字同源(文本按 Y→X,图片按 X→Y)。
// 不传 edges/nodes 时保持旧行为(只看自身 data.text),未及改造的调用点不会变。
function upstreamTextOf(n, edgesArr, nodesArr) {
const seen = new Set([n.id])
const walk = (x) => {
const srcs = edgesArr.filter((e) => e.to === x.id).map((e) => nodesArr.find((y) => y.id === e.from))
.filter((y) => y && y.type !== 'ref' && !(y.data && y.data.enabled === false)).sort(compareCanvasTextOrder)
for (const src of srcs) {
const t = selfTextOf(src)
if (t) return t
// 只穿透「本身无文案、职责是转接」的节点;组合 / LLM / 插件节点有自己的语义,不越过
if (!seen.has(src.id) && (src.type === 'prompt' || src.type === 'textout' || src.type === 'relay' || src.type === 'batch')) {
seen.add(src.id)
const up = walk(src)
if (up) return up
}
}
return ''
}
return walk(n)
}
function batchSrcText(n, edgesArr, nodesArr) {
if (!n || !n.data) return ''
const own = selfTextOf(n)
if (own) return own
// 继承态只有提示词 / 文本节点有(它们的节点体就显示「继承」);组合 / 连接 / LLM 不在此列
return (n.type === 'prompt' || n.type === 'textout') && edgesArr && nodesArr ? upstreamTextOf(n, edgesArr, nodesArr) : ''
}
function isBatchSrc(n, edgesArr, nodesArr) {
// outKind === 'prompt'(2026-11-14):插件节点声明「我输出的是提示词」后也算批量来源。
// 加在这一处而不是三处:批量节点的候选来源、端口分布、组合来源行都走 isBatchSrc,
// 认了它,「一条样式 × N 个商品图」的批量出图才成立。
return !!n && (n.type === 'prompt' || n.type === 'textout' || n.type === 'combine' || n.type === 'llm' || n.type === 'relay' || (n.data && n.data.outKind === 'prompt')) && !!batchSrcText(n)
return !!n && (n.type === 'prompt' || n.type === 'textout' || n.type === 'combine' || n.type === 'llm' || n.type === 'relay' || (n.data && n.data.outKind === 'prompt')) && !!batchSrcText(n, edgesArr, nodesArr)
}
function batchPortTop(idx, total, h) {
const gap = Math.min(30, Math.max(20, (h - 90) / Math.max(1, total - 1)))
@@ -48,10 +79,10 @@
}
if (n.data && n.data.enabled === false) return []
if (n.type === 'batch') {
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const s = inEdge.batchSrcId ? bsrcs.find((x) => x.id === inEdge.batchSrcId) : bsrcs[0]
if (!s || (s.data && s.data.enabled === false)) return []
const st = s ? batchJoinedText(n.data, batchSrcText(s)) : ''
const st = s ? batchJoinedText(n.data, batchSrcText(s, edgesArr, nodesArr)) : ''
return st ? [st] : []
}
return combineInputTexts(n, edgesArr, nodesArr)
@@ -60,18 +91,18 @@
if (!n || (n.data && n.data.enabled === false)) return []
if (n.type === 'batch') {
const bd = n.data || {}
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x) && !(x.data && x.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
return bsrcs.map((src) => batchJoinedText(bd, batchSrcText(src))).filter(Boolean)
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr) && !(x.data && x.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
return bsrcs.map((src) => batchJoinedText(bd, batchSrcText(src, edgesArr, nodesArr))).filter(Boolean)
}
if (n.type === 'relay') { const out = []; const relaySrcs = edgesArr.filter((x) => x.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter(Boolean).slice().sort(compareCanvasTextOrder); for (const src of relaySrcs) for (const t0 of combineInputTexts(src, edgesArr, nodesArr)) if (t0 && !out.includes(t0)) out.push(t0); return out }
const t = batchSrcText(n)
const t = batchSrcText(n, edgesArr, nodesArr)
if (n.type === 'textout') {
if (t) return [t]
const bEdge = edgesArr.filter((e) => e.to === n.id).map((e) => ({ e, b: nodesArr.find((x) => x.id === e.from) })).find((o) => o.b && o.b.type === 'batch')
if (bEdge) {
const bsrcs = edgesArr.filter((e) => e.to === bEdge.b.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x)).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
const bsrcs = edgesArr.filter((e) => e.to === bEdge.b.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr)).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
const target = bEdge.e.batchSrcId ? bsrcs.find((s) => s.id === bEdge.e.batchSrcId) : bsrcs[0]
const bt = target ? batchSrcText(target) : ''
const bt = target ? batchSrcText(target, edgesArr, nodesArr) : ''
return bt ? [bt] : []
}
}
+7 -7
View File
@@ -105,7 +105,7 @@
return base.map((t) => ({ ...t, sourceNodeId: own ? n.id : (t.sourceNodeId || n.id), ownerNodeId: n.id, title: ownTitle || t.title || '', text: own || t.text, refNodes: dedupeTaskRefs((t.refNodes || []).concat(refs)) }))
}
if (n.type === 'combine') { const orderedC = children.slice().sort((a, b) => { const na = graph.byId.get(a.sourceNodeId), nb = graph.byId.get(b.sourceNodeId); return na && nb ? compareCanvasTextOrder(na, nb) : 0 }); return [{ sourceNodeId: n.id, ownerNodeId: n.id, title: String((n.data && n.data.title) || '').trim(), text: own || orderedC.map((t) => t.text).filter(Boolean).join(String((n.data && n.data.sep) || (global.IWBRuntimeConstants && global.IWBRuntimeConstants.combineSep) || ', ')), refNodes: dedupeTaskRefs(orderedC.flatMap((t) => t.refNodes)), diagnostics: { cycles: orderedC.flatMap((t) => (t.diagnostics && t.diagnostics.cycles) || []), disabledSources: [] } }] }
if (n.type === 'batch') { const candidates = incoming.map((e) => graph.byId.get(e.from)).filter((x) => x && isBatchSrc(x) && !(x.data && x.data.enabled === false)); const selected = ctx.selectedBatchSourceId && candidates.find((x) => x.id === ctx.selectedBatchSourceId); const sources = selected ? [selected] : candidates; return sources.flatMap((src) => resolveNodeTaskValues(src.id, graph, { ...ctx, selectedBatchSourceId: null, stack: next }).map((t) => ({ ...t, text: batchJoinedText(n.data || {}, t.text) }))) }
if (n.type === 'batch') { const candidates = incoming.map((e) => graph.byId.get(e.from)).filter((x) => x && isBatchSrc(x, graph.edges, graph.nodes) && !(x.data && x.data.enabled === false)); const selected = ctx.selectedBatchSourceId && candidates.find((x) => x.id === ctx.selectedBatchSourceId); const sources = selected ? [selected] : candidates; return sources.flatMap((src) => resolveNodeTaskValues(src.id, graph, { ...ctx, selectedBatchSourceId: null, stack: next }).map((t) => ({ ...t, text: batchJoinedText(n.data || {}, t.text) }))) }
if (n.type === 'relay') {
const sharedRefs = dedupeTaskRefs(children.filter((t) => !t.text).flatMap((t) => t.refNodes || []))
const textTasks = [], seenTasks = new Set()
@@ -248,13 +248,13 @@
return out
}
if (n.type === 'batch') {
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x) && !(x.data && x.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr) && !(x.data && x.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const sel = inEdge && inEdge.batchSrcId ? bsrcs.find((s) => s.id === inEdge.batchSrcId) : bsrcs[0]
if (!sel) return []
const t = batchJoinedText((n.data || {}), (batchSrcText(sel) || ''))
const t = batchJoinedText((n.data || {}), (batchSrcText(sel, edgesArr, nodesArr) || ''))
return t ? [{ n: sel, text: t }] : []
}
const t = batchSrcText(n)
const t = batchSrcText(n, edgesArr, nodesArr)
return t ? [{ n, text: t }] : []
}
@@ -296,7 +296,7 @@
const bEdge = edgesArr.filter((e) => e.to === n.id).map((e) => ({ e, b: nodesArr.find((x) => x.id === e.from) })).find((o) => o.b && o.b.type === 'batch')
if (bEdge) {
const b = bEdge.b
const bsrcs = edgesArr.filter((e) => e.to === b.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x)).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
const bsrcs = edgesArr.filter((e) => e.to === b.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr)).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
const target = bEdge.e.batchSrcId ? bsrcs.find((s) => s.id === bEdge.e.batchSrcId) : bsrcs[0]
if (target) {
const seen = new Set()
@@ -333,7 +333,7 @@
}
if (n.type === 'batch') {
// 批量加文案:透传其所有输入源的参考图
const textSrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x))
const textSrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr))
const seen = new Set()
const out = []
for (const st of textSrcs) for (const r of nodeRefsOf(st, edgesArr, nodesArr, visited)) if (!seen.has(r.id)) { seen.add(r.id); out.push(r) }
@@ -344,7 +344,7 @@
// 插件节点的入边通常为空(样式节点端口只出),所以 selfRefs 往往就是全部 ——
// 少这一句,分层节点(走 layerInputsOf → nodeRefsOf)就看不到样式节点那张示例图。
if (n.type !== 'combine') return dedupeTaskRefs(direct.concat(selfRefNodesOf(n)))
const textSrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x) || (x && x.type === 'batch'))
const textSrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr) || (x && x.type === 'batch'))
const seen = new Set()
const out = []
for (const st of textSrcs) for (const r of nodeRefsOf(st, edgesArr, nodesArr, visited)) if (!seen.has(r.id)) { seen.add(r.id); out.push(r) }
+3 -3
View File
@@ -468,9 +468,9 @@
let batchSrcTxt = ''
const bEdgeT = (props.edges || []).filter((e) => e.to === node.id).map((e) => ({ e, b: (props.nodes || []).find((n) => n.id === e.from) })).find((o) => o.b && o.b.type === 'batch')
if (bEdgeT) {
const bsrcsT = (props.edges || []).filter((e) => e.to === bEdgeT.b.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n)).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
const bsrcsT = (props.edges || []).filter((e) => e.to === bEdgeT.b.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n, props.edges || [], props.nodes || [])).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
const tgtT = bEdgeT.e.batchSrcId ? bsrcsT.find((s) => s.id === bEdgeT.e.batchSrcId) : bsrcsT[0]
if (tgtT) batchSrcTxt = batchSrcText(tgtT)
if (tgtT) batchSrcTxt = batchSrcText(tgtT, props.edges || [], props.nodes || [])
}
// 透传参考图展示(按来源顺序,像提示词面板)
const tRefs = nodePreviewRefsV2(node, props.nodes || [], props.edges || [])
@@ -604,7 +604,7 @@
const { onUpdate, stop } = ctx
// 连接节点:多个来源各自追加统一文案,每个来源对应一对输入/输出端口
const d = node.data || {}
const bsrcs = (props.edges || []).filter((e) => e.to === node.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const bsrcs = (props.edges || []).filter((e) => e.to === node.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n, props.edges || [], props.nodes || [])).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const outCount = Object.keys(d.outs || {}).filter((k) => (props.nodes || []).some((n) => n.id === d.outs[k])).length // 兼容旧数据(手动模式下不再自动创建)
return el('div', { className: 'iwb-node-body' },
el('div', { className: 'iwb-row iwb-gen-head' },
+1 -1
View File
@@ -241,7 +241,7 @@ function NodeCard(props) {
if (hasOut) {
if (node.type === 'batch') {
// 连接节点:每个输入来源一个输出端口(按来源行均匀分布);无来源时默认 1 对占位端口
const bsrcs = (props.edges || []).filter((e) => e.to === node.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const bsrcs = (props.edges || []).filter((e) => e.to === node.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n, props.edges || [], props.nodes || [])).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
const list = bsrcs.length ? bsrcs : [null]
const n = list.length
list.forEach((bs, bi) => {
+24
View File
@@ -55,4 +55,28 @@ const s2 = n('s2', 'prompt', { text: 'B' }); s2.y = 10
const edges = [{ from: 's1', to: 'b' }, { from: 's2', to: 'b' }]
assert.strictEqual(T.combineInputTexts(bs, edges, [bs, s1, s2]).join('|'), 'A-!|B-!')
// ── 继承态(2026-11-23):提示词承接上游文案后,对外输出就是那条文案 ────────────
// 场景:风格库变量节点 → 提示词(自己没写字,节点体显示「继承 · 来自 上一级」)→ 组合节点。
// 出图侧一直能拿到文案(resolveNodeTaskValues 的 own || 上游),但组合侧读的是 batchSrcText,
// 原来只看 data.text ⇒ 组合里一行都没有。修复后两侧同口径;组合的拼接逻辑本身不动。
const up = n('s1', 'plugin:style-source:style', { text: '上游文案', outKind: 'prompt' }); up.x = 0; up.y = 100
const inh = n('p1', 'prompt', {}); inh.x = 300; inh.y = 100
const inhEdges = [{ from: 's1', to: 'p1' }]
assert.strictEqual(T.batchSrcText(inh, inhEdges, [up, inh]), '上游文案')
assert.strictEqual(T.isBatchSrc(inh, inhEdges, [up, inh]), true)
assert.strictEqual(T.isBatchSrc(inh), false, '不传图时保持旧行为(只看 data.text)')
assert.strictEqual(T.combineInputTexts(inh, inhEdges, [up, inh]).join('|'), '上游文案')
// 接管态:自己写了字就用自己的,不再透传
inh.data.text = '自己的文案'
assert.strictEqual(T.batchSrcText(inh, inhEdges, [up, inh]), '自己的文案')
inh.data.text = ''
// 多路上游:提示词节点不拼合,只取画布顺序第一条(与节点体「继承 · 来自 上一级」一致)
const up2 = n('s2', 'plugin:style-source:style', { text: '第二路', outKind: 'prompt' }); up2.x = 0; up2.y = 600
assert.strictEqual(T.batchSrcText(inh, [{ from: 's1', to: 'p1' }, { from: 's2', to: 'p1' }], [up, up2, inh]), '上游文案')
// 上游停用:不参与
const upOff = n('s3', 'plugin:style-source:style', { text: '停用', outKind: 'prompt', enabled: false })
assert.strictEqual(T.batchSrcText(n('p2', 'prompt', {}), [{ from: 's3', to: 'p2' }], [upOff]), '')
// 环:提示词 ↔ 中继 不死循环
assert.strictEqual(T.batchSrcText(n('p3', 'prompt', {}), [{ from: 'r3', to: 'p3' }, { from: 'p3', to: 'r3' }], [n('r3', 'relay', {})]), '')
console.log('canvas text checks passed')
+56
View File
@@ -99,3 +99,59 @@ test('提示词与文本节点显示上游继承文本,改字即接管、可
expect(errors, '全程不应有页面 JS 异常').toEqual([])
})
// 2026-11-23 用户报障:提示词接了变量节点后,文案没进组合节点(出图却有)。
// 根因是组合侧读 batchSrcText(只看 data.text),继承态提示词 data.text 为空 ⇒ 整路被丢。
// 这里钉 DOM:组合节点要出现这一行,且上游改动要跟着变(组合功能本身不变,只是拿到来源)。
const SRC2 = '组合里应该出现这段文案'
const WS2 = {
workspaces: [{
id: 'ws_c', name: '继承进组合', groups: [],
nodes: [
{ id: 'p1', type: 'prompt', x: 140, y: 160, w: 300, h: 200, data: { text: SRC2 } },
{ id: 'r1', type: 'relay', x: 520, y: 210, data: {} },
{ id: 'p2', type: 'prompt', x: 700, y: 160, w: 300, h: 200, data: {} },
{ id: 'cb', type: 'combine', x: 1040, y: 160, w: 300, h: 200, data: {} },
],
edges: [
{ id: 'c1', from: 'p1', to: 'r1' },
{ id: 'c2', from: 'r1', to: 'p2' },
{ id: 'c3', from: 'p2', to: 'cb' },
],
}],
activeId: 'ws_c', rev: 1,
}
test('提示词(继承态)的文案会进入组合节点,并跟随上游变化', async ({ page }) => {
const errors = []
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)))
await page.addInitScript((d) => {
if (localStorage.getItem('iwb_combine_inherit_init') === '1') return
localStorage.clear()
localStorage.setItem('iwb_combine_inherit_init', '1')
localStorage.setItem('iwb_web_workspaces', JSON.stringify(d.ws))
localStorage.setItem('iwb_ws_active', 'ws_c')
localStorage.setItem('iwb_web_cfg', JSON.stringify(d.cfg))
}, { ws: WS2, cfg: CFG })
await page.goto('/', { waitUntil: 'domcontentloaded' })
await page.waitForTimeout(700)
await page.locator('.iwb-home-card:not(.iwb-home-new)').first().dblclick()
await page.waitForTimeout(900)
// ① 组合节点里应出现继承来的那一行(不是空 + 红字提示)
await expect(box(page, 'cb').locator('.iwb-combine-src'), '继承态提示词的文案必须进组合').toHaveCount(1)
await expect(box(page, 'cb').locator('.iwb-combine-src')).toContainText(SRC2)
await expect(box(page, 'cb').locator('.iwb-err'), '有来源时不应再报「请连接有文本的节点」').toHaveCount(0)
// ② 跟随上游:改最上游,组合行同步(提示词未接管)
await typeInto(page, 'p1', '上游改过之后的文案')
await expect(box(page, 'cb').locator('.iwb-combine-src')).toContainText('上游改过之后的文案')
// ③ 提示词接管后,组合用提示词自己的文案
await typeInto(page, 'p2', '提示词自己写的文案')
await expect(box(page, 'cb').locator('.iwb-combine-src')).toContainText('提示词自己写的文案')
await expect(box(page, 'cb').locator('.iwb-combine-src')).not.toContainText('上游改过之后的文案')
expect(errors, '全程不应有页面 JS 异常').toEqual([])
})
+21
View File
@@ -191,4 +191,25 @@ ok('两张参考图按 X 轴排序:样式节点的图跟节点位置走', () =
assert.strictEqual(tasks[0].refs[1].value, 'https://cdn.example.com/right.png')
})
// ── ⑤ 组合节点:继承态提示词的文案与图都要到位(2026-11-23)──────────────
ok('样式 → 提示词(继承) → 组合:组合行有文案、下游拿得到参考图', () => {
const s1 = styleNode('s1', 0, 0)
const p1 = plainPrompt('p1', 300, 0, '')
const c1 = { id: 'c1', type: 'combine', x: 700, y: 0, data: { sep: ', ' } }
const nodes = [s1, p1, c1, genNode]
const edges = [edge('s1', 'p1'), edge('p1', 'c1'), edge('c1', 'g1')]
// 组合行:来自 p1(提示词节点本身),文案是它继承的那条(组合的拼接逻辑不改)
const pairs = []
for (const e of edges) if (e.to === 'c1') { const src = nodes.find((n) => n.id === e.from); pairs.push.apply(pairs, TG.combineSourcePairs(src, e, edges, nodes)) }
assert.strictEqual(pairs.length, 1)
assert.strictEqual(pairs[0].text, 'a 银发少女 in the rain')
// 组合 → 下游(文本节点 / 分层节点走 nodeRefsOf)不能丢图
assert.strictEqual(TG.nodeRefsOf(c1, edges, nodes).map((r) => r.id).join(','), 's1:ref')
// 生成任务不变:仍是 1 个任务,文案与图都在
const tasks = TG.buildGenerationTasksV2(genNode, nodes, edges)
assert.strictEqual(tasks.length, 1)
assert.strictEqual(tasks[0].text, 'a 银发少女 in the rain')
assert.strictEqual(tasks[0].refs.length, 1)
})
console.log('\nplugin-style-node: ' + passed + ' passed')