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 2993f95..d2c8e1c 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 @@ -51,6 +51,7 @@ import androidx.compose.animation.core.tween import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -299,6 +300,16 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () - ) // 判断 / while 的结论(true/false/body/done),结果界面要写明 val nodeVerdict = remember { mutableStateMapOf() } + // ★ 运行链:按**执行顺序**记下每一步。 + // 结果界面要的是"这条链上每一步的结果",不是一堆节点的最终状态 —— + // 循环转几轮就有几条记录,一眼能看出先后。 + val liveTrace = remember { mutableStateListOf>() } + // 当前正在跑哪个节点(界面顶部要显示"运行到哪了") + var nowRunning by remember { mutableStateOf("") } + // 每个节点的告警(比如"输入是空的,你漏了数据线")。 + // ★ 空输入如果不说出来,用户只会看到"明明有值却判断为真", + // 怎么查都查不出规则哪里错了 —— 规则本身没错。 + val nodeWarn = remember { mutableStateMapOf() } var panX by remember { mutableStateOf(0f) } var panY by remember { mutableStateOf(0f) } @@ -342,6 +353,11 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () - ) Text( when { + // ★ "运行到哪了"要一眼看得见:只有节点上的勾和线的流动, + // 循环转很多轮时还是不知道现在第几步。所以直接写出来。 + running && nowRunning.isNotBlank() -> + "正在跑:$nowRunning(第 ${liveTrace.size} 步)" + running -> "正在准备…" linkingFrom != null -> "点目标节点的左侧圆点接线(点空白取消)" dirty -> "未保存" // 手势规则要写出来:两指平移不是所有人一上来就知道的 @@ -380,6 +396,10 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () - when (ev.type) { "node_start" -> { liveStatus[ev.nodeId] = "running" + liveTrace.add( + Triple(ev.nodeId, ev.title.ifBlank { ev.nodeType }, ev.run) + ) + nowRunning = ev.title.ifBlank { ev.nodeType } // ★ 执行流到这一步了:把这根 exec 线点亮,让它"流"起来。 // 蓝图里就是靠这个看出"现在跑到哪了" —— // 节点上的勾只说明"跑过了",看不出**正在跑哪条线**。 @@ -396,6 +416,7 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () - nodeVerdict[ev.nodeId] = ev.branch } } + "node_warn" -> nodeWarn[ev.nodeId] = ev.warn "node_error" -> { liveStatus[ev.nodeId] = "error" nodeOutputs[ev.nodeId] = "出错:${ev.error}" @@ -403,6 +424,7 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () - "meeting_done" -> { running = false litEdge = -1 + nowRunning = "" if (ev.error.isNotBlank()) runError = ev.error } } @@ -856,6 +878,7 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () - node = node, status = status, output = nodeOutputs[node.id] ?: "", + warn = nodeWarn[node.id] ?: "", linking = linkingFrom?.nodeId == node.id, inDegree = meeting.edges.count { it.to == node.id }, outDegree = meeting.edges.count { it.from == node.id }, @@ -981,6 +1004,7 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () - vm = vm, meeting = meeting, liveOutputs = nodeOutputs, + liveTrace = liveTrace.toList(), onBack = { showResult = false }, ) return @@ -1574,6 +1598,8 @@ private fun MeetingResultScreen( vm: AppViewModel, meeting: Meeting, liveOutputs: Map, + /** 本次运行的**运行链**:按执行顺序记的 (节点id, 标题, 第几轮) */ + liveTrace: List>, onBack: () -> Unit, ) { var runs by remember { mutableStateOf>(emptyList()) } @@ -1592,12 +1618,11 @@ private fun MeetingResultScreen( loading = false } - // 当前这次(刚跑完、还没落盘成历史的那份) - val current = remember(meeting.id, liveOutputs.size) { - meeting.nodes - .filter { it.type != "end" && liveOutputs[it.id].orEmpty().isNotBlank() } - .sortedWith(compareBy({ it.y }, { it.x })) - } + // ★ 当前这次 = **运行链**(按执行顺序),不是"按图里的位置排序的节点"。 + // 用户要的是"这条链是怎么一步步走下来的":循环转几轮就有几条, + // 先后顺序就是执行顺序。按坐标排的话,循环里的节点会被排到一起, + // 完全看不出第几轮先跑了谁。 + val current = liveTrace val currentFinal = meeting.nodes.firstOrNull { it.type == "end" } ?.let { liveOutputs[it.id] }.orEmpty() @@ -1708,26 +1733,48 @@ private fun MeetingResultScreen( } Spacer(Modifier.height(10.dp)) } - current.forEach { node -> - Text( - node.title.ifBlank { - when (node.type) { - "start" -> "初始输入" - "judge" -> "判断" - else -> "智能体" + // ★ **运行链**:按执行顺序一步步列出每一步的结果。 + // 序号就是"整条链上的第几步",循环转几轮就有几条 —— + // 这才是用户要的"运行链的每次结果"。 + current.forEachIndexed { i, step -> + val (nodeId, title, runNo) = step + Row { + Text( + "${i + 1}", + fontSize = 11.sp, + color = Doubao.Blue, + fontWeight = FontWeight.Medium, + modifier = Modifier.width(20.dp).padding(top = 1.dp), + ) + Column(Modifier.weight(1f)) { + Row(verticalAlignment = Alignment.CenterVertically) { + Text( + title, + fontSize = 13.sp, + fontWeight = FontWeight.Medium, + color = doubaoText(), + ) + // 同一个节点跑了多轮就把轮次写出来 + if (liveTrace.count { it.first == nodeId } > 1) { + Spacer(Modifier.width(6.dp)) + Text( + "第 $runNo 轮", + fontSize = 11.sp, + color = doubaoTextSecondary(), + ) + } } - }, - fontSize = 13.sp, - fontWeight = FontWeight.Medium, - color = doubaoText(), - ) - Spacer(Modifier.height(3.dp)) - Text( - liveOutputs[node.id].orEmpty(), - fontSize = 12.sp, - color = doubaoTextSecondary(), - lineHeight = 17.sp, - ) + val body = liveOutputs[nodeId].orEmpty() + if (body.isNotBlank()) { + Text( + body, + fontSize = 12.sp, + color = doubaoTextSecondary(), + lineHeight = 17.sp, + ) + } + } + } Spacer(Modifier.height(10.dp)) } if (currentFinal.isNotBlank()) { @@ -1741,9 +1788,13 @@ private fun MeetingResultScreen( val text = buildString { append(currentFinal) append("\n\n————\n") - current.forEach { n -> - append("【${n.title.ifBlank { n.type }}】\n") - append(liveOutputs[n.id].orEmpty()) + current.forEachIndexed { i, step -> + append("${i + 1}. ${step.second}") + if (current.count { it.first == step.first } > 1) { + append("(第 ${step.third} 轮)") + } + append("\n") + append(liveOutputs[step.first].orEmpty()) append("\n\n") } } @@ -1808,35 +1859,60 @@ private fun MeetingResultScreen( ) if (open) { Spacer(Modifier.height(8.dp)) - // 同一个节点跑过几轮?用来决定要不要标"第N轮" + // ★ **运行链**:按执行顺序把每一步的结果列出来。 + // + // 不是"节点状态一览",而是"这条链是怎么一步步走下来的"—— + // 循环转几轮就有几条记录,先后顺序一目了然。 + // 序号也是执行顺序,不是节点在图里的位置。 val countByNode = run.steps.groupingBy { it.nodeId }.eachCount() - run.steps.forEach { s -> - Row(verticalAlignment = Alignment.CenterVertically) { + run.steps.forEachIndexed { i, s -> + Row(Modifier.padding(top = 8.dp)) { + // 序号:这一步是整条链上的第几步 Text( - buildString { - append("【${nodeLabel(s)}】") - if ((countByNode[s.nodeId] ?: 0) > 1) { - append(" 第 ${s.run} 轮") - } - }, - fontSize = 12.sp, + "${i + 1}", + fontSize = 11.sp, + color = Doubao.Blue, fontWeight = FontWeight.Medium, - color = if (s.error.isNotBlank()) { - MaterialTheme.colorScheme.error - } else { - doubaoText() - }, + modifier = Modifier + .width(20.dp) + .padding(top = 1.dp), ) - // ★ 判断 / while 走的是哪条路,写在标题旁边 - Spacer(Modifier.width(6.dp)) - VerdictBadge(s) + Column(Modifier.weight(1f)) { + Row(verticalAlignment = Alignment.CenterVertically) { + Text( + buildString { + append(nodeLabel(s)) + if ((countByNode[s.nodeId] ?: 0) > 1) { + append(" · 第 ${s.run} 轮") + } + }, + fontSize = 12.sp, + fontWeight = FontWeight.Medium, + color = if (s.error.isNotBlank()) { + MaterialTheme.colorScheme.error + } else { + doubaoText() + }, + ) + // 判断 / while 走的是哪条路,写在标题旁边 + Spacer(Modifier.width(6.dp)) + VerdictBadge(s) + } + val body = if (s.error.isNotBlank()) { + "出错:${s.error}" + } else { + s.output.ifBlank { s.note } + } + if (body.isNotBlank()) { + Text( + body, + fontSize = 12.sp, + color = doubaoTextSecondary(), + lineHeight = 17.sp, + ) + } + } } - Text( - if (s.error.isNotBlank()) "出错:${s.error}" else s.output, - fontSize = 12.sp, - color = doubaoTextSecondary(), - lineHeight = 17.sp, - ) } Text( "复制这次", @@ -1891,6 +1967,8 @@ private fun NodeCard( outDegree: Int, /** 正在连线的引脚种类(exec / data);null = 没在连线。用来灰掉接不上的引脚 */ linkingKind: String?, + /** 这个节点的告警(比如"输入是空的,漏了数据线") */ + warn: String = "", modifier: Modifier, ) { val accent = nodeColor(node.type) @@ -2024,6 +2102,20 @@ private fun NodeCard( modifier = Modifier.padding(horizontal = 6.dp), ) Spacer(Modifier.weight(1f)) + // ★ 告警:最典型的那个是"输入是空的,你漏了数据线"。 + // 不说出来的话,用户只会看到"明明有值却判断为真", + // 怎么查都查不出规则哪里错了 —— 规则本身没错,是没喂给它值。 + if (warn.isNotBlank()) { + Text( + "⚠ $warn", + fontSize = 8.sp, + color = Color(0xFFD93025), + maxLines = 4, + overflow = TextOverflow.Ellipsis, + lineHeight = 11.sp, + modifier = Modifier.padding(horizontal = 6.dp), + ) + } // 进出路数写在最底下:多路是智能体的常态,不显示用户不知道自己接全没有 Text( buildString { diff --git a/android/kernel/meeting.py b/android/kernel/meeting.py index 1eb609d..ae414bb 100644 --- a/android/kernel/meeting.py +++ b/android/kernel/meeting.py @@ -918,6 +918,27 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str, incoming = _collect_input(node_id, edges, outputs, variables, by_id) + # ★ 输入是空的、但 exec 上游明明有内容 → **大声报出来**。 + # + # 这是最容易踩、也最难查的一个坑:exec 线只排顺序、不传值, + # 所以"一根线连到底"的图里下游拿到的是空串。 + # 判断节点拿到空串时,"为空"当然为真 —— 用户看到的是 + # "明明有值却判断为真",怎么查都查不出规则哪里错了(规则本身没错)。 + # + # 与其让它悄悄判错,不如直接说"你漏画了一根数据线"。 + if not _data_in(edges, node_id): + ups = [(e.get('from'), outputs.get(e.get('from'))) + for e in _exec_in(edges, node_id)] + ups = [(nid, t) for nid, t in ups if t] + if ups: + who = by_id.get(ups[0][0], {}).get('title') or ups[0][0] + emit({ + 'type': 'node_warn', + 'nodeId': node_id, + 'warn': f'输入是空的:上游「{who}」有内容,但你没连**数据线**。' + f'exec 线只排顺序、不传值 —— 要传值得再连一根彩色数据线。', + }) + try: if node_type == 'start': # 第二轮开始,"初始输入"要把**自己上一轮的输出**当输入, diff --git a/server/src/meeting.mjs b/server/src/meeting.mjs index dcf03ff..59f5e5d 100644 --- a/server/src/meeting.mjs +++ b/server/src/meeting.mjs @@ -647,6 +647,29 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF }); const input = collectInput(nodeId, edges, outputs, variables, byId); + + // ★ 输入是空的、但 exec 上游明明有内容 → **大声报出来**。 + // + // 这是最容易踩、也最难查的一个坑:exec 线只排顺序、不传值, + // 所以"一根线连到底"的图里下游拿到的是空串。 + // 判断节点拿到空串时,"为空"当然为真 —— 用户看到的是 + // "明明有值却判断为真",怎么查都查不出规则哪里错了(规则本身没错)。 + // + // 与其让它悄悄判错,不如直接说"你漏画了一根数据线"。 + if (dataIn(edges, nodeId).length === 0) { + const ups = execIn(edges, nodeId) + .map((e) => [e.from, outputs[e.from]]) + .filter(([, t]) => t); + if (ups.length) { + const who = (byId.get(ups[0][0]) || {}).title || ups[0][0]; + emit({ + type: 'node_warn', + nodeId, + warn: `输入是空的:上游「${who}」有内容,但你没连**数据线**。` + + 'exec 线只排顺序、不传值 —— 要传值得再连一根彩色数据线。', + }); + } + } let nextIds = []; try {