界面与交互全面翻修(前两波):运行态有了 HUD 和时间轴,终态会收尾,全站令牌、组件、文案统一

来自 2026-09 的 UI/UX 审查(142 条)。本提交是前两波,第三波(记录页接入时间轴、跨页互链、check-ui 更新、全站扫尾)另行提交。

地基
- 设计令牌:全局规则和 .btn/.field/.chip 放进 CSS 层,Tailwind 工具类重新生效,选中态、开启态不再被吞掉;字号阶梯;
  辅助文字在所有底色上 >= 4.5:1;状态色专用,节点类型色与之拉开色相;「跟随系统」真的跟随,首帧不闪深色;新字标与 favicon
- 基础组件:confirmDialog / promptDialog 取代原生对话框;toast 出错不自动消失、可复制、读屏可播报;离线横幅与断线恢复;
  九种剪影的状态徽标;唯一一份状态文案(lib/status)、格式化(lib/format)、术语(lib/terms)、报错人话(lib/errors)
- 运行态内核:事件折成航迹(run/trace.ts),可投影到任意时刻;取消 / 失败 / 服务重启后统一收尾,不再永远转圈;
  run.status 随事件回写;token 事件不再堆进 events
- 后端:协作成员逐个完成即发事件,调度者决策有事件;时长分执行 / 墙钟 / 等人;API 时间带时区;
  中断的运行也发 stream.end;运行列表可筛选翻页;删除运行 / 工作流有保护;运行默认值接通;可测未保存的配置;
  报错说清发生了什么、为什么、怎么办

功能
- 画布:状态四重编码、固定高度遥测槽、按缩放三档、运行胶囊与 HUD、航迹时间轴与回放、执行轨迹边、
  等待闸门、跟随执行、正式运行只读、一次性时刻(开场点亮、回扫、阻断级联、出具印章)
- 编辑:撤销重做、版本历史、问题面板可定位、三栏可收起、模板与表达式字段区分、变量血缘、快捷键、带搜索的选择器
- 回答流 / 问数据:贴底才跟随滚动、工件下钻、出具横幅列出缺口、答案可复制导出、按会话的忙闲、
  答案不再在 2000 字处截断、重启后这一轮会收尾
- 记录页:待审批 / 运行中 / 失败页签、筛选翻页、实时接流、排错路径指到节点、封存凭证常驻
- 管理页:新的「数据」页、写操作失败都有反馈、弹窗里先测连接、统一持久的连接状态
- 外壳:导航改版、⌘K 命令面板、? 快捷键帮助、404、页面标题与 favicon 状态点、后台提醒

