From c354ea84495a7db0a2d776c15b9264d5051fac6a Mon Sep 17 00:00:00 2001 From: l Date: Sun, 11 Oct 2026 00:12:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E8=AE=AE=E6=A8=A1=E5=BC=8F=EF=BC=9A?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A4=E6=96=AD/while=20=E7=BB=93=E8=AE=BA?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=EF=BC=88node=5Fdone=20=E6=B2=A1?= =?UTF-8?q?=E5=B8=A6=20nodeType=EF=BC=89+=20=E6=A0=87=E9=A2=98=E5=86=99?= =?UTF-8?q?=E4=B8=8A=E5=8F=82=E6=95=B0=E5=92=8C=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户反馈"还是没有结果,节点标题要把运行状态、具体参数写出来"。 【根因: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 才停。轮次上限兜住了,但图本身应该让条件收敛。 --- .../com/doubao/lynxclone/ui/MeetingsScreen.kt | 73 ++++++++++++++++--- android/kernel/meeting.py | 16 ++-- server/src/meeting.mjs | 31 ++++++-- 3 files changed, 94 insertions(+), 26 deletions(-) diff --git a/android/app/src/main/java/com/doubao/lynxclone/ui/MeetingsScreen.kt b/android/app/src/main/java/com/doubao/lynxclone/ui/MeetingsScreen.kt index 41c4391..af1e60b 100644 --- a/android/app/src/main/java/com/doubao/lynxclone/ui/MeetingsScreen.kt +++ b/android/app/src/main/java/com/doubao/lynxclone/ui/MeetingsScreen.kt @@ -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) } diff --git a/android/kernel/meeting.py b/android/kernel/meeting.py index ae414bb..e532847 100644 --- a/android/kernel/meeting.py +++ b/android/kernel/meeting.py @@ -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)] diff --git a/server/src/meeting.mjs b/server/src/meeting.mjs index 59f5e5d..7848f06 100644 --- a/server/src/meeting.mjs +++ b/server/src/meeting.mjs @@ -678,7 +678,9 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF // 否则循环回来的内容会被起点覆盖掉,重复就没意义了 const text = input || String(node.text || '').trim() || (userInput || ''); outputs[nodeId] = text; - emit({ type: 'node_done', nodeId, output: text, run: runIndex, note: '用的初始输入' }); + emit({ type: 'node_done', + nodeId, + nodeType, output: text, run: runIndex, note: '用的初始输入' }); nextIds = execOut(edges, nodeId).map((e) => e.to); } else if (nodeType === 'agent') { const raw = await runAgentFn(node, input, settings, emit, nodeId, variables); @@ -690,7 +692,9 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF // 压根覆盖不到(真发生过:引擎测试全绿,一上 HTTP 就漏出 [[SET]])。 const { text: cleaned, changed } = applySets(raw, variables, node.writeVars); outputs[nodeId] = cleaned; - emit({ type: 'node_done', nodeId, output: cleaned, run: runIndex }); + emit({ type: 'node_done', + nodeId, + nodeType, output: cleaned, run: runIndex }); if (Object.keys(changed).length) { // 改了哪些变量要让用户看见,不然就是"背地里改了我的东西" emit({ @@ -726,7 +730,9 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF variables[name] = value; outputs[nodeId] = value; emit({ - type: 'node_done', nodeId, output: value, run: runIndex, + type: 'node_done', + nodeId, + nodeType, output: value, run: runIndex, note: `变量 ${name} = ${value.slice(0, 40)}`, }); // ★ 写变量**有 exec 出线**(蓝图里 Set 节点就是 exec 进 → exec 出), @@ -740,7 +746,9 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF const value = variables[name] ?? ''; outputs[nodeId] = value; emit({ - type: 'node_done', nodeId, output: value, run: runIndex, + type: 'node_done', + nodeId, + nodeType, output: value, run: runIndex, note: `读到 ${name}` + (value ? '' : '(还没设过,是空的)'), }); nextIds = execOut(edges, nodeId).map((e) => e.to); @@ -760,7 +768,8 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF outputs[nodeId] = input; emit({ type: 'node_done', - nodeId, + nodeId, + nodeType, output: input, run: runIndex, verdict: passed, @@ -773,15 +782,21 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF } else if (nodeType === 'end') { outputs[nodeId] = String(node.text || '').trim() || input; finalOutput = outputs[nodeId]; - emit({ type: 'node_done', nodeId, output: finalOutput, run: runIndex }); + emit({ type: 'node_done', + nodeId, + nodeType, output: finalOutput, run: runIndex }); nextIds = []; } else { - emit({ type: 'node_error', nodeId, error: `不认识的节点类型:${nodeType}` }); + emit({ type: 'node_error', + nodeId, + nodeType, error: `不认识的节点类型:${nodeType}` }); nextIds = []; } } catch (err) { // 单个节点出错不该让整场会议停摆:记下来,继续跑下游 - emit({ type: 'node_error', nodeId, error: err.message, run: runIndex }); + emit({ type: 'node_error', + nodeId, + nodeType, error: err.message, run: runIndex }); outputs[nodeId] = ''; nextIds = execOut(edges, nodeId).map((e) => e.to); }