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

@@ -22,6 +22,7 @@ from src.license import FeatureFlag
hide_streamlit_chrome()
render_sticky_footer()
back_to_home_link()
from src.audit import log_page_open
log_page_open("7_Multi_File_Merger")
require_feature_or_render_upgrade(FeatureFlag.MULTI_FILE_MERGER)
@@ -98,6 +99,8 @@ st.button("Merge Files", type="primary", use_container_width=True, disabled=True
# Footer
# ---------------------------------------------------------------------------
back_to_home_link(key="_back_to_home_link_bottom")
st.divider()
st.caption(
"Runs locally. Your data never leaves this computer. "