Skip to content

Fix: show feedback on first assistant message in e2e-chatbot-app#226

Open
noramxiao wants to merge 3 commits into
mainfrom
fix/streamlit-first-message-feedback
Open

Fix: show feedback on first assistant message in e2e-chatbot-app#226
noramxiao wants to merge 3 commits into
mainfrom
fix/streamlit-first-message-feedback

Conversation

@noramxiao
Copy link
Copy Markdown

@noramxiao noramxiao commented May 30, 2026

Problem

In the Streamlit e2e-chatbot-app, the thumbs up/down feedback widget doesn't appear on the first assistant message until another request is sent (reported in #42).

Why: chat history is rendered at the top of the script (app.py:101-103), and AssistantResponse.render() is what attaches the feedback widget (messages.py:58-59). But a new response is appended to history after that loop (app.py:336) and streamed inline via render_message() only — which has no feedback. Streamlit doesn't rerun on its own after the input handler, so the feedback control for the new message isn't drawn until the next user interaction triggers a rerun.

Fix

st.session_state.history.append(assistant_response)
st.rerun()

st.rerun() after appending re-renders the new response through the history loop, which attaches feedback immediately. Applies to all three task types since it's after query_endpoint_and_render() returns.

Testing

I ran the app under Streamlit's headless AppTest (streamlit==1.44.1) with the serving endpoint mocked, submitted a single message, and inspected the rendered element tree for the feedback widget (Streamlit renders st.feedback as a ButtonGroup keyed feedback_*):

app.py Result after one message
with st.rerun() (this PR) feedback widget present
with st.rerun() removed feedback widget absent — reproduces #42

So the fix demonstrably makes the feedback control appear on the first assistant message in a single turn, and its removal reproduces the original bug.

Fixes #42

noramxiao added 3 commits May 30, 2026 00:24
Chat history (including the feedback widget rendered by AssistantResponse) is
drawn at the top of the script, but a new response is appended to history
*after* that loop and streamed inline without feedback. Streamlit doesn't
rerun on its own, so the feedback control was missing on the first message
until the next request triggered a rerun. Call st.rerun() after appending the
response so it re-renders through the history loop with feedback attached.

Fixes #42

Co-authored-by: Isaac
Sends one message through a mocked endpoint and asserts the feedback widget
(rendered by AssistantResponse via the history loop) is present after a single
submission. Fails without the st.rerun() fix, passes with it.

Co-authored-by: Isaac
The fix was verified manually (AppTest before/after) rather than shipping a
test file, since the streamlit template has no existing test harness.

Co-authored-by: Isaac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In e2e-chatbot-app template the first message does not show feedback option until one more request is made

1 participant