From bd628b062e281a0c945fe94ffc055389fc3d8cb2 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sun, 22 Feb 2026 17:01:50 +0100 Subject: [PATCH] Clear stale file selector when navigating to empty folder Removes leftover file_selector and loaded_file state when the current directory has no JSON files, preventing stale data from persisting. Co-Authored-By: Claude Opus 4.6 --- app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app.py b/app.py index 77f739e..5ac1bd9 100644 --- a/app.py +++ b/app.py @@ -162,6 +162,9 @@ with st.sidebar: selected_file_name = st.radio("Select File", file_names, key="file_selector") else: st.info("No JSON files in this folder.") + if 'file_selector' in st.session_state: + del st.session_state.file_selector + st.session_state.loaded_file = None # --- GLOBAL MONITOR TOGGLE (NEW) --- st.markdown("---")