fix(ai-outfit): preview sample rows ignore Excel status (§19.9)

Add excel_service.read_all_rows (every valid data row, status-independent) and
use it in _reload_sample_rows for the preview dropdown, so previewing still
works after the whole sheet is 完成. Generation still uses load_outfit_tasks.
+1 excel test (read_all_rows includes 完成/失败, skips incomplete); offscreen
all-完成 sheet now yields sample rows; full suite (12) green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 15:09:56 +08:00
co-authored by Claude Opus 4.8
parent cf1096ad79
commit 1c9ee36488
4 changed files with 58 additions and 9 deletions
+9 -6
View File
@@ -636,17 +636,20 @@ class AiOutfitPanel(QWidget):
self._refresh_preview()
def _reload_sample_rows(self):
"""Best-effort: read the chosen Excel to fill the sample dropdown."""
"""Best-effort: read the chosen Excel to fill the sample dropdown.
Uses read_all_rows (status-independent) so preview still works after the
whole sheet is 完成 (docs/11 §10.3); generation still uses load_outfit_tasks.
"""
excel = self._excel_edit.text().strip()
tasks = []
rows = []
if excel:
try:
from services.excel_service import load_outfit_tasks
tasks = load_outfit_tasks(
excel, retry_failed=self._retry_failed_chk.isChecked())
from services.excel_service import read_all_rows
rows = read_all_rows(excel)
except Exception as exc: # noqa: BLE001 - silent for preview
logger.info("Sample rows unavailable: %s", exc)
self._fill_sample_combo(tasks)
self._fill_sample_combo(rows)
def _refresh_preview(self):
if not hasattr(self, "_preview_view"):
+34
View File
@@ -113,6 +113,40 @@ def load_outfit_tasks(excel_path, retry_failed=False):
workbook.close()
def read_all_rows(excel_path):
"""Return an OutfitTask for every valid data row, ignoring E-column status.
Unlike load_outfit_tasks (which filters for *processable* rows), this returns
all rows whose title/product/garment are filled — including 「完成」/「失败」 —
for preview/sample purposes only (docs/11 §10.3). Rows missing any of those
fields are skipped.
"""
path = Path(excel_path)
workbook = load_workbook(str(path))
try:
sheet = workbook.worksheets[0]
rows = []
for row_index in range(2, sheet.max_row + 1):
title = sheet.cell(row_index, COL_TITLE).value
product_id = sheet.cell(row_index, COL_PRODUCT_ID).value
garment_path = sheet.cell(row_index, COL_GARMENT_PATH).value
if _is_empty(title) or _is_empty(product_id) or _is_empty(garment_path):
continue
raw_status = sheet.cell(row_index, COL_STATUS).value
rows.append(
OutfitTask(
row_index=row_index,
title=_cell_text(title),
product_id=_cell_text(product_id),
garment_path=_cell_text(garment_path),
status=_cell_text(raw_status) or STATUS_PENDING,
)
)
return rows
finally:
workbook.close()
def write_outfit_result(excel_path, result):
"""Write one outfit result to columns D/E/F and save immediately."""
if not isinstance(result, OutfitResult):