fix: polling fallback когда SSE done event не доходит до клиента
Проблема: Claude Code Docker завершается, файлы на диске есть, но SSE event 'done' не доходит до браузера через nginx. UI зависает навечно. Решение: двойная страховка 1. JS: после завершения SSE stream поллит /api/batch-v2/status каждые 2с 2. API status: проверяет файлы на диске, если job.status ещё "uploaded" но batch_script.py уже существует → переводит в "analyzed" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -508,12 +508,27 @@ async def batch_v2_status(job_id: str, request: Request):
|
||||
job = batch_v2.get_job(job_id)
|
||||
if not job:
|
||||
raise HTTPException(404, "Job not found")
|
||||
|
||||
# If status is still "uploaded" but files exist on disk — Claude finished
|
||||
# but SSE didn't deliver the done event
|
||||
if job["status"] == "uploaded" and job.get("job_dir"):
|
||||
job_dir = Path(job["job_dir"])
|
||||
result_data = batch_v2._read_result_files(job_dir)
|
||||
if result_data.get("script"):
|
||||
job["analysis"] = {
|
||||
"python_script": result_data["script"],
|
||||
"summary": result_data.get("summary", {}),
|
||||
}
|
||||
job["status"] = "analyzed"
|
||||
|
||||
analysis = job.get("analysis", {})
|
||||
return {
|
||||
"status": job["status"],
|
||||
"total": job.get("total_files", 0),
|
||||
"processed": job.get("processed", 0),
|
||||
"errors": job.get("errors", [])[:20],
|
||||
"script": job.get("analysis", {}).get("python_script", ""),
|
||||
"script": analysis.get("python_script", ""),
|
||||
"summary": analysis.get("summary", {}),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user