feat(chat,proxy): add @schedule mentions and localize proxy/schedule errors

- Support @schedule mentions in DB search, server mention resolution, and frontend mention parsing/i18n.
- Return structured product error codes for proxy route validation and localize them in proxy/schedule UI.
- Preserve unchanged proxy routes when rescheduling an existing schedule whose pool has no active nodes.
This commit is contained in:
ji ruo committed 2026-12-03 14:15:52 +08:00
1 parent 8568c41528
commit e6241dda09
15 files changed
+312 -49

No files matched your search

+20
View File
@@ -43,6 +43,26 @@ export const errorMessages = {
"error.password_not_initialized": ["密码未初始化,请先设置密码", "Set up a password first"],
"error.current_password_incorrect": ["当前密码错误", "The current password is incorrect"],
"error.invalid_credentials": ["用户名或密码错误", "Incorrect username or password"],
"error.proxy_pool_no_available_nodes": [
"代理池暂无可用节点,请先在代理设置中添加并启用节点",
"No available nodes in the proxy pool. Add and enable a node in Proxy Settings first.",
],
"error.proxy_route_invalid_mode": [
"代理模式无效,必须是 inherit、direct、pool 或 proxy",
"Invalid proxy mode. Must be inherit, direct, pool, or proxy.",
],
"error.proxy_pool_node_not_found": [
"未找到代理池节点:{{id}}",
"Proxy pool node not found: {{id}}",
],
"error.proxy_route_invalid_target": [
"无效的容器路由目标(scope 必须为 task 或 session)",
"Invalid container route target (scope must be task or session).",
],
"error.proxy_route_invalid_url": [
"代理地址无效:{{detail}}",
"Invalid proxy URL: {{detail}}",
],
"update.available": ["新版本", "Update available"],
"update.hint": ["发现新版本 {{version}},点击前往更新", "Version {{version}} is available. Click to update."],
} satisfies Record<string, readonly [string, string]>;
+11
View File
@@ -297,6 +297,17 @@ test("schedule windows, counts and stored system messages follow the selected la
const original = "用户的计划与备注,包含 start_time";
assert.equal(en.scheduleErrorText(original), original);
assert.equal(en.scheduleErrorText("任务 #42:unknown original detail"), "Task #42: unknown original detail");
assert.equal(
en.scheduleErrorText("代理池暂无可用节点,请先在代理设置中添加并启用节点"),
"No available nodes in the proxy pool. Add and enable a node in Proxy Settings first.",
);
const proxyErr = Object.assign(new Error("代理池暂无可用节点,请先在代理设置中添加并启用节点"), {
code: "proxy_pool_no_available_nodes",
});
assert.equal(
localizedError(proxyErr, i18n.t.bind(i18n)),
"No available nodes in the proxy pool. Add and enable a node in Proxy Settings first.",
);
for (const [key, singular, plural] of [
["schedule.started", "Started 1 task immediately", "Started 2 tasks immediately"],
["schedule.deleted", "Deleted 1 schedule", "Deleted 2 schedules"],
+1
View File
@@ -118,6 +118,7 @@ export const messages = {
"auth.saving": ["保存中...", "Saving…"],
"auth.setupAndLogin": ["设置密码并登录", "Set password and sign in"],
"mention.task": ["任务", "Task"],
"mention.schedule": ["计划任务", "Schedule"],
"mention.finding": ["漏洞", "Finding"],
"mention.asset": ["资产", "Asset"],
"mention.company": ["企业", "Company"],
+1
View File
@@ -27,6 +27,7 @@ const messages: Record<string, string> = {
立即运行: "schedule.runtime.runNow",
"立即运行(显式恢复人工暂停)": "schedule.runtime.forceResume",
计划窗口: "schedule.runtime.window",
"代理池暂无可用节点,请先在代理设置中添加并启用节点": "error.proxy_pool_no_available_nodes",
};
const taskMessages: [RegExp, string][] = [
[/^任务 #(\d+) 未找到$/, "schedule.runtime.taskNotFound"],