fix(task-graph): 插件文本节点接多张参考图合并为 1 个任务(相册仍一图一任务)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m44s

This commit is contained in:
qiqi committed 2026-12-03 17:56:41 +08:00
1 parent 858144aabe
commit 475c048694
3 files changed
+49 -2

No files matched your search

+1 -1
View File
@@ -22,7 +22,7 @@
- 图片**新写入主通道 = IndexedDB Blob `{__blob}` / key `imgblob_<hash>_<len>`** (A) `app.js:2143`;`{__cache}`(Cache Storage)为兜底;\`ref_\`(`app.js` 内定义的 `IDB_REF_PREFIX = 'ref_'`)为 legacy 形态 (A)。
- 大图判定:`isBigDataUrl` = `data:` 且 `length > 3000` (A) `app.js:2018`;**画布保存保留阈值** `< 16384` 才原样保留 (A) `app.js:2182`。**两处阈值并存,含义不同**。
- 单测是**源码契约测试**:`tests/` 目录共 **493** 处源码文本钉点(`source.includes` / `source.indexOf` / `/re/.test(source)`),分布在 **20** 个文件(其中 `iwb-v32-web-test.js` 一个就占 **407**)→ **结构性重构会先打红测试**。**该数字已由 `tests/source-text-ratchet-test.js` 的「只减不增」棘轮守门**(2026-10-20 起守卫范围从 1 个文件扩到全目录:新增任何一处源码文本钉点都会打红)。**2026-11-12 复算**(`npm run audit:pins`,v3.24.76):二分 STRUCT **417** / NAME **76**;形态 **POS 403 / NEG 87 / COUNT 3**;难度 **易 62 / 中 316 / 难 115**。钉点减法第一批(v3.24.72)把 **537 → 505**:8 条探针钉点改为「门禁内 spec 是否真的读该计数器」、5 条改为运行时断言(生产态 `window` 上无探针)、10 条改为 DOM 断言(质量档位禁用 / 传输页无三模式按钮 / 模型项 title)、4 条改为运行时对象断言(健康检查两域、策略对象冻结)、其余 9 条有同文件 DOM 等价断言或仅剩 NEG。第二批(v3.24.76)把 **505 → 493**:94-5~7 三条「多标签释放语义」(10 处正则)换成 `tests/iwb-tabs-release.spec.js` 的 3 条真 e2e,剩 1 条「消费方契约」(断言该 spec 在门禁内且 spec 源码真的读两个探针);另 2 条 `wPurgeIntent.add` 钉点改为读 `src/workspace-purge.js`。**这一批一换就查出 3 个真缺陷**(objectURL 从未释放 / 彻底删除留孤儿标签 · session / 刷新后误回收打开标签的图)—— 见 CHANGELOG v3.24.76。
- `app.js` = 单 IIFE **9,357 行**(**双层预算**:绝对上限 9,357 / 占总源码 ≤ 40%,现 **26.2%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,690 行**(上限 **2,690**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **128** 个模块 / 26,293 行,`sourceModules` 128 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。
- `app.js` = 单 IIFE **9,357 行**(**双层预算**:绝对上限 9,357 / 占总源码 ≤ 40%,现 **26.2%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,690 行**(上限 **2,690**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **128** 个模块 / 26,303 行,`sourceModules` 128 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。
- 门禁:`npm run verify` = `verify:ci`(`build` → `node --check app.js` → `node --check dist/app.js` → `check-dist.js` → `lint`(ESLint 正确性规则,`src/` + `app.js`,P4-16a)→ `test:unit` → `test` → `test:facts`)+ `test:e2e` (A) `package.json`。
## 1.5 内存基线(2026-11-30,v3.26.115,Windows / WebView2 实测)
+11 -1
View File
@@ -188,7 +188,17 @@
// 这里原来直接返回 children,把节点自己的 data.text 丢成空串 ⇒ 发出去只有图没有提示词,
// 生图服务商报 400 INVALID_ARGUMENT。口径与上面的 prompt 分支一致:自己的文本优先,参考图取并集。
const ownTitle = String((n.data && n.data.title) || '').trim()
return children.map((t) => ({
// 2026-12-03(用户):上游**全是纯图片节点**时,合并成**一个**任务(图1+图2 一起带),
// 与内置 prompt 分支同口径;上游带文本、或来自相册等多值源时保持「一子一任务」。
// 不能无脑把 refs 取并集再逐条塞回去:相册的一图一任务会被压平成「每个任务带全部图」。
const allRefLeaves = children.length > 0 && children.every((t) => {
const sn = graph.byId.get(t.sourceNodeId)
return !!(sn && sn.type === 'ref')
})
const base = allRefLeaves
? [{ sourceNodeId: n.id, ownerNodeId: n.id, title: ownTitle, text: '', refNodes: dedupeTaskRefs(children.flatMap((t) => t.refNodes || [])), diagnostics: { cycles: children.flatMap((t) => (t.diagnostics && t.diagnostics.cycles) || []), disabledSources: [] } }]
: children
return base.map((t) => ({
...t,
ownerNodeId: n.id,
title: ownTitle || t.title || '',
+37
View File
@@ -78,5 +78,42 @@ const ep = { id: 'ep', from: 'p1', to: 'g1' }
tasks = tg.buildGenerationTasksV2(gen, [ref, promptNode, gen], [{ id: 'er', from: 'r1', to: 'p1' }, ep])
ok('内置 prompt 节点 + 上游图:文本保留', tasks.length === 1 && tasks[0].text === '内置提示词' && tasks[0].refs.length === 1)
// 6) 两张参考图 → 插件文本节点:必须合并成 1 个任务(图1+图2 一起带)
{
const r2 = { id: 'r2', type: 'ref', x: 0, y: 100, data: { url: 'data:image/png;base64,BBB' } }
const edges2 = [{ id: 'e1', from: 'r1', to: 't1' }, { id: 'e1b', from: 'r2', to: 't1' }, e2]
const ts = tg.buildGenerationTasksV2(gen, [ref, r2, tpl, gen], edges2)
ok('两张参考图 → 1 个任务', ts.length === 1, JSON.stringify(ts.map((t) => t.refs.length)))
ok('两张参考图 → refs=2 且文本保留', ts.length === 1 && ts[0].refs.length === 2 && ts[0].text === '我要画一只猫')
}
// 7) 两张参考图 + 空文本的插件节点:仍是 1 个任务(纯图任务)
{
const r2 = { id: 'r2', type: 'ref', x: 0, y: 100, data: { url: 'data:image/png;base64,BBB' } }
const tplEmpty2 = { id: 't1', type: 'plugin:promptlib:ptpl', x: 100, y: 0, data: { text: '', outKind: 'prompt' } }
const edges2 = [{ id: 'e1', from: 'r1', to: 't1' }, { id: 'e1b', from: 'r2', to: 't1' }, e2]
const ts = tg.buildGenerationTasksV2(gen, [ref, r2, tplEmpty2, gen], edges2)
ok('两张参考图 + 空文本 → 1 个任务、refs=2', ts.length === 1 && ts[0].text === '' && ts[0].refs.length === 2, JSON.stringify(ts.map((t) => ({ t: t.text, r: t.refs.length }))))
}
// 8) 回归:相册(2 张) → 插件文本节点 → 仍是一图一任务(不能被压平)
{
const album = { id: 'a1', type: 'plugin:album:album', x: 0, y: 0, data: { outKind: 'images', items: [{ src: 'data:image/png;base64,AAA' }, { src: 'data:image/png;base64,BBB' }] } }
const ea = { id: 'ea', from: 'a1', to: 't1' }
const ts = tg.buildGenerationTasksV2(gen, [album, tpl, gen], [ea, e2])
ok('相册(2 张) → 插件文本节点:仍 2 个任务、各带 1 张', ts.length === 2 && ts.every((t) => t.refs.length === 1), JSON.stringify(ts.map((t) => t.refs.length)))
ok('相册 → 插件文本节点:每个任务都带自己的文本', ts.every((t) => t.text === '我要画一只猫'))
}
// 9) 回归:两个文本上游 → 插件节点:仍是 2 个任务
{
const x1 = { id: 'x1', type: 'textout', x: -100, y: 0, data: { text: '上游A' } }
const x2 = { id: 'x2', type: 'textout', x: -100, y: 100, data: { text: '上游B' } }
const ex1 = { id: 'ex1', from: 'x1', to: 't1' }
const ex2 = { id: 'ex2', from: 'x2', to: 't1' }
const ts = tg.buildGenerationTasksV2(gen, [x1, x2, tpl, gen], [ex1, ex2, e2])
ok('两个文本上游 → 仍 2 个任务', ts.length === 2, JSON.stringify(ts.map((t) => t.text)))
}
if (failed) { console.error('plugin-text-node-refs: ' + failed + ' 项失败'); process.exit(1) }
console.log('plugin-text-node-refs checks passed')