会议模式:结果界面补上判断/while 的结论 + exec 线加方向箭头 + 最新历史默认展开

用户三条反馈。

【1. "判断结果呢?被你吃了?" / "while的分支呢?"】
上一版我把结论标签加到了**历史记录**(MeetingStep),但「本次」那块用的是
**运行链**(liveTrace),里面只存了节点名和轮次 —— 结论没进去,所以看不到。

根因:结论是在 node_done 才拿到的,而运行链是按 node_start 记的(为了能实时长出来)。
修法:node_done 时把结论**补进链里那一步**。

顺手把 liveTrace 从 Triple<id,标题,轮次> 换成 TraceStep 数据类,
带上 nodeType / verdict / branch / note —— 三个字段以上就不该用 Triple 硬塞。
(改这个的时候把复制文本那段的一行覆盖错了,编译报出来才发现,已修。)

现在结果界面的每一步都能看到:
    4  判断        [判断:假]
    2  while 循环 · 第 1 轮   [条件为真 · 继续循环]
    5  while 循环 · 第 2 轮   [条件为假 · 结束循环]
「复制本次结果」导出的小文本里也带上了。

【2. "要向这样运行连有箭头流向"(UE 那张图)】
UE 在 exec 线**中间**画一个箭头指示流向 —— 端点上的三角只说明"这是个执行口",
线本身不告诉人从哪往哪流,图一复杂基本靠猜。

现在每条 exec 线中点画一个箭头,角度取该点的切线方向
(三次贝塞尔在 t=0.5 的切线方向是 (end-start-dx, end.y-start.y)),
箭头外面先描一圈底色,压在线上的时候才看得清。
配着原来的流动光点:静止时看箭头知道方向,跑起来看点知道走到哪。

(踩了个小坑:先在 DrawScope 里直接调了 doubaoBg(),它是 @Composable,
 在那里调不了。改成在 Canvas 外面取好再传进去。)

【3. "这次的呢?"】
「本次」那块只在刚跑完的那一屏有;重新进结果屏就只剩历史,用户得自己点开才看得到。
现在**没有"本次"可看时,把最新那次历史默认展开**。

【验证】
- 引擎回归 40/40,Node 与 Python 16/16 逐用例一致
- 会议 HTTP 13/13 ×2、语音 41/41、Markdown 19/19
- 模拟器截图确认:exec 线中间有方向箭头,8 节点 8 连线的图渲染正常
This commit is contained in:
l
2026-10-10 23:34:04 +08:00
parent 496b0782ae
commit e4619c07e6

View File

