djust 0.9.7rc2

Pre-releaseReleased

This is a pre-release. djust 0.9.7 has shipped since: read the djust 0.9.7 release notes.

Added

  • LiveView state survives WS reconnect when enable_state_snapshot = True (#1465, supersedes stale PR #1429). Three companion changes to python/djust/websocket.py close a long-standing gap where enable_state_snapshot was effectively HTTP-only. (1) handle_event now mirrors the HTTP-path session save (mixins/request.py:603-609) after every successful WS event handler — fresh get_context_data() snapshot is filtered for LiveComponent instances, normalized, and aset to the Django session under liveview_<page_url>, with private (_-prefixed) attrs and components persisted alongside. (2) The load gate in handle_mount widens from if has_prerendered: to if has_prerendered or saved_state: so pure-WS reconnect (no SSR — e.g. after djustlive proxy force-closed the backend WS for snapshot) reaches the aget(view_key) lookup. (3) Mount response now skips the html field on resume — when mounted (state restored) AND has_prerendered, the client's DOM already reflects the saved state, so omitting html prevents a redundant morphdom-style DOM swap; client.js's e.html && (n.innerHTML=e.html) short-circuits cleanly. Mount response shrinks ~12KB → ~500 bytes on the resume path. The LOAD path (gate widening + skip-html on resume) is opt-in-gated via enable_state_snapshot / has_prerendered — behavior for non-opt-in views' load path is unchanged. The SAVE block in handle_event, however, fires unconditionally after every successful WS event, mirroring the HTTP-path mixins/request.py:603-609 semantics — the same session-write cost a POST incurs. Downstream consumers with high-event-rate views (e.g. dj-input per keystroke) on DB- or Redis-backed sessions should plan for that per-event write cost; the save is gated on top-level view identity (skips embedded child LiveComponent views to avoid wrong-key writes — child-view save coverage tracked at #1467) and wrapped in try/except so failures are caught and logged, never propagate to the event handler. Unblocks djustlive's "scale-to-zero with sub-50ms wake" story for stateful apps.

All releases · Atom feed