fix(findings): namespace per-tool button keys so multi-file render works

Reported: uploading multiple files on the home page and clicking Run
analysis blew up with

    StreamlitDuplicateElementKey: key='_findings_open_02_text_cleaner'

when two uploaded files both had Clean Text findings.

Root cause: ``render_findings_panel`` is invoked once per uploaded
file from ``_home.py``, but the per-tool jump button used a
filename-agnostic key:

    key=f"_findings_open_{tool_id}"

Two files both flagging Clean Text → two buttons with identical keys
→ Streamlit rejects the second one.

Fix:

- Add ``key_namespace: str = ""`` to ``render_findings_panel``. The
  helper hashes it (sha1 truncated to 8 chars) and appends to every
  button key, so different namespaces produce different keys but the
  same namespace stays stable across reruns.
- The home page now passes the filename:
  ``render_findings_panel(findings, header=f"📄 {name}", key_namespace=name)``.
- The single-call site in ``upload_and_analyze_section`` (the legacy
  helper, only used outside the new home-page path) keeps the default
  empty namespace, which is fine because that path renders findings
  for ONE file at a time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-17 02:17:03 +00:00
parent 1caedbbbc7
commit 36510eee7b
2 changed files with 23 additions and 3 deletions

View File

@@ -250,7 +250,11 @@ def _home_page() -> None:
st.markdown(f"### 📄 {name}")
st.success(t("findings.none"))
else:
render_findings_panel(findings, header=f"📄 {name}")
render_findings_panel(
findings,
header=f"📄 {name}",
key_namespace=name,
)
st.divider()
st.caption(t("chrome.footer"))