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): 供应商组启动阶段确认组已删除时也立即解除绑定

Lizicab35fa19e03
diff --git a/apps/desktop/src/main/provider-group/__tests__/remoteGroup.test.ts b/apps/desktop/src/main/provider-group/__tests__/remoteGroup.test.ts
index c15dc35be0..8d9ef3ff48 100644
--- a/apps/desktop/src/main/provider-group/__tests__/remoteGroup.test.ts
+++ b/apps/desktop/src/main/provider-group/__tests__/remoteGroup.test.ts
@@ -207,6 +207,15 @@ describe('assigning through a group on another computer', () => {
expect(next?.route).toEqual({ agentDeviceId: 'share:s1', providerId: 'anthropic' });
expect(h.bindings.get('s1')).toMatchObject({ memberKey: SHARED.key, groupDeviceId: OWNER });
});
+
+ it('drops the binding when the group is deleted before the agent starts', async () => {
+ const h = harness({ picks: [STUDIO] });
+ const context = await h.service.assignBeforeStart(START);
+ expect(h.bindings.size).toBe(1);
+ h.remote.readGroup.mockResolvedValue(null);
+ expect(await h.service.nextAfterStartFailure(context!, new Error('[REMOTE_AGENT_DEVICE_UNREACHABLE] gone'))).toBeNull();
+ expect(h.bindings.size).toBe(0);
+ });
});
describe('switching computers within a group on another computer', () => {
diff --git a/apps/desktop/src/main/provider-group/service.ts b/apps/desktop/src/main/provider-group/service.ts
index 690af1d183..70c9bf8b96 100644
--- a/apps/desktop/src/main/provider-group/service.ts
+++ b/apps/desktop/src/main/provider-group/service.ts
@@ -776,6 +776,11 @@ export function createProviderGroupService(deps: ProviderGroupServiceDeps): Prov
const source = sourceFor(context.groupDeviceId);
if (!cause || !source) return null;
const config = await source.readGroup(context.groupProviderId).catch(() => undefined);
+ // 启动阶段同样:组所在电脑确认组已删除时立即解除绑定,读不到不动。
+ if (config === null) {
+ await releaseDeletedGroup(context.sessionId);
+ return null;
+ }
if (!config?.autoSwitch) return null;
source.cool(context.groupProviderId, context.member.key, cause, null);
source.invalidate(context.member);