会议模式:修复判断/while 结论不显示(node_done 没带 nodeType)+ 标题写上参数和状态

用户反馈"还是没有结果,节点标题要把运行状态、具体参数写出来"。

【根因:node_done 事件根本没带 nodeType】
在设备上直接跑了一遍,把事件流和落盘的运行记录对着看:

    EV  node_done j  verdict=True branch='true'     ← 结论有 ✓
    STEP j  nodeType=None  verdict=True branch='true'  ← 但 nodeType 是 None ✗

`node_start` 带 nodeType,`node_done` 没带。于是运行记录里每一步的
nodeType 都是空的,结果界面那个 `when (nodeType == "judge" && ...)`
一个分支都进不去 —— **标签代码是对的,数据没送到**。
(上一版我只改了历史记录的渲染,还以为是渲染条件的问题,其实卡在这儿。)

修:两份引擎的 node_done / node_error 都带上 nodeType。

【顺便按用户要求把标题写全】
用户原话:"节点标题要把运行状态、具体参数写出来"。
只写"判断"两个字的话,图上有五个判断节点就完全分不清是哪个、
更不知道它当时在判什么,回看运行记录等于白看。

现在每一步的标题是「节点名 · 第 N 轮 · 具体参数 → 运行状态」:

    4  判断 · 第 1 轮 · 包含「苹果」      [判断:真]
    8  while 循环 · 第 3 轮              [条件为真 → 继续循环]
    3  写变量 · isRun = 2
    9  智能体 · 第 1 轮                  你好呀~我是豆包…

参数按节点类型取:
    judge   包含「x」/ 不含「x」/ 字数 > n / 为空 / 不为空 / 让模型判断
    var     isRun = 2(写死的值)或 isRun ← 上游
    readvar 变量名
    value   那个常量
老记录里没存 nodeType 的,从图里按 id 找节点补上。

【实测(模拟器截图确认)】
    7   判断 · 第 1 轮 · 为空     [判断:假]
    8   while 循环 · 第 3 轮      [条件为真 · 继续循环]
    9   智能体 · 第 1 轮          你好呀~我是豆包…
    10  判断 · 第 1 轮 · 为空     [判断:假]
    ...

【顺带】
- exec 线中间的方向箭头也验证了:开始事件→判断 中间一个 ▶,走向一目了然
- 修掉一个重复:轮次同时进了标题和旁边,界面上出现"第 3 轮 第 3 轮"

【验证】
- 引擎回归 40/40,Node 与 Python 16/16 逐用例一致
- 会议 HTTP 13/13 ×2
- 模拟器实测:判断/while 的结论标签、标题参数全部正确显示

【另外发现(不是 bug,是演示图的问题)】
while 的循环体里如果"写变量"每次都把变量写回同一个值,条件永远为真,
会一直转到 MAX_LOOP_ITERS=200 才停。轮次上限兜住了,但图本身应该让条件收敛。
This commit is contained in:
l
2026-10-11 00:12:15 +08:00
parent e4619c07e6
commit c354ea8449
3 changed files with 94 additions and 26 deletions

View File

@@ -1716,6 +1716,58 @@ if (liveTrace.isEmpty() && runs.isNotEmpty()) expanded = 0
val currentFinal = meeting.nodes.firstOrNull { it.type == "end" }
?.let { liveOutputs[it.id] }.orEmpty()
/**
* 这一步的**具体参数**:判断用的什么条件、写哪个变量、值是什么。
*
* ★ 用户明确要求"节点标题要把运行状态、具体参数写出来"。
* 只写"判断"两个字的话,图上有五个判断节点就完全分不清是哪个、
* 更不知道它当时在判什么 —— 回看运行记录等于白看。
*
* ★ 类型优先看记录里的 nodeType;老记录里没存就从图里按 id 找。
*/
fun stepParams(nodeId: String, fallbackType: String): String {
val node = meeting.nodes.firstOrNull { it.id == nodeId }
val type = fallbackType.ifBlank { node?.type.orEmpty() }
return when (type) {
"judge" -> {
val cond = when (node?.judgeKind) {
"contains" -> "包含「${node.judgeValue}」"
"not_contains" -> "不含「${node.judgeValue}」"
"longer_than" -> "字数 > ${node.judgeValue}"
"shorter_than" -> "字数 < ${node.judgeValue}"
"empty" -> "为空"
"not_empty" -> "不为空"
"ai" -> "让模型判断"
else -> node?.judgeKind.orEmpty()
}
cond
}
"var" -> node?.varName?.takeIf { it.isNotBlank() }
?.let { name -> if (node.varValue.isNotBlank()) "$name = ${node.varValue}" else "$name ← 上游" }
.orEmpty()
"readvar" -> node?.varName.orEmpty()
"value" -> node?.text.orEmpty()
"agent" -> node?.agentId?.takeIf { it.isNotBlank() }?.let { "已指定智能体" }.orEmpty()
else -> ""
}
}
/**
* 运行状态:判断走了真还是假、while 是继续还是结束。
*
* ★ 这正是用户抱怨"判断结果呢?被你吃了?"的那件事。
*/
fun stepStatus(fallbackType: String, verdict: Boolean?, branch: String): String {
return when {
fallbackType == "judge" && verdict == true -> "判断:真"
fallbackType == "judge" && verdict == false -> "判断:假"
fallbackType == "while" && branch == "body" -> "条件为真 → 继续循环"
fallbackType == "while" && branch == "done" -> "条件为假 → 结束循环"
fallbackType == "while" -> "条件判断"
else -> ""
}
}
fun nodeLabel(step: MeetingStep): String = step.title.ifBlank {
when (step.nodeType) {
"start" -> "开始事件"
@@ -1842,22 +1894,23 @@ if (liveTrace.isEmpty() && runs.isNotEmpty()) expanded = 0
Column(Modifier.weight(1f)) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
step.title,
buildString {
append(step.title)
if (liveTrace.count { it.nodeId == step.nodeId } > 1) {
append(" · 第 ${step.run} 轮")
}
// 具体参数也写进标题
val ps = stepParams(step.nodeId, step.nodeType)
if (ps.isNotBlank()) append(" · $ps")
},
fontSize = 13.sp,
fontWeight = FontWeight.Medium,
color = doubaoText(),
)
// 同一个节点跑了多轮就把轮次写出来
if (liveTrace.count { it.nodeId == step.nodeId } > 1) {
Spacer(Modifier.width(6.dp))
Text(
"第 ${step.run} 轮",
fontSize = 11.sp,
color = doubaoTextSecondary(),
)
}
// ★ 判断 / while 走了哪条路,就写在标题旁边。
// 少了它,回看时只有一段文本,根本不知道判成了什么。
// (轮次已经在上面拼进标题里了,这里不要再写一遍 ——
// 之前就是这样,界面上出现"第 3 轮 第 3 轮"。)
Spacer(Modifier.width(6.dp))
VerdictBadge(step.nodeType, step.verdict, step.branch)
}

