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): 角标不再累加目录外 attention,但保留事件账本给灵动岛水合

WZBbiao6e4024dfe706
diff --git a/apps/desktop/src/main/__tests__/appBadgeService.test.ts b/apps/desktop/src/main/__tests__/appBadgeService.test.ts
index e17f4c2f82..e98aa6a8be 100644
--- a/apps/desktop/src/main/__tests__/appBadgeService.test.ts
+++ b/apps/desktop/src/main/__tests__/appBadgeService.test.ts
@@ -182,7 +182,7 @@ describe('appBadgeService', () => {
expect(dockSetBadge).toHaveBeenLastCalledWith('');
});
- it('drops off-catalog attention once the projection arrives so the badge stays reader-clearable', async () => {
+ it('counts the projection once it arrives while keeping off-catalog attention in the event ledger', async () => {
const service = await freshService();
const event = { sender: mainWebContents };
// 首份投影前 renderer 还没挂载:逐任务通知独自撑角标,且重复打点不重复计数。
@@ -191,14 +191,17 @@ describe('appBadgeService', () => {
expect(service.getAttentionCount()).toBe(1);
service.markSessionNeedsAttention('late-review-run');
expect(service.getAttentionCount()).toBe(2);
- // 目录就绪后它就是界面的权威清单:目录外的 id 既不可见也不可清除,必须丢弃,
+ // 目录就绪后它是角标的权威清单:目录外的 id 既不可见也不可清除,不再抬角标,
// 否则角标会永久停在界面读不掉的数字上(“有未读但点不掉”)。
await publish(event, 3, ['a', 'b', 'c']);
expect(service.getAttentionCount()).toBe(3);
- expect(service.hasSessionAttention('early-task')).toBe(false);
- expect(service.hasSessionAttention('late-review-run')).toBe(false);
+ // 但事件账本不能跟着收缩:灵动岛靠 hasSessionAttention() 水合未读,
+ // 目录外会话(/review、追问 fork)的恢复路径要靠它。
+ expect(service.hasSessionAttention('early-task')).toBe(true);
+ expect(service.hasSessionAttention('late-review-run')).toBe(true);
await publish(event, 2, ['a', 'b', 'c']);
expect(service.getAttentionCount()).toBe(2);
+ expect(service.hasSessionAttention('late-review-run')).toBe(true);
service.clearSessionAttention('bot-task');
expect(service.getAttentionCount()).toBe(2);
// 目录内的 id 始终由投影接管:重复打点、迟到打点都不叠加计数。
diff --git a/apps/desktop/src/main/appBadgeService.ts b/apps/desktop/src/main/appBadgeService.ts
index 57a907ca7a..40094421c1 100644
--- a/apps/desktop/src/main/appBadgeService.ts
+++ b/apps/desktop/src/main/appBadgeService.ts
@@ -21,7 +21,8 @@ const MAX_RETAINED_SESSION_IDS = 100_000;
const attentionSessionIds = new Set<string>();
// 侧栏就绪后目录内任务按当前状态计数;目录外的 id 既不在界面上出现,也没有
// 「读到 / 删除」这类清除入口,计入只会让角标停在用户点不掉的数字上,因此只在
-// 首份投影前用事件集合兜底,避免 renderer 尚未挂载时漏掉后台提醒。
+// 首份投影前用事件集合兜底,避免 renderer 尚未挂载时漏掉后台提醒。事件集合本身
+// 不随投影收缩:灵动岛靠 hasSessionAttention() 水合未读,目录外的 id 也要留着。
let projectedAttentionCount: number | null = null;
const projectedSessionIds = new Set<string>();
@@ -91,11 +92,6 @@ export function initAppBadgeService(deps: AppBadgeServiceDeps): void {
projectedAttentionCount = count;
// 曾进入普通目录的任务始终归投影管理,删除/断连后不能被旧通知重新计入。
for (const sessionId of uniqueSessionIds) projectedSessionIds.add(sessionId);
- // 目录已是权威清单:留在目录外的 attention 永远不会出现在界面上,也没有任何
- // 清除入口(读不到、删不掉),只会把角标撑出界面上读不掉的数字。直接丢弃。
- for (const sessionId of attentionSessionIds) {
- if (!projectedSessionIds.has(sessionId)) attentionSessionIds.delete(sessionId);
- }
if (getAttentionCount() !== previousCount) applyBadge();
});
ipcMain.handle(