Describe the bug
I'm using a custom frontend repo and chainlit/react-client lib to establish a WebSocket connection with Chainlit. The issue is that the X-Chainlit-Thread-Id header doesn’t update as expected when I try to set a old thread ID dynamically through idToResume. The header only updates correctly if the page is refreshed. Without a refresh, the header retains an old value or fails to set the new thread ID, resulting in a new connection without the intended idToResume value in the header.
According to my understanding :
IdToResume hook sets the X-Chainlit-Thread-Id header and setIdtoResume from chatInteract can be used to set IdToResume.
Accordinglt whenever IdToResume changes sessionstate recoil state(if you are using one) should get updated right? but it only happens when i reload/refresh the page.
To Reproduce
Steps to reproduce the behavior:
Open the custom frontend and initiate a WebSocket connection with a specific idToResume set in the headers.
Click on an item or perform an action that updates idToResume and should trigger a new WebSocket connection with the updated X-Chainlit-Thread-Id.
Observe that the header does not update as expected and either has an empty X-Chainlit-Thread-Id or retains the old value.
Refresh the page and note that the header is then correctly updated with the intended idToResume.
Expected behavior
The X-Chainlit-Thread-Id header should update dynamically whenever idToResume is changed, without requiring a page refresh to set the new thread ID properly in the WebSocket connection.
I am looking for guidance on the best way to dynamically set X-Chainlit-Thread-Id without refreshing the page each time idToResume is updated. Is there a recommended way to ensure the WebSocket connection uses the updated idToResume header immediately upon reconnecting?
I tried using clear() and disconnect but still facing difficulties in trying to get the header updated when reconnecting to the old chat using Idtoresume hook, though the same functionality works when i reload the page.
Describe the bug I'm using a custom frontend repo and chainlit/react-client lib to establish a WebSocket connection with Chainlit. The issue is that the X-Chainlit-Thread-Id header doesn’t update as expected when I try to set a old thread ID dynamically through idToResume. The header only updates correctly if the page is refreshed. Without a refresh, the header retains an old value or fails to set the new thread ID, resulting in a new connection without the intended idToResume value in the header.
According to my understanding : IdToResume hook sets the X-Chainlit-Thread-Id header and setIdtoResume from chatInteract can be used to set IdToResume. Accordinglt whenever IdToResume changes sessionstate recoil state(if you are using one) should get updated right? but it only happens when i reload/refresh the page.
To Reproduce Steps to reproduce the behavior:
I am looking for guidance on the best way to dynamically set X-Chainlit-Thread-Id without refreshing the page each time idToResume is updated. Is there a recommended way to ensure the WebSocket connection uses the updated idToResume header immediately upon reconnecting? I tried using clear() and disconnect but still facing difficulties in trying to get the header updated when reconnecting to the old chat using Idtoresume hook, though the same functionality works when i reload the page.