Skip to content

🤯 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.

🌐 chore: translate non-English comments to English in src/store (#12393)

LobeHub Bot5ab874e8773a
diff --git a/src/store/agent/selectors/chatConfigByIdSelectors.ts b/src/store/agent/selectors/chatConfigByIdSelectors.ts
index ac278bf067e..3820dea7e84 100644
--- a/src/store/agent/selectors/chatConfigByIdSelectors.ts
+++ b/src/store/agent/selectors/chatConfigByIdSelectors.ts
@@ -20,12 +20,12 @@ const getEnableHistoryCountById = (agentId: string) => (s: AgentStoreState) => {
const config = agentSelectors.getAgentConfigById(agentId)(s);
const chatConfig = getChatConfigById(agentId)(s);
- // 如果开启了上下文缓存,且当前模型类型匹配,则不开启历史记录
+ // If context caching is enabled and the current model type matches, do not enable history count
const enableContextCaching = !chatConfig.disableContextCaching;
if (enableContextCaching && config?.model && isContextCachingModel(config.model)) return false;
- // 当开启搜索时,针对 claude 3.7 sonnet 模型不开启历史记录
+ // When search is enabled, do not enable history count for the claude 3.7 sonnet model
const searchMode = chatConfig.searchMode || 'auto';
const enableSearch = searchMode !== 'off';
diff --git a/src/store/agent/selectors/chatConfigSelectors.ts b/src/store/agent/selectors/chatConfigSelectors.ts
index 21a6f275ac7..ce628830d3a 100644
--- a/src/store/agent/selectors/chatConfigSelectors.ts
+++ b/src/store/agent/selectors/chatConfigSelectors.ts
@@ -4,7 +4,7 @@ import { type AgentStoreState } from '@/store/agent/initialState';
import { chatConfigByIdSelectors } from './chatConfigByIdSelectors';
-// ============ Current Agent Selectors (复用 chatConfigByIdSelectors) ============ //
+// ============ Current Agent Selectors (reuses chatConfigByIdSelectors) ============ //
const currentChatConfig = (s: AgentStoreState): LobeAgentChatConfig =>
chatConfigByIdSelectors.getChatConfigById(s.activeAgentId || '')(s);
diff --git a/src/store/chat/slices/aiAgent/actions/runAgent.ts b/src/store/chat/slices/aiAgent/actions/runAgent.ts
index 0382e9e76ff..8de0fa89659 100644
--- a/src/store/chat/slices/aiAgent/actions/runAgent.ts
+++ b/src/store/chat/slices/aiAgent/actions/runAgent.ts
@@ -73,10 +73,10 @@ export class AgentActionImpl {
},
});
- // 停止 loading 状态
+ // Stop loading state
this.#get().internal_toggleMessageLoading(false, assistantId);
- // 清理操作 (this will cancel the operation)
+ // Clean up operation (this will cancel the operation)
this.#get().internal_cleanupAgentOperation(assistantId);
};
@@ -92,7 +92,7 @@ export class AgentActionImpl {
return;
}
- // 更新操作元数据
+ // Update operation metadata
this.#get().updateOperationMetadata(operationId, {
lastEventId: event.timestamp.toString(),
stepCount: event.stepIndex,
@@ -108,7 +108,7 @@ export class AgentActionImpl {
}
case 'heartbeat': {
- // 心跳事件,保持连接活跃
+ // Heartbeat event, keeps the connection alive
break;
}
@@ -163,12 +163,12 @@ export class AgentActionImpl {
}
case 'stream_chunk': {
- // 处理流式内容块
+ // Handle streaming content chunk
const { chunkType } = event.data || {};
switch (chunkType) {
case 'text': {
- // 更新文本内容
+ // Update text content
context.content += event.data.content;
log(`Stream(${event.operationId}) chunk type=${chunkType}: `, event.data.content);
@@ -181,7 +181,7 @@ export class AgentActionImpl {
}
case 'reasoning': {
- // 更新文本内容
+ // Update text content
context.reasoning += event.data.reasoning;
log(`Stream(${event.operationId}) chunk type=${chunkType}: `, event.data.reasoning);
@@ -209,7 +209,7 @@ export class AgentActionImpl {
}
case 'stream_end': {
- // 流式结束,更新最终内容
+ // Stream ended, update final content
const { finalContent, toolCalls, reasoning, imageList, grounding } = event.data || {};
log(`Stream ended for ${assistantId}:`, {
hasFinalContent: !!finalContent,
@@ -234,11 +234,11 @@ export class AgentActionImpl {
});
}
- // 停止 loading 状态
+ // Stop loading state
log(`Stopping loading for ${assistantId}`);
this.#get().internal_toggleMessageLoading(false, assistantId);
- // 显示桌面通知
+ // Show desktop notification
if (isDesktop) {
try {
const { desktopNotificationService } =
@@ -282,14 +282,14 @@ export class AgentActionImpl {
const { phase, toolCall, pendingToolsCalling, requiresApproval } = event.data || {};
if (phase === 'human_approval' && requiresApproval) {
- // 需要人工批准
+ // Requires human approval
log(`Human approval required for ${assistantId}:`, pendingToolsCalling);
this.#get().updateOperationMetadata(operationId, {
needsHumanInput: true,
pendingApproval: pendingToolsCalling,
});
- // 停止 loading 状态,等待人工干预
+ // Stop loading state, waiting for human intervention
log(`Stopping loading for human approval: ${assistantId}`);
this.#get().internal_toggleMessageLoading(false, assistantId);
} else if (phase === 'tool_execution' && toolCall) {
@@ -303,10 +303,10 @@ export class AgentActionImpl {
if (phase === 'tool_execution' && result) {
log(`Tool execution completed for ${assistantId} in ${executionTime}ms:`, result);
- // 刷新消息以显示工具结果
+ // Refresh messages to display tool results
await this.#get().refreshMessages();
} else if (phase === 'execution_complete' && finalState) {
- // Agent 执行完成
+ // Agent execution complete
log(`Agent execution completed for ${assistantId}:`, finalState);
this.#get().updateOperationMetadata(operationId, {
finalStatus: finalState.status,
@@ -356,17 +356,17 @@ export class AgentActionImpl {
try {
log(`Handling human intervention ${action} for operation ${messageOpId}:`, data);
- // 发送人工干预请求
+ // Send human intervention request
await agentRuntimeService.handleHumanIntervention({
action: action as any,
data,
operationId: messageOpId,
});
- // 重新开始 loading 状态
+ // Resume loading state
this.#get().internal_toggleMessageLoading(true, assistantId);
- // 清除人工干预状态
+ // Clear human intervention state
this.#get().updateOperationMetadata(messageOpId, {
needsHumanInput: false,
pendingApproval: undefined,
diff --git a/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts b/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts
index 0f566416572..53e0b70d0b0 100644
--- a/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts
+++ b/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts
@@ -156,7 +156,7 @@ export class ConversationLifecycleActionImpl {
},
});
- // 构造服务端模式临时消息的本地媒体预览(优先使用 S3 URL)
+ // Construct local media preview for server-mode temporary messages (S3 URL takes priority)
const filesInStore = getFileStoreState().chatUploadFileList;
const tempImages: ChatImageItem[] = filesInStore
.filter((f) => f.file?.type?.startsWith('image'))
@@ -315,7 +315,7 @@ export class ConversationLifecycleActionImpl {
}
}
} finally {
- // 创建了新topic 或者 用户 cancel 了消息(或者失败了),此时无 data
+ // A new topic was created, or the user cancelled the message (or it failed), so data is absent here
if (data?.isCreateNewTopic || !data) {
this.#get().internal_dispatchMessage(
{ type: 'deleteMessages', ids: [tempId, tempAssistantId] },
diff --git a/src/store/chat/slices/builtinTool/actions/interpreter.ts b/src/store/chat/slices/builtinTool/actions/interpreter.ts
index 8d8ffcffebe..d0642d68ec2 100644
--- a/src/store/chat/slices/builtinTool/actions/interpreter.ts
+++ b/src/store/chat/slices/builtinTool/actions/interpreter.ts
@@ -65,7 +65,7 @@ export class ChatCodeInterpreterActionImpl {
const context = { operationId: interpreterOpId };
try {
- // TODO: 应该只下载 AI 用到的文件
+ // TODO: should only download files used by the AI
const files: File[] = [];
for (const message of dbMessageSelectors.dbUserMessages(this.#get())) {
for (const file of message.fileList ?? []) {
@@ -139,7 +139,7 @@ export class ChatCodeInterpreterActionImpl {
// For other errors, update message
await this.#get().optimisticUpdatePluginState(id, { error }, context);
- // 如果调用过程中出现了错误,不要触发 AI 消息
+ // If an error occurred during the call, do not trigger the AI message
return;
}
};
diff --git a/src/store/chat/slices/builtinTool/actions/search.ts b/src/store/chat/slices/builtinTool/actions/search.ts
index 79a444d209c..de3d61c9978 100644
--- a/src/store/chat/slices/builtinTool/actions/search.ts
+++ b/src/store/chat/slices/builtinTool/actions/search.ts
@@ -31,7 +31,7 @@ export class SearchActionImpl {
const operationId = this.#get().messageOperationMap[id];
const context = operationId ? { operationId } : undefined;
- // 1. 创建一个新的 tool call message
+ // 1. Create a new tool call message
const newToolCallId = `tool_call_${nanoid()}`;
const toolMessage: CreateMessageParams = {
@@ -60,14 +60,14 @@ export class SearchActionImpl {
};
const [result] = await Promise.all([
- // 1. 添加 tool message
+ // 1. Add tool message
optimisticCreateMessage(toolMessage, context),
- // 2. 将这条 tool call message 插入到 ai 消息的 tools 中
+ // 2. Insert this tool call message into the AI message's tools array
addToolItem(),
]);
if (!result) return;
- // 将新创建的 tool message 激活
+ // Activate the newly created tool message
openToolUI(result.id, message.plugin.identifier);
};
@@ -83,10 +83,10 @@ export class SearchActionImpl {
const operationId = this.#get().messageOperationMap[id];
const context = operationId ? { operationId } : undefined;
- // 1. 更新插件参数
+ // 1. Update plugin arguments
await this.#get().optimisticUpdatePluginArguments(id, data, false, context);
- // 2. 通过 invokeBuiltinTool 调用 Tool Store Executor
+ // 2. Call the Tool Store Executor via invokeBuiltinTool
const payload = {
apiName: WebBrowsingApiName.search,
arguments: JSON.stringify(data),
diff --git a/src/store/chat/slices/message/actions/publicApi.ts b/src/store/chat/slices/message/actions/publicApi.ts
index 2aa44e95a41..5aaad5c82d9 100644
--- a/src/store/chat/slices/message/actions/publicApi.ts
+++ b/src/store/chat/slices/message/actions/publicApi.ts
@@ -254,10 +254,10 @@ export class MessagePublicApiActionImpl {
const message = displayMessageSelectors.getDisplayMessageById(id)(this.#get());
if (!message) return;
- // 如果没有传入 collapsed,则取反当前状态
+ // If collapsed is not provided, toggle the current state
const nextCollapsed = collapsed ?? !message.metadata?.collapsed;
- // 直接调用现有的 optimisticUpdateMessageMetadata
+ // Directly call the existing optimisticUpdateMessageMetadata
await this.#get().optimisticUpdateMessageMetadata(id, { collapsed: nextCollapsed }, context);
};
@@ -269,10 +269,10 @@ export class MessagePublicApiActionImpl {
const message = dbMessageSelectors.getDbMessageById(id)(this.#get());
if (!message) return;
- // 如果没有传入 expanded,则取反当前状态
+ // If expanded is not provided, toggle the current state
const nextExpanded = expanded ?? !message.metadata?.inspectExpanded;
- // 直接调用现有的 optimisticUpdateMessageMetadata
+ // Directly call the existing optimisticUpdateMessageMetadata
await this.#get().optimisticUpdateMessageMetadata(
id,
{ inspectExpanded: nextExpanded },
diff --git a/src/store/chat/slices/message/selectors/displayMessage.ts b/src/store/chat/slices/message/selectors/displayMessage.ts
index 9caf631cb71..ce79b6fd44b 100644
--- a/src/store/chat/slices/message/selectors/displayMessage.ts
+++ b/src/store/chat/slices/message/selectors/displayMessage.ts
@@ -68,7 +68,7 @@ const lastDisplayMessageId = (s: ChatStoreState) => {
// ============= Thread Handling ========== //
const getChatsWithThread = (s: ChatStoreState, messages: UIChatMessage[]) => {
- // 如果没有 activeThreadId,则返回所有的主消息
+ // If there is no activeThreadId, return all top-level messages
if (!s.activeThreadId) return messages.filter((m) => !m.threadId);
const thread = s.threadMaps[s.activeTopicId!]?.find((t) => t.id === s.activeThreadId);
diff --git a/src/store/chat/slices/thread/selectors/util.ts b/src/store/chat/slices/thread/selectors/util.ts
index 8e3455a1583..7e386030235 100644
--- a/src/store/chat/slices/thread/selectors/util.ts
+++ b/src/store/chat/slices/thread/selectors/util.ts
@@ -14,12 +14,12 @@ export const genParentMessages = (
) => {
if (!startMessageId) return [];
- // 如果是独立话题模式,则只显示话题开始消息
+ // In standalone thread mode, only show the thread's starting message
if (threadMode === ThreadType.Standalone) {
return messages.filter((m) => m.id === startMessageId);
}
- // 如果是连续模式下,那么只显示话题开始消息和话题分割线
+ // In continuation mode, show only the thread's starting message and the thread divider
const targetIndex = messages.findIndex((item) => item.id === startMessageId);
if (targetIndex < 0) return [];
diff --git a/src/store/chat/slices/topic/reducer.ts b/src/store/chat/slices/topic/reducer.ts
index 8c7730df94c..299661544e3 100644
--- a/src/store/chat/slices/topic/reducer.ts
+++ b/src/store/chat/slices/topic/reducer.ts
@@ -50,7 +50,7 @@ export const topicReducer = (state: ChatTopic[] = [], payload: ChatTopicDispatch
// Only update if the merged value is different from current (excluding updatedAt)
if (!isEqual(currentTopic, mergedTopic)) {
- // TODO: updatedAt 类型后续需要修改为 Date
+ // TODO: updatedAt type needs to be changed to Date later
// @ts-ignore
draftState[topicIndex] = { ...mergedTopic, updatedAt: new Date() };
}
diff --git a/src/store/file/slices/chat/action.ts b/src/store/file/slices/chat/action.ts
index 2895fad011c..e1851804af7 100644
--- a/src/store/file/slices/chat/action.ts
+++ b/src/store/file/slices/chat/action.ts
@@ -77,7 +77,7 @@ export class FileActionImpl {
let isFinished = false;
while (!isFinished) {
- // 每间隔 2s 查询一次任务状态
+ // Poll task status every 2 seconds
await sleep(2000);
let fileItem: FileListItem | undefined = undefined;
diff --git a/src/store/image/slices/generationBatch/action.ts b/src/store/image/slices/generationBatch/action.ts
index b8ecb776783..2503b20557b 100644
--- a/src/store/image/slices/generationBatch/action.ts
+++ b/src/store/image/slices/generationBatch/action.ts
@@ -248,7 +248,7 @@ export class GenerationBatchActionImpl {
// Reset error state on success
isErrorRef.current = false;
- // 找到对应的 batch,generation 数据库记录包含 generationBatchId
+ // Find the corresponding batch; the generation database record contains generationBatchId
const currentBatches = this.#get().generationBatchesMap[topicId] || [];
const targetBatch = currentBatches.find((batch) =>
batch.generations.some((gen) => gen.id === generationId),
@@ -263,7 +263,7 @@ export class GenerationBatchActionImpl {
requestCountRef.current = 0;
if (data.generation) {
- // 更新 generation 数据
+ // Update generation data
this.#get().internal_dispatchGenerationBatch(
topicId,
{
diff --git a/src/store/utils/flattenActions.ts b/src/store/utils/flattenActions.ts
index e66a11805aa..6e27a01dbb2 100644
--- a/src/store/utils/flattenActions.ts
+++ b/src/store/utils/flattenActions.ts
@@ -1,11 +1,11 @@
/**
- * 将多个 action 对象(通常是 class 实例)扁平化为一个普通对象
+ * Flattens multiple action objects (usually class instances) into a single plain object.
*
- * 解决 class 实例无法通过 spread 操作符正确复制 prototype 方法的问题
- * 通过反射遍历 prototype chain,提取所有 public methods 并绑定 this 上下文
+ * Solves the problem of class instances being unable to correctly copy prototype methods via spread operator.
+ * Traverses the prototype chain via reflection to extract all public methods and bind them to the original `this` context.
*
- * @param actions - action 对象数组(通常是 class 实例)
- * @returns 包含所有 action 方法的普通对象
+ * @param actions - Array of action objects (usually class instances)
+ * @returns A plain object containing all action methods
*
* @example
* ```ts
@@ -19,23 +19,23 @@ export const flattenActions = <T extends object>(actions: object[]): T => {
const result = {} as T;
for (const action of actions) {
- // 遍历 prototype chain 获取所有方法
+ // Traverse the prototype chain to get all methods
let current: object | null = action;
while (current && current !== Object.prototype) {
const keys = Object.getOwnPropertyNames(current);
for (const key of keys) {
if (key === 'constructor') continue;
- if (key in result) continue; // 跳过已存在的属性(优先使用第一个 action 的方法)
+ if (key in result) continue; // Skip already-existing properties (the first action's method takes priority)
const descriptor = Object.getOwnPropertyDescriptor(current, key);
if (!descriptor) continue;
if (typeof descriptor.value === 'function') {
- // 方法: 绑定 this 上下文到原始 action 实例
+ // Method: bind `this` context to the original action instance
(result as any)[key] = descriptor.value.bind(action);
} else {
- // 非函数属性: 直接复制描述符
+ // Non-function property: copy the descriptor directly
Object.defineProperty(result, key, {
...descriptor,
configurable: true,