fix(sidebar): one new chat, retargeted — stop spawning empty chats per agent click#4474
Open
vibegui wants to merge 2 commits into
Open
fix(sidebar): one new chat, retargeted — stop spawning empty chats per agent click#4474vibegui wants to merge 2 commits into
vibegui wants to merge 2 commits into
Conversation
…ent click Clicking between agents created a brand-new empty "New chat" every time (navigateToAgent minted a fresh taskId and the route eagerly created the row), piling up empties. Now there's only ever one new chat: if you're already in an empty "New chat", clicking a different agent re-points that same thread at the new recipient (swaps the ?virtualmcpid the composer sends to) instead of creating another. Only starts a fresh chat when you're not already in one. Also derive the active-agent highlight from the URL virtualmcpid (falling back to the thread row) so it stays in sync after an in-place retarget, and factor the empty-thread check shared with the new-thread button. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Re-pointing an empty new chat now persists the new agent onto the thread row (optimistically + via COLLECTION_THREADS_UPDATE), so the sidebar row icon follows the agent you clicked instead of showing the create-time agent. Adds virtual_mcp_id to ThreadUpdateDataSchema + the update tool/storage mapping, and a ThreadManagerStore.setAgent method. The UI only calls it for unsent "New chat" threads (guarded in handleOpenAgent). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Clicking back and forth between agents in the sidebar spawned a new empty "New chat" every time — the list filled up with duplicates. Root cause:
useNavigateToAgentmints a freshtaskIdon every click and the destination route eagerly creates that thread row (useEnsureTask).Fix
There is only ever one new chat. If you're already sitting in an empty "New chat", clicking a different agent re-points that same thread at the new recipient (swaps the
?virtualmcpidthe composer/run sends to) instead of creating another empty thread. It only starts a fresh chat when you're not already in one.handleOpenAgent: when the active thread is an empty "New chat", reuse itstaskIdand set the recipient to the clicked agent (setTaskId), elsenavigateToAgentas before.virtualmcpid(falling back to the thread row), so it stays correct after an in-place retarget.isThreadEmptycheck (also used by the new-thread button).The send path already targets the URL param agent (
agent: { id: capturedVirtualMcpId }), so retargeting an unsent chat routes the first message to the right agent.Testing
tsc --noEmitclean,bun run lintclean, client build passes.🤖 Generated with Claude Code
Summary by cubic
Stops creating duplicate empty "New chat" threads when switching agents. Reuses the current unsent chat, retargets its recipient, and updates the thread row’s agent icon so only one new chat exists.
taskId, retarget the recipient on agent click, and persist the new agent to the row (setAgent→COLLECTION_THREADS_UPDATE) so the sidebar icon follows; otherwise navigate as before.virtualmcpid(fallback to thread) to keep the sidebar highlight correct after retargeting. UsesuseSearchfrom@tanstack/react-router.virtual_mcp_idtoThreadUpdateDataSchemaand storage/update mappings,ThreadManagerStore.setAgentanduseThreadActions.setAgent, plus a sharedisThreadEmptycheck to verify unsent chats.Written for commit 455da2c. Summary will update on new commits.