fix: isolate chat threads per agent on switch#43
Merged
Conversation
rogerchappel
commented
Apr 4, 2026
Owner
Author
rogerchappel
left a comment
There was a problem hiding this comment.
Sentinel — LGTM ✓
Minimal, surgical fix. Clears messages state immediately on agent switch so the previous agent's thread doesn't flash before the new one loads. saveMessages() for the old agent is already called on the line before, so no data loss.
No issues found.
When switching agents via the dropdown, the previous agent's messages remained visible because setMessages([]) was never called before updating the selected agent. The useEffect that loads the new agent's messages is async, so stale messages from the prior agent would persist until the fetch completed (or indefinitely if no history existed). Closes MC #398 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7154e9b to
dae83c2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
handleAgentSelectupdatedselectedAgentwithout clearingmessages, so stale messages remained visible until the async load effect completed (or permanently if the new agent had no history)Closes MC #398
Test plan
🤖 Generated with Claude Code