dsh-workflow-canvas 0.2.4 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -111
- package/README.zh.md +78 -75
- package/client.js +286 -171
- package/docs/DETAIL.md +13 -10
- package/docs/images/add-node-shift-a.gif +0 -0
- package/docs/images/connect-and-cut.gif +0 -0
- package/docs/images/lead-pause-resume.gif +0 -0
- package/docs/images/node-config.gif +0 -0
- package/docs/images/node-entry-en.png +0 -0
- package/docs/images/node-entry-zh.png +0 -0
- package/docs/images/node-lead-en.png +0 -0
- package/docs/images/node-lead-zh.png +0 -0
- package/docs/images/node-subagent-en.png +0 -0
- package/docs/images/node-subagent-zh.png +0 -0
- package/docs/images/parallel-and-inspect.gif +0 -0
- package/index.js +162 -56
- package/package.json +1 -1
- package/skills/workflow-canvas/SKILL.md +3 -1
package/client.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
window.__ModuleLoader__.load({
|
|
2
|
+
// Must stay identical to the published package name; DSH matches the sidebar
|
|
3
|
+
// client bundle by this id and silently skips loading if it drifts.
|
|
2
4
|
id: 'dsh-workflow-canvas',
|
|
3
5
|
factory(require) {
|
|
4
6
|
const React = require('react');
|
|
@@ -42,6 +44,8 @@ window.__ModuleLoader__.load({
|
|
|
42
44
|
|
|
43
45
|
const FX_KEY = STORAGE_PREFIX + 'fx';
|
|
44
46
|
const FX_LEVELS = ['minimal', 'standard', 'vivid'];
|
|
47
|
+
const PARALLEL_KEY = STORAGE_PREFIX + 'maxParallel';
|
|
48
|
+
const PARALLEL_STEPS = [1, 2, 4, 6, 8];
|
|
45
49
|
const STYLE_ID = 'dsh-workflow-canvas-styles';
|
|
46
50
|
|
|
47
51
|
/** Inject scoped CSS keyframes once; never touches host selectors. */
|
|
@@ -128,6 +132,7 @@ window.__ModuleLoader__.load({
|
|
|
128
132
|
savedPreset: '已保存预设', saveFailed: '保存失败(存储不可用)',
|
|
129
133
|
loadedPreset: '已载入预设', invalidPreset: '预设内容无效', deletedPreset: '已删除预设',
|
|
130
134
|
syncFailed: '同步失败', upToDate: '已是最新', syncedToHost: '已同步到 Host',
|
|
135
|
+
syncedWithStdWarn: '已同步(含可写/命令节点,请确认主对话权限已放开)',
|
|
131
136
|
cannotOpen: '无法打开会话', undoDone: '已撤销', undoNone: '没有可撤销的操作',
|
|
132
137
|
leadLocked: '入口 Lead 不能删除', modelsMissing: '模型列表未加载',
|
|
133
138
|
tipLead: 'Lead 步骤在对话里执行,画布不追踪其状态',
|
|
@@ -173,6 +178,7 @@ window.__ModuleLoader__.load({
|
|
|
173
178
|
newBlankCanvas: '+ 新建空白画布',
|
|
174
179
|
clearedCanvas: '已清空画布(可用 ↶ 撤销)',
|
|
175
180
|
cycleBlocked: '不能形成环,已阻止连线',
|
|
181
|
+
leadToLeadBlocked: 'Lead 节点不能直接连到另一个 Lead,请在中间放入子代理',
|
|
176
182
|
builtinTemplates: '内置示例模板',
|
|
177
183
|
myPresets: '我的预设',
|
|
178
184
|
duplicatedNodes: '已复制节点',
|
|
@@ -182,9 +188,13 @@ window.__ModuleLoader__.load({
|
|
|
182
188
|
fxMinimal: '极简',
|
|
183
189
|
fxStandard: '标准',
|
|
184
190
|
fxVivid: '炫酷',
|
|
191
|
+
maxParallelLabel: '最大并发',
|
|
192
|
+
tipMaxParallel: '默认 4 路并行(可选 1 / 2 / 4 / 6 / 8)。并发过高容易触发 API 限流(429)、增加多子代理同时写同一工作区的文件冲突,并放大单轮报错时的额度消耗;纯只读调研可适当调高。',
|
|
185
193
|
tipLeadReady: '上游节点已全部完成,正等待在对话里拍板继续',
|
|
186
194
|
stDeadEnd: '无出边',
|
|
187
|
-
tipDeadEnd: '
|
|
195
|
+
tipDeadEnd: '该子代理没有下游连线,运行时不生效;请连入下游节点或终审 Lead',
|
|
196
|
+
stSoloLead: '未接子代理',
|
|
197
|
+
tipSoloLead: '该 Lead 仅串联了其他 Lead,未连入任何子代理,运行时不生效',
|
|
188
198
|
singleModelHint: '当前仅 1 个可用模型,暂无其它备用路由',
|
|
189
199
|
importNone: '剪贴板里没有可识别的画布数据',
|
|
190
200
|
importBad: '画布数据格式不对',
|
|
@@ -192,7 +202,12 @@ window.__ModuleLoader__.load({
|
|
|
192
202
|
tipUndo: '撤销上一步结构改动', tipSave: '把当前画布保存为预设',
|
|
193
203
|
tipPresets: '载入已保存的预设', tipModel: '推理等级(默认 = 该模型声明的 defaultEffort)',
|
|
194
204
|
tipMemory: '记忆:复用这个节点上一次的会话(跨运行及重启后可恢复)',
|
|
195
|
-
|
|
205
|
+
memLatest: '最新',
|
|
206
|
+
memLatestOpt: '自动(最新记忆)',
|
|
207
|
+
memRunOpt: '第 {n} 次会话',
|
|
208
|
+
memEmpty: '运行后这里会列出可选的历史会话',
|
|
209
|
+
tipMemoryPick: '选择要续接的历史子会话(默认自动沿用最新记忆)',
|
|
210
|
+
tipPreset: '能力范围(点一下切换,受主对话权限上限约束):standard = 全部工具(读写文件、跑命令、子代理、工作流、网页、办公);minimal = 只读思考(文件读写关闭,没有子代理/工作流/网页)',
|
|
196
211
|
tipFallback: '失败重试:该节点出错时自动换一个模型再跑一次',
|
|
197
212
|
tipStructured: 'JSON 输出:要求该节点返回 JSON 对象,structured 连线会把结果作为 JSON 传给下游',
|
|
198
213
|
lang: 'ZH',
|
|
@@ -229,6 +244,7 @@ window.__ModuleLoader__.load({
|
|
|
229
244
|
savedPreset: 'Saved preset', saveFailed: 'Save failed (storage unavailable)',
|
|
230
245
|
loadedPreset: 'Loaded preset', invalidPreset: 'Preset content is invalid', deletedPreset: 'Deleted preset',
|
|
231
246
|
syncFailed: 'Sync failed', upToDate: 'Already up to date', syncedToHost: 'Synced to host',
|
|
247
|
+
syncedWithStdWarn: 'Synced (has write/tool nodes — check main chat permission mode)',
|
|
232
248
|
cannotOpen: 'Cannot open the session', undoDone: 'Undone', undoNone: 'Nothing to undo',
|
|
233
249
|
leadLocked: 'The entry Lead cannot be deleted', modelsMissing: 'Model list is not loaded',
|
|
234
250
|
tipLead: 'Lead steps run in the chat; the canvas does not track them',
|
|
@@ -274,6 +290,7 @@ window.__ModuleLoader__.load({
|
|
|
274
290
|
newBlankCanvas: '+ New blank canvas',
|
|
275
291
|
clearedCanvas: 'Canvas cleared (use Undo to restore)',
|
|
276
292
|
cycleBlocked: 'Cannot create a cycle',
|
|
293
|
+
leadToLeadBlocked: 'Cannot link a Lead directly to another Lead; place a subagent in between',
|
|
277
294
|
builtinTemplates: 'Starter templates',
|
|
278
295
|
myPresets: 'Saved presets',
|
|
279
296
|
duplicatedNodes: 'Duplicated nodes',
|
|
@@ -283,9 +300,13 @@ window.__ModuleLoader__.load({
|
|
|
283
300
|
fxMinimal: 'Minimal',
|
|
284
301
|
fxStandard: 'Standard',
|
|
285
302
|
fxVivid: 'Vivid',
|
|
303
|
+
maxParallelLabel: 'Max parallel',
|
|
304
|
+
tipMaxParallel: 'Default 4 concurrent subagents (1 / 2 / 4 / 6 / 8). Higher concurrency can trigger API rate limits (429), increase workspace file-edit conflicts, and widen token spend on failure; raising it is safest for read-only research.',
|
|
286
305
|
tipLeadReady: 'Upstream steps are done; waiting for Lead in chat',
|
|
287
306
|
stDeadEnd: 'No out-link',
|
|
288
|
-
tipDeadEnd: 'This subagent has no outgoing link
|
|
307
|
+
tipDeadEnd: 'This subagent has no outgoing link and is skipped at run time; wire it into a downstream node or Lead',
|
|
308
|
+
stSoloLead: 'Needs agent',
|
|
309
|
+
tipSoloLead: 'This Lead only chains from another Lead with no subagent upstream, so it is skipped at run time',
|
|
289
310
|
singleModelHint: 'Only 1 model available — no alternate fallback route',
|
|
290
311
|
importNone: 'No canvas data found in the clipboard',
|
|
291
312
|
importBad: 'Canvas data is malformed',
|
|
@@ -293,7 +314,12 @@ window.__ModuleLoader__.load({
|
|
|
293
314
|
tipUndo: 'Undo the last structural change', tipSave: 'Save this canvas as a preset',
|
|
294
315
|
tipPresets: 'Load a saved preset', tipModel: 'Reasoning effort (default = the model\'s defaultEffort)',
|
|
295
316
|
tipMemory: 'Memory: reuse this node\'s previous session (persisted across runs and restarts)',
|
|
296
|
-
|
|
317
|
+
memLatest: 'Latest',
|
|
318
|
+
memLatestOpt: 'Auto (latest)',
|
|
319
|
+
memRunOpt: 'Run #{n}',
|
|
320
|
+
memEmpty: 'Past runs appear here after running',
|
|
321
|
+
tipMemoryPick: 'Pick which past child session to resume (defaults to latest)',
|
|
322
|
+
tipPreset: 'Capability (click to toggle; bounded by the main chat permission mode): standard = all tools (files, shells, subagents, workflow, web, office); minimal = read-only thinking (no file writes, no subagents/workflow/web)',
|
|
297
323
|
tipFallback: 'Retry: when this node fails, rerun it once on another model',
|
|
298
324
|
tipStructured: 'JSON output: require an object result; structured links pass it downstream as JSON',
|
|
299
325
|
lang: 'EN',
|
|
@@ -725,132 +751,59 @@ window.__ModuleLoader__.load({
|
|
|
725
751
|
return out.length === nodes.length ? out : null;
|
|
726
752
|
}
|
|
727
753
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
const rest = nodes.filter((n) => n.id !== 'lead');
|
|
736
|
-
if (!rest.length) return { error: '画布上还没有可执行的节点' };
|
|
737
|
-
const task = String(entry.task || '').trim();
|
|
738
|
-
if (!task) return { error: '请先在 Lead 节点填写「本次任务」' };
|
|
739
|
-
|
|
740
|
-
const byIdAll = new Map(rest.map((n) => [n.id, n]));
|
|
741
|
-
|
|
742
|
-
const reachable = new Set([entry.id]);
|
|
743
|
-
let grew = true;
|
|
744
|
-
while (grew) {
|
|
745
|
-
grew = false;
|
|
746
|
-
for (const e of edges) {
|
|
747
|
-
if (reachable.has(e.from) && !reachable.has(e.to)) { reachable.add(e.to); grew = true; }
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
const orphan = rest.filter((n) => !reachable.has(n.id));
|
|
751
|
-
if (orphan.length) {
|
|
752
|
-
return { error: '这些节点没有从入口 Lead 连过来:' + orphan.map((n) => n.label).join('、') };
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
const dataEdgesAll = edges.filter((e) => e.from !== entry.id && byIdAll.has(e.from) && byIdAll.has(e.to));
|
|
756
|
-
|
|
757
|
-
// Lead-kind nodes are executed by the conversation itself, which can only
|
|
758
|
-
// happen after the script returns — so they must be terminal.
|
|
759
|
-
const leadNodes = rest.filter((n) => n.kind === 'lead');
|
|
760
|
-
for (const ln of leadNodes) {
|
|
761
|
-
if (dataEdgesAll.some((e) => e.from === ln.id)) {
|
|
762
|
-
return {
|
|
763
|
-
error: '中间 Lead 节点暂不支持(「' + ln.label + '」后面还有步骤)。'
|
|
764
|
-
+ '把中间这一步换成子代理,或把它移到流程末尾。',
|
|
765
|
-
};
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
const agentNodes = rest.filter((n) => n.kind !== 'lead');
|
|
770
|
-
if (!agentNodes.length) return { error: '需要至少一个子代理节点来执行' };
|
|
771
|
-
|
|
772
|
-
const byId = new Map(agentNodes.map((n) => [n.id, n]));
|
|
773
|
-
const dataEdges = dataEdgesAll.filter((e) => byId.has(e.from) && byId.has(e.to));
|
|
774
|
-
const order = topoOrder(agentNodes, dataEdges);
|
|
775
|
-
if (!order) return { error: '存在环,无法生成有向无环图的脚本' };
|
|
776
|
-
|
|
777
|
-
const upstream = new Map(agentNodes.map((n) => [n.id, []]));
|
|
778
|
-
for (const e of dataEdges) upstream.get(e.to).push(e);
|
|
779
|
-
const hasDownstream = new Set(dataEdges.map((e) => e.from));
|
|
780
|
-
|
|
781
|
-
// Hand back everything a lead step consumes, plus every terminal agent.
|
|
782
|
-
const delivered = [];
|
|
783
|
-
const deliver = (id) => { if (byId.has(id) && !delivered.includes(id)) delivered.push(id); };
|
|
784
|
-
for (const ln of leadNodes) {
|
|
785
|
-
for (const e of dataEdgesAll) if (e.to === ln.id) deliver(e.from);
|
|
754
|
+
/** Ids reachable from the entry Lead via O(V + E) BFS; every other node is skipped at run time. */
|
|
755
|
+
function reachableFrom(nodes, edges) {
|
|
756
|
+
const adj = new Map();
|
|
757
|
+
for (const e of edges || []) {
|
|
758
|
+
if (!e || !e.from || !e.to) continue;
|
|
759
|
+
if (!adj.has(e.from)) adj.set(e.from, []);
|
|
760
|
+
adj.get(e.from).push(e.to);
|
|
786
761
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
const ups = upstream.get(id);
|
|
794
|
-
const isRoot = ups.length === 0;
|
|
795
|
-
const upsLabels = ups.map((e) => (byId.get(e.from) || {}).label).filter(Boolean);
|
|
796
|
-
const downs = dataEdgesAll.filter((e) => e.from === id).map((e) => (byIdAll.get(e.to) || {}).label).filter(Boolean);
|
|
797
|
-
const head = [];
|
|
798
|
-
head.push('【工作流节点】你在一个多步工作流里负责「' + node.label + '」这一步(子代理)。');
|
|
799
|
-
if (isRoot) head.push('【总任务】' + task);
|
|
800
|
-
head.push('【职责】' + (node.role || node.label || id));
|
|
801
|
-
if (upsLabels.length) head.push('【上游】' + upsLabels.join('、') + ' 已交付结果给你(见下文)。');
|
|
802
|
-
head.push('【下游】' + (downs.length ? downs.join('、') + ' 会使用你的输出。' : '你是终点,结果会直接交付给用户。'));
|
|
803
|
-
head.push('【要求】只完成你这一步;输出要能被下游直接使用,不要重复上游已完成的工作。');
|
|
804
|
-
const pieces = [JSON.stringify(head.join('\n') + '\n')];
|
|
805
|
-
for (const e of ups) {
|
|
806
|
-
const from = byId.get(e.from);
|
|
807
|
-
pieces.push(JSON.stringify('\n## 来自【' + from.label + '】(' + (e.type || 'prompt') + ')\n'));
|
|
808
|
-
pieces.push(varOf(e.from));
|
|
762
|
+
const set = new Set(['lead']);
|
|
763
|
+
const queue = ['lead'];
|
|
764
|
+
for (let i = 0; i < queue.length; i += 1) {
|
|
765
|
+
const cur = queue[i];
|
|
766
|
+
for (const next of adj.get(cur) || []) {
|
|
767
|
+
if (!set.has(next)) { set.add(next); queue.push(next); }
|
|
809
768
|
}
|
|
810
|
-
// The label carries the canvas node id so the client can match the
|
|
811
|
-
// spawned subagent session back to its node through the catalog.
|
|
812
|
-
const opts = ["label: " + JSON.stringify((node.label || id) + '#' + id), "phase: 'run'"];
|
|
813
|
-
if (node.provider) opts.push('provider: ' + JSON.stringify(node.provider));
|
|
814
|
-
if (node.model) opts.push('model: ' + JSON.stringify(node.model));
|
|
815
|
-
lines.push('const ' + varOf(id) + ' = await agent(' + pieces.join(' + ') + ', { ' + opts.join(', ') + ' });');
|
|
816
769
|
}
|
|
817
|
-
|
|
818
|
-
const rets = delivered.map((id) => JSON.stringify(byId.get(id).label) + ': ' + varOf(id));
|
|
819
|
-
lines.push('return { ' + rets.join(', ') + ' };');
|
|
820
|
-
|
|
821
|
-
// These run in the conversation after the script returns.
|
|
822
|
-
const leadSteps = leadNodes.map((ln) => ({
|
|
823
|
-
label: ln.label,
|
|
824
|
-
role: ln.role || ln.label,
|
|
825
|
-
needs: dataEdgesAll.filter((e) => e.to === ln.id).map((e) => (byIdAll.get(e.from) || {}).label).filter(Boolean),
|
|
826
|
-
}));
|
|
827
|
-
|
|
828
|
-
return { script: lines.join('\n'), leadSteps };
|
|
770
|
+
return set;
|
|
829
771
|
}
|
|
830
772
|
|
|
831
|
-
/**
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
773
|
+
/**
|
|
774
|
+
* Reachable non-entry Lead nodes that have zero reachable subagent upstream
|
|
775
|
+
* (chained solely from another Lead). Rendered dashed and skipped at run time;
|
|
776
|
+
* connecting any subagent into them makes them active immediately.
|
|
777
|
+
*/
|
|
778
|
+
function soloLeadNodeIds(nodes, edges) {
|
|
779
|
+
const list = Array.isArray(nodes) ? nodes : [];
|
|
780
|
+
const linkList = Array.isArray(edges) ? edges : [];
|
|
781
|
+
const reachable = reachableFrom(list, linkList);
|
|
782
|
+
const byId = new Map(list.map((n) => [n.id, n]));
|
|
783
|
+
const out = new Set();
|
|
784
|
+
for (const n of list) {
|
|
785
|
+
if (n.kind !== 'lead' || n.id === 'lead' || !reachable.has(n.id)) continue;
|
|
786
|
+
const hasAgentUp = linkList.some((e) => {
|
|
787
|
+
if (!e || e.to !== n.id || !reachable.has(e.from) || e.from === 'lead') return false;
|
|
788
|
+
const src = byId.get(e.from);
|
|
789
|
+
return Boolean(src && src.kind !== 'lead');
|
|
790
|
+
});
|
|
791
|
+
if (!hasAgentUp) out.add(n.id);
|
|
840
792
|
}
|
|
841
|
-
return
|
|
793
|
+
return out;
|
|
842
794
|
}
|
|
843
795
|
|
|
844
796
|
/**
|
|
845
797
|
* Reachable agent nodes with zero outgoing edges when the graph has at least
|
|
846
|
-
* one
|
|
847
|
-
*
|
|
798
|
+
* one active downstream Lead that is NOT an ancestor of that agent (dangling
|
|
799
|
+
* branch whose output is never consumed). Rendered dashed and skipped at run time.
|
|
848
800
|
*/
|
|
849
801
|
function deadEndNodeIds(nodes, edges) {
|
|
850
802
|
const list = Array.isArray(nodes) ? nodes : [];
|
|
851
803
|
const linkList = Array.isArray(edges) ? edges : [];
|
|
852
804
|
const reachable = reachableFrom(list, linkList);
|
|
853
|
-
const
|
|
805
|
+
const soloLeads = soloLeadNodeIds(list, linkList);
|
|
806
|
+
const downstreamLeads = list.filter((n) => n.kind === 'lead' && n.id !== 'lead' && reachable.has(n.id) && !soloLeads.has(n.id));
|
|
854
807
|
if (!downstreamLeads.length) return new Set();
|
|
855
808
|
const hasOut = new Set(linkList.map((e) => e.from));
|
|
856
809
|
const parents = new Map();
|
|
@@ -1098,31 +1051,38 @@ window.__ModuleLoader__.load({
|
|
|
1098
1051
|
}
|
|
1099
1052
|
|
|
1100
1053
|
/** Everything the Host executor needs; no prompts are pre-rendered here. */
|
|
1101
|
-
function buildPlan(nodes, edges) {
|
|
1054
|
+
function buildPlan(nodes, edges, opts) {
|
|
1102
1055
|
const entry = nodes.find((n) => n.id === 'lead');
|
|
1103
1056
|
if (!entry) return { error: '缺少入口 Lead 节点' };
|
|
1104
1057
|
const task = String(entry.task || '').trim();
|
|
1105
1058
|
const rest = nodes.filter((n) => n.id !== 'lead');
|
|
1106
1059
|
if (!rest.length) return { error: '画布上还没有可执行的节点' };
|
|
1107
|
-
//
|
|
1108
|
-
//
|
|
1060
|
+
// Unconnected nodes, solo Lead-to-Lead nodes, and dangling dead-end agents
|
|
1061
|
+
// are shown dashed on the canvas and skipped at run time.
|
|
1109
1062
|
const reachableIds = reachableFrom(nodes, edges);
|
|
1063
|
+
const soloLeads = soloLeadNodeIds(nodes, edges);
|
|
1064
|
+
const deadEnds = deadEndNodeIds(nodes, edges);
|
|
1065
|
+
const isInactive = (n) => !reachableIds.has(n.id) || soloLeads.has(n.id) || deadEnds.has(n.id);
|
|
1110
1066
|
|
|
1111
|
-
const
|
|
1067
|
+
const skipped = rest.filter((n) => isInactive(n));
|
|
1068
|
+
const active = rest.filter((n) => !isInactive(n));
|
|
1069
|
+
if (!active.length) {
|
|
1070
|
+
return { error: '没有从入口 Lead 连通的有效节点,无法执行' };
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
const activeIds = new Set(active.map((n) => n.id));
|
|
1112
1074
|
const planEdges = edges
|
|
1113
|
-
.filter((e) => (e.from === 'lead' ||
|
|
1075
|
+
.filter((e) => (e.from === 'lead' || activeIds.has(e.from)) && activeIds.has(e.to))
|
|
1114
1076
|
.map((e) => ({ from: e.from, to: e.to, type: e.type || 'prompt' }));
|
|
1115
1077
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
if (!active.length) {
|
|
1120
|
-
return { error: '没有从入口 Lead 连通的节点,无法执行' };
|
|
1121
|
-
}
|
|
1078
|
+
const maxParallel = opts && Number.isFinite(Number(opts.maxParallel))
|
|
1079
|
+
? Math.max(1, Math.min(8, Math.floor(Number(opts.maxParallel))))
|
|
1080
|
+
: 4;
|
|
1122
1081
|
|
|
1123
1082
|
return {
|
|
1124
1083
|
plan: {
|
|
1125
1084
|
task,
|
|
1085
|
+
maxParallel,
|
|
1126
1086
|
skipped: skipped.map((n) => n.label || n.id),
|
|
1127
1087
|
nodes: active.map((n) => ({
|
|
1128
1088
|
id: n.id,
|
|
@@ -1134,6 +1094,7 @@ window.__ModuleLoader__.load({
|
|
|
1134
1094
|
reasoning: n.reasoning || '',
|
|
1135
1095
|
preset: n.preset === 'minimal' ? 'minimal' : 'standard',
|
|
1136
1096
|
keepSession: Boolean(n.keepSession),
|
|
1097
|
+
memoryChildId: n.memoryChildId || '',
|
|
1137
1098
|
// A structured link is the only thing that decides this: no separate switch.
|
|
1138
1099
|
structured: planEdges.some((e) => e.from === n.id && e.type === 'structured'),
|
|
1139
1100
|
fallbackModel: n.fallbackModel || '',
|
|
@@ -1181,6 +1142,25 @@ window.__ModuleLoader__.load({
|
|
|
1181
1142
|
return FX_LEVELS[(idx + 1) % FX_LEVELS.length];
|
|
1182
1143
|
}
|
|
1183
1144
|
|
|
1145
|
+
function loadMaxParallel() {
|
|
1146
|
+
try {
|
|
1147
|
+
const raw = Number(window.localStorage.getItem(PARALLEL_KEY));
|
|
1148
|
+
if (Number.isFinite(raw) && raw >= 1 && raw <= 8) return Math.floor(raw);
|
|
1149
|
+
} catch (_e) { /* ignore */ }
|
|
1150
|
+
return 4;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
function saveMaxParallel(n) {
|
|
1154
|
+
try {
|
|
1155
|
+
if (Number.isFinite(n) && n >= 1 && n <= 8) window.localStorage.setItem(PARALLEL_KEY, String(Math.floor(n)));
|
|
1156
|
+
} catch (_e) { /* ignore */ }
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
function nextMaxParallel(cur) {
|
|
1160
|
+
const idx = PARALLEL_STEPS.indexOf(Number(cur));
|
|
1161
|
+
return PARALLEL_STEPS[(idx + 1) % PARALLEL_STEPS.length];
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1184
1164
|
/** Compute the next `{ k, x, y }` keeping the content point under `(mx, my)` fixed. */
|
|
1185
1165
|
function zoomAroundPoint(cur, mx, my, deltaY, deltaMode) {
|
|
1186
1166
|
if (!deltaY) return cur;
|
|
@@ -1311,6 +1291,9 @@ window.__ModuleLoader__.load({
|
|
|
1311
1291
|
const [helpOpen, setHelpOpen] = useState(false);
|
|
1312
1292
|
const [cutMode, setCutMode] = useState(loadCutMode);
|
|
1313
1293
|
const [fxLevel, setFxLevel] = useState(loadEffectLevel);
|
|
1294
|
+
const [maxParallel, setMaxParallel] = useState(loadMaxParallel);
|
|
1295
|
+
const maxParallelRef = useRef(maxParallel);
|
|
1296
|
+
maxParallelRef.current = maxParallel;
|
|
1314
1297
|
useEffect(() => { ensureStyles(); }, []);
|
|
1315
1298
|
const cutRef = useRef(null);
|
|
1316
1299
|
/** Timestamp of the remote document being applied, so saving it does not bump the clock. */
|
|
@@ -1347,6 +1330,7 @@ window.__ModuleLoader__.load({
|
|
|
1347
1330
|
viewRef.current = view;
|
|
1348
1331
|
const [statusById, setStatusById] = useState({});
|
|
1349
1332
|
const [runsById, setRunsById] = useState({});
|
|
1333
|
+
const [sessionRunning, setSessionRunning] = useState(false);
|
|
1350
1334
|
const [presets, setPresets] = useState(loadPresets);
|
|
1351
1335
|
const [presetOpen, setPresetOpen] = useState(null);
|
|
1352
1336
|
const [presetName, setPresetName] = useState('');
|
|
@@ -1372,14 +1356,32 @@ window.__ModuleLoader__.load({
|
|
|
1372
1356
|
saveDoc(sessionId, { nodes, edges, enabled }, stamp === null ? undefined : stamp);
|
|
1373
1357
|
}, [sessionId, nodes, edges, enabled]);
|
|
1374
1358
|
|
|
1359
|
+
// Plan signature excludes visual (x, y) coordinates so dragging nodes does
|
|
1360
|
+
// not trigger false "unsaved changes" warnings; `skipDirtyOnce` suppresses
|
|
1361
|
+
// the dirty flag when applying a canvas written by the Host itself.
|
|
1362
|
+
const planSig = (nextEnabled, curNodes, curEdges, overrideParallel) => {
|
|
1363
|
+
const mp = typeof overrideParallel === 'number' ? overrideParallel : maxParallelRef.current;
|
|
1364
|
+
const res = buildPlan(curNodes, curEdges, { maxParallel: mp });
|
|
1365
|
+
const payload = res.error
|
|
1366
|
+
? { enabled: nextEnabled, error: res.error }
|
|
1367
|
+
: { enabled: nextEnabled, plan: res.plan };
|
|
1368
|
+
return JSON.stringify(payload);
|
|
1369
|
+
};
|
|
1370
|
+
|
|
1375
1371
|
// Any structural edit after enabling leaves the Host copy stale,
|
|
1376
|
-
// except
|
|
1372
|
+
// except pure position drags (same plan signature) or updates from Host.
|
|
1377
1373
|
useEffect(() => {
|
|
1378
1374
|
if (skipDirtyOnce.current) {
|
|
1379
1375
|
skipDirtyOnce.current = false;
|
|
1380
1376
|
return;
|
|
1381
1377
|
}
|
|
1382
|
-
if (enabled)
|
|
1378
|
+
if (!enabled) return;
|
|
1379
|
+
const sig = planSig(true, nodes, edges);
|
|
1380
|
+
if (lastSync.current && sig === lastSync.current) {
|
|
1381
|
+
setDirty(false);
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
setDirty(true);
|
|
1383
1385
|
}, [nodes, edges]);
|
|
1384
1386
|
|
|
1385
1387
|
// A disabled canvas shows no run status at all.
|
|
@@ -1423,25 +1425,22 @@ window.__ModuleLoader__.load({
|
|
|
1423
1425
|
// Publishing costs one visible command row in the conversation, so it only
|
|
1424
1426
|
// happens when the user enables the canvas, loads a preset/import, clears,
|
|
1425
1427
|
// or asks for it explicitly.
|
|
1426
|
-
const pushPlan = (nextEnabled, overrideNodes, overrideEdges) => {
|
|
1428
|
+
const pushPlan = (nextEnabled, overrideNodes, overrideEdges, overrideParallel) => {
|
|
1427
1429
|
try {
|
|
1428
1430
|
const face = sessionFace(sessionId);
|
|
1429
1431
|
if (!face || typeof face.command !== 'function') { flash(t('syncFailed')); return; }
|
|
1430
1432
|
const curNodes = Array.isArray(overrideNodes) ? overrideNodes : nodesRef.current;
|
|
1431
1433
|
const curEdges = Array.isArray(overrideEdges) ? overrideEdges : edgesRef.current;
|
|
1432
|
-
const
|
|
1433
|
-
|
|
1434
|
-
? { enabled: nextEnabled, error: res.error }
|
|
1435
|
-
: { enabled: nextEnabled, plan: res.plan };
|
|
1436
|
-
const sig = JSON.stringify(payload);
|
|
1437
|
-
if (sig === lastSync.current) { flash(t('upToDate')); return; }
|
|
1434
|
+
const sig = planSig(nextEnabled, curNodes, curEdges, overrideParallel);
|
|
1435
|
+
if (sig === lastSync.current) { setDirty(false); flash(t('upToDate')); return; }
|
|
1438
1436
|
const line = '/canvas-sync ' + encodeURIComponent(sig);
|
|
1437
|
+
const hasStandardAgent = nextEnabled && curNodes.some((n) => n && n.kind !== 'lead' && (n.preset || 'standard') !== 'minimal');
|
|
1439
1438
|
face.command(line).then((ack) => {
|
|
1440
1439
|
if (ack && ack.ok) {
|
|
1441
1440
|
lastSync.current = sig;
|
|
1442
1441
|
setDirty(false);
|
|
1443
1442
|
snapshotStaleCatalog();
|
|
1444
|
-
flash(t('syncedToHost'));
|
|
1443
|
+
flash(hasStandardAgent ? t('syncedWithStdWarn') : t('syncedToHost'));
|
|
1445
1444
|
} else {
|
|
1446
1445
|
flash(t('syncFailed'));
|
|
1447
1446
|
}
|
|
@@ -1527,11 +1526,17 @@ window.__ModuleLoader__.load({
|
|
|
1527
1526
|
const timing = timingProj && timingProj.values && timingProj.values.subagentTiming;
|
|
1528
1527
|
if (entry.id) {
|
|
1529
1528
|
const prev = nextRuns[nodeId];
|
|
1529
|
+
const prevHistory = prev && Array.isArray(prev.history) ? prev.history : [];
|
|
1530
|
+
const exists = prevHistory.some((hItem) => hItem.childId === entry.id);
|
|
1531
|
+
const history = exists
|
|
1532
|
+
? prevHistory
|
|
1533
|
+
: prevHistory.concat([{ childId: entry.id, label, index: prevHistory.length + 1 }]);
|
|
1530
1534
|
nextRuns[nodeId] = {
|
|
1531
1535
|
childId: entry.id,
|
|
1532
1536
|
label,
|
|
1533
1537
|
mode: entry.mode || 'continuable',
|
|
1534
|
-
count:
|
|
1538
|
+
count: history.length,
|
|
1539
|
+
history,
|
|
1535
1540
|
};
|
|
1536
1541
|
}
|
|
1537
1542
|
if (child && child.running) {
|
|
@@ -1565,6 +1570,7 @@ window.__ModuleLoader__.load({
|
|
|
1565
1570
|
const stop = () => { if (timer) { clearInterval(timer); timer = null; } };
|
|
1566
1571
|
let wasRunning = false;
|
|
1567
1572
|
try { wasRunning = Boolean(face.getSnapshot().running); } catch (_e) { wasRunning = false; }
|
|
1573
|
+
setSessionRunning(wasRunning);
|
|
1568
1574
|
read();
|
|
1569
1575
|
if (wasRunning) timer = setInterval(read, 700);
|
|
1570
1576
|
const onSnapshot = () => {
|
|
@@ -1572,6 +1578,7 @@ window.__ModuleLoader__.load({
|
|
|
1572
1578
|
try { running = Boolean(face.getSnapshot().running); } catch (_e) { running = false; }
|
|
1573
1579
|
const finished = !running && wasRunning;
|
|
1574
1580
|
wasRunning = running;
|
|
1581
|
+
setSessionRunning(running);
|
|
1575
1582
|
if (running && !timer) { read(); timer = setInterval(read, 700); }
|
|
1576
1583
|
if (!running && timer) { stop(); read(); }
|
|
1577
1584
|
if (finished && typeof sessions.refreshProjections === 'function') {
|
|
@@ -2295,6 +2302,7 @@ window.__ModuleLoader__.load({
|
|
|
2295
2302
|
const threshold = 12 / (viewRef.current.k || 1);
|
|
2296
2303
|
const from = cutRef.current;
|
|
2297
2304
|
const steps = Math.max(1, Math.ceil(Math.hypot(p.x - from.x, p.y - from.y) / 6));
|
|
2305
|
+
const nodeMap = new Map(nodes.map((n) => [n.id, n]));
|
|
2298
2306
|
for (let step = 1; step <= steps; step += 1) {
|
|
2299
2307
|
const t = step / steps;
|
|
2300
2308
|
const canvasSpot = {
|
|
@@ -2303,8 +2311,8 @@ window.__ModuleLoader__.load({
|
|
|
2303
2311
|
};
|
|
2304
2312
|
for (const edge of edges) {
|
|
2305
2313
|
if (cutHits.current.has(edge.id)) continue;
|
|
2306
|
-
const source =
|
|
2307
|
-
const target =
|
|
2314
|
+
const source = nodeMap.get(edge.from);
|
|
2315
|
+
const target = nodeMap.get(edge.to);
|
|
2308
2316
|
if (!source || !target) continue;
|
|
2309
2317
|
if (distanceToEdge(canvasSpot, source, target, edge.type) <= threshold) {
|
|
2310
2318
|
cutHits.current.add(edge.id);
|
|
@@ -2668,13 +2676,66 @@ window.__ModuleLoader__.load({
|
|
|
2668
2676
|
isOpen && h('div', { style: S.menu, onMouseDown: (e) => e.stopPropagation() }, rows),
|
|
2669
2677
|
);
|
|
2670
2678
|
};
|
|
2671
|
-
const memoryToggle = (node) =>
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2679
|
+
const memoryToggle = (node) => {
|
|
2680
|
+
const runInfo = runsById[node.id];
|
|
2681
|
+
const history = (runInfo && Array.isArray(runInfo.history)) ? runInfo.history : [];
|
|
2682
|
+
const showPicker = Boolean(node.keepSession);
|
|
2683
|
+
const key = 'm:' + node.id;
|
|
2684
|
+
const isOpen = openModelFor === key;
|
|
2685
|
+
const pickedItem = node.memoryChildId
|
|
2686
|
+
? history.find((item) => item.childId === node.memoryChildId)
|
|
2687
|
+
: undefined;
|
|
2688
|
+
const pickLabel = !node.memoryChildId
|
|
2689
|
+
? t('memLatest')
|
|
2690
|
+
: (pickedItem ? ('#' + pickedItem.index) : String(node.memoryChildId).slice(-6));
|
|
2691
|
+
const toggleBtn = h('button', {
|
|
2692
|
+
style: showPicker
|
|
2693
|
+
? { ...(node.keepSession ? S.toggleSwitchOn : S.toggleSwitch), flex: '0 0 34px', width: '34px' }
|
|
2694
|
+
: (node.keepSession ? S.toggleSwitchOn : S.toggleSwitch),
|
|
2695
|
+
type: 'button',
|
|
2696
|
+
title: t('tipMemory'),
|
|
2697
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
2698
|
+
onClick: () => updateNode(node.id, { keepSession: !node.keepSession }),
|
|
2699
|
+
}, node.keepSession ? t('on') : t('off'));
|
|
2700
|
+
if (!showPicker) return toggleBtn;
|
|
2701
|
+
const rows = [
|
|
2702
|
+
h('div', {
|
|
2703
|
+
key: 'latest',
|
|
2704
|
+
style: !node.memoryChildId ? { ...S.menuRow, background: C.hover, color: C.accent } : S.menuRow,
|
|
2705
|
+
onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
|
|
2706
|
+
onMouseLeave: (e) => { e.currentTarget.style.background = !node.memoryChildId ? C.hover : 'transparent'; },
|
|
2707
|
+
onClick: () => { updateNode(node.id, { memoryChildId: '' }); setOpenModelFor(null); },
|
|
2708
|
+
}, t('memLatestOpt')),
|
|
2709
|
+
...history.map((item) => {
|
|
2710
|
+
const selectedRow = node.memoryChildId === item.childId;
|
|
2711
|
+
return h('div', {
|
|
2712
|
+
key: item.childId,
|
|
2713
|
+
style: selectedRow ? { ...S.menuRow, background: C.hover, color: C.accent } : S.menuRow,
|
|
2714
|
+
title: item.childId,
|
|
2715
|
+
onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
|
|
2716
|
+
onMouseLeave: (e) => { e.currentTarget.style.background = selectedRow ? C.hover : 'transparent'; },
|
|
2717
|
+
onClick: () => { updateNode(node.id, { memoryChildId: item.childId }); setOpenModelFor(null); },
|
|
2718
|
+
}, t('memRunOpt').replace('{n}', String(item.index)) + ' (' + String(item.childId).slice(-5) + ')');
|
|
2719
|
+
}),
|
|
2720
|
+
!history.length && h('div', { key: 'mem-empty', style: S.presetEmpty }, t('memEmpty')),
|
|
2721
|
+
];
|
|
2722
|
+
return h('div', { style: { display: 'flex', alignItems: 'center', gap: '4px', flex: '1 1 auto', minWidth: 0 } },
|
|
2723
|
+
toggleBtn,
|
|
2724
|
+
h('div', { ref: isOpen ? dropdownRef : undefined, style: { position: 'relative', flex: '1 1 auto', minWidth: 0 } },
|
|
2725
|
+
h('button', {
|
|
2726
|
+
style: S.selectBtn,
|
|
2727
|
+
type: 'button',
|
|
2728
|
+
title: t('tipMemoryPick'),
|
|
2729
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
2730
|
+
onClick: () => setOpenModelFor(isOpen ? null : key),
|
|
2731
|
+
},
|
|
2732
|
+
h('span', { style: S.selectText }, pickLabel),
|
|
2733
|
+
h('span', { style: S.caret }, '▾'),
|
|
2734
|
+
),
|
|
2735
|
+
isOpen && h('div', { style: S.menu, onMouseDown: (e) => e.stopPropagation() }, rows),
|
|
2736
|
+
),
|
|
2737
|
+
);
|
|
2738
|
+
};
|
|
2678
2739
|
|
|
2679
2740
|
const reasoningControl = (node) => {
|
|
2680
2741
|
const key = 'r:' + node.id;
|
|
@@ -2766,11 +2827,17 @@ window.__ModuleLoader__.load({
|
|
|
2766
2827
|
}
|
|
2767
2828
|
const reachableIds = reachableFrom(nodes, edges);
|
|
2768
2829
|
const nodeById = new Map(nodes.map((n) => [n.id, n]));
|
|
2830
|
+
const soloLeadIds = soloLeadNodeIds(nodes, edges);
|
|
2769
2831
|
const deadEndIds = deadEndNodeIds(nodes, edges);
|
|
2770
2832
|
|
|
2771
|
-
//
|
|
2772
|
-
//
|
|
2833
|
+
// Lead nodes are never spawned, so their status is derived from graph state:
|
|
2834
|
+
// - Intermediate Lead (has downstream): glows "Ready" until any child starts,
|
|
2835
|
+
// then settles to "Done".
|
|
2836
|
+
// - Terminal Lead (no downstream): Host finishes in one shot, so it glows only
|
|
2837
|
+
// while the main conversation is still streaming (`sessionRunning`), then
|
|
2838
|
+
// settles to "Done" once the turn ends.
|
|
2773
2839
|
const leadReadyIds = new Set();
|
|
2840
|
+
const leadDoneIds = new Set();
|
|
2774
2841
|
if (enabled) {
|
|
2775
2842
|
for (const n of nodes) {
|
|
2776
2843
|
if (n.kind !== 'lead' || n.id === 'lead' || !reachableIds.has(n.id)) continue;
|
|
@@ -2780,10 +2847,17 @@ window.__ModuleLoader__.load({
|
|
|
2780
2847
|
if (!upIds.length) continue;
|
|
2781
2848
|
const upAgents = upIds.filter((id) => nodeById.get(id).kind !== 'lead');
|
|
2782
2849
|
if (!upAgents.length) continue;
|
|
2783
|
-
const allUpDone = upAgents.every((id) => statusById[id] === 'done');
|
|
2850
|
+
const allUpDone = upAgents.every((id) => statusById[id] === 'done' || statusById[id] === 'failed');
|
|
2851
|
+
if (!allUpDone) continue;
|
|
2784
2852
|
const downIds = edges.filter((e) => e.from === n.id).map((e) => e.to);
|
|
2785
|
-
|
|
2786
|
-
|
|
2853
|
+
if (!downIds.length) {
|
|
2854
|
+
if (sessionRunning) leadReadyIds.add(n.id);
|
|
2855
|
+
else leadDoneIds.add(n.id);
|
|
2856
|
+
} else {
|
|
2857
|
+
const anyDownStarted = downIds.some((id) => Boolean(statusById[id]));
|
|
2858
|
+
if (!anyDownStarted) leadReadyIds.add(n.id);
|
|
2859
|
+
else leadDoneIds.add(n.id);
|
|
2860
|
+
}
|
|
2787
2861
|
}
|
|
2788
2862
|
}
|
|
2789
2863
|
|
|
@@ -2799,18 +2873,27 @@ window.__ModuleLoader__.load({
|
|
|
2799
2873
|
const toRunning = enabled && statusById[edge.to] === 'running';
|
|
2800
2874
|
const fromReady = edge.from === 'lead'
|
|
2801
2875
|
|| from.kind === 'lead'
|
|
2802
|
-
|| statusById[edge.from] === 'done'
|
|
2876
|
+
|| statusById[edge.from] === 'done'
|
|
2877
|
+
|| statusById[edge.from] === 'failed';
|
|
2803
2878
|
const isFlowing = enabled && !highlighted && (
|
|
2804
2879
|
(toRunning && fromReady)
|
|
2805
|
-
|| (leadReadyIds.has(edge.to) && statusById[edge.from] === 'done')
|
|
2880
|
+
|| (leadReadyIds.has(edge.to) && (statusById[edge.from] === 'done' || statusById[edge.from] === 'failed'))
|
|
2806
2881
|
);
|
|
2807
|
-
const
|
|
2808
|
-
|
|
2882
|
+
const fromSettled = edge.from === 'lead'
|
|
2883
|
+
|| statusById[edge.from] === 'done'
|
|
2884
|
+
|| statusById[edge.from] === 'failed'
|
|
2885
|
+
|| leadDoneIds.has(edge.from);
|
|
2886
|
+
const toSettled = statusById[edge.to] === 'done'
|
|
2887
|
+
|| statusById[edge.to] === 'running'
|
|
2888
|
+
|| statusById[edge.to] === 'failed'
|
|
2889
|
+
|| leadReadyIds.has(edge.to)
|
|
2890
|
+
|| leadDoneIds.has(edge.to);
|
|
2891
|
+
const isCompletedLink = enabled && !highlighted && fromSettled && toSettled;
|
|
2809
2892
|
const dimmed = hasSel && !linkedToSel && !highlighted && !isFlowing;
|
|
2810
2893
|
const strokeColor = highlighted ? '#e5534b' : color;
|
|
2811
2894
|
const baseWidth = highlighted ? 3 : (linkedToSel || isFlowing ? 2.6 : 2);
|
|
2812
2895
|
const baseOpacity = dimmed ? 0.26 : (isFlowing || linkedToSel ? 1 : (isCompletedLink ? 0.92 : 0.78));
|
|
2813
|
-
const useGlow = fxLevel === 'vivid' && !dimmed
|
|
2896
|
+
const useGlow = fxLevel === 'vivid' && !dimmed;
|
|
2814
2897
|
const showDashFlow = isFlowing && fxLevel !== 'minimal';
|
|
2815
2898
|
const showBead = isFlowing && fxLevel === 'vivid';
|
|
2816
2899
|
|
|
@@ -3008,6 +3091,32 @@ window.__ModuleLoader__.load({
|
|
|
3008
3091
|
flash(t('fxLabel') + t('sep') + fxName(next));
|
|
3009
3092
|
},
|
|
3010
3093
|
}, t('fxLabel') + t('sep') + fxName(fxLevel)),
|
|
3094
|
+
h('div', {
|
|
3095
|
+
style: { ...S.moreRow, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '8px' },
|
|
3096
|
+
title: t('tipMaxParallel'),
|
|
3097
|
+
onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
|
|
3098
|
+
onMouseLeave: (e) => { e.currentTarget.style.background = 'transparent'; },
|
|
3099
|
+
onClick: () => {
|
|
3100
|
+
const next = nextMaxParallel(maxParallel);
|
|
3101
|
+
setMaxParallel(next);
|
|
3102
|
+
maxParallelRef.current = next;
|
|
3103
|
+
saveMaxParallel(next);
|
|
3104
|
+
if (enabled) pushPlan(true, undefined, undefined, next);
|
|
3105
|
+
else flash(t('maxParallelLabel') + t('sep') + next);
|
|
3106
|
+
},
|
|
3107
|
+
},
|
|
3108
|
+
h('span', null, t('maxParallelLabel') + t('sep') + maxParallel),
|
|
3109
|
+
h('span', {
|
|
3110
|
+
title: t('tipMaxParallel'),
|
|
3111
|
+
style: {
|
|
3112
|
+
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
|
3113
|
+
width: '14px', height: '14px', borderRadius: '50%',
|
|
3114
|
+
border: '1px solid ' + (maxParallel > 4 ? '#d29922' : C.dim),
|
|
3115
|
+
color: maxParallel > 4 ? '#d29922' : C.dim,
|
|
3116
|
+
fontSize: '10px', fontWeight: 700, lineHeight: '12px', flex: '0 0 auto',
|
|
3117
|
+
},
|
|
3118
|
+
}, '!'),
|
|
3119
|
+
),
|
|
3011
3120
|
h('div', {
|
|
3012
3121
|
style: S.moreRow,
|
|
3013
3122
|
onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
|
|
@@ -3198,12 +3307,15 @@ window.__ModuleLoader__.load({
|
|
|
3198
3307
|
}),
|
|
3199
3308
|
);
|
|
3200
3309
|
const isOrphan = node.id !== 'lead' && !reachableIds.has(node.id);
|
|
3310
|
+
const isSoloLead = soloLeadIds.has(node.id);
|
|
3201
3311
|
const isDeadEnd = deadEndIds.has(node.id);
|
|
3312
|
+
const isInactive = isOrphan || isSoloLead || isDeadEnd;
|
|
3202
3313
|
const isSelected = selectedSet.has(node.id);
|
|
3203
3314
|
const nodeStatus = enabled ? statusById[node.id] : undefined;
|
|
3204
3315
|
const isLeadReady = leadReadyIds.has(node.id);
|
|
3316
|
+
const isLeadDone = leadDoneIds.has(node.id);
|
|
3205
3317
|
const isRunning = !isLeadKind && nodeStatus === 'running';
|
|
3206
|
-
const isDone = !isLeadKind && nodeStatus === 'done';
|
|
3318
|
+
const isDone = (!isLeadKind && nodeStatus === 'done') || isLeadDone;
|
|
3207
3319
|
const isFailed = !isLeadKind && nodeStatus === 'failed';
|
|
3208
3320
|
const isPulsing = (isRunning || isLeadReady) && fxLevel !== 'minimal';
|
|
3209
3321
|
const nodeClass = 'dsh-wc-node'
|
|
@@ -3233,10 +3345,10 @@ window.__ModuleLoader__.load({
|
|
|
3233
3345
|
left: node.x + WORLD_PAD,
|
|
3234
3346
|
top: node.y + WORLD_PAD,
|
|
3235
3347
|
...(isLeadKind ? S.leadNode : null),
|
|
3236
|
-
...(
|
|
3348
|
+
...(isInactive ? S.orphanNode : null),
|
|
3237
3349
|
...(stateStyle || null),
|
|
3238
3350
|
},
|
|
3239
|
-
title: isOrphan ? t('orphanTip') : undefined,
|
|
3351
|
+
title: isOrphan ? t('orphanTip') : (isSoloLead ? t('tipSoloLead') : (isDeadEnd ? t('tipDeadEnd') : undefined)),
|
|
3240
3352
|
onMouseDown: (e) => onNodeDown(e, node.id),
|
|
3241
3353
|
},
|
|
3242
3354
|
h('div', {
|
|
@@ -3256,30 +3368,33 @@ window.__ModuleLoader__.load({
|
|
|
3256
3368
|
(() => {
|
|
3257
3369
|
const latestRun = !isLeadKind ? runsById[node.id] : null;
|
|
3258
3370
|
const statusColor = isLeadReady ? '#2f81f7'
|
|
3259
|
-
:
|
|
3260
|
-
:
|
|
3261
|
-
: nodeStatus === '
|
|
3262
|
-
: nodeStatus === '
|
|
3371
|
+
: isLeadDone ? '#3fb950'
|
|
3372
|
+
: isLeadKind ? C.dim
|
|
3373
|
+
: nodeStatus === 'running' ? '#2f81f7'
|
|
3374
|
+
: nodeStatus === 'failed' ? '#e5534b'
|
|
3375
|
+
: nodeStatus === 'done' ? '#3fb950' : C.dim;
|
|
3263
3376
|
const statusTint = isLeadReady || nodeStatus === 'running'
|
|
3264
3377
|
? 'rgba(47,129,247,0.14)'
|
|
3265
3378
|
: nodeStatus === 'failed'
|
|
3266
3379
|
? 'rgba(229,83,75,0.14)'
|
|
3267
|
-
:
|
|
3380
|
+
: isDone
|
|
3268
3381
|
? 'rgba(63,185,80,0.14)'
|
|
3269
3382
|
: 'transparent';
|
|
3270
3383
|
const statusLabel = isOrphan ? t('stOrphan')
|
|
3271
|
-
:
|
|
3272
|
-
:
|
|
3273
|
-
:
|
|
3274
|
-
:
|
|
3275
|
-
: nodeStatus === '
|
|
3384
|
+
: isSoloLead ? t('stSoloLead')
|
|
3385
|
+
: isLeadReady ? t('stLeadReady')
|
|
3386
|
+
: isLeadDone ? t('stDone')
|
|
3387
|
+
: isLeadKind ? t('stLead')
|
|
3388
|
+
: nodeStatus === 'running' ? t('stRunning')
|
|
3389
|
+
: nodeStatus === 'failed' ? t('stFailed')
|
|
3390
|
+
: nodeStatus === 'done' ? t('stDone') : t('stPending');
|
|
3276
3391
|
const glyph = nodeStatus === 'running'
|
|
3277
3392
|
? h('span', {
|
|
3278
3393
|
className: fxLevel !== 'minimal' ? 'dsh-wc-dot-live' : undefined,
|
|
3279
3394
|
style: { width: '6px', height: '6px', borderRadius: '50%', background: statusColor, flex: '0 0 auto' },
|
|
3280
3395
|
})
|
|
3281
3396
|
: isLeadReady ? h('span', { className: fxLevel !== 'minimal' ? 'dsh-wc-dot-live' : undefined }, '⏸')
|
|
3282
|
-
:
|
|
3397
|
+
: isDone ? '✓'
|
|
3283
3398
|
: nodeStatus === 'failed' ? '✕' : null;
|
|
3284
3399
|
if (latestRun) {
|
|
3285
3400
|
const label = enabled ? statusLabel : t('openChat');
|
|
@@ -3430,7 +3545,7 @@ window.__ModuleLoader__.load({
|
|
|
3430
3545
|
try { console.error('[workflow-canvas] apply failed', error); } catch (_e) { /* ignore */ }
|
|
3431
3546
|
}
|
|
3432
3547
|
},
|
|
3433
|
-
__test: { topoOrder, wouldCycle, layoutGraph, builtinTemplates, deadEndNodeIds, nextEffectLevel, zoomAroundPoint, scrubZoom,
|
|
3548
|
+
__test: { topoOrder, wouldCycle, soloLeadNodeIds, layoutGraph, builtinTemplates, deadEndNodeIds, nextEffectLevel, nextMaxParallel, zoomAroundPoint, scrubZoom, buildPlan, loadDoc, saveDoc, storageKey, socketCenterY, distanceToEdge, edgeCurve },
|
|
3434
3549
|
};
|
|
3435
3550
|
},
|
|
3436
3551
|
});
|