hx-boost: fall back to a full reload when a deploy changes head assets #149

Merged
CrowderSoup merged 1 commit from hx-boost-reload-on-deploy into main 2026-12-02 00:04:55 +00:00
Owner

Problem

Sidebar and bottom-bar navigation use hx-boost="true", which swaps only <body> and leaves <head> untouched. If a tab stays open across a deploy that changes app.css or app.js (producing new manifest-hashed URLs), subsequent boosted clicks render the new HTML with the old stylesheet/scripts until the user manually refreshes.

Fix

  • Snapshot the same-origin <link rel="stylesheet">, <script src>, and <meta name="vsuite-editor"> URLs from document.head once at initial page load in static/app.js (so runtime additions like lazy-loaded vsuite-editor.js or browser extensions don't trigger false reloads).
  • On htmx:beforeSwap for boosted page navigations, compare the incoming response's <head> assets against the snapshot; when they differ, cancel the swap and fall back to a real navigation/reload so the browser loads the new assets.
  • Added Playwright tests in tests/browser/test_sidebar_boost_browser.py verifying both the post-deploy full reload and that lazy-loading vsuite-editor.js does not break normal boosted swaps.
## Problem Sidebar and bottom-bar navigation use `hx-boost="true"`, which swaps only `<body>` and leaves `<head>` untouched. If a tab stays open across a deploy that changes `app.css` or `app.js` (producing new manifest-hashed URLs), subsequent boosted clicks render the new HTML with the old stylesheet/scripts until the user manually refreshes. ## Fix - Snapshot the same-origin `<link rel="stylesheet">`, `<script src>`, and `<meta name="vsuite-editor">` URLs from `document.head` once at initial page load in `static/app.js` (so runtime additions like lazy-loaded `vsuite-editor.js` or browser extensions don't trigger false reloads). - On `htmx:beforeSwap` for boosted page navigations, compare the incoming response's `<head>` assets against the snapshot; when they differ, cancel the swap and fall back to a real navigation/reload so the browser loads the new assets. - Added Playwright tests in `tests/browser/test_sidebar_boost_browser.py` verifying both the post-deploy full reload and that lazy-loading `vsuite-editor.js` does not break normal boosted swaps.
hx-boost: fall back to a full reload when a deploy changes head assets
All checks were successful
tests / pytest (push) Successful in 2m13s
fc95713366
Sign in to join this conversation.
No description provided.