B6/B7: failed终态前端可见 + SSE事件链核实

B6 错误态:
- 后端已加 TaskStatus.FAILED + 异常区分重试中/耗尽(014迁移ALTER status ENUM)
- 前端 TaskStatus 类型加 failed
- RecentTasksBar/history STATUS_LABEL 补 failed 标签
- history 页 HISTORY_STATUSES 纳入 failed(否则失败任务前端找不到)
- FatalErrorBanner + useSse error 不再静默丢弃

B7: 核实 SSE(ticket换JWT) + 事件消费链无缺口,标绿

tsc EXIT=0
This commit is contained in:
yangqianqian
2026-06-16 12:45:13 +08:00
parent ea423e8a32
commit 1b488752e6
13 changed files with 102 additions and 11 deletions

View File

@@ -140,16 +140,21 @@ def run_generation_pipeline(self, task_id: int) -> dict:
except Exception as exc:
logger.error("run_generation_pipeline failed: task_id=%s err=%s", task_id, exc)
# 重试耗尽才落 FAILED 终态;还能重试则保持 GENERATING(别伪装成"待开始")。
# B6:失败要可见,区分"没跑(pending)"和"跑挂了(failed)"。
exhausted = self.request.retries >= self.max_retries
try:
from app.models.task import GenerationTask as GT
from app.constants.enums import TaskStatus as TS
t = db.query(GT).filter(GT.id == task_id).first()
if t:
t.status = TS.PENDING
t.status = TS.FAILED if exhausted else TS.GENERATING
db.commit()
except Exception:
pass
_push_event_sync(task_id, workspace_id, "error", {"code": 50001, "message": str(exc)}, seq + 1)
if exhausted:
return {"task_id": task_id, "status": "failed", "error": str(exc)}
raise self.retry(exc=exc)
finally:
db.close()