- 后端: file_start 事件改为在获取信号量之后发送,避免并发时所有文件同时'开始'导致进度瞬间跳到90% - 前端: 进度追踪改为基于 file_end 事件(完成)而非 file_start(开始),进度条平滑反映实际审查进度
This commit is contained in:
+1
-1
@@ -134,7 +134,7 @@ func GenerateReview(db *sql.DB, repoPath, base, head string, topN, concurrency i
|
|||||||
sem <- struct{}{} // acquire slot
|
sem <- struct{}{} // acquire slot
|
||||||
defer func() { <-sem }() // release 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 {
|
if safeCallback != nil {
|
||||||
safeCallback("file_start", map[string]interface{}{
|
safeCallback("file_start", map[string]interface{}{
|
||||||
"file": f.Filename,
|
"file": f.Filename,
|
||||||
|
|||||||
@@ -368,9 +368,6 @@
|
|||||||
},
|
},
|
||||||
file_start(data) {
|
file_start(data) {
|
||||||
currentFile = data.file || '';
|
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})`;
|
document.getElementById('progress-text').textContent = `正在审查: ${currentFile} (${completedFiles}/${totalFiles})`;
|
||||||
|
|
||||||
// Initialize file review entry
|
// Initialize file review entry
|
||||||
@@ -389,7 +386,10 @@
|
|||||||
appendSuggestionCard(data);
|
appendSuggestionCard(data);
|
||||||
},
|
},
|
||||||
file_end(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) {
|
file_summary(data) {
|
||||||
if (data.file && fileReviews[data.file]) {
|
if (data.file && fileReviews[data.file]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user