View File

@@ -945,7 +945,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
# 否则循环回来的内容会被起点覆盖掉,重复就没意义了
text = incoming or (node.get('text') or '').strip() or (user_input or '')
outputs[node_id] = text
emit({'type': 'node_done', 'nodeId': node_id, 'output': text,
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type, 'output': text,
'run': run_index, 'note': '用的初始输入'})
next_ids = [e['to'] for e in _exec_out(edges, node_id)]
@@ -965,7 +965,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
keep = False
outputs[node_id] = cond_text
emit({'type': 'node_done', 'nodeId': node_id, 'output': cond_text,
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type, 'output': cond_text,
'run': run_index, 'verdict': keep,
'branch': 'body' if keep else 'done',
'note': (f'第 {used + 1} 轮:条件={cond_text[:30]!r} → '
@@ -1023,7 +1023,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
# 压根覆盖不到(真发生过:引擎测试全绿,一上 HTTP 就漏出 [[SET]])。
cleaned, changed = apply_sets(raw, variables, node.get('writeVars'))
outputs[node_id] = cleaned
emit({'type': 'node_done', 'nodeId': node_id, 'output': cleaned, 'run': run_index})
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type, 'output': cleaned, 'run': run_index})
if changed:
# 改了哪些变量要让用户看见,不然就是"背地里改了我的东西"
emit({'type': 'node_vars', 'nodeId': node_id, 'vars': changed,
@@ -1064,7 +1064,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
raise ValueError('读变量节点没填变量名')
value = variables.get(name, '')
outputs[node_id] = value
emit({'type': 'node_done', 'nodeId': node_id, 'output': value, 'run': run_index,
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type, 'output': value, 'run': run_index,
'note': f'读到 {name}' + ('' if value else '(还没设过,是空的)')})
next_ids = [e['to'] for e in _exec_out(edges, node_id)]
@@ -1080,7 +1080,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
# 这个错误是验证脚本抓到的(输出是"真 收到[true]")。
# 判断结论走 verdict 字段,不占 output。
outputs[node_id] = incoming
emit({'type': 'node_done', 'nodeId': node_id,
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type,
'output': incoming,
'run': run_index,
'verdict': passed,
@@ -1100,16 +1100,16 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
elif node_type == 'end':
outputs[node_id] = (node.get('text') or '').strip() or incoming
final_output = outputs[node_id]
emit({'type': 'node_done', 'nodeId': node_id, 'output': final_output, 'run': run_index})
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type, 'output': final_output, 'run': run_index})
next_ids = []
else:
emit({'type': 'node_error', 'nodeId': node_id, 'error': f'不认识的节点类型:{node_type}'})
emit({'type': 'node_error', 'nodeId': node_id, 'nodeType': node_type, 'error': f'不认识的节点类型:{node_type}'})
next_ids = []
except Exception as exc: # noqa: BLE001
# 单个节点出错不该让整场会议停摆:记下来,继续跑下游
emit({'type': 'node_error', 'nodeId': node_id, 'error': str(exc), 'run': run_index})
emit({'type': 'node_error', 'nodeId': node_id, 'nodeType': node_type, 'error': str(exc), 'run': run_index})
outputs[node_id] = ''
next_ids = [e['to'] for e in _exec_out(edges, node_id)]