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。

Merge upstream main and retain WeChat cleanup test wiring

Chrisd2bd4e3c2469
diff --cc apps/desktop/src/main/im/shared/__tests__/botImConnectionRuntime.test.ts
index b463987415,8b44142749..e538cd9ef0
--- a/apps/desktop/src/main/im/shared/__tests__/botImConnectionRuntime.test.ts
+++ b/apps/desktop/src/main/im/shared/__tests__/botImConnectionRuntime.test.ts
@@@ -91,8 -91,7 +92,8 @@@ import
stopBotImConnections,
__testing,
} from '../botImConnectionRuntime';
- import { listBotImConnections, secretKeyPrefixFor } from '../botImConnectionStore';
+ import { addBotImConnectionRecord, listBotImConnections, secretKeyPrefixFor } from '../botImConnectionStore';
+import { readWechatChannelSettings, writeWechatCompanionBinding, writeWechatWorkingDir } from '../../wechat/channelSettings';
import {
adoptPersonalBot,
configureBotImPersonalAdoption,
@@@ -325,6 -322,47 +326,48 @@@ describe('bot im connection runtime', (
});
});
+ // #6439: persisted connections can fail init and remain in instances. Exercise
+ // the real store/start/select lifecycle (unit) instead of a selector replica.
+ it('skips failed and ownerless Feishu connections without changing the resolved recipient', async () => {
+ const states = [
+ { kind: 'error', owner: 'ou_failed' },
+ { kind: 'connected', owner: null },
+ { kind: 'connected', owner: 'ou_target' },
+ { kind: 'connected', owner: 'ou_other' },
+ ];
+ const records: BotImConnectionRecord[] = [];
+ for (let index = 0; index < states.length; index += 1) {
+ records.push(await addBotImConnectionRecord({ botId: 'bot-mia', channel: 'feishu' }, { now: () => index }));
+ }
+ configureBotImConnectionRuntime({
++ removeWechatCompanionBinding: h.drainWechat,
+ create: (record) => {
+ const state = states[records.findIndex((candidate) => candidate.id === record.id)]!;
+ return {
+ kind: 'feishu',
+ im: {
+ init: async () => { if (state.kind === 'error') throw new Error('startup failed'); },
+ dispose: async () => undefined,
+ onStatusChange: () => () => undefined,
+ getStatus: () => ({ kind: state.kind }),
+ getOwnerOpenId: () => state.owner,
+ } as never,
+ orchestrator: fakeOrchestrator() as never,
+ };
+ },
+ settingsIdentity: () => ({ telegramToken: null, feishuAppId: null, wecomBotId: null, dingtalkAppKey: null, discordToken: null }),
+ listKnownGroups: async () => [],
+ });
+ await startBotImConnections();
+ expect(getBotFeishuTransport('bot-mia')?.getOwnerOpenId()).toBe('ou_target');
+ states[2]!.kind = 'error';
+ // A later tool phase must not retry a resolved target through another owner.
+ expect(getBotFeishuTransport('bot-mia', 'ou_target')).toBeNull();
+ expect(getBotFeishuTransport('unrelated-bot')).toBeNull();
+ await stopBotImConnections();
+ expect(getBotFeishuTransport('bot-mia')).toBeNull();
+ });
+
it('lists known groups with their per-connection activation and toggles it live', async () => {
const added = await addBotImConnection({
botId: 'bot-mia',