Add HTML5 project panel SSE updates
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-17 02:46:21 +03:00
parent fb66cfba6f
commit 8a1c0da0ea
3 changed files with 34 additions and 9 deletions
+16 -3
View File
@@ -1,8 +1,9 @@
from __future__ import annotations
import json
import asyncio
import base64
import hashlib
import json
import os
import re
import shutil
@@ -1694,21 +1695,33 @@ async def html5_project_editor(project_id: str, q: str = "") -> Response:
@app.get("/html5/projects/{project_id}/events")
async def html5_project_events(project_id: str, once: bool = False) -> StreamingResponse:
def stream_status():
async def stream_status():
while True:
try:
snapshot = _project_snapshot_or_404(project_id)
fragment = render_html5_status(project_id, snapshot)
report = await project_report(project_id)
findings = await get_review(project_id)
flowchart = await project_flowchart(project_id, focus=None, depth=1, limit=80)
except HTTPException as error:
fragment = f'<span>project: {project_id}</span><span>error: {error.detail}</span>'
report = None
findings = None
flowchart = None
yield _html5_sse_event("status", fragment)
yield _html5_sse_event(
"authoring-changes",
render_html5_authoring_changes(project_id, _authoring_change_summaries(project_id)),
)
if report is not None:
yield _html5_sse_event("project-report", render_html5_project_report(project_id, report))
if findings is not None:
yield _html5_sse_event("project-review", render_html5_review(project_id, findings))
if flowchart is not None:
yield _html5_sse_event("project-flowchart", render_html5_flowchart(project_id, flowchart))
if once:
break
time.sleep(5)
await asyncio.sleep(5)
return StreamingResponse(
stream_status(),