Sometimes using if prompt := st.chat_input resets the page

I was using the if prompt := st.chat_input to collect chat input as shown in an example but sometimes (not all the time) the page view is reloaded… jumping to the top of the page and then to the bottom. When the chat gets long it is unsettling to suddenly see the whole content jump to the top and then scroll to the bottom.

Some of the comments in the forum suggest that if prompt := st.chat_input is the best way to get user input for chat. Any suggestions?

This happens even with the basic echo chat demo code… just keep adding a bunch of dummy messages and then it starts jumping to the top of the page (Chrome, streamlit 1.30). Build a basic LLM chat app - Streamlit Docs

Seems a little better in 1.31… still checking though.

The correct term is rerun the code from top to bottom.

Yes chat_input does that and that is normal.

Chat elements/widgets such as chat_input and chat_message are designed for conversational apps. This is driven by the ChatGPT chatting revolution.

The page reload / rerunning of the code did not always happen, 1 time for each 10-15 chat inputs. I figured it would always happen or never happen, not occasionally. In any case with 1.31, it looks like we can now package these parts into containers / other elements. Looking forward to testing that out.