From b6c049158dfe5805c790774edaa0c692b79d2489 Mon Sep 17 00:00:00 2001 From: Madhu Nunna Date: Mon, 9 Mar 2026 09:30:38 -0700 Subject: [PATCH 1/4] fix: remove uninitialized details_placeholder reference in app_streaming.py In app_streaming.py, details_placeholder was checked in session state but never initialized, causing AttributeError on newer Streamlit versions. Unlike app.py which properly initializes it, app_streaming.py has no use for it. Removed the dead code block. Fixes #140 --- 04-UX-demos/01-streamlit-template/docker_app/app_streaming.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py b/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py index b6cd1fc3..75265000 100644 --- a/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py +++ b/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py @@ -85,10 +85,6 @@ def logout(): # Add user message to chat history st.session_state.messages.append({"role": "user", "content": prompt}) - # Clear previous tool usage details - if "details_placeholder" in st.session_state: - st.session_state.details_placeholder.empty() - # Display user message with st.chat_message("user"): st.write(prompt) From b35917128da5bb74ada39a68dffe9bbb04f273c7 Mon Sep 17 00:00:00 2001 From: Madhu Nunna Date: Mon, 30 Mar 2026 11:07:52 -0700 Subject: [PATCH 2/4] fix(streamlit): Initialize details_placeholder at startup Initialize details_placeholder in session state at app startup to prevent uninitialized reference errors while preserving the cleanup behavior that prevents stale tool details from persisting across prompts. This addresses feedback on PR-232 by using the safer approach of initializing the placeholder rather than removing the cleanup call. --- 04-UX-demos/01-streamlit-template/docker_app/app_streaming.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py b/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py index 75265000..74cb50a4 100644 --- a/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py +++ b/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py @@ -15,6 +15,10 @@ if "messages" not in st.session_state: st.session_state.messages = [] +# Initialize details placeholder +if "details_placeholder" not in st.session_state: + st.session_state.details_placeholder = st.empty() + # ID of Secrets Manager containing cognito parameters secrets_manager_id = Config.SECRETS_MANAGER_ID From 6f1eeb4ae9c29b312916e2293d47b88da0f3932d Mon Sep 17 00:00:00 2001 From: Madhu Nunna Date: Mon, 30 Mar 2026 11:17:23 -0700 Subject: [PATCH 3/4] fix(streamlit): Restore cleanup call for details_placeholder Add back the cleanup call that clears details_placeholder between prompts. The previous commit only added initialization but missed restoring the cleanup behavior that prevents stale tool details from persisting. Now the fix properly: - Initializes details_placeholder at startup (prevents crash) - Clears it before each new prompt (prevents stale content) --- 04-UX-demos/01-streamlit-template/docker_app/app_streaming.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py b/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py index 74cb50a4..39e5f311 100644 --- a/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py +++ b/04-UX-demos/01-streamlit-template/docker_app/app_streaming.py @@ -89,6 +89,10 @@ def logout(): # Add user message to chat history st.session_state.messages.append({"role": "user", "content": prompt}) + # Clear previous tool usage details + if "details_placeholder" in st.session_state: + st.session_state.details_placeholder.empty() + # Display user message with st.chat_message("user"): st.write(prompt) From ef37c440c60d24bfde9a55487d680daa2d99b7b2 Mon Sep 17 00:00:00 2001 From: Madhu Nunna Date: Mon, 30 Mar 2026 17:28:06 -0700 Subject: [PATCH 4/4] chore: add Madhu Nunna to CONTRIBUTORS.md --- CONTRIBUTORS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 816ff856..0e2a6683 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -14,4 +14,5 @@ - [Evandro Franco](https://github.com/evandrofranco) - [Sanghwa Na](https://github.com/didhd) - [Neelam Koshiya](https://github.com/neelamkoshiya) -- [Asif Mithawala](https://github.com/asifma) \ No newline at end of file +- [Asif Mithawala](https://github.com/asifma) +- [Madhu Nunna](https://github.com/madhununna) \ No newline at end of file