界面文案整改:口语改书面、术语统一、不再露出实现细节;修掉几处说错的提示;新增文案检查防回潮

一、文案(前端约 1600 处,后端传到界面的约 880 处)
- 术语统一:工作流层面用「运行」(继续运行、重新运行、试运行),节点和工具层面用「执行」,不再用「跑」;
  总时长 / 执行时长 / 等待审批;服务端;助手;Agent;token;工作流;固定版本;模型接入;系统提示;批准 / 驳回;受管级别
- 口语改书面:取不到、没取回来、读不懂、连不上、多半、照样、兜底、揉成这类说法改成「无法 / 未能 / 失败 / 请」;去掉拟人写法
- 不再露出实现细节:界面上不写 checkpoint、同一拍、哈希(凭证处除外),不写改版历史(「以前…」「老数据」);
  报错、校验、门禁、自动修复里裸写的配置键名和枚举值换成界面上的中文标签,由新的 backend/app/engine/labels.py 统一提供;
  发布弹窗里结论句的选项不再是 off / require_citation
- 同一件事只留一种说法:生成阶段文案、出具档位说明、画布锁定提示各合成一份
- 去掉界面上的工业场景示例(MES、ERP、「张工」「王工」)和真实产品名,换成通用示例

二、说错的提示(都有测试证明)
- 数据库测连接失败时的专用提示以前从不出现(按报错文字全等比较,永远比不上):改为按错误类型判断,不再拼出重复的前缀
- 「设置 → 供应商」改指「设置 → 模型接入」;「在设置里建数据源」改指「数据」页
- 缺少 API Key、模型接入已停用的报错不再夹英文,写明去哪里填
- 两处原因说错(「这种引用在后续版本支持」「这一版还不支持」)改成真实原因
- 节点说明里不准确的说法改正:代码节点在 microVM 或系统沙箱中执行;报告撰写、口径卡的说明不再说过头
- 导出的证据 CSV 里两列同名,第三列改为「片段编号」

三、前后端对齐
- 前端按后端原文识别日志、报错的地方,新旧两种写法都认得(历史运行里存的是旧文字),逐条补了新旧原文的核对
- 后端交回模型的原指令放进单独的 for_model 字段,前端在解析响应时去掉,不会显示到界面上

四、检查
- 检查脚本里按原文匹配的断言改成新文案;改完会变成永远成立的反向断言逐条修正,并做了变异验证
- 新增 check-copy(静态扫描前端界面字符串和后端上界面的文案):再出现「跑」「后端」「多半」「令牌」、
  界面上的 Copilot、裸写的配置键名、半角标点等就报错;确需保留的写进 scripts/copy-allow.json 并注明理由
