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 server/app/components (#12165)

LobeHub Botffeec13c2854
diff --git a/src/app/(backend)/api/agent/run/route.ts b/src/app/(backend)/api/agent/run/route.ts
index 098f5d815f0..d2a0029519d 100644
--- a/src/app/(backend)/api/agent/run/route.ts
+++ b/src/app/(backend)/api/agent/run/route.ts
@@ -81,7 +81,7 @@ export async function POST(request: NextRequest) {
const serverDB = await getServerDB();
const agentRuntimeService = new AgentRuntimeService(serverDB, metadata.userId);
- // 使用 AgentRuntimeService 执行步骤
+ // Execute step using AgentRuntimeService
const result = await agentRuntimeService.executeStep({
approvedToolCall,
context,
@@ -133,7 +133,7 @@ export async function POST(request: NextRequest) {
}
/**
- * 健康检查端点
+ * Health check endpoint
*/
export async function GET() {
try {
diff --git a/src/app/(backend)/api/agent/stream/route.ts b/src/app/(backend)/api/agent/stream/route.ts
index ecac99330a0..6e967274ba6 100644
--- a/src/app/(backend)/api/agent/stream/route.ts
+++ b/src/app/(backend)/api/agent/stream/route.ts
@@ -31,7 +31,7 @@ export async function GET(request: NextRequest) {
log(`Starting SSE connection for operation ${operationId} from eventId ${lastEventId}`);
- // 创建 Server-Sent Events 流
+ // Create Server-Sent Events stream
const stream = new ReadableStream({
cancel(reason) {
log(`SSE connection cancelled for operation ${operationId}:`, reason);
@@ -45,23 +45,23 @@ export async function GET(request: NextRequest) {
start(controller) {
const writer = createSSEWriter(controller);
- // 发送连接确认事件
+ // Send connection confirmation event
writer.writeConnection(operationId, lastEventId);
log(`SSE connection established for operation ${operationId}`);
- // 如果需要,先发送历史事件
+ // If needed, send historical events first
if (includeHistory) {
streamManager
.getStreamHistory(operationId, 50)
.then((history) => {
- // 按时间顺序发送历史事件(最早的在前面)
+ // Send historical events in chronological order (earliest first)
const sortedHistory = history.reverse();
sortedHistory.forEach((event) => {
- // 只发送比 lastEventId 更新的事件
+ // Only send events newer than lastEventId
if (!lastEventId || lastEventId === '0' || event.timestamp.toString() > lastEventId) {
try {
- // 添加 SSE 特定的字段,保持与实时事件格式一致
+ // Add SSE-specific fields, keeping format consistent with real-time events
const sseEvent = {
...event,
operationId,
@@ -89,14 +89,14 @@ export async function GET(request: NextRequest) {
});
}
- // 创建 AbortController 用于取消订阅
+ // Create AbortController for canceling subscription
const abortController = new AbortController();
// Track if stream has ended (agent_runtime_end received)
// Once set to true, no more events will be sent
let streamEnded = false;
- // 定期发送心跳(每 30 秒)
+ // Send heartbeat periodically (every 30 seconds)
const heartbeatInterval = setInterval(() => {
// Skip heartbeat if stream has ended
if (streamEnded) {
@@ -124,7 +124,7 @@ export async function GET(request: NextRequest) {
log(`SSE connection closed for operation ${operationId}`);
};
- // 订阅新的流式事件
+ // Subscribe to new streaming events
const subscribeToEvents = async () => {
try {
await streamManager.subscribeStreamEvents(
@@ -138,7 +138,7 @@ export async function GET(request: NextRequest) {
}
try {
- // 添加 SSE 特定的字段
+ // Add SSE-specific fields
const sseEvent = {
...event,
operationId,
@@ -158,7 +158,7 @@ export async function GET(request: NextRequest) {
totalLatency,
);
- // 如果收到 agent_runtime_end 事件,立即终止流
+ // If agent_runtime_end event is received, terminate stream immediately
if (event.type === 'agent_runtime_end') {
log(
`Agent runtime ended for operation ${operationId}, terminating stream immediately`,
@@ -194,18 +194,18 @@ export async function GET(request: NextRequest) {
}
};
- // 开始订阅
+ // Start subscription
subscribeToEvents();
- // 监听连接关闭
+ // Listen for connection close
request.signal?.addEventListener('abort', cleanup);
- // 存储清理函数以便在 cancel 时调用
+ // Store cleanup function for calling during cancel
(controller as any)._cleanup = cleanup;
},
});
- // 设置 SSE 响应头
+ // Set SSE response headers
return new Response(stream, {
headers: createSSEHeaders(),
});
diff --git a/src/app/(backend)/oidc/consent/route.ts b/src/app/(backend)/oidc/consent/route.ts
index 04449dec313..f017830f64e 100644
--- a/src/app/(backend)/oidc/consent/route.ts
+++ b/src/app/(backend)/oidc/consent/route.ts
@@ -58,14 +58,14 @@ export async function POST(request: NextRequest) {
} else {
log(`Handling 'consent' prompt`);
- // 1. 获取必要的 ID
+ // 1. Get necessary IDs
const clientId = details.params.client_id as string;
- // 2. 查找或创建 Grant 对象
+ // 2. Find or create Grant object
const grant = await oidcService.findOrCreateGrants(userId!, clientId, details.grantId);
- // 3. 将用户同意的 scopes 和 claims 添加到 Grant 对象
- // 这些信息通常在 details.prompt.details 中
+ // 3. Add user-consented scopes and claims to Grant object
+ // This information is typically in details.prompt.details
const missingOIDCScope = (prompt.details.missingOIDCScope as string[]) || [];
if (missingOIDCScope) {
grant.addOIDCScope(missingOIDCScope.join(' '));
@@ -85,16 +85,16 @@ export async function POST(request: NextRequest) {
log('Added resource scopes for %s to grant: %s', indicator, scopes.join(' '));
}
}
- // 如果使用了 RAR (Rich Authorization Requests),也需要添加到 grant
+ // If RAR (Rich Authorization Requests) is used, it also needs to be added to grant
// if (prompt.details.rar) {
// prompt.details.rar.forEach(detail => grant.addRar(detail));
// }
- // 4. 保存 Grant 对象以获取其 jti (grantId)
+ // 4. Save Grant object to get its jti (grantId)
const newGrantId = await grant.save();
log('Saved grant with ID: %s', newGrantId);
- // 5. 准备包含 grantId 的 result
+ // 5. Prepare result containing grantId
result = { consent: { grantId: newGrantId } };
log('Consent result prepared with grantId');
@@ -114,7 +114,7 @@ export async function POST(request: NextRequest) {
const internalRedirectUrlString = await oidcService.getInteractionResult(uid, result);
log('OIDC Provider internal redirect URL string: %s', internalRedirectUrlString);
- // 直接使用 APP_URL 作为基础
+ // Use APP_URL directly as base
if (appEnv.APP_URL) {
const baseUrl = new URL(appEnv.APP_URL);
const internalUrl = new URL(internalRedirectUrlString);
@@ -128,7 +128,7 @@ export async function POST(request: NextRequest) {
});
}
- // 后备方案:使用原始内部URL
+ // Fallback: use original internal URL
log('Using internal redirect URL directly: %s', internalRedirectUrlString);
return NextResponse.redirect(new URL(internalRedirectUrlString), {
status: 303,
diff --git a/src/app/(backend)/trpc/async/[trpc]/route.ts b/src/app/(backend)/trpc/async/[trpc]/route.ts
index 60478315034..c028cac102d 100644
--- a/src/app/(backend)/trpc/async/[trpc]/route.ts
+++ b/src/app/(backend)/trpc/async/[trpc]/route.ts
@@ -12,7 +12,7 @@ const handler = (req: NextRequest) => {
const preparedReq = prepareRequestForTRPC(req);
return fetchRequestHandler({
- // 避免请求之间互相影响
+ // Avoid interference between requests
// https://github.com/lobehub/lobe-chat/discussions/7442#discussioncomment-13658563
allowBatching: false,
diff --git a/src/app/robots.tsx b/src/app/robots.tsx
index a040c34ff67..b1fc2a2dedf 100644
--- a/src/app/robots.tsx
+++ b/src/app/robots.tsx
@@ -3,8 +3,8 @@ import { type MetadataRoute } from 'next';
import { Sitemap } from '@/server/sitemap';
import { getCanonicalUrl } from '@/server/utils/url';
-// Robots文件缓存配置 - 24小时重新验证
-export const revalidate = 86_400; // 24小时 - 内容页面缓存
+// Robots file cache configuration - revalidate every 24 hours
+export const revalidate = 86_400; // 24 hours - content page cache
export const dynamic = 'force-static';
const robots = (): MetadataRoute.Robots => {
diff --git a/src/app/sitemap.tsx b/src/app/sitemap.tsx
index e167f7ad4a6..98335de773a 100644
--- a/src/app/sitemap.tsx
+++ b/src/app/sitemap.tsx
@@ -2,8 +2,8 @@ import { type MetadataRoute } from 'next';
import { LAST_MODIFIED, Sitemap, SitemapType } from '@/server/sitemap';
-// Sitemap缓存配置 - 24小时重新验证
-export const revalidate = 86_400; // 24小时 - 内容页面缓存
+// Sitemap cache configuration - revalidate every 24 hours
+export const revalidate = 86_400; // 24 hours - content page cache
export const dynamic = 'force-static';
export const generateSitemapLink = (url: string) =>
@@ -13,17 +13,17 @@ export const generateSitemapLink = (url: string) =>
export async function generateSitemaps() {
const sitemapModule = new Sitemap();
- // 生成动态的sitemap列表,包括分页的sitemap
+ // Generate dynamic sitemap list, including paginated sitemaps
const staticSitemaps = sitemapModule.sitemapIndexs;
- // 获取需要分页的类型的页数
+ // Get page counts for types that need pagination
const [pluginPages, assistantPages, modelPages] = await Promise.all([
sitemapModule.getPluginPageCount(),
sitemapModule.getAssistantPageCount(),
sitemapModule.getModelPageCount(),
]);
- // 生成分页sitemap ID列表
+ // Generate paginated sitemap ID list
const paginatedSitemaps = [
...Array.from({ length: pluginPages }, (_, i) => ({ id: `plugins-${i + 1}` as SitemapType })),
...Array.from({ length: assistantPages }, (_, i) => ({
@@ -35,7 +35,7 @@ export async function generateSitemaps() {
return [...staticSitemaps, ...paginatedSitemaps];
}
-// 解析分页ID
+// Parse paginated ID
export function parsePaginatedId(id: string): { page?: number; type: SitemapType } {
if (id.includes('-')) {
const [type, pageStr] = id.split('-');
@@ -74,7 +74,7 @@ export default async function sitemap({
return sitemapModule.getProviders();
}
default: {
- // 处理分页的sitemap(plugins-1, assistants-2, mcp-3等)
+ // Handle paginated sitemaps (plugins-1, assistants-2, mcp-3, etc.)
if (id.startsWith('plugins-')) {
const pageNum = parseInt(id.split('-')[1], 10);
return sitemapModule.getPlugins(pageNum);
@@ -88,7 +88,7 @@ export default async function sitemap({
return sitemapModule.getModels(pageNum);
}
- // 默认返回空数组
+ // Default to empty array
return [];
}
}
diff --git a/src/components/AnimatedCollapsed/index.tsx b/src/components/AnimatedCollapsed/index.tsx
index e6f3e3aaf9b..ca947d1dca1 100644
--- a/src/components/AnimatedCollapsed/index.tsx
+++ b/src/components/AnimatedCollapsed/index.tsx
@@ -31,7 +31,7 @@ const AnimatedCollapsed = memo<AnimatedCollapsedProps>(
style={style}
transition={{
duration: 0.2,
- ease: [0.4, 0, 0.2, 1], // 使用 ease-out 缓动函数
+ ease: [0.4, 0, 0.2, 1], // Use ease-out easing function
}}
variants={{
collapsed: {
diff --git a/src/components/DragUpload/useDragUpload.tsx b/src/components/DragUpload/useDragUpload.tsx
index 962015a1abc..64a52e14aa7 100644
--- a/src/components/DragUpload/useDragUpload.tsx
+++ b/src/components/DragUpload/useDragUpload.tsx
@@ -125,7 +125,7 @@ export const useDragUpload = (onUploadFiles: (files: File[]) => Promise<void>) =
if (files.length === 0) return;
- // 检查是否有图片文件且模型不支持视觉功能
+ // Check if there are image files and the model does not support vision
const hasImageFiles = files.some((file) => file.type.startsWith('image/'));
if (hasImageFiles && !supportVision) {
message.warning(t('upload.clientMode.visionNotSupported'));
@@ -144,7 +144,7 @@ export const useDragUpload = (onUploadFiles: (files: File[]) => Promise<void>) =
const files = await getFileListFromDataTransferItems(items);
if (files.length === 0) return;
- // 检查是否有图片文件且模型不支持视觉功能
+ // Check if there are image files and the model does not support vision
const hasImageFiles = files.some((file) => file.type.startsWith('image/'));
if (hasImageFiles && !supportVision) {
message.warning(t('upload.clientMode.visionNotSupported'));
diff --git a/src/components/InvalidAPIKey/ComfyUIForm.tsx b/src/components/InvalidAPIKey/ComfyUIForm.tsx
index 431b4e83d8b..77312d2f6ed 100644
--- a/src/components/InvalidAPIKey/ComfyUIForm.tsx
+++ b/src/components/InvalidAPIKey/ComfyUIForm.tsx
@@ -72,7 +72,7 @@ const ComfyUIForm = memo<ComfyUIFormProps>(({ description }) => {
username: '',
});
- // Update form values when comfyUIConfig changes (配置反读)
+ // Update form values when comfyUIConfig changes (config read-back)
// Use individual primitive values to avoid infinite re-renders
useEffect(() => {
if (comfyUIConfig) {
diff --git a/src/components/MCPStdioCommandInput/index.tsx b/src/components/MCPStdioCommandInput/index.tsx
index 1702565e174..9ed0c2ec844 100644
--- a/src/components/MCPStdioCommandInput/index.tsx
+++ b/src/components/MCPStdioCommandInput/index.tsx
@@ -10,9 +10,9 @@ import { AutoComplete, type AutoCompleteProps } from '@lobehub/ui';
import { Flexbox } from '@lobehub/ui';
import { type FC, memo } from 'react';
-// 定义预设的命令选项
+// Define preset command options
const STDIO_COMMAND_OPTIONS: {
- // 假设图标是 React 函数组件
+ // Assuming icon is a React function component
color?: string;
icon?: FC<{ color?: string; size?: number }>;
value: string;
diff --git a/src/components/StatisticCard/growthPercentage.tsx b/src/components/StatisticCard/growthPercentage.tsx
index bb2cd3e52cf..40c26048db3 100644
--- a/src/components/StatisticCard/growthPercentage.tsx
+++ b/src/components/StatisticCard/growthPercentage.tsx
@@ -1,7 +1,7 @@
export const calcGrowthPercentage = (currentCount: number, previousCount: number) => {
if (typeof currentCount !== 'number') return 0;
return previousCount !== 0
- ? ((currentCount - previousCount) / previousCount) * 100 // 计算增长百分比
+ ? ((currentCount - previousCount) / previousCount) * 100 // Calculate growth percentage
: currentCount > 0
? 100
: 0;
diff --git a/src/components/TipGuide/index.tsx b/src/components/TipGuide/index.tsx
index 933f7c8a769..3ed38e6a6ae 100644
--- a/src/components/TipGuide/index.tsx
+++ b/src/components/TipGuide/index.tsx
@@ -32,39 +32,39 @@ const styles = createStaticStyles(({ css }) => {
export interface TipGuideProps {
/**
- * 引导内容
+ * Guide content
*/
children?: ReactNode;
/**
- * 类名
+ * Class name
*/
className?: string;
/**
- * 默认时候的打开状态
+ * Default open state
*/
defaultOpen?: boolean;
/**
- * 用于自定义 footer 部分的 render api
+ * Render function for customizing the footer section
*/
footerRender?: (dom: ReactNode) => ReactNode;
/**
- * 最大宽度
+ * Maximum width
*/
maxWidth?: number;
/**
- * 纵向偏移值
+ * Vertical offset value
*/
offsetY?: number;
/**
- * 当 open 属性变化时候的触发
+ * Callback triggered when the open property changes
*/
onOpenChange: (open: boolean) => void;
/**
- * 受控的 open 属性
+ * Controlled open property
*/
open?: boolean;
/**
- * Tooltip 位置,默认为 bottom
+ * Tooltip placement, defaults to bottom
*/
placement?: TooltipProps['placement'];
/**
@@ -73,7 +73,7 @@ export interface TipGuideProps {
style?: CSSProperties;
tip?: boolean;
/**
- * 引导标题
+ * Guide title
*/
title: string;
}
diff --git a/src/server/services/oidc/oidcProvider.ts b/src/server/services/oidc/oidcProvider.ts
index 0c783b1c586..b985a66ad6e 100644
--- a/src/server/services/oidc/oidcProvider.ts
+++ b/src/server/services/oidc/oidcProvider.ts
@@ -3,13 +3,13 @@ import { authEnv } from '@/envs/auth';
import { type OIDCProvider, createOIDCProvider } from '@/libs/oidc-provider/provider';
/**
- * OIDC Provider 实例
+ * OIDC Provider instance
*/
let provider: OIDCProvider;
/**
- * 获取 OIDC Provider 实例
- * @returns OIDC Provider 实例
+ * Get OIDC Provider instance
+ * @returns OIDC Provider instance
*/
export const getOIDCProvider = async (): Promise<OIDCProvider> => {
if (!provider) {
diff --git a/src/server/sitemap.ts b/src/server/sitemap.ts
index 634fe5a0a80..b311cd813e5 100644
--- a/src/server/sitemap.ts
+++ b/src/server/sitemap.ts
@@ -222,7 +222,7 @@ export class Sitemap {
// If page number is not specified, return all (backward compatibility)
const sitmap = list
- .filter((item) => item.identifier) // 过滤掉 identifier 为空的项目
+ .filter((item) => item.identifier) // Filter out items with empty identifiers
.map((item) =>
this._genSitemap(urlJoin('/community/agent', item.identifier), {
lastModified: item?.lastModified || LAST_MODIFIED,
@@ -251,7 +251,7 @@ export class Sitemap {
// If page number is not specified, return all (backward compatibility)
const sitmap = list
- .filter((item) => item.identifier) // 过滤掉 identifier 为空的项目
+ .filter((item) => item.identifier) // Filter out items with empty identifiers
.map((item) =>
this._genSitemap(urlJoin('/community/plugin', item.identifier), {
lastModified: item?.lastModified || LAST_MODIFIED,
@@ -280,7 +280,7 @@ export class Sitemap {
// If page number is not specified, return all (backward compatibility)
const sitmap = list
- .filter((item) => item.identifier) // 过滤掉 identifier 为空的项目
+ .filter((item) => item.identifier) // Filter out items with empty identifiers
.map((item) =>
this._genSitemap(urlJoin('/community/model', item.identifier), {
lastModified: item?.lastModified || LAST_MODIFIED,
@@ -292,7 +292,7 @@ export class Sitemap {
async getProviders(): Promise<MetadataRoute.Sitemap> {
const list = await this.discoverService.getProviderIdentifiers();
const sitmap = list
- .filter((item) => item.identifier) // 过滤掉 identifier 为空的项目
+ .filter((item) => item.identifier) // Filter out items with empty identifiers
.map((item) =>
this._genSitemap(urlJoin('/community/provider', item.identifier), {
lastModified: item?.lastModified || LAST_MODIFIED,