chainlit
chainlit copied to clipboard
UI redirects to starter page when editing first message after switching between conversations
Describe the bug
When editing the first message in a conversation after switching between multiple conversations, the UI incorrectly redirects to the starter page instead of displaying the edited conversation. This bug occurs specifically when chat profiles (@cl.set_chat_profiles) are enabled in the application.
To Reproduce Steps to reproduce the behavior:
- Enable chat profiles in your Chainlit application (e.g., Standard/Premium model selection)
- Create a new conversation by sending a message (e.g., "Hey")
- Wait for the assistant response to complete
- Create a second conversation by clicking "New Chat" and sending another message (e.g., "What's up?")
- Wait for the assistant response to complete
- Switch back to the first conversation using the thread sidebar
- Edit the first message in that conversation (change "Hey" to "Hey, what's new?")
- Submit the edited message
- See error: UI redirects to starter page instead of showing the edited conversation
Expected behavior After editing the first message, the conversation should continue normally with:
- The edited user message displayed
- The assistant processing and responding to the edited message
- The conversation remaining in the same thread without redirecting to starter page
Screenshots
Technical Details
- Chainlit Version: 2.8.4 and 2.9.0 (tested on both)
- Backend Framework: Python with SQLAlchemy data layer
- Authentication: OAuth (Microsoft Entra ID)
- Database: PostgreSQL
- Feature Combination: Bug only occurs when
@cl.set_chat_profilesis configured
Desktop (please complete the following information):
- OS: macOS
- Browser: Chrome/Safari
- Version: Latest
Root Cause Analysis Through systematic debugging and testing, we identified that the bug is caused by an interaction between three Chainlit features:
- Chat profiles (
@cl.set_chat_profiles) - Model/configuration selection UI - Thread switching - Navigating between different conversation threads
- First message editing - Editing the initial message in a conversation
When all three features are combined in this specific workflow, Chainlit's frontend state management incorrectly triggers a redirect to the starter page.
Workaround
✅ Confirmed workaround: Removing @cl.set_chat_profiles completely resolves the issue. With chat profiles disabled, first message editing after thread switching works correctly without any starter page redirects.
Backend Investigation Results Extensive debugging confirmed this is a frontend-only issue - the backend processes everything correctly:
✅ Backend processing works perfectly:
- Thread metadata loads correctly (messages restored properly)
- Message editing logic works correctly (truncates history as expected)
- API calls succeed (HTTP 200 OK responses)
- Database persistence works correctly
- Session state management works correctly
✅ Test results:
- With chat profiles enabled: Bug reproduces consistently
- With chat profiles disabled: Bug does not occur, editing works perfectly
Additional context
- Bug is reproducible across multiple Chainlit versions (2.8.4, 2.9.0)
- Issue only occurs with first message editing after thread switching when chat profiles are enabled
- Regular message editing (non-first messages) works correctly even with chat profiles
- Backend maintains perfect data consistency throughout the process
- The bug appears to be in how the frontend manages the combination of profile state + thread state + message editing state
Suggested Investigation Areas for Chainlit Team
- Chat profile state management during thread switching
- Interaction between profile selection state and message editing workflows
- Frontend thread state management when profiles are configured
- UI routing logic when processing edited messages with active chat profiles
- Starter page trigger conditions in the frontend when multiple state features interact
Updated post with new findings.