🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix: skip sendMessageInServer in Gateway mode + NavItem loading fix + i18n (#13681)
Arvin Xu4d7cbfea8ebe
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 629020b39c3..a6ba5c008d1 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -229,6 +229,7 @@"operation.contextCompression": "Context too long, compressing history...","operation.execAgentRuntime": "Preparing response","operation.execClientTask": "Executing task",+ "operation.execServerAgentRuntime": "Running… You can switch tasks or close the page—I'll keep going.","operation.sendMessage": "Sending message","owner": "Group owner","pageCopilot.title": "Page Agent",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 7a2a9d04ee7..6bed9d2a32b 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -229,6 +229,7 @@"operation.contextCompression": "上下文过长,正在压缩历史记录……","operation.execAgentRuntime": "准备响应中","operation.execClientTask": "执行任务中",+ "operation.execServerAgentRuntime": "运行中…你可以切换任务或关闭页面,我会继续执行。","operation.sendMessage": "消息发送中","owner": "群主","pageCopilot.title": "文稿助理",diff --git a/src/features/NavPanel/components/NavItem.tsx b/src/features/NavPanel/components/NavItem.tsxindex 0339174e6ab..c245fc6a242 100644--- a/src/features/NavPanel/components/NavItem.tsx+++ b/src/features/NavPanel/components/NavItem.tsx@@ -107,7 +107,7 @@ const NavItem = memo<NavItemProps>(if (href && !isModifierClick(e)) {e.preventDefault();}- if (disabled || loading) return;+ if (disabled) return;onClick?.(e);}}{...linkProps}diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.tsindex 98700d2adaf..916de99d324 100644--- a/src/locales/default/chat.ts+++ b/src/locales/default/chat.ts@@ -248,6 +248,8 @@ export default {'operation.contextCompression': 'Context too long, compressing history...','operation.execAgentRuntime': 'Preparing response','operation.execClientTask': 'Executing task',+ 'operation.execServerAgentRuntime':+ 'Running… You can switch tasks or close the page — the task will keep going.','operation.sendMessage': 'Sending message','owner': 'Group owner','pageCopilot.title': 'Page Agent',diff --git a/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts b/src/store/chat/slices/aiChat/actions/conversationLifecycle.tsindex 925f83b4f57..d623310cffa 100644--- a/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts+++ b/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts@@ -340,6 +340,31 @@ export class ConversationLifecycleActionImpl {inputSendErrorMsg: undefined,});+ // ── Gateway mode: skip sendMessageInServer, let execAgentTask handle everything ──+ if (this.#get().isGatewayModeEnabled()) {+ this.#get().completeOperation(operationId);++ try {+ const result = await this.#get().executeGatewayAgent({+ context: operationContext,+ message,+ });++ return {+ assistantMessageId: result.assistantMessageId,+ userMessageId: result.userMessageId,+ };+ } catch (e) {+ console.error('[Gateway] Failed to start server-side agent:', e);+ this.#get().failOperation(operationId, {+ message: e instanceof Error ? e.message : 'Unknown error',+ type: 'GatewayError',+ });+ return;+ }+ }++ // ── Client mode: send via server API then run agent locally ──let data: SendMessageServerResponse | undefined;try {const { model, provider } = agentSelectors.getAgentConfigById(agentId)(getAgentStoreState());@@ -582,32 +607,7 @@ export class ConversationLifecycleActionImpl {}}- // ── AI execution ──-- // Gateway mode: server-side execution via WebSocket (opt-in via Labs toggle)- if (this.#get().isGatewayModeEnabled()) {- try {- await this.#get().executeGatewayAgent({- assistantMessageId: data.assistantMessageId,- context: execContext,- message,- parentOperationId: operationId,- topicId: data.topicId,- userMessageId: data.userMessageId,- });- } catch (e) {- console.error('[Gateway] Failed to start server-side agent:', e);- if (data.topicId) this.#get().internal_updateTopicLoading(data.topicId, false);- }-- return {- assistantMessageId: data.assistantMessageId,- createdThreadId: data.createdThreadId,- userMessageId: data.userMessageId,- };- }-- // Client mode: run agent loop locally+ // ── AI execution (client mode) ──{const displayMessages = displayMessageSelectors.getDisplayMessagesByKey(messageMapKey(execContext),diff --git a/src/store/chat/slices/aiChat/actions/gateway.ts b/src/store/chat/slices/aiChat/actions/gateway.tsindex 55d2b6d8c2e..7a5783fd5a4 100644--- a/src/store/chat/slices/aiChat/actions/gateway.ts+++ b/src/store/chat/slices/aiChat/actions/gateway.ts@@ -1,4 +1,4 @@-import type { ConversationContext } from '@lobechat/types';+import type { ConversationContext, ExecAgentResult } from '@lobechat/types';import type {AgentStreamClientOptions,@@ -169,20 +169,27 @@ export class GatewayActionImpl {* Execute agent task via Gateway WebSocket.* Call isGatewayModeEnabled() first to check availability.*/+ /**+ * Execute agent task via Gateway WebSocket.+ * The backend creates user + assistant messages and the topic (if needed).+ * Returns the result so the caller can handle topic switching.+ */+ /**+ * Execute agent task via Gateway WebSocket.+ * The backend creates user + assistant messages and the topic (if needed),+ * then starts the agent. This method handles topic switching and WebSocket connection.+ */executeGatewayAgent = async (params: {- assistantMessageId: string;context: ConversationContext;message: string;- parentOperationId: string;- topicId?: string;- userMessageId: string;- }): Promise<void> => {- const { assistantMessageId, context, message, parentOperationId, topicId, userMessageId } =- params;+ }): Promise<ExecAgentResult> => {+ const { context, message } = params;const agentGatewayUrl =window.global_serverConfigStore!.getState().serverConfig.agentGatewayUrl!;+ const isCreateNewTopic = !context.topicId;+const result = await aiAgentService.execAgentTask({agentId: context.agentId,appContext: {@@ -191,24 +198,33 @@ export class GatewayActionImpl {threadId: context.threadId,topicId: context.topicId,},- existingMessageIds: [userMessageId, assistantMessageId],prompt: message,});+ // If server created a new topic, switch to it and clean up the _new key temp messages+ if (isCreateNewTopic && result.topicId) {+ await this.#get().switchTopic(result.topicId, { clearNewKey: true });+ }++ // Use the server-created topicId for the execution context+ const execContext = { ...context, topicId: result.topicId };++ if (result.topicId) {+ this.#get().internal_updateTopicLoading(result.topicId, true);+ }+// Create a dedicated operation for gateway execution with correct contextconst { operationId: gatewayOpId } = this.#get().startOperation({- context,- parentOperationId,+ context: execContext,type: 'execServerAgentRuntime',});- // Associate the initial assistant message with the gateway operation- // so the UI shows loading/generating state via the operation system- this.#get().associateMessageWithOperation(assistantMessageId, gatewayOpId);+ // Associate the server-created assistant message with the gateway operation+ this.#get().associateMessageWithOperation(result.assistantMessageId, gatewayOpId);const eventHandler = createGatewayEventHandler(this.#get, {- assistantMessageId,- context,+ assistantMessageId: result.assistantMessageId,+ context: execContext,operationId: gatewayOpId,});@@ -217,11 +233,13 @@ export class GatewayActionImpl {onEvent: eventHandler,onSessionComplete: () => {this.#get().completeOperation(gatewayOpId);- if (topicId) this.#get().internal_updateTopicLoading(topicId, false);+ if (result.topicId) this.#get().internal_updateTopicLoading(result.topicId, false);},operationId: result.operationId,token: result.token || '',});++ return result;};private internal_cleanupGatewayConnection = (operationId: string): void => {