@@ -275,6 +275,8 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () -
var linkingFrom by remember { mutableStateOf<LinkFrom?>(null) }
// 点中的连线(要能删)。存的是 edges 里的下标。
var selectedEdge by remember { mutableStateOf<Int?>(null) }
// 画布底色。drawPath 里不能用 @Composable,所以在这里先取好。
val boardBg = doubaoBg()
// 变量管理面板
var showVars by remember { mutableStateOf(false) }
var running by remember { mutableStateOf(false) }
@@ -303,7 +305,7 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () -
// ★ 运行链:按**执行顺序**记下每一步。
// 结果界面要的是"这条链上每一步的结果",不是一堆节点的最终状态 ——
// 循环转几轮就有几条记录,一眼能看出先后。
val liveTrace = remember { mutableStateListOf<Triple<String, String, Int>>() }
val liveTrace = remember { mutableStateListOf<TraceStep>() }
// 当前正在跑哪个节点(界面顶部要显示"运行到哪了")
var nowRunning by remember { mutableStateOf("") }
// 每个节点的告警(比如"输入是空的,你漏了数据线")。
@@ -397,7 +399,12 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () -
"node_start" -> {
liveStatus[ev.nodeId] = "running"
liveTrace.add(
Triple(ev.nodeId, ev.title.ifBlank { ev.nodeType }, ev.run)
TraceStep(
nodeId = ev.nodeId,
title = ev.title.ifBlank { ev.nodeType },
nodeType = ev.nodeType,
run = ev.run,
)
)
nowRunning = ev.title.ifBlank { ev.nodeType }
// ★ 执行流到这一步了:把这根 exec 线点亮,让它"流"起来。
@@ -415,6 +422,20 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () -
if (ev.branch.isNotBlank()) {
nodeVerdict[ev.nodeId] = ev.branch
}
// ★ 把结论补进运行链里**这一步**。
//
// 链是按 node_start 记的(这样能实时长出来),
// 而结论要到 node_done 才有。不补的话结果界面
// 就只有节点名和输出,"judge 走了真还是假"完全看不到 ——
// 用户的原话是"判断结果呢?被你吃了?"。
val at = liveTrace.indexOfLast { it.nodeId == ev.nodeId }
if (at >= 0) {
liveTrace[at] = liveTrace[at].copy(
verdict = ev.verdict,
branch = ev.branch,
note = ev.note,
)
}
}
"node_warn" -> nodeWarn[ev.nodeId] = ev.warn
"node_error" -> {
@@ -790,6 +811,53 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () -
}
drawPath(arrow, color)
}
// ★ **exec 线上的方向箭头**(照 UE 蓝图)。
//
// 线本身不告诉人"从哪往哪流",端点上的三角只说明"这是个执行口"。
// UE 在**线中间**画一个箭头,一眼看出方向 —— 图一复杂,没这个基本靠猜。
//
// 位置取曲线中点,角度取中点处的切线:
// 三次贝塞尔在 t=0.5 的切线方向是 (end-start-dx, end.y-start.y)。
if (edge.kind == "exec") {
val mid = bezierAt(
start,
Offset(start.x + dx, start.y),
Offset(end.x - dx, end.y),
end,
0.5f,
)
val ang = kotlin.math.atan2(end.y - start.y, end.x - start.x - dx)
val al = 6.dp.toPx()
val dirArrow = Path().apply {
moveTo(mid.x + al * kotlin.math.cos(ang), mid.y + al * kotlin.math.sin(ang))
lineTo(mid.x + al * kotlin.math.cos(ang + 2.5f), mid.y + al * kotlin.math.sin(ang + 2.5f))
lineTo(mid.x + al * kotlin.math.cos(ang - 2.5f), mid.y + al * kotlin.math.sin(ang - 2.5f))
close()
}
// 先描一圈背景色:箭头压在线上的时候才看得清
drawPath(dirArrow, boardBg, style = Stroke(width = 3.dp.toPx()))
drawPath(dirArrow, if (isSel) Doubao.Blue else EXEC_BORDER)
}
// ★ **执行流的流动效果**(照 UE 蓝图)。
//
// 节点上的勾只说明"这个节点跑过了",看不出**现在正跑哪一步**、
@@ -1267,6 +1335,23 @@ private fun portOut(node: MeetingNode, kind: String, branch: String): Offset =
* 结果转义在几道工具链里被搞乱,编译报了一堆 Char/String 不匹配。
* 三个字段就该用三个字段,别为了省事把结构化数据拍成字符串。
*/
/**
* 运行链上的一步。
*
* ★ 为什么要带上 verdict / branch:结果界面要写明"判断走了真还是假"、
* "while 这一轮是继续还是结束"。只存节点名 + 输出的话,回看时
* 只看到一段文本,完全不知道当时判成了什么。
*/
private data class TraceStep(
val nodeId: String,
val title: String,
val nodeType: String,
val run: Int,
val verdict: Boolean? = null,
val branch: String = "",
val note: String = "",
)
private data class LinkFrom(val nodeId: String, val kind: String, val branch: String)
/** 执行引脚画成白色三角、数据引脚画成彩色圆点 —— 蓝图就靠这个一眼分辨 */
@@ -1599,7 +1684,7 @@ private fun MeetingResultScreen(
meeting: Meeting,
liveOutputs: Map<String, String>,
/** 本次运行的**运行链**:按执行顺序记的 (节点id, 标题, 第几轮) */
liveTrace: List<Triple<String, String, Int>>,
liveTrace: List<TraceStep>,
onBack: () -> Unit,
) {
var runs by remember { mutableStateOf<List<MeetingRun>>(emptyList()) }
@@ -1612,6 +1697,11 @@ private fun MeetingResultScreen(
LaunchedEffect(meeting.id) {
try {
runs = vm.client.meetingRuns(meeting.id)
// ★ 没有"本次"可看时(比如重新进这一屏),把**最新那次**历史默认展开。
// 不展开的话用户只看到一堆时间戳,还得自己点一下才知道这次跑了什么 ——
// 用户的原话是"这次的呢?"。
if (liveTrace.isEmpty() && runs.isNotEmpty()) expanded = 0
} catch (_: Exception) {
// 读不到历史不算错:至少还能看当前这次
}
@@ -1645,15 +1735,19 @@ private fun MeetingResultScreen(
* ★ 用户明确要求:"结果界面要有节点的状态,比如判断节点你要写明是真是假"。
* 回看时只看到一段文本的话,根本不知道当时判成了什么 ——
* 尤其是循环跑很多轮、每次判的结果还不一样的时候。
*
* ★ 参数是 (节点类型, 结论, 分支) 而不是 MeetingStep:
* 历史记录用的是 MeetingStep、本次运行用的是 TraceStep,
* 两边都要显示同一枚标签,所以按字段取而不是按类型取。
*/
@Composable
fun VerdictBadge(step: MeetingStep) {
fun VerdictBadge(nodeType: String, verdict: Boolean?, branch: String) {
val (text, tint) = when {
step.nodeType == "judge" && step.verdict == true -> "判断:真" to Color(0xFF34A853)
step.nodeType == "judge" && step.verdict == false -> "判断:假" to Color(0xFFEA4335)
step.nodeType == "while" && step.branch == "body" -> "条件为真 · 继续循环" to Color(0xFF34A853)
step.nodeType == "while" && step.branch == "done" -> "条件为假 · 结束循环" to Color(0xFFEA4335)
step.nodeType == "while" -> "条件判断" to doubaoTextSecondary()
nodeType == "judge" && verdict == true -> "判断:真" to Color(0xFF34A853)
nodeType == "judge" && verdict == false -> "判断:假" to Color(0xFFEA4335)
nodeType == "while" && branch == "body" -> "条件为真 · 继续循环" to Color(0xFF34A853)
nodeType == "while" && branch == "done" -> "条件为假 · 结束循环" to Color(0xFFEA4335)
nodeType == "while" -> "条件判断" to doubaoTextSecondary()
else -> return
}
Surface(
@@ -1737,7 +1831,6 @@ private fun MeetingResultScreen(
// 序号就是"整条链上的第几步",循环转几轮就有几条 ——
// 这才是用户要的"运行链的每次结果"。
current.forEachIndexed { i, step ->
val (nodeId, title, runNo) = step
Row {
Text(
"${i + 1}",
@@ -1749,22 +1842,26 @@ private fun MeetingResultScreen(
Column(Modifier.weight(1f)) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
title,
step.title,
fontSize = 13.sp,
fontWeight = FontWeight.Medium,
color = doubaoText(),
)
// 同一个节点跑了多轮就把轮次写出来
if (liveTrace.count { it.first == nodeId } > 1) {
if (liveTrace.count { it.nodeId == step.nodeId } > 1) {
Spacer(Modifier.width(6.dp))
Text(
"第 $runNo 轮",
"第 ${step.run} 轮",
fontSize = 11.sp,
color = doubaoTextSecondary(),
)
}
// ★ 判断 / while 走了哪条路,就写在标题旁边。
// 少了它,回看时只有一段文本,根本不知道判成了什么。
Spacer(Modifier.width(6.dp))
VerdictBadge(step.nodeType, step.verdict, step.branch)
}
val body = liveOutputs[nodeId].orEmpty()
val body = liveOutputs[step.nodeId].orEmpty()
if (body.isNotBlank()) {
Text(
body,
@@ -1789,12 +1886,20 @@ private fun MeetingResultScreen(
append(currentFinal)
append("\n\n————\n")
current.forEachIndexed { i, step ->
append("${i + 1}. ${step.second}")
if (current.count { it.first == step.first } > 1) {
append("(第 ${step.third} 轮)")
append("${i + 1}. ${step.title}")
if (current.count { it.nodeId == step.nodeId } > 1) {
append("(第 ${step.run} 轮)")
}
val mark = when {
step.nodeType == "judge" && step.verdict == true -> "判断:真"
step.nodeType == "judge" && step.verdict == false -> "判断:假"
step.nodeType == "while" && step.branch == "body" -> "条件为真 · 继续循环"
step.nodeType == "while" && step.branch == "done" -> "条件为假 · 结束循环"
else -> ""
}
if (mark.isNotEmpty()) append(" [$mark]")
append("\n")
append(liveOutputs[step.first].orEmpty())
append(liveOutputs[step.nodeId].orEmpty())
append("\n\n")
}
}
@@ -1896,7 +2001,7 @@ private fun MeetingResultScreen(
)
// 判断 / while 走的是哪条路,写在标题旁边
Spacer(Modifier.width(6.dp))
VerdictBadge(s)
VerdictBadge(s.nodeType, s.verdict, s.branch)
}
val body = if (s.error.isNotBlank()) {
"出错:${s.error}"