框架(看板): 运行记录落地页候选/决策换为真实列表(99 已建,随创作链点亮)

This commit is contained in:
zizi 2026-07-31 11:02:16 +08:00
parent aa82445ec7
commit bf6cbc02b1

View File

@ -470,10 +470,27 @@ def view_runs():
runs_html = (f"<div class='card'><div class='hd'>运行(最近 50)</div>"
+ _RUN_COLS + _run_rows(runs) + "</tbody></table></div>") if runs else \
empty_gap("暂无运行记录", "创作链落库后,每次运行登记一行(example_run)。")
cand = (empty_gap("待审候选 · 待落库", "候选表(99)未建,AI 候选正文暂无持久化登记。")
if not table_exists("example_candidate") else "<div class='empty'>候选表已建 · 暂无候选</div>")
dec = (empty_gap("用户决策 · 待落库", "决策记录表(99)未建,接受/合并/丢弃暂以 git 提交留痕。")
if not table_exists("example_user_decision") else "<div class='empty'>决策表已建 · 暂无决策</div>")
if table_exists("example_candidate"):
_, cands = q("SELECT id, work_id, target_chapter, candidate_version, run_type, state, source_role "
"FROM example_candidate WHERE deleted=false AND state IN ('draft','checking','passed') "
"ORDER BY create_time DESC LIMIT 30")
cand = ("<div class='card'><div class='hd'>待审候选(活跃)</div><table><thead>"
"<tr><th class='num'>id</th><th>作品</th><th class='num'>章</th><th>版本</th><th>类型</th><th>状态</th><th>角色</th></tr></thead><tbody>"
+ "".join(f"<tr><td class='num'>{esc(c[0])}</td><td>{esc(c[1])}</td><td class='num'>{esc(c[2])}</td>"
f"<td><code>{esc(c[3])}</code></td><td>{esc(c[4])}</td><td>{chip(c[5])}</td><td>{esc(c[6])}</td></tr>" for c in cands)
+ "</tbody></table></div>") if cands else "<div class='empty'>候选表已建 · 暂无待审候选</div>"
else:
cand = empty_gap("待审候选 · 待落库", "候选表(99)未建,AI 候选正文暂无持久化登记。")
if table_exists("example_user_decision"):
_, decs = q("SELECT work_id, target_chapter, decision, rationale, decided_by, create_time "
"FROM example_user_decision ORDER BY create_time DESC LIMIT 30")
dec = ("<div class='card'><div class='hd'>用户决策(最近 30)</div><table><thead>"
"<tr><th>作品</th><th class='num'>章</th><th>决策</th><th>理据</th><th>决策人</th><th>时间</th></tr></thead><tbody>"
+ "".join(f"<tr><td>{esc(d[0])}</td><td class='num'>{esc(d[1])}</td><td>{chip({'accept':'good','merge':'warn','discard':'crit'}.get(d[2],'warn'), d[2])}</td>"
f"<td>{esc((d[3] or '')[:40])}</td><td>{esc(d[4])}</td><td>{esc(d[5])}</td></tr>" for d in decs)
+ "</tbody></table></div>") if decs else "<div class='empty'>决策表已建 · 暂无决策</div>"
else:
dec = empty_gap("用户决策 · 待落库", "决策记录表(99)未建,接受/合并/丢弃暂以 git 提交留痕。")
body = (f"<h1>运行记录<span class='sub'>agentic 的操作与产出 · 流程 05 · 质量 06</span></h1>"
f"{entries}{runs_html}<h2>待审候选</h2>{cand}<h2>用户决策</h2>{dec}")
return layout("运行记录", body, "/runs")