From fb66cfba6fc98c36ac9b70f0da7325146d6125cd Mon Sep 17 00:00:00 2001 From: Mikhail Date: Sun, 17 May 2026 02:41:02 +0300 Subject: [PATCH] Add HTML5 authoring SSE updates --- services/api-server/src/api_server/html5.py | 13 ++++++++++--- services/api-server/src/api_server/main.py | 4 ++++ services/api-server/tests/test_api.py | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/services/api-server/src/api_server/html5.py b/services/api-server/src/api_server/html5.py index 6d59de9..b9f1c0a 100644 --- a/services/api-server/src/api_server/html5.py +++ b/services/api-server/src/api_server/html5.py @@ -206,7 +206,13 @@ def render_html5_editor( tree_nodes = objects[:120] or modules[:120] selected_module = modules[0] if modules else None content = f""" -
+
{_topbar(project_id, project_nav)}
-
+
{render_html5_status(project_id, snapshot)}
@@ -651,6 +657,7 @@ def render_html5_authoring_changes(project_id: str, changes: Iterable[object] | data-html5-authoring-changes hx-get="/html5/projects/{quote(project_id)}/authoring/changes" hx-trigger="load" + sse-swap="authoring-changes" hx-swap="outerHTML" >
Authoring
@@ -667,7 +674,7 @@ def render_html5_authoring_changes(project_id: str, changes: Iterable[object] | class="authoring-panel" data-html5-authoring-changes hx-get="/html5/projects/{quote(project_id)}/authoring/changes" - hx-trigger="every 15s" + sse-swap="authoring-changes" hx-swap="outerHTML" >
Authoring ยท {len(change_list)}
diff --git a/services/api-server/src/api_server/main.py b/services/api-server/src/api_server/main.py index f204127..1c71bbf 100644 --- a/services/api-server/src/api_server/main.py +++ b/services/api-server/src/api_server/main.py @@ -1702,6 +1702,10 @@ async def html5_project_events(project_id: str, once: bool = False) -> Streaming except HTTPException as error: fragment = f'project: {project_id}error: {error.detail}' yield _html5_sse_event("status", fragment) + yield _html5_sse_event( + "authoring-changes", + render_html5_authoring_changes(project_id, _authoring_change_summaries(project_id)), + ) if once: break time.sleep(5) diff --git a/services/api-server/tests/test_api.py b/services/api-server/tests/test_api.py index c39a7b3..21533a5 100644 --- a/services/api-server/tests/test_api.py +++ b/services/api-server/tests/test_api.py @@ -125,6 +125,7 @@ def test_html5_server_rendered_project_editor(tmp_path: Path): assert f'hx-post="/html5/projects/{project_id}/authoring/metadata-object-preview"' in editor.text assert "data-html5-authoring-changes" in editor.text assert f'hx-get="/html5/projects/{project_id}/authoring/changes"' in editor.text + assert 'sse-swap="authoring-changes"' in editor.text assert 'hx-get="/html5/projects/' in editor.text assert 'hx-target="[data-html5-symbol-results]"' in editor.text assert 'hx-target="[data-html5-symbol-detail]"' in editor.text @@ -145,6 +146,8 @@ def test_html5_server_rendered_project_editor(tmp_path: Path): with client.stream("GET", f"/html5/projects/{project_id}/events?once=1") as events: first_chunk = next(events.iter_text()) assert "event: status" in first_chunk + assert "event: authoring-changes" in first_chunk + assert "data-html5-authoring-changes" in first_chunk assert "data:" in first_chunk assert project_id in first_chunk