From c7b03303e440b4a2c280bbf27c19c38b8b0d6047 Mon Sep 17 00:00:00 2001 From: wonder Date: Sun, 21 Jun 2026 15:17:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=AE=A1=E6=9F=A5=E8=BF=9B=E5=BA=A6=E6=9D=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 后端: file_start 事件改为在获取信号量之后发送,避免并发时所有文件同时'开始'导致进度瞬间跳到90% - 前端: 进度追踪改为基于 file_end 事件(完成)而非 file_start(开始),进度条平滑反映实际审查进度 --- services/review.go | 2 +- templates/pages/review.html | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/review.go b/services/review.go index b2c7cba..86c8815 100644 --- a/services/review.go +++ b/services/review.go @@ -134,7 +134,7 @@ func GenerateReview(db *sql.DB, repoPath, base, head string, topN, concurrency i sem <- struct{}{} // acquire slot defer func() { <-sem }() // release slot - // Send file_start (order doesn't matter, frontend tracks by filename) + // Send file_start after acquiring semaphore — this means the file is actually being reviewed now if safeCallback != nil { safeCallback("file_start", map[string]interface{}{ "file": f.Filename, diff --git a/templates/pages/review.html b/templates/pages/review.html index 977b76c..231447e 100644 --- a/templates/pages/review.html +++ b/templates/pages/review.html @@ -368,9 +368,6 @@ }, file_start(data) { currentFile = data.file || ''; - completedFiles++; - const pct = totalFiles > 0 ? Math.round((completedFiles / totalFiles) * 80 + 10) : 50; - document.getElementById('progress-bar').style.width = pct + '%'; document.getElementById('progress-text').textContent = `正在审查: ${currentFile} (${completedFiles}/${totalFiles})`; // Initialize file review entry @@ -389,7 +386,10 @@ appendSuggestionCard(data); }, file_end(data) { - // File done + completedFiles++; + const pct = totalFiles > 0 ? Math.round((completedFiles / totalFiles) * 80 + 10) : 50; + document.getElementById('progress-bar').style.width = pct + '%'; + document.getElementById('progress-text').textContent = `已完成 ${completedFiles}/${totalFiles} 个文件`; }, file_summary(data) { if (data.file && fileReviews[data.file]) {