diff --git a/templates/code_review.html b/templates/code_review.html index 68bf6fd..bbbac21 100644 --- a/templates/code_review.html +++ b/templates/code_review.html @@ -439,11 +439,6 @@ 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)/ 30s(idle) const interval = state.status === 'running' ? 3000 : 30000; _polling = setTimeout(poll, interval); @@ -455,7 +450,12 @@ async function poll() { async function loadHistory() { try { const r = await fetch('/code-review/api/history?limit=15'); - renderHistory(await r.json()); + const items = await r.json(); + renderHistory(items); + // 無 active pipeline 且尚未顯示任何 pipeline 內容時,自動展示最新一筆 + if (items.length && !_lastPipelineId) { + loadHistoryItem(0); + } } catch(e) { document.getElementById('historyList').innerHTML = '
載入失敗
'; }