Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 本地化飞书权限模式失败提示

david40a690610ab1
diff --git a/apps/desktop/src/main/im/feishu/__tests__/feishuAdapter.test.ts b/apps/desktop/src/main/im/feishu/__tests__/feishuAdapter.test.ts
index dafd510bb8..3c2adbdf07 100644
--- a/apps/desktop/src/main/im/feishu/__tests__/feishuAdapter.test.ts
+++ b/apps/desktop/src/main/im/feishu/__tests__/feishuAdapter.test.ts
@@ -57,6 +57,7 @@ import type {
IMMessageEvent,
IMStatus,
} from '@cindy/im';
+import { getResolvedMainLocale, setMainLocale } from '../../../i18n';
import { buildFeishuAdapter } from '../adapter';
import { formatHistoryTime } from '../groupContext';
@@ -136,6 +137,27 @@ describe('feishu ImChannelAdapter characterization', () => {
expect(adapter.sessions.source).toBe('feishu');
});
+ it('权限模式不兼容提示在发送时跟随当前语言', () => {
+ const originalLocale = getResolvedMainLocale();
+ const copy = adapter.ui.error?.permissionModeUnsupported;
+ expect(copy).toBeTypeOf('function');
+ if (typeof copy !== 'function') throw new Error('missing permission mode copy');
+
+ try {
+ setMainLocale('en');
+ expect(copy('acceptEdits')).toBe(
+ 'The current Agent cannot run on this channel in this permission mode, so messages cannot be processed. Send /permission to choose a supported mode.',
+ );
+
+ setMainLocale('zh-CN');
+ expect(copy('acceptEdits')).toBe(
+ '当前 Agent 不支持以此权限模式在该渠道运行,消息将无法处理。请发送 /permission 调整权限模式。',
+ );
+ } finally {
+ setMainLocale(originalLocale);
+ }
+ });
+
it('session id 格式 feishu_{botAppId}_{openId} — 跨重启稳定, 老用户续上历史', () => {
expect(adapter.sessions.sessionIdFor('cli_abc', 'ou_xyz')).toBe('feishu_cli_abc_ou_xyz');
});
diff --git a/apps/desktop/src/main/im/feishu/uiText.ts b/apps/desktop/src/main/im/feishu/uiText.ts
index 5b4859cae5..6a97f5c859 100644
--- a/apps/desktop/src/main/im/feishu/uiText.ts
+++ b/apps/desktop/src/main/im/feishu/uiText.ts
@@ -13,6 +13,7 @@
import type { IMUnsupportedEntry } from '@cindy/im';
+import { t } from '../../i18n';
import type { ImUiTextPack } from '../shared/types';
export const ui = {
@@ -92,16 +93,8 @@ export const ui = {
error: {
agentUnsupported:
'🤔 当前选择的 Agent 在这个渠道需要逐条权限确认,暂时上不了场,换一个 Agent 再试~',
- permissionModeUnsupported: (permissionMode: string) => {
- // 「完全访问」已由渠道设置显式放行(护栏取缔), 这里实际只剩
- // acceptEdits(自动接受编辑)会被群强确认策略拒绝 — 按档位点名报错。
- const modeLabel =
- permissionMode === 'acceptEdits' ? '「自动接受编辑」' : '当前权限档';
- return (
- `⚠️ 群/话题会话不能用${modeLabel} — 群上下文里有成员可控的内容,必须保留操作确认。\n` +
- '我往你私聊发了张修复卡,去点一下切回「自动审批」就能继续~(也可以发 /permission 手动切)'
- );
- },
+ permissionModeUnsupported: () =>
+ t('settings.imBot.defaults.permissionModeUnsupportedOnChannelHint'),
},
// ── card text (sent via @cindy/im InteractiveCardSpec) ──────────────────────
diff --git a/apps/desktop/src/main/im/shared/__tests__/turnRunnerSendOutcome.test.ts b/apps/desktop/src/main/im/shared/__tests__/turnRunnerSendOutcome.test.ts
index 22803de247..538965ca7e 100644
--- a/apps/desktop/src/main/im/shared/__tests__/turnRunnerSendOutcome.test.ts
+++ b/apps/desktop/src/main/im/shared/__tests__/turnRunnerSendOutcome.test.ts
@@ -1255,7 +1255,7 @@ describe('turnRunner send outcome policy (feishu adapter characterization)', ()
// 群 lane 报错文案之外, 再发一张一键修复卡到 owner 私聊。
expect(mocks.feishuIm.sendText).toHaveBeenCalledWith(
'g/oc_group1/omt_t1',
- expect.stringContaining('群/话题会话不能用'),
+ expect.stringContaining('/permission'),
expect.anything(),
);
expect(mocks.feishuIm.sendInteractiveCard).toHaveBeenCalledWith(