From e178ff43f279df5c6cd0769f4d83eb0fcac1d6b4 Mon Sep 17 00:00:00 2001 From: HugoXK Date: Tue, 17 Nov 2026 06:39:36 +0000 Subject: [PATCH 1/3] feat(ui): say workspace instead of FlyBot instance on normal-user pages Replace the machinery name with the product term on /dashboard, /console, /repos/:id and /settings: status lines, banners, the inbox heading, the next-run sentence, the usage line, the repository chip, the eyebrow and the heading. Rename the start, stop and reinitialize controls for the workspace and give each one a one-line hint. The footer brand line and the stageMode form values stay. Fixes #228 Docs-not-needed: copy-only change in src/views; routes, contracts and the architecture are unchanged. Written-by: Fledge Platform Dev-2 --- changelog.d/228-plain-language.changed.md | 1 + src/views/checklist.ts | 2 +- src/views/pages.ts | 52 +++--- test/limits.test.ts | 2 +- test/nextAction.test.ts | 4 +- test/pages.test.ts | 20 +-- test/plainLanguage.test.ts | 195 ++++++++++++++++++++++ test/setupChecklist.test.ts | 2 +- test/team.test.ts | 4 +- 9 files changed, 239 insertions(+), 43 deletions(-) create mode 100644 changelog.d/228-plain-language.changed.md create mode 100644 test/plainLanguage.test.ts diff --git a/changelog.d/228-plain-language.changed.md b/changelog.d/228-plain-language.changed.md new file mode 100644 index 00000000..08ab4c2c --- /dev/null +++ b/changelog.d/228-plain-language.changed.md @@ -0,0 +1 @@ +The normal-user pages — dashboard, console, repository page and settings — now say workspace instead of FlyBot instance, and the start, stop and reinitialize controls are named for the workspace and each carry a one-line hint. The footer brand line and the stage-mode form values are unchanged. diff --git a/src/views/checklist.ts b/src/views/checklist.ts index e3a2667a..e521adff 100644 --- a/src/views/checklist.ts +++ b/src/views/checklist.ts @@ -140,7 +140,7 @@ export function setupChecklist(state: SetupState, t: Translate): SetupChecklist }, { key: 'instance', - title: t('启动 FlyBot 实例', 'Start the FlyBot instance'), + title: t('启动工作区', 'Start workspace'), done: state.instanceReady, action: { href: repoHref, label: t('打开仓库启动', 'Open the repository') }, blocked: !state.modelConfigured && !state.platformAvailable diff --git a/src/views/pages.ts b/src/views/pages.ts index f61540a2..41327734 100644 --- a/src/views/pages.ts +++ b/src/views/pages.ts @@ -584,7 +584,7 @@ export function inboxSection(locale: Locale, viewer: Viewer, questions: InboxQue
${escapeHtml(t('需要你处理', 'Needs your input'))}
-

${escapeHtml(t('FlyBot 在等你回答', 'FlyBot is waiting for you'))} ${questions.length}

+

${escapeHtml(t('工作区在等你回答', 'Workspace is waiting for you'))} ${questions.length}

${escapeHtml(t('回答会直接发送给正在运行的团队,不需要进入仓库工作台。', 'Answers go straight to the running team; you do not need to open the repository console.'))}