This commit is contained in:
ThearchyHelios
2026-09-30 08:05:15 +08:00
parent 68fb353f27
commit 03c18c4d78
221 changed files with 6580 additions and 4795 deletions
+37 -13
View File
@@ -15,7 +15,7 @@ const BASE = '/api'
*/
export type ApiErrorKind = 'network' | 'http'
export const NETWORK_MESSAGE = '连不上后端服务(可能没启动或正在重启),稍后重试'
export const NETWORK_MESSAGE = '无法连接服务(服务端可能未启动或正在重启),请稍后重试'
export class ApiError extends Error {
kind: ApiErrorKind
@@ -78,7 +78,8 @@ function actorHeader(): Record<string, string> {
function describeDetail(detail: unknown, path?: string): string {
if (typeof detail === 'string') return detail
if (Array.isArray(detail)) return `${VALIDATION_TITLE}:${describeValidation(detail, path).join(';')}`
try { return JSON.stringify(detail) } catch { return String(detail) }
// 对象形态的 detail 原样 JSON 化只会把一串花括号摆到提示里:界面只说无法识别,原文在调用方的 raw 里
return '请求失败,服务端返回了无法识别的错误信息'
}
/**
@@ -91,6 +92,29 @@ function isGatewayFailure(status: number, bodyText: string, isJson: boolean): bo
return status === 500 && !bodyText.trim()
}
/**
* 后端交回模型用的改写指令:报告核对的 violations、助手自查的问题条目里带着 for_model。那是写给模型的
* 原话(「单元格要写成 Q<编号>.r<行>.<列>」这类),界面只显示给人看的 message。前端没有任何地方读它,
* 就在数据进来的地方去掉——原始事件、工件原文、展开详情这些直接显示 JSON 的地方也就不会露出来。
*/
const MODEL_NOTE = 'for_model'
function dropModelNotes(v: unknown): void {
if (Array.isArray(v)) {
for (const x of v) dropModelNotes(x)
} else if (v && typeof v === 'object') {
delete (v as Record<string, unknown>)[MODEL_NOTE]
for (const x of Object.values(v)) dropModelNotes(x)
}
}
/** 解析响应体;带 for_model 的(先按原文粗筛,不带的不走一遍)去掉它 */
export function parseBody(text: string): any {
const body = JSON.parse(text)
if (text.includes(`"${MODEL_NOTE}"`)) dropModelNotes(body)
return body
}
async function request<T>(path: string, init?: RequestInit & { timeoutMs?: number }): Promise<T> {
const { timeoutMs, ...rest } = init ?? {}
// 自己的超时和调用方的取消要分开:调用方取消照旧抛 AbortError(没人想看到
@@ -117,7 +141,7 @@ async function request<T>(path: string, init?: RequestInit & { timeoutMs?: numbe
})
} catch (e: any) {
if (timedOut) {
const err = new ApiError(0, `后端 ${Math.round(timeoutMs! / 1000)} 秒没有响应,稍后重试`,
const err = new ApiError(0, `服务端 ${Math.round(timeoutMs! / 1000)} 秒未响应,请稍后重试`,
{ kind: 'network', raw: `timeout after ${timeoutMs}ms: ${path}`, timeoutMs })
report(false, err)
throw err
@@ -134,7 +158,7 @@ async function request<T>(path: string, init?: RequestInit & { timeoutMs?: numbe
if (!res.ok) throw failure(res.status, res.statusText, await res.text().catch(() => ''), path)
report(true)
if (res.status === 204) return undefined as T
return res.json()
return parseBody(await res.text())
}
/** 后端 {detail, code} 里的机读码;没有就是 undefined */
@@ -164,8 +188,8 @@ function failure(status: number, statusText: string, text: string, path?: string
})
}
const message = status >= 500
? `后端出错了(${status}),详情看服务日志`
: `请求没有成功(${status} ${statusText})`
? `服务端错误(${status}),详情请查看服务日志`
: `请求失败(HTTP ${status})`
return new ApiError(status, message, { raw: `${status} ${statusText}\n${text.slice(0, 2000)}` })
}
@@ -219,9 +243,9 @@ function upload<T>(path: string, form: FormData, opts?: UploadOptions): Promise<
report(true)
if (xhr.status === 204 || !xhr.responseText) { resolve(undefined as T); return }
try {
resolve(JSON.parse(xhr.responseText))
resolve(parseBody(xhr.responseText))
} catch {
reject(new ApiError(xhr.status, '后端回的内容读不懂', { raw: xhr.responseText.slice(0, 2000) }))
reject(new ApiError(xhr.status, '无法解析服务端返回的内容', { raw: xhr.responseText.slice(0, 2000) }))
}
}
xhr.onerror = () => {
@@ -839,8 +863,8 @@ export function streamCopilot(
}
report(true)
onEnd(isJson ? describeDetail(body?.detail ?? body, '/copilot/generate-stream')
: res.status >= 500 ? `后端出错了(${res.status}),详情看服务日志`
: `请求没有成功(${res.status} ${res.statusText})`, { status: res.status, code: isJson ? codeOf(body) : undefined })
: res.status >= 500 ? `服务端错误(${res.status}),详情请查看服务日志`
: `请求失败(HTTP ${res.status})`, { status: res.status, code: isJson ? codeOf(body) : undefined })
return
}
report(true)
@@ -857,7 +881,7 @@ export function streamCopilot(
buffer = buffer.slice(idx + 2)
if (!frame.startsWith('data: ')) continue
try {
onOp(JSON.parse(frame.slice(6)))
onOp(parseBody(frame.slice(6)))
} catch { /* 半截帧,忽略 */ }
}
}
@@ -870,7 +894,7 @@ export function streamCopilot(
onEnd(NETWORK_MESSAGE)
return
}
onEnd(e?.message ?? '连接中断')
onEnd(e?.message ?? '连接中断,请重试')
}
})()
return () => controller.abort()
@@ -905,7 +929,7 @@ export function streamRun(
socket = new WebSocket(`${proto}://${location.host}/api/runs/${runId}/stream?after=${lastSeq}`)
socket.onmessage = (ev) => {
const event = JSON.parse(ev.data) as RunEvent & { type: string; status?: string }
const event = parseBody(ev.data) as RunEvent & { type: string; status?: string }
if (event.type === 'stream.end') {
closed = true
socket?.close()