anyone else get this issue in the chatbot app where the header is replicated after you type your first question into the chatbot? it only happens on the first one, where there’s empty screen space, but it looks really bad.
If you’re creating a debugging post, please include the following info:
Share the link to the public app (deployed on Community Cloud).
Share the link to your app’s public GitHub repository (including a requirements file).
Share the full text of the error message (not a screenshot).
I fixed this by only showing the header if a question has not yet been asked.
Only show header/description if there are no user messages yet
if not any(msg[“role”] == “user” for msg in st.session_state.messages):
st.title(“Paul’s Chatbot v0.5”)
st.markdown(“”"
This chatbot can answer questions about your documents.
Ask any question about the content in your documents! This demo is focused on a psychology book. Ask it questions about how the human brain works, how to stick with a habit, or how we are easily fooled.
“”")
Just fyi, this is called a stale element. When Streamlit reruns, it “stales” everything on the page and draws over everything in order. (This is for efficiency so it’s not reconstructing everything on the front end from scratch if it doesn’t have to.) Only when it gets to the end of the script run does Streamlit discard any leftover stale elements. That means when you remove an element from one run to the next and have a longer script run, you may see a lingering stale element. This often happens when you use spinners, for example, because they exist on one script run and not the next.
Appreciate the explanation.
Are you saying there’s no known fix? Or is it the spinner that’s causing it?
It’s a weird one because it doesn’t happen every time, I tried a couple of fixes and thought I’d got it, but then it randomly pops back. It looks kinda clunky, especially on people’s first impression of using it.
The fact that it’s transparent is interesting, if something knows it needs to make it transparent, can’t we make it so that something makes it invisible until/unless its actually required or before its deleted?
Thanks for the reply.
You can fix it, but it requires boilerplate code to manually clear out the element or make sure there is a null replacement for the missing element on the rerun.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.