feat(nav): ← Back to Home link on every tool page

Multi-file workflow: a user uploads several files on Home, clicks
"Open <Tool>" on one file's findings, lands on a tool page. The
sidebar lets them get back to Home, but a top-of-page back affordance
is more discoverable and keeps the hand in the same screen region as
the upload list they're working through.

- New ``back_to_home_link()`` helper in components/_legacy.py renders
  a secondary button that calls ``st.switch_page("app.py")`` — under
  ``st.navigation`` that routes to the default (Home) page.
- Wired into every tool page (1-9) directly after
  ``hide_streamlit_chrome()`` and BEFORE the license gate so a Lite
  user who lands on a locked tool can navigate away without paying.
- New i18n key ``nav.back_to_home`` ("← Back to Home" /
  "← Volver al inicio") in en/es packs.

2008 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-16 20:38:01 +00:00
parent 604debb9a9
commit 502a72cd46
13 changed files with 42 additions and 2 deletions

View File

@@ -46,6 +46,7 @@ from .activation import ( # noqa: F401 re-exported
__all__ = [
# Shared chrome / pickup
"back_to_home_link",
"hide_streamlit_chrome",
"shutdown_app",
"pickup_or_upload",

View File

@@ -187,6 +187,25 @@ def _farewell_script() -> str:
)
def back_to_home_link(*, key: str = "_back_to_home_link") -> None:
"""Render a small "← Back to Home" affordance near the top of a tool page.
Tool pages reached from the home findings panel benefit from an
explicit return-to-home control so a user working through findings
on multiple uploaded files can hop between files without hunting
through the sidebar.
Implementation note: ``st.switch_page("app.py")`` routes back to the
entry script which, under ``st.navigation``, lands on the default
page (Home). Streamlit's button is used (rather than ``st.page_link``)
because the entry script is a navigation manager, not a registered
Page object, and ``page_link`` to ``app.py`` renders inconsistently
across Streamlit minor versions.
"""
if st.button(_t("nav.back_to_home"), key=key, type="secondary"):
st.switch_page("app.py")
def shutdown_app() -> None:
"""Terminate the Streamlit server immediately, no confirm.