Skip to content

fix: isolate chat threads per agent on switch#43

Merged
rogerchappel merged 1 commit into
mainfrom
fix/chat-thread-bleed-on-agent-switch
Apr 4, 2026
Merged

fix: isolate chat threads per agent on switch#43
rogerchappel merged 1 commit into
mainfrom
fix/chat-thread-bleed-on-agent-switch

Conversation

@rogerchappel
Copy link
Copy Markdown
Owner

Summary

  • Clear message state immediately when switching agents in the chat dropdown, preventing the previous agent's conversation from bleeding into the new agent's view
  • Root cause: handleAgentSelect updated selectedAgent without clearing messages, 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

  • Open chat, send messages to Agent A
  • Switch to Agent B via dropdown — verify Agent A's messages disappear immediately
  • Switch back to Agent A — verify Agent A's messages reload from cache
  • Switch to an agent with no chat history — verify empty state shown, not previous agent's thread

🤖 Generated with Claude Code

Copy link
Copy Markdown
Owner Author

@rogerchappel rogerchappel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@rogerchappel rogerchappel force-pushed the fix/chat-thread-bleed-on-agent-switch branch from 7154e9b to dae83c2 Compare April 4, 2026 21:23
@rogerchappel rogerchappel merged commit 1bb05dc into main Apr 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant