Update TaskCard.tsx

This commit is contained in:
Sun Tao 2025-11-07 17:29:26 +08:00
parent d18cc9f1fb
commit 2bb4bf877b

View file

@ -332,27 +332,17 @@ export function TaskCard({
onClick={() => {
if (task.agent) {
// Switch to the chatStore that owns this task card (for multi-turn conversations)
if (chatId) {
const activeProjectId = projectStore.activeProjectId;
const activeChatStore = projectStore.getActiveChatStore();
const project = activeProjectId
? projectStore.projects?.[activeProjectId]
: undefined;
if (activeChatStore && project?.chatStores) {
const currentChatId = Object.keys(project.chatStores).find(
(id) => project.chatStores[id] === activeChatStore
) ?? null;
// Only switch if this is a different chat
if (activeProjectId && currentChatId !== chatId) {
projectStore.setActiveChatStore(activeProjectId, chatId);
}
} else if (activeProjectId) {
// If no active chat store, set based on this task
projectStore.setActiveChatStore(activeProjectId, chatId);
}
}
if (chatId && projectStore.activeProjectId) {
const activeChatStore = projectStore.getActiveChatStore();
const currentChatId = activeChatStore ? Object.keys(projectStore.projects[projectStore.activeProjectId].chatStores).find(
id => projectStore.projects[projectStore.activeProjectId].chatStores[id] === activeChatStore
) : null;
// Only switch if this is a different chat
if (currentChatId !== chatId) {
projectStore.setActiveChatStore(projectStore.activeProjectId, chatId);
}
}
// Set the active workspace and agent
chatStore.setActiveWorkSpace(