feat(roundtable): 历史卡片显示所用业务链(自由模式) + 诊断只收报错日志
- 历史「分析记录」卡片/侧边栏列表:把「第X步」改为本次会商所用业务链名, 无链条显示「自由模式」。后端 list 轻量 meta 从 step2 正则抽取 chain_title (不整体解析大块 JSON),个人草稿 + task 草稿两个 store 都覆盖。 - 会商诊断改为只收集报错日志:record_diagnostic 写库前丢弃 level==info 运行日志(begin/consensus/gather/job_started),只留 warning/error。 单点收口覆盖前台/后台/recorder 全部写路径;诊断页标题改「会商报错日志」。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e28277b21b
commit
7748661963
11 files changed
+85
-13
No files matched your search
+26
@@ -11,6 +11,7 @@ All write/read paths are scoped by ``user_id`` for ownership isolation.
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
from datetime import UTC, datetime
|
||||
from typing import Any
|
||||
|
||||
@@ -24,6 +25,29 @@ from deerflow.persistence.roundtable_drafts.model import (
|
||||
|
||||
_UNSET = object()
|
||||
|
||||
# 业务链名抽取:在已加载进内存的 step2 JSON 串里直接找 `"chain":{...,"title":"X"}`,
|
||||
# 不整体 json.loads(step2 是 LONGTEXT 大块),只做一次廉价正则扫描。`"chain":null`
|
||||
# (recommend/自由模式)不匹配 → 返回 None。`[^{}]*?` 限定在 chain 对象内({id,title}
|
||||
# 无嵌套花括号)。
|
||||
_CHAIN_TITLE_RE = re.compile(r'"chain"\s*:\s*\{[^{}]*?"title"\s*:\s*"((?:\\.|[^"\\])*)"')
|
||||
|
||||
|
||||
def _extract_chain_title(step2_raw: Any) -> str | None:
|
||||
"""从 step2 原始 JSON 串里抽取所用业务链名(无链条 → None,前端显示「自由模式」)。"""
|
||||
if not isinstance(step2_raw, str) or not step2_raw:
|
||||
return None
|
||||
m = _CHAIN_TITLE_RE.search(step2_raw)
|
||||
if not m:
|
||||
return None
|
||||
title = m.group(1)
|
||||
try:
|
||||
# 还原 JSON 字符串转义(\" \\ \n \uXXXX 等)。
|
||||
title = json.loads(f'"{title}"')
|
||||
except Exception:
|
||||
pass
|
||||
title = title.strip()
|
||||
return title or None
|
||||
|
||||
|
||||
def _loads(value: Any) -> Any:
|
||||
if not isinstance(value, str):
|
||||
@@ -56,6 +80,8 @@ class RoundtableDraftRepository:
|
||||
"task_id": row.task_id,
|
||||
"title": row.title,
|
||||
"furthest_step": row.furthest_step,
|
||||
# 所用业务链名(历史卡片展示用);无链条 → None → 前端显示「自由模式」。
|
||||
"chain_title": _extract_chain_title(row.step2),
|
||||
"created_at": row.created_at.isoformat() if isinstance(row.created_at, datetime) else row.created_at,
|
||||
"updated_at": row.updated_at.isoformat() if isinstance(row.updated_at, datetime) else row.updated_at,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user