Skip to content

Move HTMX fragment rendering into PostgreSQL - #84

Merged
seanwevans merged 1 commit into
mainfrom
codex/move-rendering-boundary-into-postgresql
Jul 31, 2026
Merged

seanwevans merged 1 commit into
mainfrom
codex/move-rendering-boundary-into-postgresql

Conversation

@seanwevans

Copy link
Copy Markdown
Owner

Motivation

  • Reduce client-side complexity by moving HTML fragment rendering and escaping into the database so HTMX can perform native fragment swaps.
  • Ensure untrusted command/output values are safely escaped server-side to eliminate client-side JSON parsing and DOM construction for RPC responses.
  • Provide a clear PostgREST-compatible HTML contract so the frontend can request text/html fragments directly.

Description

  • Add sql/html_fragments.sql which declares a "text/html" domain, adds pg_shell_html_escape, and provides latest_output_html and submit_command_html RPCs that return escaped HTML fragments.
  • Register the new SQL file in sql/install.sql so the HTML RPCs install with the rest of the schema.
  • Update the static UI in html/index.html to call latest_output_html and submit_command_html, include hx-headers to request text/html, and use hx-swap="innerHTML"/hx-swap="beforeend" to let HTMX perform native swaps.
  • Remove the client-side JSON renderer and json-encoding extension by deleting html/app.js and html/vendor/json-enc-1.9.12.js, and add SQL/browser tests plus README updates that document the HTML RPC contract.

Testing

  • Ran the full test suite with pytest -q, yielding 54 passed, 24 skipped where skipped tests require optional external services (database/PostgREST/Playwright) and are expected to be environment-dependent.
  • All modified tests covering SQL rendering (tests/test_functions.py) and browser expectations (tests/test_html_ui.py) passed in the CI-like run.

Codex Task

@seanwevans
seanwevans merged commit 5089460 into main Jul 31, 2026
2 checks passed
@seanwevans
seanwevans deleted the codex/move-rendering-boundary-into-postgresql branch July 31, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant