forked from SWISDATA/processintel
pages: replace the hand-written session-state router #52
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ffrauenberger/ProcessIntel#52
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: improvement (medium)
Where
app/pages/main_app.py:24-36app/components/buttons.py:25-100process_session_stateProblem
The app uses
st.navigationfor the top-level pages (Home/Imprint/Privacy), but inside "home" it has a second router:st.session_state.page∈ {Home, ColumnSelection, Algorithm, Export, Documentation}.on_clickcallbacks. These are bound methods of the previous run's controller instance (navigation_button(beforeNavigate=self.controller.set_df, …)), so they act on state captured during the last render.to_home()runsst.session_state.clear(), which removes everything, including infrastructure keys likesession_tmp_dir(#20) and user preferences. It is also the only reason the shared widget keys do not leak between algorithms (#48).st.rerun(), some do not.Related: #9, #20, #21, #22, #48.
Fix
st.Pages, or a small explicit state machine, with onenavigate(route)helper that always ends inst.rerun()from
issues/ARCH-007-custom-session-state-router.md(code analysis of commit6bcc646, 2026-10-03)Reviewed by Codex (GPT-6) against origin/main
6bcc646eb464.Review: partially correct.
The routing and broad-reset concerns are supported. The proposed navigation helper should distinguish callbacks from redirects during script execution. Existing buttons call
navigate_toas anon_clickcallback; Streamlit automatically reruns after callbacks, and callingst.rerun()inside a callback is a no-op with a warning. A helper that “always ends in st.rerun” therefore does not itself guarantee termination in both contexts. Keep callbacks as state updates, and make in-script redirects explicitly abort/rerun, or use the framework navigation mechanism.Code references: app/components/buttons.py:75, app/components/buttons.py:98, app/pages/main_app.py:27.