feat(ai-outfit): clear 'no pending rows' message + keep preview on generate (§19.10)

- _on_finished(total==0) now shows _show_no_pending_message: counts 完成/失败
  via read_all_rows and tells the user how to redo (clear E column / retry
  failed), instead of the silent '完成 0,失败 0'.
- _on_tasks_loaded no longer calls _fill_sample_combo(tasks), so generating on
  an all-完成 sheet no longer empties the preview dropdown (read_all_rows owns it).
- Offscreen-verified both paths; full suite (12 files) green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 15:17:43 +08:00
co-authored by Claude Opus 4.8
parent 2643b19686
commit d962b60816
2 changed files with 36 additions and 4 deletions
+33 -1
View File
@@ -806,7 +806,8 @@ class AiOutfitPanel(QWidget):
self._set_cell(row, 5, "—")
self._progress.setMaximum(max(1, len(tasks)))
self._update_stats(0, 0, len(tasks))
self._fill_sample_combo(tasks)
# Preview sample rows are owned by read_all_rows (§10.3/§10.4); don't reset
# them to the run's task list (which is empty when the sheet is all 完成).
self._append_log("已加载 {} 行待处理任务".format(len(tasks)))
def _on_progress(self, completed, total, result):
@@ -831,12 +832,43 @@ class AiOutfitPanel(QWidget):
def _on_finished(self, summary):
self._set_running(False)
if getattr(summary, "total", 0) == 0:
self._append_log("没有待处理的行。")
self._show_no_pending_message()
return
msg = "完成 {},失败 {}{}".format(
summary.success_count, summary.failure_count,
"(已停止)" if getattr(summary, "stopped", False) else "")
self._append_log("批量结束:" + msg)
QMessageBox.information(self, "AI 穿搭", "本次生成结束。\n" + msg)
def _show_no_pending_message(self):
"""Explain why nothing ran: rows already 完成/失败, and how to redo (§10.4)."""
done = failed = 0
excel = self._excel_edit.text().strip()
if excel:
try:
from services.excel_service import (
STATUS_DONE, STATUS_FAILED, read_all_rows)
for r in read_all_rows(excel):
if r.status == STATUS_DONE:
done += 1
elif r.status == STATUS_FAILED:
failed += 1
except Exception: # noqa: BLE001 - best effort
pass
if done == 0 and failed == 0:
text = "该表没有可处理的行(标题/货号/衣服图为空的行会被跳过)。"
else:
parts = []
if done:
parts.append("已完成 {} 行(已跳过)".format(done))
if failed:
parts.append("失败 {} 行(勾选「重试上次失败的行」可重做)".format(failed))
text = ("该表没有待处理的行:" + ";".join(parts)
+ "。\n要重做已完成的行,请清空对应行的状态(E)列后重试。")
QMessageBox.information(self, "没有待处理的行", text)
def _on_failed(self, message):
self._set_running(False)
self._append_log("无法开始:" + message)