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。

test: lock orca lead home to same engine and classify favorites by error code

PraiseZhuc3f9319b4571
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/sessionAgentSwitchHandler.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/sessionAgentSwitchHandler.test.ts
index a3a434af84..b7c51e7dae 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/sessionAgentSwitchHandler.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/sessionAgentSwitchHandler.test.ts
@@ -1452,6 +1452,19 @@ describe('远程 Agent:选模型时换 Agent 所在电脑', () => {
);
});
+ it('协同 Lead 切回本机必须同引擎:换引擎仍拒绝', async () => {
+ const leadHome = relocationHarness({ orcaRole: 'lead', agentDeviceId: 'office-pc' });
+ await expect(
+ performSessionAgentSwitch(leadHome.deps, {
+ ...backToTaskComputer,
+ targetAgentKind: 'codex',
+ model: 'gpt-5.5',
+ }),
+ ).rejects.toThrow(/UNSUPPORTED_CAPABILITY/);
+ expect(leadHome.pending.get('s1')).toBeUndefined();
+ expect(leadHome.calls).toEqual([]);
+ });
+
it('非法位置参数被拒绝', async () => {
const h = relocationHarness();
await expect(performSessionAgentSwitch(h.deps, { ...backToTaskComputer, agentDeviceId: 'bad id!' }))
diff --git a/apps/desktop/src/renderer/__tests__/orcaLeadOfflineModelPanel.test.ts b/apps/desktop/src/renderer/__tests__/orcaLeadOfflineModelPanel.test.ts
index e231274471..6967e749c7 100644
--- a/apps/desktop/src/renderer/__tests__/orcaLeadOfflineModelPanel.test.ts
+++ b/apps/desktop/src/renderer/__tests__/orcaLeadOfflineModelPanel.test.ts
@@ -87,12 +87,25 @@ describe('sessionRemoteAgentDevicesForOrcaFallback', () => {
});
describe('favoritesSyncFailureI18nKey', () => {
- it('按连接不可达与版本不支持分开,不再笼统归因于被控电脑需要更新', () => {
- expect(favoritesSyncFailureI18nKey('unreachable')).toBe(
+ it('连接类错误码用 Unreachable 文案,其余错误保留原文案', () => {
+ expect(favoritesSyncFailureI18nKey('DEVICE_LINK_NOT_CONNECTED')).toBe(
'newChat.modelSelector.unified.favoritesSyncFailedUnreachable',
);
- expect(favoritesSyncFailureI18nKey('unsupported')).toBe(
- 'newChat.modelSelector.unified.favoritesSyncFailedUnsupported',
+ expect(favoritesSyncFailureI18nKey('DEVICE_LINK_DEVICE_OFFLINE')).toBe(
+ 'newChat.modelSelector.unified.favoritesSyncFailedUnreachable',
+ );
+ expect(favoritesSyncFailureI18nKey('DEVICE_LINK_TIMEOUT')).toBe(
+ 'newChat.modelSelector.unified.favoritesSyncFailedUnreachable',
+ );
+ expect(favoritesSyncFailureI18nKey('DEVICE_LINK_BUSY')).toBe(
+ 'newChat.modelSelector.unified.favoritesSyncFailedUnreachable',
+ );
+ expect(favoritesSyncFailureI18nKey('DEVICE_LINK_CHANNEL_NOT_ALLOWED')).toBe(
+ 'newChat.modelSelector.unified.favoritesSyncFailed',
+ );
+ expect(favoritesSyncFailureI18nKey(null)).toBe('newChat.modelSelector.unified.favoritesSyncFailed');
+ expect(favoritesSyncFailureI18nKey(undefined)).toBe(
+ 'newChat.modelSelector.unified.favoritesSyncFailed',
);
});
});
@@ -104,29 +117,45 @@ describe('ChatInput 接线', () => {
expect(chatInput).toContain('sessionRemoteAgentDevicesForOrcaFallback(');
expect(chatInput).toContain('sessionAgentSwitchSupportedOf({');
});
+
+ it('fallback 打开时把统一面板引擎集合锁到当前引擎', () => {
+ const chatInput = read('../components/new-chat/ChatInput.tsx');
+ expect(chatInput).toContain('(!sessionEngineFilter || orcaLeadLocalFallback)');
+ });
});
describe('收藏同步失败词表', () => {
const locales = ['zh-CN', 'zh-TW', 'en', 'ja', 'ko'] as const;
- const misleading = /可能需要更新|may need an update|업데이트해야|更新が必要/;
- it('五份 locale 按失败原因区分,且不再暗示被控电脑需要更新', () => {
+ it('五份 locale:连不上用新 Unreachable 文案,其它错误保留原 favoritesSyncFailed,无 Unsupported key', () => {
+ const expectedUnreachable: Record<(typeof locales)[number], string> = {
+ 'zh-CN': '收藏暂时没有同步:那台电脑当前连不上。恢复连接后重新打开即可。',
+ 'zh-TW': '收藏暫時沒有同步:那台電腦目前連不上。恢復連線後重新開啟即可。',
+ en: 'Favorites are not synced yet: that computer is unreachable. Reopen the picker after the connection returns.',
+ ja: 'お気に入りはまだ同期されていません。そのパソコンに現在接続できません。接続が戻ってから開き直してください。',
+ ko: '즐겨찾기가 아직 동기화되지 않았습니다. 그 컴퓨터에 현재 연결할 수 없습니다. 연결이 복구된 후 다시 여세요.',
+ };
+ const expectedOriginal: Record<(typeof locales)[number], string> = {
+ 'zh-CN': '收藏未能同步。请重新打开重试;被控电脑可能需要更新。',
+ 'zh-TW': '收藏未能同步。請重新開啟重試;被控電腦可能需要更新。',
+ en: 'Favorites could not sync. Reopen the picker to retry; the remote computer may need an update.',
+ ja: 'お気に入りを同期できません。選択画面を開き直してください。接続先の更新が必要な場合があります。',
+ ko: '즐겨찾기를 동기화할 수 없습니다. 선택 화면을 다시 여세요. 원격 컴퓨터를 업데이트해야 할 수 있습니다.',
+ };
for (const locale of locales) {
const json = JSON.parse(
read(`../i18n/locales/${locale}/common.json`),
) as {
newChat: {
modelSelector: {
- unified: Record<string, string>;
+ unified: Record<string, string | undefined>;
};
};
};
const unified = json.newChat.modelSelector.unified;
- expect(unified.favoritesSyncFailedUnreachable).toEqual(expect.any(String));
- expect(unified.favoritesSyncFailedUnsupported).toEqual(expect.any(String));
- expect(unified.favoritesSyncFailedUnreachable).not.toMatch(misleading);
- expect(unified.favoritesSyncFailedUnsupported).not.toMatch(misleading);
- expect(unified.favoritesSyncFailed ?? '').not.toMatch(misleading);
+ expect(unified.favoritesSyncFailedUnreachable).toBe(expectedUnreachable[locale]);
+ expect(unified.favoritesSyncFailed).toBe(expectedOriginal[locale]);
+ expect(unified.favoritesSyncFailedUnsupported).toBeUndefined();
}
});
});
diff --git a/apps/desktop/src/renderer/__tests__/remoteModelFavorites.test.tsx b/apps/desktop/src/renderer/__tests__/remoteModelFavorites.test.tsx
index de15b82511..ca48a5ef22 100644
--- a/apps/desktop/src/renderer/__tests__/remoteModelFavorites.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/remoteModelFavorites.test.tsx
@@ -61,6 +61,20 @@ it.each(['status', 'peer', 'responsive'])('retains keyed favorites on failed %s
expect(view.items).toEqual([]);
expect(view.error).toBe(false);
});
+it('records DEVICE_LINK connection error codes and clears them after a successful refresh', async () => {
+ await act(async () => root.render(createElement(Probe, {})));
+ invoke.mockRejectedValueOnce(new Error('[DEVICE_LINK_NOT_CONNECTED] offline'));
+ await act(async () => statusChanged());
+ expect(view.error).toBe(true);
+ expect(view.errorCode).toBe('DEVICE_LINK_NOT_CONNECTED');
+ invoke.mockRejectedValueOnce(new Error('[DEVICE_LINK_CHANNEL_NOT_ALLOWED] old host'));
+ await act(async () => statusChanged());
+ expect(view.errorCode).toBe('DEVICE_LINK_CHANNEL_NOT_ALLOWED');
+ invoke.mockResolvedValue([]);
+ await act(async () => statusChanged());
+ expect(view.error).toBe(false);
+ expect(view.errorCode).toBeNull();
+});
it('remote favorite add/update/remove use remote operations, never browser storage', async () => {
const local = vi.spyOn(Storage.prototype, 'setItem');
await act(async () => root.render(createElement(Probe, {})));