fix(sidebar): 创建新对话后侧边栏类型过滤器不联动致多智能体对话错位显示
- send.ts:占位对话按新建类型插入对应过滤器缓存并同步切换 sidebarConversationType - mode.ts:输入栏类型选择器切换时联动 setSidebarConversationType(纯本地零请求)
This commit is contained in:
parent
1b775545cc
commit
c79c64aad0
@ -286,12 +286,6 @@ export const sendMethods = {
|
|||||||
targetConversationId = createResult.conversation_id;
|
targetConversationId = createResult.conversation_id;
|
||||||
// 创建即定型:落地对话类型(与后端 metadata 保持一致)
|
// 创建即定型:落地对话类型(与后端 metadata 保持一致)
|
||||||
this.currentConversationType = isMultiAgent ? 'multi_agent' : 'normal';
|
this.currentConversationType = isMultiAgent ? 'multi_agent' : 'normal';
|
||||||
try {
|
|
||||||
const { useConversationStore } = await import('../../../stores/conversation');
|
|
||||||
useConversationStore().$patch({ multiAgentMode: isMultiAgent });
|
|
||||||
} catch (_e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
this.skipConversationHistoryReload = true;
|
this.skipConversationHistoryReload = true;
|
||||||
this.currentConversationId = targetConversationId;
|
this.currentConversationId = targetConversationId;
|
||||||
this.currentConversationTitle = '新对话';
|
this.currentConversationTitle = '新对话';
|
||||||
@ -302,36 +296,61 @@ export const sendMethods = {
|
|||||||
total_messages: 0,
|
total_messages: 0,
|
||||||
total_tools: 0
|
total_tools: 0
|
||||||
};
|
};
|
||||||
this.conversations.splice(
|
// 新建对话的类型同时决定侧边栏过滤器目标类型
|
||||||
0,
|
const targetType = isMultiAgent ? 'multi_agent' : 'normal';
|
||||||
this.conversations.length,
|
|
||||||
newPlaceholder,
|
|
||||||
...this.conversations.filter((conv) => conv && conv.id !== targetConversationId)
|
|
||||||
);
|
|
||||||
|
|
||||||
// 分组视图下同步到当前工作区
|
|
||||||
try {
|
try {
|
||||||
const { useConversationStore } = await import('../../../stores/conversation');
|
const { useConversationStore } = await import('../../../stores/conversation');
|
||||||
const conversationStore = useConversationStore();
|
const conversationStore = useConversationStore();
|
||||||
const currentWorkspaceId = this.currentHostWorkspaceId;
|
conversationStore.$patch({ multiAgentMode: isMultiAgent });
|
||||||
if (currentWorkspaceId) {
|
|
||||||
conversationStore.ensureWorkspaceGroup(currentWorkspaceId);
|
// 占位对话按「新建类型」插入对应过滤器缓存(而非当前过滤器类型的缓存),
|
||||||
const group = conversationStore.workspaceGroups.find(
|
// 并同步切换侧边栏「智能体/多智能体」过滤器,避免创建后错位显示(需刷新才归位)。
|
||||||
(g: any) => g.workspaceId === currentWorkspaceId
|
const targetCache = conversationStore.conversationsCache[targetType];
|
||||||
);
|
targetCache.list.splice(
|
||||||
if (group) {
|
0,
|
||||||
group.conversations.splice(
|
targetCache.list.length,
|
||||||
0,
|
newPlaceholder,
|
||||||
group.conversations.length,
|
...targetCache.list.filter((conv: any) => conv && conv.id !== targetConversationId)
|
||||||
newPlaceholder,
|
);
|
||||||
...group.conversations.filter((conv: any) => conv.id !== targetConversationId)
|
if (conversationStore.sidebarConversationType !== targetType) {
|
||||||
|
conversationStore.setSidebarConversationType(targetType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分组视图下同步到当前工作区(同样按目标类型缓存落位)
|
||||||
|
try {
|
||||||
|
const currentWorkspaceId = this.currentHostWorkspaceId;
|
||||||
|
if (currentWorkspaceId) {
|
||||||
|
conversationStore.ensureWorkspaceGroup(currentWorkspaceId);
|
||||||
|
const group = conversationStore.workspaceGroups.find(
|
||||||
|
(g: any) => g.workspaceId === currentWorkspaceId
|
||||||
);
|
);
|
||||||
group.expanded = true;
|
if (group) {
|
||||||
group.visibleOffset = 0;
|
const groupList = group.conversationsByType?.[targetType];
|
||||||
group.visibleLimit = 5;
|
if (groupList) {
|
||||||
|
groupList.splice(
|
||||||
|
0,
|
||||||
|
groupList.length,
|
||||||
|
newPlaceholder,
|
||||||
|
...groupList.filter((conv: any) => conv && conv.id !== targetConversationId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
group.expanded = true;
|
||||||
|
group.visibleOffset = 0;
|
||||||
|
group.visibleLimit = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_err) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
// 目标类型缓存从未加载过时走切换补载:placeholder 会被真实列表全量覆盖,
|
||||||
|
// 新创建对话在后端 updated_at 最新仍在顶部,不会重复也不会丢失。
|
||||||
|
if (!conversationStore.conversationsCache[targetType].loaded) {
|
||||||
|
if (typeof this.handleSidebarConversationTypeChange === 'function') {
|
||||||
|
this.handleSidebarConversationTypeChange(targetType).catch(() => {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_err) {
|
} catch (_e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -138,11 +138,24 @@ export const modeMethods = {
|
|||||||
this.inputCloseMenus?.();
|
this.inputCloseMenus?.();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleSelectNewConversationType(type) {
|
async handleSelectNewConversationType(type) {
|
||||||
const normalized = type === 'multi_agent' ? 'multi_agent' : 'agent';
|
const normalized = type === 'multi_agent' ? 'multi_agent' : 'agent';
|
||||||
this.newConversationType = normalized;
|
this.newConversationType = normalized;
|
||||||
persistNewConversationType(normalized);
|
persistNewConversationType(normalized);
|
||||||
this.agentTypeMenuOpen = false;
|
this.agentTypeMenuOpen = false;
|
||||||
|
// 选择即联动:同步切换侧边栏「智能体/多智能体」过滤器(纯本地引用交换、零请求)。
|
||||||
|
// 选择器仅在空对话可用(有对话时禁用展示态),此处置空判断作防御;
|
||||||
|
// 进入已有对话后两个状态保持解耦,互不干扰。
|
||||||
|
if (!this.currentConversationId) {
|
||||||
|
try {
|
||||||
|
const { useConversationStore } = await import('../../../stores/conversation');
|
||||||
|
useConversationStore().setSidebarConversationType(
|
||||||
|
normalized === 'multi_agent' ? 'multi_agent' : 'normal'
|
||||||
|
);
|
||||||
|
} catch (_e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
toggleModeMenu() {
|
toggleModeMenu() {
|
||||||
if (!this.isConnected || this.streamingMessage) {
|
if (!this.isConnected || this.streamingMessage) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user