-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: command menu disappears after unmounting and mounting copilot widget back #2385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Before Widget unmounted and clear the method of window.clearChainlitCopilotThredId, call the window.clearChainlitCopilotThreadId?.();
@maoguy I don't quite understand this issue. Could you please provide more details? |
ReproduceTo Reproduce,you can try to do that 👇: Possible causeI believe the root cause is that after the plug-in was uninstalled and remounted, no new session was initiated.Therefore the websocket of backend don`t know when should push the new config again.👇 |
@maoguy Oh, understood. I'll take a look at this case during this week. |
The proposed fix in this PR changes the threadId on every remount. I don't believe this is the right fix. |
I believe the plugin should expose configurable lifecycle hooks—such as a "afterMounted" that fires once the plugin is successfully mounted,or a "beforeUnmounted" hook that is invoked right before the plugin is torn down. With either of these two lifecycle hooks available, we could call window.clearChainlitCopilotThreadId inside mountedCallback (to start a fresh session after remount) or inside beforeUnmounted (to clean up the current session before the plugin is torn down), ensuring the thread ID is properly reset. |
I think the root cause is that after the browser-side plugin is unmounted and remounted, the server is unaware of the change, so the WebSocket-based set_commands event is never pushed. |
I believe the correct fix would be to store the set_commands event in the persistence layer—likely by converting it into a Step. |
Could this approach be interpreted as modifying the react-client layer to persist a copy of the commandsState—a global state managed by Recoil—into localStorage?☺ |
Before Widget unmounted and clear the method of window.clearChainlitCopilotThredId, call the window.clearChainlitCopilotThreadId?.();
which can fix the bug : #2384