diff --git a/wwwroot/api/todo_detail.dspy b/wwwroot/api/todo_detail.dspy index 2302717..fff5081 100644 --- a/wwwroot/api/todo_detail.dspy +++ b/wwwroot/api/todo_detail.dspy @@ -168,44 +168,65 @@ async with DBPools().sqlorContext(dbname) as sor: bug_id = _s(getattr(h, 'bug_id', '')) if task_type in ('requirement_confirmation', 'design_confirmation'): + drecs = [] + pm_comment = '' if src_task_id: trecs = await sor.sqlExe( "SELECT title, state FROM pipeline_tasks WHERE id=${t}$", {"t": src_task_id}) await sor.sqlExe("COMMIT", {}) if trecs: sub_lines.append('原任务:' + _s(getattr(trecs[0], 'title', ''))) + # 角色 agent 产出的交付件(排除 pm_review —— 那是审核记录不是待确认内容) drecs = await sor.sqlExe( - "SELECT title, deliverable_type, content, review_status, review_comment, " - "created_by, created_at FROM pipeline_deliverables " - "WHERE task_id=${t}$ ORDER BY created_at DESC LIMIT 5", {"t": src_task_id}) + "SELECT title, deliverable_type, content, file_path, review_status, " + "review_comment, created_by, created_at FROM pipeline_deliverables " + "WHERE task_id=${t}$ AND deliverable_type<>'pm_review' " + "ORDER BY created_at DESC LIMIT 3", {"t": src_task_id}) await sor.sqlExe("COMMIT", {}) - else: - drecs = [] + # PM 审核意见单独取(content 是 JSON,取其中 comment) + prrecs = await sor.sqlExe( + "SELECT content, review_comment, created_at FROM pipeline_deliverables " + "WHERE task_id=${t}$ AND deliverable_type='pm_review' " + "ORDER BY created_at DESC LIMIT 1", {"t": src_task_id}) + await sor.sqlExe("COMMIT", {}) + if prrecs: + pm_comment = _s(getattr(prrecs[0], 'review_comment', '')) + raw = _s(getattr(prrecs[0], 'content', '')) + if raw: + try: + _pj = _json.loads(raw) + pm_comment = _s(_pj.get('comment')) or pm_comment + except Exception: + pm_comment = pm_comment or raw + if pm_comment: + md.append('## PM 审核意见') + md.append('') + md.append(pm_comment) + md.append('') if drecs: - d0 = drecs[0] - md.append('## 待确认交付件:' + (_s(getattr(d0, 'title', '')) or '(未命名)')) - md.append('') - md.append('- 类型:' + (_s(getattr(d0, 'deliverable_type', '')) or '-') - + ' | 产出:' + (_s(getattr(d0, 'created_by', '')) or '-') - + ' | 时间:' + _s(getattr(d0, 'created_at', ''))) - rc = _s(getattr(d0, 'review_comment', '')) - if rc: - md.append('- PM 评审意见:' + rc) - md.append('') - md.append('---') - md.append('') - md.append(_s(getattr(d0, 'content', '')) or '(交付件正文为空,请到工作空间查看文件)') - md.append('') - if len(drecs) > 1: + for _i in range(len(drecs)): + dx = drecs[_i] + _head = '## 待确认交付件' if _i == 0 else '## 交付件(更早版本)' + md.append(_head + ':' + (_s(getattr(dx, 'title', '')) or '(未命名)')) + md.append('') + md.append('- 类型:' + (_s(getattr(dx, 'deliverable_type', '')) or '-') + + ' | 产出:' + (_s(getattr(dx, 'created_by', '')) or '-') + + ' | 时间:' + _s(getattr(dx, 'created_at', '')) + + ' | 评审:' + (_s(getattr(dx, 'review_status', '')) or '-')) + _fp = _s(getattr(dx, 'file_path', '')) + if _fp: + md.append('- 文件:`' + _fp + '`') + md.append('') md.append('---') md.append('') - md.append('## 历史版本') - md.append('') - for dx in drecs[1:]: - md.append('- ' + _s(getattr(dx, 'created_at', '')) + ' | ' - + (_s(getattr(dx, 'title', '')) or '-') + ' | ' - + (_s(getattr(dx, 'review_status', '')) or '-')) + _content = _s(getattr(dx, 'content', '')) + if len(_content) > 20000: + _content = _content[:20000] + '\n\n…(内容过长已截断,完整版见上面的文件路径)' + md.append(_content or '(交付件正文为空,请到项目工作空间 deliverables 目录查看文件)') md.append('') + if _i == 0 and len(drecs) > 1: + md.append('---') + md.append('') else: md.append('## 待确认内容') md.append('')