验证(沙箱):tsc 干净,pytest 579 passed,14 个检查脚本中 13 个全绿;check-ui 剩 1 项旧断言(按旧日期格式找运行行),第三波更新。
This commit is contained in:
ThearchyHelios
2026-09-26 23:11:31 +08:00
parent 95ff6470d1
commit e10c4f23fc
132 changed files with 43558 additions and 5399 deletions
+44 -9
View File
@@ -10,8 +10,9 @@ from langgraph.graph import END, START, StateGraph
from app.core.events import EventType
from app.engine.context import NodeContext, NodeError, RunContext
from app.engine.errors import describe_exception, raw_detail
from app.engine.nodes import control, human, io, knowledge, llm, metrics, multi, tools
from app.engine.schema import GraphNode, GraphSpec, NodeType, back_edges
from app.engine.schema import GraphNode, GraphSpec, NodeType, back_edges, innermost_loops
from app.engine.state import GraphState
NodeRunner = Callable[[GraphState, NodeContext], Awaitable[dict[str, Any]]]
@@ -40,11 +41,13 @@ RUNNERS: dict[NodeType, NodeRunner] = {
ROUTING_TYPES = {NodeType.BRANCH, NodeType.LOOP}
def _wrap(node: GraphNode, run_ctx: RunContext) -> Callable[[GraphState], Awaitable[dict[str, Any]]]:
def _wrap(
node: GraphNode, run_ctx: RunContext, loop_id: str | None = None,
) -> Callable[[GraphState], Awaitable[dict[str, Any]]]:
"""给节点执行器套上事件、计时、重试和错误处理。
画布上看到的每一次高亮、每一条耗时,都来自这层包装;
执行器本身只管自己那点业务逻辑。
执行器本身只管自己那点业务逻辑。loop_id 是直接包住它的那层循环。
"""
runner = RUNNERS.get(node.type)
ctx = NodeContext(node=node, run=run_ctx)
@@ -66,7 +69,8 @@ def _wrap(node: GraphNode, run_ctx: RunContext) -> Callable[[GraphState], Awaita
retries = int(node.config.get("retries", 0) or 0)
backoff = float(node.config.get("retry_backoff", 1.0) or 1.0)
started = time.perf_counter()
ctx.emit(EventType.NODE_STARTED, node_type=str(node.type), label=node.title)
ctx.emit(EventType.NODE_STARTED, node_type=str(node.type), label=node.title,
**_started_context(node.id, state, run_ctx, loop_id))
last_error: Exception | None = None
for attempt in range(retries + 1):
@@ -140,8 +144,10 @@ def _wrap(node: GraphNode, run_ctx: RunContext) -> Callable[[GraphState], Awaita
elapsed = int((time.perf_counter() - started) * 1000)
message = _describe(last_error)
# node_id 要带上:前端靠它把出错的节点从"转圈"收敛成"失败"
ctx.emit(EventType.NODE_FAILED, error=message, duration_ms=elapsed, node_id=node.id)
# node_id 要带上:前端靠它把出错的节点从"转圈"收敛成"失败"。
# error 是给人看的那句,原始异常放 detail,排查的人照样拿得到
ctx.emit(EventType.NODE_FAILED, error=message, duration_ms=elapsed, node_id=node.id,
detail=_detail(last_error))
# 容错模式:记下错误继续往下走,而不是让整张图挂掉
if node.config.get("on_error") == "continue":
@@ -162,12 +168,39 @@ def _wrap(node: GraphNode, run_ctx: RunContext) -> Callable[[GraphState], Awaita
def _describe(error: BaseException | None) -> str:
"""错误消息。NodeError 的 message 本来就是写给人看的,不用再前缀类型名。"""
"""错误消息。NodeError 的 message 本来就是写给人看的;别的异常翻成一句原因,
不带类型名和内部符号——界面上出现过「_make_query_tool.<locals>._run() got an
unexpected keyword argument」这种首行报错。"""
if error is None:
return "未知错误"
if isinstance(error, NodeError):
return str(error)
return f"{type(error).__name__}: {error}"
return f"执行出错:{describe_exception(error)}"
def _detail(error: BaseException | None) -> str | None:
"""原始异常。NodeError 自己是人话,真正的原因在它包住的那个异常里。"""
if isinstance(error, NodeError):
return raw_detail(error.__cause__) if error.__cause__ is not None else None
return raw_detail(error)
def _started_context(
node_id: str, state: GraphState, run_ctx: RunContext, loop_id: str | None,
) -> dict[str, Any]:
"""node.started 附带的上下文:在循环的第几轮,以及是不是恢复后的那次重放。"""
out: dict[str, Any] = {}
if loop_id:
mark = (state.get("loops") or {}).get(loop_id)
# 循环节点决定进 body 时已经把 index 推进到"这一轮的序号"(从 1 数)
if isinstance(mark, dict) and not mark.get("finished") and mark.get("index"):
out["iteration"] = int(mark["index"])
pending = run_ctx.extra.get("resumed")
if isinstance(pending, set) and node_id in pending:
# 只有恢复后第一次跑到它才算重放;同一次运行里之后再进来是正常执行
pending.discard(node_id)
out["resumed"] = True
return out
def _vars_preview(updates: dict[str, Any]) -> dict[str, Any] | None:
@@ -277,9 +310,11 @@ def compile_graph(spec: GraphSpec, run_ctx: RunContext) -> StateGraph:
builder = StateGraph(GraphState)
node_map = spec.node_map()
joins = _join_nodes(spec, node_map)
enclosing = innermost_loops(spec)
for node in spec.nodes:
builder.add_node(node.id, _wrap(node, run_ctx), defer=node.id in joins)
builder.add_node(node.id, _wrap(node, run_ctx, enclosing.get(node.id)),
defer=node.id in joins)
# 入口
entries = spec.entry_nodes()