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(bots): 解除唯一后台任务责任后仍保留委派归属 scope

Chris110067ab6290
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botTaskResponsibility.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botTaskResponsibility.test.ts
index 8c2d185e8c..772fb7e8b0 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/botTaskResponsibility.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/botTaskResponsibility.test.ts
@@ -65,3 +65,13 @@ it('keeps healthy companions visible while failing closed for a damaged release
expect(scopes).toEqual([{ botId: 'healthy', directories: [], sessionIds: ['owned'], delegatedSessionIds: [] }]);
expect(await fs.readFile(file, 'utf8')).toBe('{broken');
});
+
+it('keeps a Bot that released its only background task as that task\'s origin', async () => {
+ await setTaskResponsibility(root, 'origin', 'child', false, () => {});
+ const scopes = await collectTaskResponsibilityScopes(['origin', 'idle'], async (botId) => ({
+ sessionIds: responsibleSessionIds(botId === 'origin' ? ['child'] : [], await readTaskResponsibilities(root, botId)),
+ delegatedSessionIds: botId === 'origin' ? ['child'] : [],
+ }));
+ // Nothing followed any more, but the owner chip still names the Bot; a Bot with nothing at all stays out.
+ expect(scopes).toEqual([{ botId: 'origin', directories: [], sessionIds: [], delegatedSessionIds: ['child'] }]);
+});
diff --git a/apps/desktop/src/main/maker-ipc/botTaskResponsibility.ts b/apps/desktop/src/main/maker-ipc/botTaskResponsibility.ts
index cf58c447fb..9cff807b61 100644
--- a/apps/desktop/src/main/maker-ipc/botTaskResponsibility.ts
+++ b/apps/desktop/src/main/maker-ipc/botTaskResponsibility.ts
@@ -94,5 +94,7 @@ export async function collectTaskResponsibilityScopes(
return { botId, directories: [], sessionIds: [], delegatedSessionIds: [] };
}
}));
- return scopes.filter((scope) => scope.sessionIds.length > 0);
+ // A Bot that released its only background task is still that task's origin: keep the scope
+ // for the owner chip even when nothing is followed any more.
+ return scopes.filter((scope) => scope.sessionIds.length > 0 || scope.delegatedSessionIds.length > 0);
}