refactor(gui): drop Review page + normalization gate
Home is now the only entry point: the "Run analysis" button on the upload section IS the review step (findings render inline via render_findings_panel). Tool pages no longer gate on a passed normalization — running the analyzer is sufficient context. Removed: - src/gui/pages/0_Review.py - src/gui/components/gate.py (re-export seam) - require_normalization_gate() in src/gui/components/_legacy.py - "review" section enum in tools_registry.py - Data Review entry in app.py navigation - require_normalization_gate() calls + imports in all nine tool pages - tests/gui/test_gate.py (whole file) - TestReviewWorkflow in tests/gui/test_workflows.py - 0_Review entry in tests/gui/test_smoke.py PAGE_SLUGS - stash_upload's normalization_result+normalization_for stashing - stash_upload_without_gate (was the gate's negative-path helper) 2017 tests pass (16 retired with the gate flow). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,14 +11,13 @@ they need without dragging the entire kitchen-sink module:
|
||||
components/
|
||||
__init__.py ← compatibility shim (this file)
|
||||
_legacy.py ← original components.py, unchanged
|
||||
gate.py ← gate-only seam (require_normalization_gate)
|
||||
findings.py ← analyzer-finding rendering seam
|
||||
dedup_review.py ← dedup match-group cards + review pipeline
|
||||
shared.py ← chrome / file-pickup helpers used by every tool
|
||||
|
||||
A standalone Find Duplicates build, for example, can ship without
|
||||
``findings.py`` and ``gate.py`` — those modules import the analyzer /
|
||||
gate code that the Lite SKU does not include.
|
||||
``findings.py`` — that module imports the analyzer code that the
|
||||
Lite SKU does not include.
|
||||
|
||||
Adding new tooling: drop new helpers into the appropriate seam module.
|
||||
Add their names to its ``__all__`` and to this file's ``__all__`` if
|
||||
@@ -46,11 +45,10 @@ from .activation import ( # noqa: F401 re-exported
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
# Shared chrome / pickup / gate
|
||||
# Shared chrome / pickup
|
||||
"hide_streamlit_chrome",
|
||||
"quit_button",
|
||||
"pickup_or_upload",
|
||||
"require_normalization_gate",
|
||||
# License gate + activation form
|
||||
"render_activation_form",
|
||||
"render_license_status_sidebar",
|
||||
|
||||
@@ -1264,45 +1264,6 @@ class _StashedUpload:
|
||||
return self._data
|
||||
|
||||
|
||||
def require_normalization_gate() -> None:
|
||||
"""Block the calling tool page until the upload has passed the gate.
|
||||
|
||||
Tool pages should call this immediately after their imports. When the
|
||||
current session upload has not been normalized — no
|
||||
``normalization_result``, the result is for a different upload, or the
|
||||
result didn't pass — the user is shown a banner and a button to jump
|
||||
to the Review page; the rest of the page is short-circuited via
|
||||
``st.stop()``.
|
||||
|
||||
Pages that genuinely don't need a clean dataframe (rare) can opt out
|
||||
by simply not calling this.
|
||||
"""
|
||||
import hashlib
|
||||
has_upload = st.session_state.get("home_uploaded_bytes") is not None
|
||||
if not has_upload:
|
||||
# No upload yet — let the page's own uploader handle it; the gate
|
||||
# will kick in once a file is present.
|
||||
return
|
||||
|
||||
upload_hash = hashlib.sha256(
|
||||
st.session_state["home_uploaded_bytes"]
|
||||
).hexdigest()
|
||||
result = st.session_state.get("normalization_result")
|
||||
matched = (
|
||||
result is not None
|
||||
and st.session_state.get("normalization_for") == upload_hash
|
||||
and getattr(result, "passed", False)
|
||||
)
|
||||
if matched:
|
||||
return
|
||||
|
||||
name = st.session_state.get("home_uploaded_name") or _t("gate.default_name")
|
||||
st.warning(_t("gate.warning", name=name))
|
||||
if st.button(_t("gate.open_review"), type="primary"):
|
||||
st.switch_page("pages/0_Review.py")
|
||||
st.stop()
|
||||
|
||||
|
||||
def pickup_or_upload(
|
||||
*,
|
||||
label: str,
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
"""Normalization-gate guard for tool pages.
|
||||
|
||||
``require_normalization_gate`` short-circuits a tool page when the
|
||||
current upload has not yet passed the gate, redirecting the user to the
|
||||
Review & Normalize page. Pulled into its own seam module so:
|
||||
|
||||
* A build that includes the gate (Pro / Suite SKUs) imports this.
|
||||
* A standalone single-tool build that bypasses the gate can omit this
|
||||
module entirely without removing the helper from a shared file.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from ._legacy import require_normalization_gate
|
||||
|
||||
__all__ = ["require_normalization_gate"]
|
||||
Reference in New Issue
Block a user