diff --git a/docs/inventory/visible-controls.json b/docs/inventory/visible-controls.json index f99d9fb29..d65b0ddf2 100644 --- a/docs/inventory/visible-controls.json +++ b/docs/inventory/visible-controls.json @@ -2372,10 +2372,10 @@ {"source": "flybot_workspace/static/onboarding/app.mjs", "line": 463, "construction": "const box = document.createElement('input');", "execution_profile": "onboarding", "verification": "unverified dynamic construction site; conditional instances require execution"}, {"source": "flybot_workspace/static/onboarding/app.mjs", "line": 484, "construction": "const choice = document.createElement('select');", "execution_profile": "onboarding", "verification": "unverified dynamic construction site; conditional instances require execution"}, {"source": "flybot_workspace/static/profile/app.mjs", "line": 297, "construction": "const link = document.createElement('a');", "execution_profile": "profile", "verification": "unverified dynamic construction site; conditional instances require execution"}, - {"source": "flybot_workspace/static/settings/app.mjs", "line": 732, "construction": "const cancel = document.createElement('button');", "execution_profile": "settings", "verification": "unverified dynamic construction site; conditional instances require execution"}, - {"source": "flybot_workspace/static/settings/app.mjs", "line": 736, "construction": "const confirm = document.createElement('button');", "execution_profile": "settings", "verification": "unverified dynamic construction site; conditional instances require execution"}, - {"source": "flybot_workspace/static/settings/app.mjs", "line": 944, "construction": "const button = document.createElement('button');", "execution_profile": "settings", "verification": "unverified dynamic construction site; conditional instances require execution"}, - {"source": "flybot_workspace/static/settings/app.mjs", "line": 1098, "construction": "const remove = document.createElement('button');", "execution_profile": "settings", "verification": "unverified dynamic construction site; conditional instances require execution"}, + {"source": "flybot_workspace/static/settings/app.mjs", "line": 807, "construction": "const cancel = document.createElement('button');", "execution_profile": "settings", "verification": "unverified dynamic construction site; conditional instances require execution"}, + {"source": "flybot_workspace/static/settings/app.mjs", "line": 811, "construction": "const confirm = document.createElement('button');", "execution_profile": "settings", "verification": "unverified dynamic construction site; conditional instances require execution"}, + {"source": "flybot_workspace/static/settings/app.mjs", "line": 1019, "construction": "const button = document.createElement('button');", "execution_profile": "settings", "verification": "unverified dynamic construction site; conditional instances require execution"}, + {"source": "flybot_workspace/static/settings/app.mjs", "line": 1173, "construction": "const remove = document.createElement('button');", "execution_profile": "settings", "verification": "unverified dynamic construction site; conditional instances require execution"}, {"source": "flybot_workspace/static/settings/connected-tools.mjs", "line": 55, "construction": "const button = document.createElement('button')", "execution_profile": "settings", "verification": "unverified dynamic construction site; conditional instances require execution"}, {"source": "flybot_workspace/static/settings/custom-mcp.mjs", "line": 23, "construction": "const remove = document.createElement('button')", "execution_profile": "settings", "verification": "unverified dynamic construction site; conditional instances require execution"}, {"source": "flybot_workspace/static/shell/app.mjs", "line": 257, "construction": "link = doc.createElement('a');", "execution_profile": "shell", "verification": "unverified dynamic construction site; conditional instances require execution"}, diff --git a/flybot_workspace/static/settings/app.mjs b/flybot_workspace/static/settings/app.mjs index e928a8f57..5080d5e2a 100644 --- a/flybot_workspace/static/settings/app.mjs +++ b/flybot_workspace/static/settings/app.mjs @@ -70,17 +70,20 @@ function nextSwitchLabel(values, theme) { return clockLabel(theme === 'dark' ? end : start); } -export function describeAppearance(values, now = new Date(), media) { +export function describeAppearance(values, now = new Date(), media, source) { const theme = resolveTheme(values || { appearance: 'system' }, now, media); - const look = theme === 'dark' ? '深色' : '浅色'; + const text = key => settingsText(source, 'settings.runtime.appearance.' + key); + const look = theme === 'dark' ? uiText(source, 'settings.appearance.dark') : uiText(source, 'settings.appearance.light'); const appearance = values && values.appearance; - if (appearance === 'light') return '当前为浅色。'; - if (appearance === 'dark') return '当前为深色。'; + if (appearance === 'light') return text('current-light'); + if (appearance === 'dark') return text('current-dark'); if (appearance === 'auto') { const until = nextSwitchLabel(values, theme); - return until ? look + ',直到 ' + until + '。' : '当前为' + look + '。'; + return until + ? settingsText(source, 'settings.runtime.appearance.until', {look, until}) + : settingsText(source, 'settings.runtime.appearance.current', {look}); } - return '当前为' + look + '(跟随系统)。'; + return settingsText(source, 'settings.runtime.appearance.current-system', {look}); } const OVERVIEW_CHOICES = { @@ -90,6 +93,72 @@ const OVERVIEW_CHOICES = { 'appearance.system': ['跟随系统', 'System'], }; +// Settings runtime strings. Values the shared catalog already carries (for +// example `settings.appearance.light` and `settings.saved`) are reused through +// uiText on purpose; the entries below cover the sentences only this page emits. +// zh is the single source: without a document uiText returns it unchanged. +const SETTINGS_TEXT = { + 'settings.runtime.appearance.current-light': ['当前为浅色。', 'Light now.'], + 'settings.runtime.appearance.current-dark': ['当前为深色。', 'Dark now.'], + 'settings.runtime.appearance.until': ['{look},直到 {until}。', '{look} until {until}.'], + 'settings.runtime.appearance.current': ['当前为{look}。', '{look} now.'], + 'settings.runtime.appearance.current-system': ['当前为{look}(跟随系统)。', '{look} (following the system).'], + + 'settings.runtime.media.noun-video': ['视频', 'video'], + 'settings.runtime.media.noun-music': ['音乐', 'music'], + 'settings.runtime.media.noun-model3d': ['3D 模型', '3D model'], + 'settings.runtime.media.key-saved': ['{noun}密钥已保存。', 'The {noun} key is saved.'], + 'settings.runtime.media.unconfigured': ['尚未配置{noun}密钥。', 'No {noun} key is configured yet.'], + 'settings.runtime.media.reading': ['正在读取{noun}配置…', 'Reading the {noun} configuration…'], + 'settings.runtime.media.read-failed': ['无法读取{noun}配置,请刷新后重试。', + 'Could not read the {noun} configuration. Refresh the page and try again.'], + 'settings.runtime.media.saving': ['正在保存…', 'Saving…'], + 'settings.runtime.media.key-removed': ['已移除{noun}密钥。', 'The {noun} key was removed.'], + 'settings.runtime.media.saved': ['{noun}配置已保存。', 'The {noun} configuration was saved.'], + 'settings.runtime.media.updated-elsewhere': ['{noun}配置已在其他窗口更新,请重新输入密钥。', + 'The {noun} configuration changed in another window. Enter the key again.'], + 'settings.runtime.media.save-failed': ['无法保存{noun}配置,请重试。', + 'Could not save the {noun} configuration. Try again.'], + 'settings.runtime.media.key-required': ['请输入{noun} API 密钥。', 'Enter the {noun} API key.'], + + 'settings.runtime.image.key-saved': ['图片密钥已保存。', 'The image key is saved.'], + 'settings.runtime.image.unconfigured': ['尚未配置图片密钥。', 'No image key is configured yet.'], + 'settings.runtime.image.reading': ['正在读取图片配置…', 'Reading the image configuration…'], + 'settings.runtime.image.read-failed': ['无法读取图片配置,请刷新后重试。', + 'Could not read the image configuration. Refresh the page and try again.'], + 'settings.runtime.image.saving': ['正在保存…', 'Saving…'], + 'settings.runtime.image.key-removed': ['已移除图片密钥。', 'The image key was removed.'], + 'settings.runtime.image.saved': ['图片配置已保存。', 'The image configuration was saved.'], + 'settings.runtime.image.save-failed': ['无法保存图片配置,请重试。', + 'Could not save the image configuration. Try again.'], + + 'settings.runtime.skill-secret.delete-question': ['删除技能密钥「{name}」?', 'Delete the skill key “{name}”?'], + 'settings.runtime.skill-secret.delete-confirm': ['确认删除', 'Delete'], + 'settings.runtime.skill-secret.cancel': ['取消', 'Cancel'], + 'settings.runtime.skill-secret.delete-label': ['删除', 'Delete'], + 'settings.runtime.skill-secret.delete-failed': ['无法删除技能密钥。', 'Could not delete the skill key.'], + 'settings.runtime.skill-secret.deleted': ['已删除技能密钥「{name}」。', 'Deleted the skill key “{name}”.'], + 'settings.runtime.skill-secret.save-failed': ['保存技能密钥失败。', 'Could not save the skill key.'], + 'settings.runtime.skill-secret.saved': ['技能密钥已保存。', 'The skill key was saved.'], + + 'settings.runtime.signin.with': ['使用 {label} 登录', 'Sign in with {label}'], + 'settings.runtime.signin.start-failed': ['无法开始第三方登录。', 'Could not start the third-party sign-in.'], + 'settings.runtime.signin.failed': ['登录失败。', 'Sign-in failed.'], + 'settings.runtime.session.read-failed': ['无法读取会话。', 'Could not read the session.'], + 'settings.runtime.signout.failed': ['退出失败。', 'Sign-out failed.'], + + 'settings.runtime.form.nothing-to-save': ['没有需要保存的更改。', 'There are no changes to save.'], + 'settings.runtime.form.conflict': ['设置已在别处更新,已重新加载,请再保存一次。', + 'Settings changed elsewhere and were reloaded. Save once more.'], + 'settings.runtime.form.save-failed': ['保存失败。', 'Could not save the settings.'], +}; + +// uiText reads document.documentElement.lang; without a document it falls back +// to the zh source, so exported helpers keep their previous output. +export function settingsText(source, key, values) { + return uiText(source, key, values, SETTINGS_TEXT) || ''; +} + export function syncOverviewCurrentValues(document, values) { const appearance = document.getElementById('appearance-current'); if (appearance) { @@ -590,9 +659,12 @@ export function syncPrivacySaveButton(document, current, next) { button.disabled = Object.keys(privacyChanges(current, next)).length === 0; } -export function removeSecretPrompt(item) { +export function removeSecretPrompt(item, source) { const name = String((item && item.name) || ''); - return {question: `删除技能密钥「${name}」?`, confirmLabel: '确认删除'}; + return { + question: settingsText(source, 'settings.runtime.skill-secret.delete-question', {name}), + confirmLabel: settingsText(source, 'settings.runtime.skill-secret.delete-confirm'), + }; } function messageFor(error, fallback) { @@ -600,7 +672,7 @@ function messageFor(error, fallback) { return fallback; } -function mountMediaApi(document, request, type, noun) { +function mountMediaApi(document, request, type) { const id = type + '-api'; const form = document.getElementById(id + '-form'); if (!form) return null; @@ -610,12 +682,14 @@ function mountMediaApi(document, request, type, noun) { const keyInput = form.elements.api_key; const endpoint = '/v1/model-api/' + type; const responseKey = type + '_api'; + const mediaText = (key, values) => settingsText(document, 'settings.runtime.media.' + key, { + noun: settingsText(document, 'settings.runtime.media.noun-' + type), ...values}); let config = null; function fill(view, message) { config.revision = view.revision; remove.hidden = !view.has_api_key; - status.textContent = message || (view.has_api_key ? noun + '密钥已保存。' : '尚未配置' + noun + '密钥。'); + status.textContent = message || mediaText(view.has_api_key ? 'key-saved' : 'unconfigured'); fields.disabled = false; } @@ -623,12 +697,12 @@ function mountMediaApi(document, request, type, noun) { const active = config; if (!active || active.busy) return; active.busy = fields.disabled = true; - status.textContent = '正在读取' + noun + '配置…'; + status.textContent = mediaText('reading'); const response = await request('GET', endpoint).catch(() => ({status: 0, body: {}})); if (active !== config) return; active.busy = false; if (response.status === 200 && response.body[responseKey]) fill(response.body[responseKey], message); - else status.textContent = '无法读取' + noun + '配置,请刷新后重试。'; + else status.textContent = mediaText('read-failed'); } async function save(api_key) { @@ -636,17 +710,17 @@ function mountMediaApi(document, request, type, noun) { if (!active || active.revision === null || active.busy) return; active.busy = fields.disabled = true; keyInput.value = ''; - status.textContent = '正在保存…'; + status.textContent = mediaText('saving'); const response = await request('POST', endpoint, {revision: active.revision, api_key}) .catch(() => ({status: 0, body: {}})); if (active !== config) return; active.busy = fields.disabled = false; if (response.status === 200 && response.body[responseKey]) { - fill(response.body[responseKey], api_key === null ? '已移除' + noun + '密钥。' : noun + '配置已保存。'); + fill(response.body[responseKey], mediaText(api_key === null ? 'key-removed' : 'saved')); } else if (response.status === 409) { - await load(noun + '配置已在其他窗口更新,请重新输入密钥。'); + await load(mediaText('updated-elsewhere')); } else { - status.textContent = messageFor(response.body.error, '无法保存' + noun + '配置,请重试。'); + status.textContent = messageFor(response.body.error, mediaText('save-failed')); } } @@ -654,7 +728,7 @@ function mountMediaApi(document, request, type, noun) { event.preventDefault(); const secret = keyInput.value.trim(); if (secret) void save(secret); - else status.textContent = '请输入' + noun + ' API 密钥。'; + else status.textContent = mediaText('key-required'); }); remove.addEventListener('click', () => void save(null)); @@ -675,6 +749,7 @@ function mountMediaApi(document, request, type, noun) { } export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = {}) { + const runtimeText = (key, values) => settingsText(document, 'settings.runtime.' + key, values); const status = document.getElementById('status'); const loginPanel = document.getElementById('login-panel'); const settingsPanel = document.getElementById('settings-panel'); @@ -688,9 +763,9 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = const imageStatus = document.getElementById('image-api-status'); const removeImageKey = document.getElementById('clear-image-api'); const mediaApis = [ - mountMediaApi(document, request, 'video', '视频'), - mountMediaApi(document, request, 'music', '音乐'), - mountMediaApi(document, request, 'model3d', '3D 模型'), + mountMediaApi(document, request, 'video'), + mountMediaApi(document, request, 'music'), + mountMediaApi(document, request, 'model3d'), ].filter(Boolean); let imageAccount = null; let imageRevision = null; @@ -720,7 +795,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = function askSecretConfirmation(row, trigger, item) { closeSecretConfirm(false); - const {question, confirmLabel} = removeSecretPrompt(item); + const {question, confirmLabel} = removeSecretPrompt(item, document); const box = document.createElement('span'); box.className = 'skill-secret-confirm'; box.setAttribute('role', 'alertdialog'); @@ -731,7 +806,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = box.setAttribute('aria-labelledby', questionNode.id); const cancel = document.createElement('button'); cancel.type = 'button'; - cancel.textContent = '取消'; + cancel.textContent = settingsText(document, 'settings.runtime.skill-secret.cancel'); cancel.addEventListener('click', () => closeSecretConfirm(true)); const confirm = document.createElement('button'); confirm.type = 'button'; @@ -741,11 +816,11 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = closeSecretConfirm(false); const result = await request('POST', '/v1/skill-secrets', {name: target.name, action: 'delete'}); if (result.status !== 200) { - show('error', messageFor(result.body.error, '无法删除技能密钥。')); + show('error', messageFor(result.body.error, settingsText(document, 'settings.runtime.skill-secret.delete-failed'))); return; } await renderSkillSecrets(); - show('ok', `已删除技能密钥「${target.name}」。`); + show('ok', settingsText(document, 'settings.runtime.skill-secret.deleted', {name: target.name})); }); box.appendChild(questionNode); box.appendChild(cancel); @@ -771,7 +846,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = syncAppearanceButton(document, current); syncAppearanceExtras(document, current); const appearanceStatus = document.getElementById('appearance-status'); - if (appearanceStatus) appearanceStatus.textContent = describeAppearance(current); + if (appearanceStatus) appearanceStatus.textContent = describeAppearance(current, undefined, undefined, document); syncOverviewCurrentValues(document, current); const languageCurrent = document.getElementById('language-current'); const languageSelect = form.querySelector('select[name="language"]'); @@ -903,7 +978,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = return; } if (session.status !== 200) { - show('error', messageFor(session.body.error, '无法读取会话。')); + show('error', messageFor(session.body.error, runtimeText('session.read-failed'))); return; } const account = session.body.user.id ?? session.body.user.username; @@ -943,12 +1018,12 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = for (const item of listed.body.items) { const button = document.createElement('button'); button.type = 'button'; - button.textContent = '使用 ' + item.label + ' 登录'; + button.textContent = runtimeText('signin.with', {label: item.label}); button.dataset.provider = item.id; button.addEventListener('click', async () => { const started = await request('POST', '/v1/auth/oidc/start', {provider: item.id}); if (started.status !== 200 || !started.body.authorization_url) { - show('error', messageFor(started.body.error, '无法开始第三方登录。')); + show('error', messageFor(started.body.error, runtimeText('signin.start-failed'))); return; } globalThis.location.assign(started.body.authorization_url); @@ -964,7 +1039,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = password: document.getElementById('password').value, }); if (result.status !== 200) { - show('error', messageFor(result.body.error, '登录失败。')); + show('error', messageFor(result.body.error, runtimeText('signin.failed'))); return; } document.getElementById('password').value = ''; @@ -1055,7 +1130,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = const changes = diff(current, readForm(form)); delete changes.language; if (!Object.keys(changes).length) { - show('ok', '没有需要保存的更改。'); + show('ok', runtimeText('form.nothing-to-save')); return; } const sequence = loadSequence; @@ -1066,18 +1141,18 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = revision = result.body.error.current.revision; fillForm(form, current); refreshAppearance(); - show('error', '设置已在别处更新,已重新加载,请再保存一次。'); + show('error', runtimeText('form.conflict')); return; } if (result.status !== 200) { - show('error', messageFor(result.body.error, '保存失败。')); + show('error', messageFor(result.body.error, runtimeText('form.save-failed'))); return; } current = result.body.settings.values; revision = result.body.settings.revision; fillForm(form, current); refreshAppearance(); - show('ok', '已保存。'); + show('ok', uiText(document, 'settings.saved')); syncPrivacySaveButton(document, current, readForm(form)); }); @@ -1097,7 +1172,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = name.textContent = item.name; const remove = document.createElement('button'); remove.type = 'button'; - remove.textContent = '删除'; + remove.textContent = settingsText(document, 'settings.runtime.skill-secret.delete-label'); remove.addEventListener('click', () => askSecretConfirmation(row, remove, item)); row.appendChild(name); row.appendChild(remove); @@ -1131,10 +1206,10 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = const result = await request('POST', '/v1/skill-secrets', {name, action: 'set', value}); skillForm.elements.value.value = ''; if (result.status !== 200) { - show('error', messageFor(result.body.error, '保存技能密钥失败。')); + show('error', messageFor(result.body.error, runtimeText('skill-secret.save-failed'))); return; } - show('ok', '技能密钥已保存。'); + show('ok', runtimeText('skill-secret.saved')); skillForm.hidden = true; await renderSkillSecrets(); }); @@ -1157,7 +1232,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = imageForm.elements.model.value = config.model; imageForm.elements.api_key.value = ''; removeImageKey.hidden = !config.api_key_set; - imageStatus.textContent = message || (config.api_key_set ? '图片密钥已保存。' : '尚未配置图片密钥。'); + imageStatus.textContent = message || runtimeText(config.api_key_set ? 'image.key-saved' : 'image.unconfigured'); imageFields.disabled = false; } @@ -1165,28 +1240,28 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = if (imageLoading) return; const account = imageAccount; imageLoading = true; - imageStatus.textContent = '正在读取图片配置…'; + imageStatus.textContent = runtimeText('image.reading'); const response = await request('GET','/v1/model-api/image').catch(() => ({status:0,body:{}})); if (account !== imageAccount) return; imageLoading = false; if (response.status === 200 && response.body.image_api) fillImageApi(response.body.image_api); - else imageStatus.textContent = '无法读取图片配置,请刷新后重试。'; + else imageStatus.textContent = runtimeText('image.read-failed'); } async function saveImageApi(changes) { if (imageRevision === null || imageLoading || imageSaving) return; const account = imageAccount; imageSaving = imageFields.disabled = true; - imageStatus.textContent = '正在保存…'; + imageStatus.textContent = runtimeText('image.saving'); const response = await request('POST','/v1/model-api/image',{revision:imageRevision,changes}) .catch(() => ({status:0,body:{}})); if (account !== imageAccount) return; imageSaving = imageFields.disabled = false; imageForm.elements.api_key.value = ''; if (response.status === 200 && response.body.image_api) { - fillImageApi(response.body.image_api,changes.api_key === null ? '已移除图片密钥。' : '图片配置已保存。'); + fillImageApi(response.body.image_api, runtimeText(changes.api_key === null ? 'image.key-removed' : 'image.saved')); } else if (response.status === 409) await loadImageApi(); - else imageStatus.textContent = messageFor(response.body.error,'无法保存图片配置,请重试。'); + else imageStatus.textContent = messageFor(response.body.error, runtimeText('image.save-failed')); } imageForm?.addEventListener('submit',event => { @@ -1249,7 +1324,7 @@ export function mount(document, {fetcher = globalThis.fetch.bind(globalThis)} = event.preventDefault(); const result = await request('POST', '/v1/auth/logout', {}); if (result.status !== 200) { - show('error', messageFor(result.body.error, '退出失败。')); + show('error', messageFor(result.body.error, runtimeText('signout.failed'))); return; } current = null; diff --git a/tests/settings_page.test.mjs b/tests/settings_page.test.mjs index 70d8296d4..55009a932 100644 --- a/tests/settings_page.test.mjs +++ b/tests/settings_page.test.mjs @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'; import test from 'node:test'; import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; -import { applyComposioRows, applyConnectorSearch, applySettingsView, composioMessage, composioRowState, connectorsText, pickConnection, CONNECTOR_CATALOG, csrfCookie, describeAppearance, diff, filterConnectorCatalog, mount, newlineBinding, privacyChanges, readForm, renderModelApi, settingsViewFromLocation, syncAppearanceExtras, syncOverviewCurrentValues, syncMcpDialog, syncPrivacySaveButton, syncShortcutRows } from '../flybot_workspace/static/settings/app.mjs'; +import { applyComposioRows, applyConnectorSearch, applySettingsView, composioMessage, composioRowState, connectorsText, pickConnection, CONNECTOR_CATALOG, csrfCookie, describeAppearance, diff, filterConnectorCatalog, mount, newlineBinding, privacyChanges, readForm, removeSecretPrompt, renderModelApi, settingsText, settingsViewFromLocation, syncAppearanceExtras, syncOverviewCurrentValues, syncMcpDialog, syncPrivacySaveButton, syncShortcutRows } from '../flybot_workspace/static/settings/app.mjs'; import { mountToolApprovals } from '../flybot_workspace/static/settings/connected-tools.mjs'; test('csrfCookie reads host-bound and development cookie names only', () => { @@ -1106,6 +1106,44 @@ test('connector state strings follow the system locale', () => { assert.equal(composioMessage({code: 'composio_conflict'}, ''), 'Composio 报告连接冲突。请刷新页面查看当前连接,再重试。'); }); +test('settings runtime strings follow the system locale', () => { + const document = {documentElement: {lang: 'en'}}; + const afternoon = new Date(2026, 10, 18, 15, 0, 0); + assert.equal(describeAppearance({appearance: 'light'}, undefined, undefined, document), 'Light now.'); + assert.equal(describeAppearance({appearance: 'dark'}, undefined, undefined, document), 'Dark now.'); + assert.equal( + describeAppearance({appearance: 'auto', appearance_schedule: 'sunset_sunrise'}, afternoon, undefined, document), + 'Light until 22:00.', + ); + assert.equal(describeAppearance({appearance: 'system'}, afternoon, {matches: false}, document), + 'Light (following the system).'); + assert.deepEqual(removeSecretPrompt({name: 'alpha'}, document), + {question: 'Delete the skill key “alpha”?', confirmLabel: 'Delete'}); + assert.equal(settingsText(document, 'settings.runtime.image.key-saved'), 'The image key is saved.'); + assert.equal(settingsText(document, 'settings.runtime.media.updated-elsewhere', {noun: 'video'}), + 'The video configuration changed in another window. Enter the key again.'); + assert.equal(settingsText(document, 'settings.runtime.media.key-required', {noun: '3D model'}), + 'Enter the 3D model API key.'); + assert.equal(settingsText(document, 'settings.runtime.form.conflict'), + 'Settings changed elsewhere and were reloaded. Save once more.'); + assert.equal(settingsText(document, 'settings.saved'), 'Saved.'); + + document.documentElement.lang = 'zh-CN'; + assert.equal(describeAppearance({appearance: 'light'}, undefined, undefined, document), '当前为浅色。'); + assert.equal( + describeAppearance({appearance: 'auto', appearance_schedule: 'sunset_sunrise'}, afternoon, undefined, document), + '浅色,直到 22:00。', + ); + assert.equal(describeAppearance({appearance: 'system'}, afternoon, {matches: true}, document), '当前为深色(跟随系统)。'); + assert.deepEqual(removeSecretPrompt({name: 'alpha'}, document), + {question: '删除技能密钥「alpha」?', confirmLabel: '确认删除'}); + assert.equal(settingsText(document, 'settings.runtime.media.key-required', {noun: '视频'}), '请输入视频 API 密钥。'); + assert.equal(settingsText(document, 'settings.runtime.form.conflict'), + '设置已在别处更新,已重新加载,请再保存一次。'); + assert.equal(settingsText(document, 'settings.runtime.signin.with', {label: 'GitHub'}), '使用 GitHub 登录'); + assert.equal(describeAppearance({appearance: 'light'}), '当前为浅色。'); +}); + test('connected-tool approvals do not imply a connected account before key setup', () => { const source = readFileSync(fileURLToPath(new URL('../flybot_workspace/static/settings/connected-tools.mjs', import.meta.url)), 'utf8');