- 添加 prompt_locale 参数支持简体中文、繁体中文和英文提示词本地化 - 移除内置 agents 配置以简化系统架构 - 更新 ContextBuilder 使用动态提示词模板而非硬编码内容 - 在 AgentLoop、Web 接口和 AgentService 中传递 locale 参数 - 添加输出语言指令确保用户界面内容按指定语言生成 - 扩展前端 LanguageSwitcher 组件支持三种语言选项 - 优化 Header 和侧边栏组件的响应式布局和文本截断处理 - 更新测试用例验证不同语言环境下的提示词正确性
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { buildTaskTimelineView } from '@/lib/task-timeline-view';
|
|
import type { BackendTask, ProcessEvent } from '@/types';
|
|
|
|
function task(): BackendTask {
|
|
return {
|
|
task_id: 'task-1',
|
|
session_id: 'web:default',
|
|
description: 'Build report',
|
|
goal: 'Build report',
|
|
constraints: [],
|
|
priority: 0,
|
|
status: 'running',
|
|
creator: 'user',
|
|
created_at: '2026-06-04T00:00:00.000Z',
|
|
updated_at: '2026-06-04T00:01:00.000Z',
|
|
run_ids: ['main-run'],
|
|
skill_names: [],
|
|
feedback: [],
|
|
metadata: {},
|
|
};
|
|
}
|
|
|
|
describe('buildTaskTimelineView', () => {
|
|
it('builds canonical task timeline cards from matching live process data', () => {
|
|
const liveEvents: ProcessEvent[] = [
|
|
{
|
|
event_id: 'plan',
|
|
run_id: 'main-run',
|
|
kind: 'task_planned',
|
|
actor_type: 'system',
|
|
actor_id: 'planner',
|
|
actor_name: 'Planner',
|
|
text: 'Plan created',
|
|
created_at: '2026-06-04T00:00:10.000Z',
|
|
},
|
|
];
|
|
|
|
const view = buildTaskTimelineView({
|
|
task: task(),
|
|
liveEvents,
|
|
locale: 'en-US',
|
|
});
|
|
|
|
expect(view?.cards.map((card) => card.type)).toEqual(['task_created', 'plan']);
|
|
expect(view?.cards.map((card) => card.title)).toEqual(['Task created', 'Execution plan']);
|
|
expect(view?.process.events.map((event) => event.event_id)).toEqual(['plan']);
|
|
});
|
|
|
|
it('returns null when there is no active task to display', () => {
|
|
expect(buildTaskTimelineView({ task: null })).toBeNull();
|
|
});
|
|
});
|