chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

UI redirects to starter page when editing first message after switching between conversations

Open Sanady opened this issue 1 week ago • 1 comments
trafficstars

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:

  1. Enable chat profiles in your Chainlit application (e.g., Standard/Premium model selection)
  2. Create a new conversation by sending a message (e.g., "Hey")
  3. Wait for the assistant response to complete
  4. Create a second conversation by clicking "New Chat" and sending another message (e.g., "What's up?")
  5. Wait for the assistant response to complete
  6. Switch back to the first conversation using the thread sidebar
  7. Edit the first message in that conversation (change "Hey" to "Hey, what's new?")
  8. Submit the edited message
  9. 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_profiles is 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:

  1. Chat profiles (@cl.set_chat_profiles) - Model/configuration selection UI
  2. Thread switching - Navigating between different conversation threads
  3. 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.

WorkaroundConfirmed 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

  1. Chat profile state management during thread switching
  2. Interaction between profile selection state and message editing workflows
  3. Frontend thread state management when profiles are configured
  4. UI routing logic when processing edited messages with active chat profiles
  5. Starter page trigger conditions in the frontend when multiple state features interact

Sanady avatar Nov 12 '25 13:11 Sanady

Updated post with new findings.

Sanady avatar Nov 13 '25 09:11 Sanady