Add s-expression wire format support and test detail view

- HTMX beforeSwap hook intercepts text/sexp responses and renders
  them client-side via sexp.js before HTMX swaps the result in
- sexp_response() helper for returning text/sexp from route handlers
- Test detail page (/test/<nodeid>) with clickable test names
- HTMX navigation to detail returns sexp wire format (4x smaller
  than pre-rendered HTML), full page loads render server-side
- ~test-detail component with back link, outcome badge, and
  error traceback display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 23:45:28 +00:00
parent 269bcc02be
commit fec5ecdfb1
5 changed files with 136 additions and 1 deletions

View File

@@ -208,3 +208,46 @@ async def render_results_partial(result: dict | None, running: bool,
"""HTMX partial: just the results section (wrapped in polling div)."""
inner = _results_partial_html(result, running, csrf, active_filter, active_service)
return _wrap_results_div(inner, running)
async def render_test_detail_page(ctx: dict, test: dict) -> str:
"""Full page: test detail view."""
hdr = _header_stack_html(ctx)
detail_row = render(
"menu-row",
id="test-detail-row", level=2, colour="sky",
link_href=f"/test/{test['nodeid']}",
link_label=test["nodeid"].rsplit("::", 1)[-1],
)
hdr += render("header-child", id="test-header-child",
inner_html=detail_row)
content = render(
"test-detail",
nodeid=test["nodeid"],
outcome=test["outcome"],
duration=str(test["duration"]),
longrepr=test.get("longrepr", ""),
)
body_end = client_components_tag()
return full_page(ctx, header_rows_html=hdr, content_html=content,
body_end_html=body_end)
def test_detail_sexp(test: dict) -> str:
"""Return s-expression wire format for a test detail view.
When a client has sexp.js loaded (HTMX navigation from the dashboard),
we can send the raw s-expression instead of pre-rendered HTML.
sexp.js will render it client-side.
"""
from shared.sexp.parser import serialize
nodeid = serialize(test["nodeid"])
outcome = serialize(test["outcome"])
duration = serialize(str(test["duration"]))
longrepr = serialize(test.get("longrepr", ""))
return (
f"(section :id \"main-panel\""
f" :class \"flex-1 md:h-full md:min-h-0 overflow-y-auto overscroll-contain js-grid-viewport\""
f" (~test-detail :nodeid {nodeid} :outcome {outcome}"
f" :duration {duration} :longrepr {longrepr}))"
)