fix(nav): restore real Streamlit Back-to-Home button — preserves state

Reported: after the sticky-footer href fix (be7191a) the back-to-home
click worked but the home-page upload list disappeared. Full-page
navigation via ``<a href>`` doesn't preserve ``st.session_state`` on
the user's Streamlit build.

Trade-off forced: pick visible-from-anywhere sticky footer OR state
preservation. Can't have both because ``st.switch_page`` (soft nav,
preserves state) needs a real Streamlit button widget, and Streamlit
widgets can't be reliably CSS-positioned to the viewport bottom —
Streamlit owns the widget DOM and remounts it on every rerun.

State preservation wins. Going back to the pre-sticky design:

- ``render_sticky_footer()`` becomes a no-op shim. Kept as a callable
  so the call sites in every tool page don't have to be touched in
  this commit; the original implementation is preserved as
  ``_render_sticky_footer_DISABLED`` if we ever decide to revisit.
- Every Ready/Coming-Soon tool page (1-9) gets ``back_to_home_link()``
  reinstated near the top of the page (visible at scroll-top) AND
  ``back_to_home_link(key="_back_to_home_link_bottom")`` reinstated
  near the bottom of the page (visible at scroll-bottom). Both
  instances call ``st.switch_page`` via the existing helper — soft
  nav, no full reload, ``st.session_state["home_uploads"]`` and
  every other session-state key survive.

User trades the "always-visible while scrolling" sticky behavior for
the upload-list-survives-navigation behavior. The two-button pattern
(top + bottom) was what we had before the sticky-footer experiment;
on short pages both are visible at once, on long pages the user has
one in reach at either end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-17 02:31:50 +00:00
parent be7191a5d1
commit 7cb1bc922d
10 changed files with 53 additions and 0 deletions

View File

@@ -521,6 +521,32 @@ html_download_button = local_download_button
def render_sticky_footer() -> None:
"""No-op shim.
The previous implementation injected a CSS-positioned ``<a href>``
footer into the page body. It looked nice (always-visible bar at
the viewport bottom) but the click was a FULL-page navigation,
which on the user's Streamlit build doesn't preserve
``st.session_state`` — uploads disappeared after every Back to
Home click. Soft navigation via ``st.switch_page`` requires a
real Streamlit button widget, which we can't reliably
CSS-position to the viewport bottom because Streamlit owns the
widget's DOM container and remounts it on every rerun.
So the sticky footer is retired. Each tool page renders the
real Streamlit-button version of ``back_to_home_link`` near the
top AND near the bottom (the two-instance pattern from before
the sticky-footer attempt), so the button is visible at both
ends of the page without ever risking state loss.
Kept as a callable so existing tool-page imports + call sites
don't have to be touched in this commit — they all resolve to
this no-op.
"""
return
def _render_sticky_footer_DISABLED() -> None:
"""Slim fixed-position footer at the bottom of the viewport.
Contains a "Back to Home" link that's always visible regardless of