${returnTo === '/dashboard' ? '' : `${escapeHtml(t('查看仓库', 'View repositories'))}`} @@ -856,7 +856,7 @@ export interface NextRunFact { function nextRunLine(next: NextRun, t: Translate): string { switch (next.state) { case 'disabled': return t('仓库已停用,自动运行不会开始', 'Repository disabled; no automatic run starts') - case 'not-ready': return t('FlyBot 实例未就绪,自动运行不会开始', 'FlyBot instance not ready; no automatic run starts') + case 'not-ready': return t('工作区未就绪,自动运行不会开始', 'Workspace not ready; no automatic run starts') case 'auto-off': return t('自动工作已关闭', 'Auto work off') case 'active-job': return t('当前任务结束后再排', 'After the active job finishes') case 'idle': return t('空闲:没有开放工作项;会按发现间隔检查', 'Idle: no open work; the discovery interval still runs') @@ -953,8 +953,8 @@ function nextActionFor(input: { return { kind: 'questions', title: questions.length === 1 - ? t('FlyBot 在等你回答 1 个问题。', 'FlyBot is waiting on 1 answer.') - : t(`FlyBot 在等你回答 ${questions.length} 个问题。`, `FlyBot is waiting on ${questions.length} answers.`), + ? t('工作区在等你回答 1 个问题。', 'Workspace is waiting on 1 answer.') + : t(`工作区在等你回答 ${questions.length} 个问题。`, `Workspace is waiting on ${questions.length} answers.`), body: t('回答会直接发送给正在运行的团队。', 'Answers go straight to the running team.'), href: '#inbox', label: t('去回答', 'Answer'), @@ -1499,7 +1499,7 @@ export function repoPage(input: { config: Config; locale: Locale; viewer: Viewer ? { body: t('先选择你在这个仓库的角色,然后运行第一个任务。', 'Choose your role for this repository, then run the first job.'), action: { href: '#role', label: t('选择角色', 'Choose a role') } } : runnable ? { body: t('立即运行会创建这个仓库的第一个任务;每次运行只开一个 PR。', 'Run now creates the first job for this repository; each run opens at most one pull request.'), action: { formAction: `/repos/${repo.id}/run`, label: t('立即运行', 'Run now'), csrf: csrf(viewer) } } - : { body: t('先修复 FlyBot 实例或 GitHub 凭据,然后再运行。', 'Fix the FlyBot instance or the GitHub credential first, then run.'), action: { label: t('实例与凭据在本页的连接卡片里。', 'The instance and the credential are on the connection card of this page.') } } + : { body: t('先修复工作区或 GitHub 凭据,然后再运行。', 'Fix the workspace or the GitHub credential first, then run.'), action: { label: t('实例与凭据在本页的连接卡片里。', 'The instance and the credential are on the connection card of this page.') } } const instanceHealthTone = config.flybot.instanceImage === '' ? 'busy' : instance === undefined @@ -1511,7 +1511,7 @@ export function repoPage(input: { config: Config; locale: Locale; viewer: Viewer ? t('未启用', 'not enabled') : instance === undefined ? t('未创建', 'not created') : statusLabel(t, instance.status) const instanceHealthReason = config.flybot.instanceImage === '' - ? t('这个部署没有启用每仓库 FlyBot 实例。', 'This deployment has no per-repository FlyBot instance.') + ? t('这个部署没有启用每仓库工作区。', 'This deployment has no per-repository workspace.') : instance === undefined ? t('实例尚未创建。', 'The instance has not been created yet.') : instanceReason(t, instance.status, instance.last_error) @@ -1519,23 +1519,23 @@ export function repoPage(input: { config: Config; locale: Locale; viewer: Viewer // #472 slice 3: the instance state is a page-level message, not a banner in the // team card. `failed` is an error; any other non-ready state is informational. if (config.flybot.instanceImage === '') { - pageMessages.push({ level: 'info', key: 'instance-disabled', text: t('这个部署没有启用每仓库 FlyBot 实例,任务由全局 mock/runner 处理。', 'This deployment has no per-repository FlyBot instance; jobs use the global mock/runner.') }) + pageMessages.push({ level: 'info', key: 'instance-disabled', text: t('这个部署没有启用每仓库工作区,任务由全局 mock/runner 处理。', 'This deployment has no per-repository workspace; jobs use the global mock/runner.') }) } else if (instance === undefined) { - pageMessages.push({ level: 'info', key: 'instance-missing', text: t('FlyBot 实例尚未创建。保存仓库后会自动初始化;也可以手动启动。', 'The FlyBot instance has not been created yet. It starts automatically after the repository is saved, or you can start it manually.') }) + pageMessages.push({ level: 'info', key: 'instance-missing', text: t('工作区尚未创建。保存仓库后会自动初始化;也可以手动启动。', 'The workspace has not been created yet. It starts automatically after the repository is saved, or you can start it manually.') }) } else if (instance.status !== 'ready') { pageMessages.push({ level: instance.status === 'failed' ? 'error' : 'warning', key: 'instance-status', - text: `${t('FlyBot 实例:', 'FlyBot instance: ')}${instanceHealthStatus} · ${instanceHealthReason}`, + text: `${t('工作区:', 'Workspace: ')}${instanceHealthStatus} · ${instanceHealthReason}`, }) } const instanceActions = config.flybot.instanceImage === '' ? '' : instance === undefined || instance.status === 'failed' || instance.status === 'stopped' - ? `
${csrf(viewer)}
` + ? `
${csrf(viewer)}${infoTip(t('工作区就绪后,团队才能开始工作。', 'The team can start work once the workspace is ready.'))}
` : instance.status === 'ready' - ? `
${csrf(viewer)}
` - : `
${csrf(viewer)}
` + ? `
${csrf(viewer)}${infoTip(t('停止会中断正在运行的工作。', 'Stopping interrupts running work.'))}
` + : `
${csrf(viewer)}${infoTip(t('重新初始化会重建工作区。', 'Reinitializing rebuilds the workspace.'))}
` const permission = permissionLabel(t, repo.permission) const reviewerScopeText = instanceTeam === null ? '' : instanceTeam.reviewerScope === 'upstream' ? t('上游全部 PR', 'all upstream PRs') @@ -1566,7 +1566,7 @@ export function repoPage(input: { config: Config; locale: Locale; viewer: Viewer ${escapeHtml(t('发现间隔', 'Discovery every'))}${escapeHtml(intervalLabel(discoveryIntervalMinutes, t))} ${escapeHtml(t('下次约', 'Next'))}${escapeHtml(nextRunText)} ${escapeHtml(t('排期控制台', 'Schedule console'))} - FlyBot${flybotAvailable ? (instance === undefined ? escapeHtml(t('未创建', 'not created')) : badge(t, instance.status)) : escapeHtml(t('未启用', 'not enabled'))} + ${escapeHtml(t('工作区', 'Workspace'))}${flybotAvailable ? (instance === undefined ? escapeHtml(t('未创建', 'not created')) : badge(t, instance.status)) : escapeHtml(t('未启用', 'not enabled'))} ${escapeHtml(t('GitHub 凭据', 'GitHub credential'))}${escapeHtml(credentialOk ? t('正常', 'ok') : t('失效', 'invalid'))} ${badge(t, repo.last_status ?? 'idle')}
@@ -1610,8 +1610,8 @@ export function repoPage(input: { config: Config; locale: Locale; viewer: Viewer const instanceCard = `
-
${escapeHtml(t('每仓库 FlyBot', 'Per-repository FlyBot'))}
-

${escapeHtml(advanced ? t('实例与团队', 'Instance & team') : t('FlyBot 状态', 'FlyBot status'))}

+
${escapeHtml(t('每仓库工作区', 'PER-REPOSITORY WORKSPACE'))}
+

${escapeHtml(advanced ? t('实例与团队', 'Instance & team') : t('工作区状态', 'Workspace status'))}

${escapeHtml(instanceHealthStatus)} · ${escapeHtml(instanceHealthReason)}

${escapeHtml(t('最近检查', 'Last health check'))} ${escapeHtml(instanceLastHealth)}${advanced && instance !== undefined ? ` · ${escapeHtml(instance.container)}` : ''}${instanceReady && advanced ? ` · ${escapeHtml(t('任务先发给总控,再由负责人执行', 'jobs go to the Chief, then the Lead'))}` : ''}

${instance === undefined || instance.last_error === null ? '' : `
${escapeHtml(t('技术详情', 'Technical detail'))}
${escapeHtml(instance.last_error)}
`} @@ -1644,7 +1644,7 @@ export function repoPage(input: { config: Config; locale: Locale; viewer: Viewer

- ` : `

${escapeHtml(t('FlyBot 实例就绪后可以和 Chief 沟通。', 'You can talk to the Chief after the FlyBot instance is ready.'))}

`} + ` : `

${escapeHtml(t('工作区就绪后可以和 Chief 沟通。', 'You can talk to the Chief after the workspace is ready.'))}

`}
` const roleDescriptions: Record = { maintainer: t('可以运行 review / triage / 维护类任务;需要 GitHub admin 或 maintain 权限。', 'Can run review/triage/maintenance jobs; requires GitHub admin or maintain permission.'), @@ -1703,7 +1703,7 @@ export function repoPage(input: { config: Config; locale: Locale; viewer: Viewer : !credentialOk ? t('GitHub 凭据失效;工作项不会开始。', 'The GitHub credential is invalid; work items will not start.') : flybotAvailable && !flybotReady - ? t('FlyBot 实例未就绪;工作项不会开始。', 'The FlyBot instance is not ready; work items will not start.') + ? t('工作区未就绪;工作项不会开始。', 'The workspace is not ready; work items will not start.') : repo.auto_iterate !== 1 ? t('自动工作已关闭;可以从操作里手动开始。', 'Automatic work is off; start an item manually from its actions.') : input.activeJob === true @@ -1759,12 +1759,12 @@ export function repoPage(input: { config: Config; locale: Locale; viewer: Viewer
${prRows}
PR${escapeHtml(t('状态', 'Status'))}${escapeHtml(t('核实', 'Verified'))}${escapeHtml(t('审核分', 'Review'))}${escapeHtml(t('成本', 'Cost'))}${escapeHtml(t('创建', 'Created'))}
` const lifecycleItems: string[] = [] if (!repoEnabled) lifecycleItems.push(t('仓库已停用:不会自动或手动运行任务。', 'Repository disabled: no jobs run automatically or manually.')) - if (flybotAvailable && instance?.status !== 'ready') lifecycleItems.push(t(`FlyBot ${instance === undefined ? '未创建' : statusLabel(t, instance.status)}:任务不会运行。`, `FlyBot is ${instance === undefined ? 'not created' : statusLabel(t, instance.status)}: jobs will not run.`)) + if (flybotAvailable && instance?.status !== 'ready') lifecycleItems.push(t(`工作区${instance === undefined ? '未创建' : statusLabel(t, instance.status)}:任务不会运行。`, `Workspace is ${instance === undefined ? 'not created' : statusLabel(t, instance.status)}: jobs will not run.`)) if (!credentialOk) lifecycleItems.push(t('GitHub 凭据失效:调度已暂停。', 'GitHub credentials are invalid: scheduling is paused.')) if (repo.auto_iterate === 1 && (!repoEnabled || !flybotReady)) lifecycleItems.push(t('自动工作已开启,但当前不会运行。', 'Auto work is on but cannot run right now.')) const lifecycleActions = [ !repoEnabled ? `
${csrf(viewer)}
` : '', - flybotAvailable && instance?.status !== 'ready' ? `
${csrf(viewer)}
` : '', + flybotAvailable && instance?.status !== 'ready' ? `
${csrf(viewer)}${infoTip(t('工作区就绪后,团队才能开始工作。', 'The team can start work once the workspace is ready.'))}
` : '', !credentialOk ? `${escapeHtml(t('重新授权 GitHub', 'Re-authorize GitHub'))}` : '', ].join('') if (lifecycleItems.length > 0) { @@ -1794,11 +1794,11 @@ export function repoPage(input: { config: Config; locale: Locale; viewer: Viewer : `` const dangerCard = `

${escapeHtml(t('危险操作', 'Danger zone'))}

-

${escapeHtml(t('这里的操作只影响 Fledge 连接,不会删除 GitHub 仓库。停止调度会保留实例和历史;停止 FlyBot 会停止容器;删除会移除连接、实例、任务和 token。', 'These actions affect the Fledge connection only; the GitHub repository is not deleted. Stop scheduling keeps the instance and history; Stop FlyBot stops the container; Delete removes the connection, instance, jobs and tokens.'))}

+

${escapeHtml(t('这里的操作只影响 Fledge 连接,不会删除 GitHub 仓库。停止调度会保留实例和历史;停止工作区会停止容器;删除会移除连接、实例、任务和 token。', 'These actions affect the Fledge connection only; the GitHub repository is not deleted. Stop scheduling keeps the instance and history; stopping the workspace stops the container; Delete removes the connection, instance, jobs and tokens.'))}

${reauthBanner}
${repoEnabled ? `
${csrf(viewer)}
` : `
${csrf(viewer)}
`} - ${flybotAvailable ? (instance?.status === 'ready' ? `
${csrf(viewer)}
` : `
${csrf(viewer)}
`) : ''} + ${flybotAvailable ? (instance?.status === 'ready' ? `
${csrf(viewer)}${infoTip(t('停止会中断正在运行的工作。', 'Stopping interrupts running work.'))}
` : `
${csrf(viewer)}${infoTip(t('工作区就绪后,团队才能开始工作。', 'The team can start work once the workspace is ready.'))}
`) : ''}
${csrf(viewer)} @@ -1842,8 +1842,8 @@ export function repoPage(input: { config: Config; locale: Locale; viewer: Viewer
` const usage = input.usage const usageLine = usage === undefined ? '' : `

${escapeHtml(t( - `已用仓库 ${usage.repos}/${usage.reposCap === 0 ? '∞' : usage.reposCap},FlyBot 实例 ${usage.instances}/${usage.instancesCap === 0 ? '∞' : usage.instancesCap}`, - `Repositories used ${usage.repos}/${usage.reposCap === 0 ? '∞' : usage.reposCap}, FlyBot instances ${usage.instances}/${usage.instancesCap === 0 ? '∞' : usage.instancesCap}`, + `已用仓库 ${usage.repos}/${usage.reposCap === 0 ? '∞' : usage.reposCap},工作区 ${usage.instances}/${usage.instancesCap === 0 ? '∞' : usage.instancesCap}`, + `Repositories used ${usage.repos}/${usage.reposCap === 0 ? '∞' : usage.reposCap}, workspaces ${usage.instances}/${usage.instancesCap === 0 ? '∞' : usage.instancesCap}`, ))}

` // #471: a settings refusal names the field it refused (`?field=interval`). The // detail belongs beside that control and the banner keeps only the summary, so @@ -2383,7 +2383,7 @@ export function settingsPage(input: {

${escapeHtml(t('API token', 'API tokens'))}

-

${escapeHtml(t('给脚本或 FlyBot 调用的网关 token(flg_…)。它不是你的 GitHub token,也不是模型 key。', 'Gateway tokens (flg_…) for scripts or FlyBot. They are neither your GitHub token nor a model key.'))}

+

${escapeHtml(t('给脚本或工作区调用的网关 token(flg_…)。它不是你的 GitHub token,也不是模型 key。', 'Gateway tokens (flg_…) for scripts or the workspace. They are neither your GitHub token nor a model key.'))}

${newToken === undefined ? '' : ``}
${tokenRows}
${escapeHtml(t('前缀', 'Prefix'))}${escapeHtml(t('名称', 'Name'))}${escapeHtml(t('范围', 'Scope'))}${escapeHtml(t('有效期', 'Expires'))}${escapeHtml(t('最近使用', 'Last used'))}
${csrf(viewer)} @@ -3099,7 +3099,7 @@ export function workspacePage(input: { const reposById = new Map(repos.map((repo) => [repo.id, `${repo.upstream_owner || repo.owner}/${repo.upstream_name || repo.name}`])) const repoBlock = repos.length === 0 ? `
-

${escapeHtml(t('还没有仓库。', 'No repositories yet.'))} ${escapeHtml(t('添加第一个仓库后,FlyBot 才会开始迭代。', 'Add your first repository and FlyBot can start iterating.'))}

+

${escapeHtml(t('还没有仓库。', 'No repositories yet.'))} ${escapeHtml(t('添加第一个仓库后,工作区才会开始迭代。', 'Add your first repository and the workspace can start iterating.'))}

${escapeHtml(t('添加仓库', 'Add repository'))}
` : `
${repos @@ -3142,7 +3142,7 @@ export function workspacePage(input: {
${escapeHtml(t('仓库', 'Repositories'))}${repos.length}${escapeHtml(t('已接入', 'Connected'))} ${escapeHtml(t('进行中', 'In progress'))}${active}${escapeHtml(t('排队或运行', 'Queued or running'))} - ${escapeHtml(t('需要你处理', 'Needs your input'))}${questions.length}${escapeHtml(questions.length === 0 ? t('没有待回答问题', 'No open questions') : t('FlyBot 正在等你', 'FlyBot is waiting'))} + ${escapeHtml(t('需要你处理', 'Needs your input'))}${questions.length}${escapeHtml(questions.length === 0 ? t('没有待回答问题', 'No open questions') : t('工作区正在等你', 'Workspace is waiting'))} ${escapeHtml(t('平台额度', 'Platform quota'))}${quota.unlimited ? escapeHtml(t('不限额', 'Unlimited')) : quotaMoney(quota.remainingCny)}${escapeHtml(quota.unlimited ? t('用量仍会记录', 'usage is still recorded') : t(`剩余 / ${money(quota.initialCny)}`, `left of ${money(quota.initialCny)}`))}
diff --git a/test/limits.test.ts b/test/limits.test.ts index fdc14322..2871c066 100644 --- a/test/limits.test.ts +++ b/test/limits.test.ts @@ -234,7 +234,7 @@ test('the repository page shows used / cap for both ceilings', async () => { } as Parameters[0]) assert.match(html, /data-usage-line/) assert.match(html, /Repositories used 1\/2/) - assert.match(html, /FlyBot instances 1\/3/) + assert.match(html, /workspaces 1\/3/) } finally { store.close() } diff --git a/test/nextAction.test.ts b/test/nextAction.test.ts index ad04732e..202bea41 100644 --- a/test/nextAction.test.ts +++ b/test/nextAction.test.ts @@ -140,7 +140,7 @@ test('an open question outranks an alert, because only the user can answer it', } const section = nextActionBlock(render('en', { questions: [question], alerts: [criticalAlert] })) assert.match(section, /data-next-action="questions"/) - assert.match(section, /FlyBot is waiting on 1 answer/) + assert.match(section, /Workspace is waiting on 1 answer/) assert.deepEqual(targets(section), ['#inbox'], 'the answer form is one tap away') assert.doesNotMatch(section, /45 minutes/, 'an alert does not displace a question only the user can answer') }) @@ -215,7 +215,7 @@ test('platform quota satisfies the model step, so the next action is the instanc const html = render('en', { setup }) const section = nextActionBlock(html) assert.match(section, /data-next-action="setup"/) - assert.match(section, /Start the FlyBot instance/, 'the platform-funded first run advances past the model step') + assert.match(section, /Start workspace/, 'the platform-funded first run advances past the model step') assert.doesNotMatch(section, /Add a model provider/, 'an optional model step is not the primary action') assert.match(html, /Using platform quota/, 'the checklist still says where the model comes from') }) diff --git a/test/pages.test.ts b/test/pages.test.ts index 46ae49e3..5e41dc73 100644 --- a/test/pages.test.ts +++ b/test/pages.test.ts @@ -2107,7 +2107,7 @@ test('both repository lists translate the reviewer badge', () => { // `Instances.stop()` keeps the previous error and a starting instance has none, so // every non-ready state must say what it is doing, in both languages, with its own // action — and only `failed` may report a health failure. -test('every FlyBot instance state names itself, its own action and never calls a non-ready instance healthy', () => { +test('every workspace state names itself, its own action and never calls a non-ready workspace healthy', () => { const config = testConfig({ flybot: { ...testConfig().flybot, instanceImage: 'image' } }) const store = new Store(':memory:') try { @@ -2136,12 +2136,12 @@ test('every FlyBot instance state names itself, its own action and never calls a return card.slice(0, end) } const cases = [ - { status: 'ready', lastError: null, zhBadge: '就绪', enBadge: 'Ready', zhReason: '健康检查正常', enReason: 'Health check ok', zhAction: '停止 FlyBot', enAction: 'Stop FlyBot', action: 'instance/stop' }, - { status: 'failed', lastError: 'TypeError: fetch failed', zhBadge: '失败', enBadge: 'Failed', zhReason: 'Bridge 无法连接', enReason: 'Bridge unreachable', zhAction: '启动 FlyBot', enAction: 'Start FlyBot', action: 'instance' }, - { status: 'failed', lastError: null, zhBadge: '失败', enBadge: 'Failed', zhReason: '健康检查失败', enReason: 'Health check failed', zhAction: '启动 FlyBot', enAction: 'Start FlyBot', action: 'instance' }, - { status: 'stopped', lastError: 'health check failed: stopped from the console', zhBadge: '已停止', enBadge: 'Stopped', zhReason: '实例已停止,不会接受新任务', enReason: 'The instance is stopped and takes no new jobs', zhAction: '启动 FlyBot', enAction: 'Start FlyBot', action: 'instance' }, - { status: 'starting', lastError: null, zhBadge: '启动中', enBadge: 'Starting', zhReason: '实例正在创建,还未就绪', enReason: 'The instance is being created and is not ready yet', zhAction: '重新初始化 FlyBot', enAction: 'Reinitialize FlyBot', action: 'instance' }, - { status: 'provisioning', lastError: 'TypeError: fetch failed', zhBadge: '初始化中', enBadge: 'Provisioning', zhReason: '实例正在初始化,还未就绪', enReason: 'The instance is being provisioned and is not ready yet', zhAction: '重新初始化 FlyBot', enAction: 'Reinitialize FlyBot', action: 'instance' }, + { status: 'ready', lastError: null, zhBadge: '就绪', enBadge: 'Ready', zhReason: '健康检查正常', enReason: 'Health check ok', zhAction: '停止工作区', enAction: 'Stop workspace', action: 'instance/stop' }, + { status: 'failed', lastError: 'TypeError: fetch failed', zhBadge: '失败', enBadge: 'Failed', zhReason: 'Bridge 无法连接', enReason: 'Bridge unreachable', zhAction: '启动工作区', enAction: 'Start workspace', action: 'instance' }, + { status: 'failed', lastError: null, zhBadge: '失败', enBadge: 'Failed', zhReason: '健康检查失败', enReason: 'Health check failed', zhAction: '启动工作区', enAction: 'Start workspace', action: 'instance' }, + { status: 'stopped', lastError: 'health check failed: stopped from the console', zhBadge: '已停止', enBadge: 'Stopped', zhReason: '实例已停止,不会接受新任务', enReason: 'The instance is stopped and takes no new jobs', zhAction: '启动工作区', enAction: 'Start workspace', action: 'instance' }, + { status: 'starting', lastError: null, zhBadge: '启动中', enBadge: 'Starting', zhReason: '实例正在创建,还未就绪', enReason: 'The instance is being created and is not ready yet', zhAction: '重新初始化工作区', enAction: 'Reinitialize workspace', action: 'instance' }, + { status: 'provisioning', lastError: 'TypeError: fetch failed', zhBadge: '初始化中', enBadge: 'Provisioning', zhReason: '实例正在初始化,还未就绪', enReason: 'The instance is being provisioned and is not ready yet', zhAction: '重新初始化工作区', enAction: 'Reinitialize workspace', action: 'instance' }, ] for (const state of cases) { saveInstance(state.status, state.lastError) @@ -2158,7 +2158,7 @@ test('every FlyBot instance state names itself, its own action and never calls a assert.ok(instanceCard(zh).includes(`action="/repos/${repo.id}/${state.action}"`), `${name}: the zh action posts its own form`) assert.ok(instanceCard(en).includes(`action="/repos/${repo.id}/${state.action}"`), `${name}: the en action posts its own form`) if (state.status === 'ready') { - assert.ok(!en.includes('FlyBot instance:'), 'a ready instance raises no page-level message') + assert.ok(!en.includes('Workspace: '), 'a ready instance raises no page-level message') assert.ok(!en.includes('Health check failed'), 'a ready instance never reports a failure') continue } @@ -2167,8 +2167,8 @@ test('every FlyBot instance state names itself, its own action and never calls a assert.ok(!instanceCard(en).includes('Health check ok'), `${name}: a non-ready instance is never called healthy in en`) assert.ok(!zh.includes('健康检查正常'), `${name}: the zh page never calls a non-ready instance healthy`) assert.ok(!en.includes('Health check ok'), `${name}: the en page never calls a non-ready instance healthy`) - assert.ok(zh.includes(`FlyBot 实例:${state.zhBadge} · ${state.zhReason}`), `${name}: the zh page message repeats the status and the reason`) - assert.ok(en.includes(`FlyBot instance: ${state.enBadge} · ${state.enReason}`), `${name}: the en page message repeats the status and the reason`) + assert.ok(zh.includes(`工作区:${state.zhBadge} · ${state.zhReason}`), `${name}: the zh page message repeats the status and the reason`) + assert.ok(en.includes(`Workspace: ${state.enBadge} · ${state.enReason}`), `${name}: the en page message repeats the status and the reason`) if (state.lastError !== null && state.status !== 'failed') { assert.ok(!summaryLine(en).includes(state.lastError), `${name}: an old error is not the reason of a non-failed state`) } diff --git a/test/plainLanguage.test.ts b/test/plainLanguage.test.ts new file mode 100644 index 00000000..eb442a1a --- /dev/null +++ b/test/plainLanguage.test.ts @@ -0,0 +1,195 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { buildApp } from '../src/app.js' +import { Store } from '../src/db.js' +import { MockRunner } from '../src/jobs/mock.js' +import { makeUser, MemoryMailer, sessionFor, testConfig } from './helpers.js' + +// #228: the normal-user surfaces name the product, not the machinery. The four +// pages every signed-in user reaches — /dashboard, /console, /repos/:id and +// /settings — must not name FlyBot or DSH in visible text, while the footer +// brand line and the stageMode form values survive the sweep. Rendered through +// the real routes, so the test reads the same server HTML the browser gets. + +const FORBIDDEN = [ + { pattern: /FlyBot/, what: 'FlyBot' }, + { pattern: /DSH/, what: 'DSH' }, + { pattern: /团队阶段门禁/, what: '团队阶段门禁' }, + { pattern: /Team stage gate/, what: 'Team stage gate' }, + { pattern: /\benforced\b/, what: 'enforced' }, + { pattern: /\bshadow\b/, what: 'shadow' }, +] + +const START_HINT = { zh: '工作区就绪后,团队才能开始工作。', en: 'The team can start work once the workspace is ready.' } +const STOP_HINT = { zh: '停止会中断正在运行的工作。', en: 'Stopping interrupts running work.' } +const REINIT_HINT = { zh: '重新初始化会重建工作区。', en: 'Reinitializing rebuilds the workspace.' } + +// Visible text only: the advanced operator blocks, the footer block and any +// script/style payload are removed first, then every tag — attributes included — +// so value="enforced" or name="…" can never satisfy the sweep. +function visibleText(html: string): string { + return html + .replace(/]*advanced-help[^>]*>[\s\S]*?<\/details>/g, '\n') + .replace(//g, '\n') + .replace(//gi, '\n') + .replace(//gi, '\n') + .replace(/<[^>]*>/g, '\n') +} + +interface Harness { + built: Awaited> + store: Store + user: { id: string } + repo: { id: string } + readyRepo: { id: string } + cookie: string + normal: { user: { id: string }; repo: { id: string }; cookie: string } +} + +async function createRepo(store: Store, id: string, userId: string, name: string, autoIterate: boolean): Promise<{ id: string }> { + return store.createRepo({ + id, userId, owner: 'acme', name, defaultBranch: 'main', tokenEnc: 'x', permission: 'admin', + repoRole: 'maintainer', goal: '', autoIterate, intervalMinutes: 1440, + }) +} + +async function harness(): Promise { + const config = testConfig({ flybot: { ...testConfig().flybot, instanceImage: 'image' } }) + const store = new Store(':memory:') + const built = await buildApp({ config, store, mailer: new MemoryMailer(), runner: new MockRunner(), startScheduler: false }) + const user = makeUser(store, { login: 'plain-language-user', status: 'approved', superadmin: true }) + // The dashboard answers "workspace not ready" only on its all-clear card, and + // that card needs a complete first run: an instance, a model and a finished + // job. Those live on a repository with automatic iteration off, so it never + // enters the next-run choice and cannot shadow the two repositories whose + // answer this test reads. + const readyRepo = await createRepo(store, 'repo_plain_ready', user.id, 'ready', false) + saveInstance(store, readyRepo.id, user.id, 'ready', null) + store.createModelProvider({ id: 'prov_plain', userId: user.id, label: 'p', baseUrl: 'https://example.test', keyEnc: 'x', allowPrivate: false }) + store.createProviderModel({ id: 'pm_plain', providerId: 'prov_plain', model: 'm', label: 'm' }) + store.setRepoModelSelection(readyRepo.id, ['pm_plain'], 'pm_plain') + store.createJob({ id: 'job_plain_first', repoId: readyRepo.id, userId: user.id, trigger: 'manual', goal: 'g', callbackHash: 'cb', platformTokenHash: '' }) + store.updateJob('job_plain_first', { status: 'succeeded' }) + const repo = await createRepo(store, 'repo_plain_language', user.id, 'demo', true) + await createRepo(store, 'repo_plain_second', user.id, 'second', true) + // A plain approved user: the normal-user surface the issue is written for, with + // no advanced operator region. + const normalUser = makeUser(store, { login: 'plain-language-normal', status: 'approved' }) + const normalRepo = await createRepo(store, 'repo_plain_normal', normalUser.id, 'normal', true) + const { cookie } = sessionFor(built, user) + const normalSession = sessionFor(built, normalUser) + return { built, store, user, repo, readyRepo, cookie, normal: { user: normalUser, repo: normalRepo, cookie: normalSession.cookie } } +} + +function saveInstance(store: Store, repoId: string, userId: string, status: string, lastError: string | null): void { + store.saveRepoInstance({ + repo_id: repoId, user_id: userId, container: 'fledge-plain', network: 'n', data_dir: '/tmp/plain', + bridge_script: '/tmp/bridge', dsh_port: 1, bridge_port: 2, model_port: 3, model_bind: '127.0.0.1', + image: 'image', status, chief_session: 'chief', team_json: JSON.stringify({ chief: 'c', lead: 'l', product: 'p', test: 't', security: 's', reviewer: 'r', dev1: 'd1', dev2: 'd2', reviewerScope: 'upstream', team: 'DigitalMate' }), + bridge_token_enc: 'x', bridge_pid: null, log_pid: null, last_error: lastError, + created_at: '2026-11-16T08:00:00.000Z', updated_at: '2026-11-16T08:00:00.000Z', last_health_at: '2026-11-16T08:00:00.000Z', + }) +} + +function get(h: Harness, url: string, locale: string) { + return getAs(h, h.cookie, url, locale) +} + +function getAs(h: Harness, cookie: string, url: string, locale: string) { + return h.built.app.inject({ method: 'GET', url, headers: { cookie, 'accept-language': locale } }) +} + +test('no normal-user page names the machinery in visible text (zh and en)', async () => { + const h = await harness() + try { + for (const locale of ['zh', 'en'] as const) { + for (const url of ['/dashboard', '/console', `/repos/${h.repo.id}`, '/settings']) { + const response = await get(h, url, locale) + assert.equal(response.statusCode, 200, `${locale} ${url}: renders`) + const text = visibleText(response.body) + for (const { pattern, what } of FORBIDDEN) { + const match = pattern.exec(text) + assert.equal(match, null, `${locale} ${url}: visible text must not name ${what}${match === null ? '' : ` (found near: ${JSON.stringify(text.slice(Math.max(0, match.index - 40), match.index + 40).replace(/\s+/g, ' '))})`}`) + } + } + } + } finally { + await h.built.close() + } +}) + +test('the footer brand line and the stageMode values survive the sweep', async () => { + const h = await harness() + try { + const zhPages = await Promise.all(['/dashboard', '/console', `/repos/${h.repo.id}`, '/settings'].map((url) => get(h, url, 'zh'))) + for (const page of zhPages) assert.ok(page.body.includes('由 FlyBot 驱动'), 'every zh page keeps the brand in the footer, so the sweep cannot pass by deleting the footer') + const enSettings = await get(h, '/settings', 'en') + assert.ok(enSettings.body.includes('powered by FlyBot'), 'the English page keeps the brand line too') + const repo = await get(h, `/repos/${h.repo.id}`, 'en') + for (const value of ['enforced', 'shadow', 'off']) { + assert.ok(repo.body.includes(`value="${value}"`), `the stageMode form still submits value="${value}"`) + } + } finally { + await h.built.close() + } +}) + +test('the next-run sentence and the inbox heading are fixed at every call site they share', async () => { + const h = await harness() + try { + const zh = { dashboard: await get(h, '/dashboard', 'zh'), repo: await get(h, `/repos/${h.repo.id}`, 'zh'), console: await get(h, '/console', 'zh') } + const en = { dashboard: await get(h, '/dashboard', 'en'), repo: await get(h, `/repos/${h.repo.id}`, 'en'), console: await get(h, '/console', 'en') } + // The dashboard names the next run on its all-clear card; a fixture that fell + // back to another card would make the assertion below test nothing. + for (const page of [zh.dashboard, en.dashboard]) assert.ok(page.body.includes('data-next-action="clear"'), 'the dashboard fixture reaches the all-clear card') + // The same helper renders on both surfaces; a fix applied to one call site + // only is red here. + for (const page of [zh.dashboard, zh.repo]) assert.ok(page.body.includes('工作区未就绪,自动运行不会开始'), 'zh next-run sentence on the dashboard and the repository page') + for (const page of [en.dashboard, en.repo]) assert.ok(page.body.includes('Workspace not ready; no automatic run starts'), 'en next-run sentence on the dashboard and the repository page') + for (const page of [zh.dashboard, zh.repo, zh.console]) assert.ok(page.body.includes('工作区在等你回答'), 'zh inbox heading on dashboard, repository and console') + for (const page of [en.dashboard, en.repo, en.console]) assert.ok(page.body.includes('Workspace is waiting for you'), 'en inbox heading on dashboard, repository and console') + } finally { + await h.built.close() + } +}) + +test('every renamed workspace control has a plain label and a one-line hint, in both locales', async () => { + const h = await harness() + try { + const cases = [ + { status: null, label: { zh: '启动工作区', en: 'Start workspace' }, hint: START_HINT }, + { status: 'ready', label: { zh: '停止工作区', en: 'Stop workspace' }, hint: STOP_HINT }, + { status: 'starting', label: { zh: '重新初始化工作区', en: 'Reinitialize workspace' }, hint: REINIT_HINT }, + ] as const + for (const state of cases) { + if (state.status !== null) saveInstance(h.store, h.repo.id, h.user.id, state.status, null) + for (const locale of ['zh', 'en'] as const) { + const page = await get(h, `/repos/${h.repo.id}`, locale) + assert.ok(page.body.includes(state.label[locale]), `${locale}: the ${state.status ?? 'missing'} instance offers ${state.label[locale]}`) + assert.ok(page.body.includes(state.hint[locale]), `${locale}: ${state.label[locale]} carries its one-line hint`) + } + } + } finally { + await h.built.close() + } +}) + +test('renamed copy does not mix the other language into a page', async () => { + const h = await harness() + try { + // The plain user's repository page is the surface the issue is written for: + // no advanced operator region, so the workspace heading is the one rendered. + const zhRepo = visibleText((await getAs(h, h.normal.cookie, `/repos/${h.normal.repo.id}`, 'zh')).body) + const enRepo = visibleText((await getAs(h, h.normal.cookie, `/repos/${h.normal.repo.id}`, 'en')).body) + assert.ok(zhRepo.includes('工作区状态'), 'zh uses the workspace heading') + assert.ok(!zhRepo.includes('Workspace status'), 'zh page never prints the English heading') + assert.ok(enRepo.includes('Workspace status'), 'en uses the workspace heading') + assert.ok(!enRepo.includes('工作区状态'), 'en page never prints the Chinese heading') + assert.ok(zhRepo.includes('每仓库工作区'), 'zh eyebrow is translated') + assert.ok(!zhRepo.includes('PER-REPOSITORY WORKSPACE'), 'zh page never prints the English eyebrow') + assert.ok(enRepo.includes('PER-REPOSITORY WORKSPACE'), 'en eyebrow is translated') + assert.ok(!enRepo.includes('每仓库工作区'), 'en page never prints the Chinese eyebrow') + } finally { + await h.built.close() + } +}) diff --git a/test/setupChecklist.test.ts b/test/setupChecklist.test.ts index affa7b29..4ec27f23 100644 --- a/test/setupChecklist.test.ts +++ b/test/setupChecklist.test.ts @@ -171,7 +171,7 @@ test('the dashboard shows platform quota instead of a model requirement when the assert.match(page.body, /may not cover the first run/) assert.match(page.body, /setup-warning/) const nextAction = page.body.match(/
/)?.[0] ?? '' - assert.match(nextAction, /Start the FlyBot instance/, 'the platform-funded run does not stop at the model step') + assert.match(nextAction, /Start workspace/, 'the platform-funded run does not stop at the model step') assert.doesNotMatch(nextAction, /Add a model provider/, 'the optional model step is not the primary action') } finally { await built.app.close() diff --git a/test/team.test.ts b/test/team.test.ts index eb0fae29..6ff395a3 100644 --- a/test/team.test.ts +++ b/test/team.test.ts @@ -114,7 +114,7 @@ test('team console reads live state and sends guidance', async () => { const consolePage = await built.app.inject({ method: 'GET', url: '/console', headers: { cookie } }) assert.equal(consolePage.statusCode, 200) - assert.match(consolePage.body, /FlyBot 在等你回答/) + assert.match(consolePage.body, /工作区在等你回答/) assert.match(consolePage.body, /Which path should the next job take\?/) assert.match(consolePage.body, new RegExp(`/repos/${repo.id}/team/answer`)) assert.match(consolePage.body, /openJiuwen-ai\/DigitalMate/) @@ -124,7 +124,7 @@ test('team console reads live state and sends guidance', async () => { const dashboardPage = await built.app.inject({ method: 'GET', url: '/dashboard', headers: { cookie } }) assert.equal(dashboardPage.statusCode, 200) - assert.match(dashboardPage.body, /FlyBot 在等你回答/) + assert.match(dashboardPage.body, /工作区在等你回答/) assert.match(dashboardPage.body, /Which path should the next job take\?/) const api = await built.app.inject({ method: 'GET', url: `/api/repos/${repo.id}/team`, headers: { cookie } }) From 36d9c8c00a3b1722ea0165adea3f0eac89840caf Mon Sep 17 00:00:00 2001 From: HugoXK Date: Tue, 17 Nov 2026 06:51:08 +0000 Subject: [PATCH 2/3] fix(test): match a whitespace end tag in the visible-text sweep CodeQL's bad-tag-filter query flags `` for missing ``, so the sweep allows whitespace before `>` on the script and style end tags. Fixes #228 Docs-not-needed: test-only regex; no product copy, route or doc changes. Written-by: Fledge Platform Dev-2 --- test/plainLanguage.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/plainLanguage.test.ts b/test/plainLanguage.test.ts index eb442a1a..74c3ba0e 100644 --- a/test/plainLanguage.test.ts +++ b/test/plainLanguage.test.ts @@ -31,8 +31,11 @@ function visibleText(html: string): string { return html .replace(/]*advanced-help[^>]*>[\s\S]*?<\/details>/g, '\n') .replace(//g, '\n') - .replace(//gi, '\n') - .replace(//gi, '\n') + // The end tag may carry whitespace before `>` (``), which a bare + // `` pattern would miss — CodeQL's bad-tag-filter query flags that + // shape, so both tags allow it. + .replace(/]*>[\s\S]*?<\/script\s*>/gi, '\n') + .replace(/]*>[\s\S]*?<\/style\s*>/gi, '\n') .replace(/<[^>]*>/g, '\n') } From 4191645a26c6c8386e4955df7b2c41fe4a7ab77c Mon Sep 17 00:00:00 2001 From: HugoXK Date: Tue, 17 Nov 2026 07:01:38 +0000 Subject: [PATCH 3/3] fix(test): accept any end-tag body in the visible-text sweep The CodeQL annotation names `` as an end tag a `\s*` pattern misses, so the sweep now accepts any text up to `>` on the script and style end tags, which is what the HTML tokenizer does. Fixes #228 Docs-not-needed: test-only regex; no product copy, route or doc changes. Written-by: Fledge Platform Dev-2 --- test/plainLanguage.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/plainLanguage.test.ts b/test/plainLanguage.test.ts index 74c3ba0e..2266c3bf 100644 --- a/test/plainLanguage.test.ts +++ b/test/plainLanguage.test.ts @@ -31,11 +31,11 @@ function visibleText(html: string): string { return html .replace(/]*advanced-help[^>]*>[\s\S]*?<\/details>/g, '\n') .replace(//g, '\n') - // The end tag may carry whitespace before `>` (``), which a bare - // `` pattern would miss — CodeQL's bad-tag-filter query flags that - // shape, so both tags allow it. - .replace(/]*>[\s\S]*?<\/script\s*>/gi, '\n') - .replace(/]*>[\s\S]*?<\/style\s*>/gi, '\n') + // An HTML end tag may carry anything before `>` (``, ``), + // which a bare `` pattern would miss — CodeQL's bad-tag-filter query + // flags that shape, so both end tags accept any text up to `>`. + .replace(/]*>[\s\S]*?<\/script[^>]*>/gi, '\n') + .replace(/]*>[\s\S]*?<\/style[^>]*>/gi, '\n') .replace(/<[^>]*>/g, '\n') }