feat: 支持多语言提示词本地化和界面优化

- 添加 prompt_locale 参数支持简体中文、繁体中文和英文提示词本地化
- 移除内置 agents 配置以简化系统架构
- 更新 ContextBuilder 使用动态提示词模板而非硬编码内容
- 在 AgentLoop、Web 接口和 AgentService 中传递 locale 参数
- 添加输出语言指令确保用户界面内容按指定语言生成
- 扩展前端 LanguageSwitcher 组件支持三种语言选项
- 优化 Header 和侧边栏组件的响应式布局和文本截断处理
- 更新测试用例验证不同语言环境下的提示词正确性
This commit is contained in:
2026-06-10 16:11:05 +08:00
parent 9cc3334ea7
commit fc9fd93c36
51 changed files with 7493 additions and 619 deletions

View File

@ -23,6 +23,7 @@ import {
getSession,
getSessionProcess,
listSessions,
promptLocaleForAppLocale,
sendMessage,
submitChatFeedback,
uploadFile,
@ -44,7 +45,7 @@ function isSessionUpdatedEvent(data: WsEvent | Record<string, unknown>): data is
return data.type === 'session_updated' && typeof data.session_id === 'string';
}
function activeTaskStatusLabel(status: string, locale: 'zh-CN' | 'en-US') {
function activeTaskStatusLabel(status: string, locale: string) {
if (status === 'needs_revision') return pickAppText(locale, '待修改', 'Needs revision');
if (status === 'awaiting_acceptance') return pickAppText(locale, '待验收', 'Awaiting acceptance');
if (status === 'running') return pickAppText(locale, '进行中', 'Running');
@ -140,8 +141,9 @@ export default function ChatPage() {
liveRuns: processRuns,
liveEvents: processEvents,
liveArtifacts: processArtifacts,
locale,
}),
[activeTaskDetail, processArtifacts, processEvents, processRuns]
[activeTaskDetail, locale, processArtifacts, processEvents, processRuns]
);
const loadSessions = useCallback(async () => {
@ -400,6 +402,7 @@ export default function ChatPage() {
type: 'message',
content: msgContent,
thinking_enabled: thinkingModeEnabled,
prompt_locale: promptLocaleForAppLocale(locale),
};
if (attachments.length > 0) {
wsPayload.attachments = attachments;

View File

@ -97,8 +97,9 @@ export default function TaskDetailPage() {
liveRuns: processRuns,
liveEvents: processEvents,
liveArtifacts: processArtifacts,
locale,
}),
[backendTask, processArtifacts, processEvents, processRuns]
[backendTask, locale, processArtifacts, processEvents, processRuns]
);
const timelineCards = timelineView?.cards ?? [];

View File

@ -222,7 +222,7 @@ function OrdinaryTaskCard({
onDelete,
}: {
task: BackendTask;
locale: 'zh-CN' | 'en-US';
locale: string;
onDelete: () => void;
}) {
const title = task.short_title || String(task.metadata?.short_title || '') || task.description || task.goal || task.task_id;
@ -284,7 +284,7 @@ function OrdinaryTaskCard({
);
}
function taskStatusLabel(status: string, locale: 'zh-CN' | 'en-US') {
function taskStatusLabel(status: string, locale: string) {
const labels: Record<string, [string, string]> = {
open: ['已创建', 'Open'],
running: ['执行中', 'Running'],
@ -297,7 +297,7 @@ function taskStatusLabel(status: string, locale: 'zh-CN' | 'en-US') {
return label ? pickAppText(locale, label[0], label[1]) : status;
}
function taskSourceLabel(task: BackendTask, locale: 'zh-CN' | 'en-US') {
function taskSourceLabel(task: BackendTask, locale: string) {
if (task.metadata?.source === 'scheduled_run') {
return pickAppText(locale, '定时通知修改', 'Scheduled notification revision');
}
@ -520,7 +520,7 @@ function ScheduledJobCard({
onRemove,
}: {
job: CronJob;
locale: 'zh-CN' | 'en-US';
locale: string;
formatTime: (ms: number | null) => string;
onToggle: (checked: boolean) => void;
onRun: () => void;