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 pull request #627 from feat/workflow-tasks-panel

Lizia9a1316e835d
diff --cc apps/desktop/src/main/__tests__/heartbeatService.test.ts
index 24f1e3ea8f,9c76b8f0ea..21c092c279
--- a/apps/desktop/src/main/__tests__/heartbeatService.test.ts
+++ b/apps/desktop/src/main/__tests__/heartbeatService.test.ts
@@@ -139,22 -136,10 +139,25 @@@ describe('heartbeat service app-mode is
expect(mocks.createHeartbeatClient.mock.calls[1][0].host.getUid()).toBe('cloud-user-2');
});
+ it('restarts Cindy heartbeat when the same authenticated owner moves to another realm', async () => {
+ mocks.authState = authState('cloud', 'cloud-user-1');
+ const { initHeartbeatService } = await loadService();
+ initHeartbeatService();
+
+ mocks.authRealm = 'global';
+ pushAuthState(authState('cloud', 'cloud-user-1'));
+
+ expect(mocks.heartbeatStop).toHaveBeenCalledTimes(1);
+ expect(mocks.createHeartbeatClient).toHaveBeenCalledTimes(2);
+ expect(mocks.createHeartbeatClient.mock.calls[1][0].endpoint).toBe(
+ 'https://heartbeat.global.example.test',
+ );
+ });
+
- it('keeps the TapDB daily-active cadence across signed-out, local, and cloud modes', async () => {
+ it('never broadcasts to renderers, even across local-midnight boundaries', async () => {
+ // 回归钉子:TapDB 的 0 点跨天续报(tapdb:daily-active)已删——它曾把所有过夜
+ // 挂机设备的活跃压在 00:00-00:01,在 TapDB 小时趋势上制造 0 点尖峰。活跃现在
+ // 由 renderer 侧交互驱动,main 的心跳服务不得再有任何面向 renderer 的广播。
const { initHeartbeatService } = await loadService();
initHeartbeatService();
diff --cc apps/desktop/src/main/heartbeatService.ts
index 9cfc305d41,f01e458f17..dd496d1d9b
--- a/apps/desktop/src/main/heartbeatService.ts
+++ b/apps/desktop/src/main/heartbeatService.ts
@@@ -35,10 -38,7 +38,8 @@@ type AuthStateSnapshot = ReturnType<typ
let handle: HeartbeatHandle | null = null;
let handleUid: string | null = null;
+let handleRealm: ReturnType<typeof authManager.getActiveAuthRealm> | null = null;
- let tapdbTimer: NodeJS.Timeout | null = null;
let unsubscribeAuth: (() => void) | null = null;
- let lastTapdbActiveDate = getLocalDateKey();
/** 已验证 cloud 会话返回其 user.id,其余模式一律 null(= 不上报云端心跳)。 */
function verifiedCloudUserId(state: AuthStateSnapshot): string | null {