fix(telegram+review): 修復 PPT 按鈕無反應 + Code Review 頁面空白
All checks were successful
CD Pipeline / deploy (push) Successful in 1m28s

PPT 按鈕:
- telegram_bot_service.py 新增 cmd:* handler,透過 Thread 轉發到
  OpenClaw Flask 內部 API(/bot/internal/cmd)
- openclaw_bot_routes.py 新增 /bot/internal/cmd 端點,背景執行 handle_cmd()

Code Review 頁面:
- get_history() 補回 findings / openclaw_report 欄位
- code_review.html history 項目可點擊,自動載入詳細內容
- poll() 無 active pipeline 時自動顯示最新歷史記錄

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ogt
2026-04-22 08:56:10 +08:00
parent 5761aeb1ce
commit b11789db77
4 changed files with 93 additions and 2 deletions

View File

@@ -367,12 +367,15 @@ function renderStatusBar(state) {
}
// ── History ───────────────────────────────────────────────────────
let _historyData = [];
function renderHistory(items) {
_historyData = items;
const el = document.getElementById('historyList');
if (!items.length) { el.innerHTML = '<div class="empty"><div>尚無歷史記錄</div></div>'; return; }
el.innerHTML = items.map(h => {
el.innerHTML = items.map((h, idx) => {
const sev = h.severity_summary || {};
return `<div class="hist-item">
return `<div class="hist-item" onclick="loadHistoryItem(${idx})" data-idx="${idx}">
<div style="display:flex;justify-content:space-between">
<span class="hist-sha">${h.commit_sha}</span>
<span style="font-size:11px;color:var(--muted)">${h.created_at.slice(0,16).replace('T',' ')}</span>
@@ -389,6 +392,34 @@ function renderHistory(items) {
}).join('');
}
function loadHistoryItem(idx) {
const h = _historyData[idx];
if (!h) return;
document.querySelectorAll('.hist-item').forEach((el, i) => {
el.style.borderColor = i === idx ? 'var(--blue)' : '';
});
renderSeverity(h.severity_summary);
const files = (h.changed_files||[]).slice(0,5).map(f=>`<code>${f.split('/').pop()}</code>`).join(' ');
const more = (h.changed_files||[]).length > 5 ? `<span style="color:var(--muted)">+${h.changed_files.length-5}</span>` : '';
document.getElementById('commitInfo').innerHTML = `
<div><b>Commit</b> <code>${h.commit_sha}</code></div>
<div><b>Branch</b> <code>${h.branch||'?'}</code></div>
<div><b>時間</b> ${h.created_at.slice(0,16).replace('T',' ')}</div>
<div><b>變更</b> ${files} ${more}</div>`;
document.getElementById('pipelineId').textContent = (h.pipeline_id||'').slice(-14);
const sBar = document.getElementById('statusBar');
sBar.style.display = 'block';
sBar.className = 'completed';
sBar.innerHTML = `✅ <b>歷史記錄</b> — Commit ${h.commit_sha}${h.auto_fix ? ' 🔧 已自動修復' : ''}`;
renderFindings(h.findings || []);
renderOpenClaw(h.openclaw_report || '');
renderEA(h.ea_decision || {}, h.auto_fix || false);
for (let i = 1; i <= 5; i++) {
const el = document.getElementById('step-' + i);
if (el) { el.className = 'step ok'; el.querySelector('.step-num').textContent = '✓'; }
}
}
// ── Main polling loop ─────────────────────────────────────────────
async function poll() {
try {
@@ -408,6 +439,11 @@ async function poll() {
renderCommitInfo(state);
document.getElementById('pipelineId').textContent = (state.pipeline_id||'').slice(-14);
// 無 active pipeline 時,自動顯示最新歷史記錄
if (!state.status && _historyData.length && !_lastPipelineId) {
loadHistoryItem(0);
}
// 每 3s 輪詢running/ 30sidle
const interval = state.status === 'running' ? 3000 : 30000;
_polling = setTimeout(poll, interval);