diff --git a/changelog.d/3114-capability-refusals-zh.fixed.md b/changelog.d/3114-capability-refusals-zh.fixed.md new file mode 100644 index 000000000..cc16cc403 --- /dev/null +++ b/changelog.d/3114-capability-refusals-zh.fixed.md @@ -0,0 +1 @@ +The Capabilities page now says, in a Chinese window, why a pack cannot be saved and why a capability is no longer there: the refusal that carries the child capability name, and the two that carry a capability name or an unapproved stdio MCP name, read Chinese, with the name exactly as the host wrote it ([#3114](https://github.com/ThinkFlowLab/FlyBot/issues/3114)). diff --git a/core/client.js b/core/client.js index f2aff9b18..1a6be9caa 100644 --- a/core/client.js +++ b/core/client.js @@ -1777,7 +1777,14 @@ var HOST_ERRORS = [ // `connector-send` names the notifier's own refusal, and its fallback literal, in the brackets. [/^Feishu refused the message \((.+)\)$/, "飞书拒收这条消息($1)"], [/^Pick up to (\d+) apps$/, "最多选 $1 个应用"], - [/^Composio answered (\d+)([\s\S]*)$/, "Composio 返回了 $1$2"] + [/^Composio answered (\d+)([\s\S]*)$/, "Composio 返回了 $1$2"], + // #3114 cut 33: the Capabilities page's three refusals that carry a name. Anchored at both ends + // because the whole host message arrives here (api.js); the name is data and is copied through, so a + // dot, a bracket or a line break in it can never be read as part of the sentence. `stdio` stays as + // the host wrote it: it names the transport the Allow button is about. + [/^Packs can include only saved MCP servers and skills\. (.+) is not one\.$/, "能力包里只能放已保存的 MCP 服务和技能;$1 不是其中之一。"], + [/^No capability named (.+)\.$/, "找不到叫 $1 的能力。"], + [/^No unapproved stdio MCP named (.+)\.$/, "找不到叫 $1 的待批准 stdio MCP 服务。"] ]; var HOST_ZH = { "Request failed": "请求失败", diff --git a/core/src/client/i18n.js b/core/src/client/i18n.js index 953962414..b3c8818e6 100644 --- a/core/src/client/i18n.js +++ b/core/src/client/i18n.js @@ -1738,6 +1738,13 @@ const HOST_ERRORS = [ [/^Feishu refused the message \((.+)\)$/, '飞书拒收这条消息($1)'], [/^Pick up to (\d+) apps$/, '最多选 $1 个应用'], [/^Composio answered (\d+)([\s\S]*)$/, 'Composio 返回了 $1$2'], + // #3114 cut 33: the Capabilities page's three refusals that carry a name. Anchored at both ends + // because the whole host message arrives here (api.js); the name is data and is copied through, so a + // dot, a bracket or a line break in it can never be read as part of the sentence. `stdio` stays as + // the host wrote it: it names the transport the Allow button is about. + [/^Packs can include only saved MCP servers and skills\. (.+) is not one\.$/, '能力包里只能放已保存的 MCP 服务和技能;$1 不是其中之一。'], + [/^No capability named (.+)\.$/, '找不到叫 $1 的能力。'], + [/^No unapproved stdio MCP named (.+)\.$/, '找不到叫 $1 的待批准 stdio MCP 服务。'], ] const HOST_ZH = { 'Request failed': '请求失败', diff --git a/core/test/i18n.test.js b/core/test/i18n.test.js index 36dac9349..7e7bad8de 100644 --- a/core/test/i18n.test.js +++ b/core/test/i18n.test.js @@ -64,3 +64,42 @@ test('#1813: the Project board queue states read in Chinese', () => { // The board keeps emitting the lowercase ids; only the Chinese dictionary changes. assert.equal(t('running'), 'running') }) + +// #3114 cut 33: the Capabilities page's three refusals that carry a name. `(.+)` is the name and +// String.replace copies it through, so a dot or a bracket in a team file's name is data, not syntax. +test('#3114 cut 33: the capability refusals that carry a name read in Chinese, and the name stays as it is', () => { + const off = installLocale(fakeLocale('zh')) + try { + assert.equal(hostText('Packs can include only saved MCP servers and skills. web-search is not one.'), + '能力包里只能放已保存的 MCP 服务和技能;web-search 不是其中之一。') + assert.equal(hostText('No capability named web-search.'), '找不到叫 web-search 的能力。') + assert.equal(hostText('No unapproved stdio MCP named web-search.'), '找不到叫 web-search 的待批准 stdio MCP 服务。') + // A name is whatever the team file holds, so a dot or a bracket is copied and never parsed. + assert.equal(hostText('No capability named a.b.'), '找不到叫 a.b 的能力。') + assert.equal(hostText('No capability named a(b).'), '找不到叫 a(b) 的能力。') + // The one shape that cannot be told from a name holding ". ": the name is still copied verbatim. + assert.equal(hostText('No capability named web-search. Try again.'), '找不到叫 web-search. Try again 的能力。') + // Sentences this cut leaves in English: no closing full stop, text before the sentence, a line + // break in the name, a pack line without its stop, a stdio line without its stop, and the + // endpoint fallback no caller reaches. + for (const message of [ + 'No capability named web-search', + 'The host said: No capability named web-search.', + 'No capability named web-\nsearch.', + 'Packs can include only saved MCP servers and skills. web-search is not one', + 'No unapproved stdio MCP named web-search', + 'Unknown capability operation.', + ]) assert.equal(hostText(message), message) + } finally { + off() + } +}) + +// A window that is not zh gets the host's sentence, not a translation of it (these three have no key). +test('#3114 cut 33: an English window keeps the capability refusals as the host wrote them', () => { + for (const message of [ + 'Packs can include only saved MCP servers and skills. web-search is not one.', + 'No capability named web-search.', + 'No unapproved stdio MCP named web-search.', + ]) assert.equal(hostText(message), message) +}) diff --git a/core/test/settings-error-placement.test.js b/core/test/settings-error-placement.test.js index 355d606a3..ef0bd509d 100644 --- a/core/test/settings-error-placement.test.js +++ b/core/test/settings-error-placement.test.js @@ -196,3 +196,35 @@ test('#3114 cut 31: an English window reads the same form and the same refusals assert.equal(await refusedForm(raw), raw, `"${raw}" draws exactly as the host wrote it`) } }) + +// #3114 cut 33: a pack refusal names the child capability that is gone; the name is data and is copied untouched. +test('#3114 cut 33: a zh window reads the pack refusal with the child name untouched', async () => { + await inLang('zh', async () => { + assert.equal(await refusedForm('Packs can include only saved MCP servers and skills. web-search is not one.'), + '能力包里只能放已保存的 MCP 服务和技能;web-search 不是其中之一。') + assert.equal(await refusedForm('Packs can include only saved MCP servers and skills. 报告.2026 is not one.'), + '能力包里只能放已保存的 MCP 服务和技能;报告.2026 不是其中之一。') + }) +}) + +// #3114 cut 33: the two refusals a stale row leaves on the same page (another window, or a Bot's own delete_capability), which land in the dialog's own `run`. +test('#3114 cut 33: a zh window reads the stale-row capability refusals where the dialog shows them', async () => { + await inLang('zh', async () => { + const props = { page: 'capabilities', roster, actions, useUpdate: () => ({}) } + let tree = expand(SettingsDialog, props) + const page = all(tree).find(node => node?.type === CapabilitiesPage) + assert.ok(page, 'the dialog draws the Capabilities page') + for (const [raw, chinese] of [ + ['No capability named web-search.', '找不到叫 web-search 的能力。'], + ['No unapproved stdio MCP named web-search.', '找不到叫 web-search 的待批准 stdio MCP 服务。'], + ]) { + // api.js translated the host sentence before it threw, so the stub hands over what it threw. + page.props.run(Promise.reject(new Error(hostText(raw)))) + await flush() + tree = render(SettingsDialog, props) + const alert = all(tree).find(node => node?.props?.role === 'alert') + assert.ok(alert, `"${raw}" is on screen`) + assert.equal(text(alert), chinese) + } + }) +}) diff --git a/patches/ds-bot/0001-core-fixes.patch b/patches/ds-bot/0001-core-fixes.patch index 6e49e699d..aac83ebf9 100644 --- a/patches/ds-bot/0001-core-fixes.patch +++ b/patches/ds-bot/0001-core-fixes.patch @@ -2053,7 +2053,7 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js [/^HTTP (\d+)$/, '请求失败(HTTP $1)'], [/^GitHub answered (\d+)$/, 'GitHub 返回了 $1'], [/^Keep the name under (\d+) characters$/, '名字不能超过 $1 个字'], -@@ -872,6 +872,27 @@ const HOST_ERRORS = [ +@@ -872,6 +872,34 @@ const HOST_ERRORS = [ [/^No entry in [\s\S]* matches "([\s\S]*)"\.[\s\S]*$/, '找不到「$1」这条记忆'], [/^"([\s\S]*)" matches (\d+) entries in [\s\S]*$/, '「$1」对应了 $2 条记忆,请说得更具体'], [/^Memory cannot change now: [\s\S]*$/, '现在不能修改记忆:另一个 dsh 正在使用这个 Bot 团队'], @@ -2078,6 +2078,13 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js + [/^Feishu refused the message \((.+)\)$/, '飞书拒收这条消息($1)'], + [/^Pick up to (\d+) apps$/, '最多选 $1 个应用'], + [/^Composio answered (\d+)([\s\S]*)$/, 'Composio 返回了 $1$2'], ++ // #3114 cut 33: the Capabilities page's three refusals that carry a name. Anchored at both ends ++ // because the whole host message arrives here (api.js); the name is data and is copied through, so a ++ // dot, a bracket or a line break in it can never be read as part of the sentence. `stdio` stays as ++ // the host wrote it: it names the transport the Allow button is about. ++ [/^Packs can include only saved MCP servers and skills\. (.+) is not one\.$/, '能力包里只能放已保存的 MCP 服务和技能;$1 不是其中之一。'], ++ [/^No capability named (.+)\.$/, '找不到叫 $1 的能力。'], ++ [/^No unapproved stdio MCP named (.+)\.$/, '找不到叫 $1 的待批准 stdio MCP 服务。'], ] const HOST_ZH = { 'Request failed': '请求失败', @@ -13793,7 +13800,7 @@ diff --git a/test/home-lock.test.js b/test/home-lock.test.js diff --git a/test/i18n.test.js b/test/i18n.test.js --- a/test/i18n.test.js +++ b/test/i18n.test.js -@@ -49,3 +49,18 @@ test('copy follows the DSH language and stays English without a locale service', +@@ -49,3 +49,57 @@ test('copy follows the DSH language and stays English without a locale service', assert.equal(t('Model'), 'Model') assert.equal(hostText('A Bot named Writer already exists'), 'A Bot named Writer already exists') }) @@ -13812,6 +13819,45 @@ diff --git a/test/i18n.test.js b/test/i18n.test.js + // The board keeps emitting the lowercase ids; only the Chinese dictionary changes. + assert.equal(t('running'), 'running') +}) ++ ++// #3114 cut 33: the Capabilities page's three refusals that carry a name. `(.+)` is the name and ++// String.replace copies it through, so a dot or a bracket in a team file's name is data, not syntax. ++test('#3114 cut 33: the capability refusals that carry a name read in Chinese, and the name stays as it is', () => { ++ const off = installLocale(fakeLocale('zh')) ++ try { ++ assert.equal(hostText('Packs can include only saved MCP servers and skills. web-search is not one.'), ++ '能力包里只能放已保存的 MCP 服务和技能;web-search 不是其中之一。') ++ assert.equal(hostText('No capability named web-search.'), '找不到叫 web-search 的能力。') ++ assert.equal(hostText('No unapproved stdio MCP named web-search.'), '找不到叫 web-search 的待批准 stdio MCP 服务。') ++ // A name is whatever the team file holds, so a dot or a bracket is copied and never parsed. ++ assert.equal(hostText('No capability named a.b.'), '找不到叫 a.b 的能力。') ++ assert.equal(hostText('No capability named a(b).'), '找不到叫 a(b) 的能力。') ++ // The one shape that cannot be told from a name holding ". ": the name is still copied verbatim. ++ assert.equal(hostText('No capability named web-search. Try again.'), '找不到叫 web-search. Try again 的能力。') ++ // Sentences this cut leaves in English: no closing full stop, text before the sentence, a line ++ // break in the name, a pack line without its stop, a stdio line without its stop, and the ++ // endpoint fallback no caller reaches. ++ for (const message of [ ++ 'No capability named web-search', ++ 'The host said: No capability named web-search.', ++ 'No capability named web-\nsearch.', ++ 'Packs can include only saved MCP servers and skills. web-search is not one', ++ 'No unapproved stdio MCP named web-search', ++ 'Unknown capability operation.', ++ ]) assert.equal(hostText(message), message) ++ } finally { ++ off() ++ } ++}) ++ ++// A window that is not zh gets the host's sentence, not a translation of it (these three have no key). ++test('#3114 cut 33: an English window keeps the capability refusals as the host wrote them', () => { ++ for (const message of [ ++ 'Packs can include only saved MCP servers and skills. web-search is not one.', ++ 'No capability named web-search.', ++ 'No unapproved stdio MCP named web-search.', ++ ]) assert.equal(hostText(message), message) ++}) diff --git a/test/images.test.js b/test/images.test.js --- a/test/images.test.js +++ b/test/images.test.js diff --git a/patches/ds-bot/0008-client-bundle.patch b/patches/ds-bot/0008-client-bundle.patch index 00a044bb5..8613ead3d 100644 --- a/patches/ds-bot/0008-client-bundle.patch +++ b/patches/ds-bot/0008-client-bundle.patch @@ -1308,7 +1308,7 @@ diff --git a/client.js b/client.js [/^HTTP (\d+)$/, "请求失败(HTTP $1)"], [/^GitHub answered (\d+)$/, "GitHub 返回了 $1"], [/^Keep the name under (\d+) characters$/, "名字不能超过 $1 个字"], -@@ -918,7 +918,28 @@ var HOST_ERRORS = [ +@@ -918,7 +918,35 @@ var HOST_ERRORS = [ [/^There is no entry (.+)\.$/, "没有第 $1 条"], [/^No entry in [\s\S]* matches "([\s\S]*)"\.[\s\S]*$/, "找不到「$1」这条记忆"], [/^"([\s\S]*)" matches (\d+) entries in [\s\S]*$/, "「$1」对应了 $2 条记忆,请说得更具体"], @@ -1334,7 +1334,14 @@ diff --git a/client.js b/client.js + // `connector-send` names the notifier's own refusal, and its fallback literal, in the brackets. + [/^Feishu refused the message \((.+)\)$/, "飞书拒收这条消息($1)"], + [/^Pick up to (\d+) apps$/, "最多选 $1 个应用"], -+ [/^Composio answered (\d+)([\s\S]*)$/, "Composio 返回了 $1$2"] ++ [/^Composio answered (\d+)([\s\S]*)$/, "Composio 返回了 $1$2"], ++ // #3114 cut 33: the Capabilities page's three refusals that carry a name. Anchored at both ends ++ // because the whole host message arrives here (api.js); the name is data and is copied through, so a ++ // dot, a bracket or a line break in it can never be read as part of the sentence. `stdio` stays as ++ // the host wrote it: it names the transport the Allow button is about. ++ [/^Packs can include only saved MCP servers and skills\. (.+) is not one\.$/, "能力包里只能放已保存的 MCP 服务和技能;$1 不是其中之一。"], ++ [/^No capability named (.+)\.$/, "找不到叫 $1 的能力。"], ++ [/^No unapproved stdio MCP named (.+)\.$/, "找不到叫 $1 的待批准 stdio MCP 服务。"] ]; var HOST_ZH = { "Request failed": "请求失败", diff --git a/patches/ds-bot/files/test/settings-error-placement.test.js b/patches/ds-bot/files/test/settings-error-placement.test.js index 355d606a3..ef0bd509d 100644 --- a/patches/ds-bot/files/test/settings-error-placement.test.js +++ b/patches/ds-bot/files/test/settings-error-placement.test.js @@ -196,3 +196,35 @@ test('#3114 cut 31: an English window reads the same form and the same refusals assert.equal(await refusedForm(raw), raw, `"${raw}" draws exactly as the host wrote it`) } }) + +// #3114 cut 33: a pack refusal names the child capability that is gone; the name is data and is copied untouched. +test('#3114 cut 33: a zh window reads the pack refusal with the child name untouched', async () => { + await inLang('zh', async () => { + assert.equal(await refusedForm('Packs can include only saved MCP servers and skills. web-search is not one.'), + '能力包里只能放已保存的 MCP 服务和技能;web-search 不是其中之一。') + assert.equal(await refusedForm('Packs can include only saved MCP servers and skills. 报告.2026 is not one.'), + '能力包里只能放已保存的 MCP 服务和技能;报告.2026 不是其中之一。') + }) +}) + +// #3114 cut 33: the two refusals a stale row leaves on the same page (another window, or a Bot's own delete_capability), which land in the dialog's own `run`. +test('#3114 cut 33: a zh window reads the stale-row capability refusals where the dialog shows them', async () => { + await inLang('zh', async () => { + const props = { page: 'capabilities', roster, actions, useUpdate: () => ({}) } + let tree = expand(SettingsDialog, props) + const page = all(tree).find(node => node?.type === CapabilitiesPage) + assert.ok(page, 'the dialog draws the Capabilities page') + for (const [raw, chinese] of [ + ['No capability named web-search.', '找不到叫 web-search 的能力。'], + ['No unapproved stdio MCP named web-search.', '找不到叫 web-search 的待批准 stdio MCP 服务。'], + ]) { + // api.js translated the host sentence before it threw, so the stub hands over what it threw. + page.props.run(Promise.reject(new Error(hostText(raw)))) + await flush() + tree = render(SettingsDialog, props) + const alert = all(tree).find(node => node?.props?.role === 'alert') + assert.ok(alert, `"${raw}" is on screen`) + assert.equal(text(alert), chinese) + } + }) +})