Add HTML5 authoring completion preview
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-16 23:06:50 +03:00
parent a62e213b2f
commit b7876db8ef
3 changed files with 111 additions and 1 deletions
@@ -38,6 +38,7 @@ from pydantic import BaseModel, Field
from api_server.html5 import (
render_html5_authoring_changes,
render_html5_authoring_change_detail,
render_html5_authoring_preview_result,
render_html5_authoring_rollback_result,
render_html5_editor,
render_html5_index,
@@ -1769,6 +1770,30 @@ async def html5_project_authoring_apply_rollback(project_id: str, change_id: str
return Response(html, media_type="text/html; charset=utf-8")
@app.post("/html5/projects/{project_id}/authoring/completion-preview")
async def html5_project_authoring_completion_preview(project_id: str, request: Request) -> Response:
form = await _html5_form_data(request)
cursor_line_value = _form_value(form, "cursor_line")
try:
cursor_line = int(cursor_line_value) if cursor_line_value else None
except ValueError:
cursor_line = None
payload = AuthoringCompletionPreviewRequest(
object_name=_form_value(form, "object_name"),
routine_name=_form_value(form, "routine_name"),
cursor_line=cursor_line,
source_text=_form_value(form, "source_text"),
intent=_form_value(form, "intent") or "guarded-return",
user_id=_form_value(form, "user_id"),
)
try:
preview = await authoring_completion_preview(project_id, payload)
html = render_html5_authoring_preview_result(project_id, preview)
except HTTPException as error:
html = render_html5_authoring_preview_result(project_id, error=str(error.detail))
return Response(html, media_type="text/html; charset=utf-8")
@app.get("/html5/projects/{project_id}/setup")
async def html5_project_setup(project_id: str) -> Response:
setup = _project_setup_response(project_id)