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(teammates): honor absent activity snapshots and isolate unread test

zqchris3dd5890db508
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/teammatesSection.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/teammatesSection.test.tsx
index a6920cbfa7..06179eedd5 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/teammatesSection.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/teammatesSection.test.tsx
@@ -490,12 +490,16 @@ describe('TeammatesSection header', () => {
expect(screen.getByRole('button', { name: 'Writer' }).hasAttribute('aria-current')).toBe(false);
});
- it('keeps a completed unread reply green after the live snapshot returns to idle, then clears on read', async () => {
+ it('keeps a completed unread reply green after the live snapshot is removed, then clears on read', async () => {
mocks.profiles = [{ ...bot({ id: 'bot-1', name: 'Writer' }), lastMessageRole: 'assistant' }];
mocks.unread = { 'bot-1': 1 };
- mocks.islandActivity = new Map([['bot-1-chat', { sessionId: 'bot-1-chat', phase: 'idle' }]]);
+ mocks.islandActivity = new Map([['bot-1-chat', { sessionId: 'bot-1-chat', phase: 'completed' }]]);
const view = await renderSidebar();
expect(view.container.querySelector('[data-teammate-status="done"]')).not.toBeNull();
+ // Idle is represented by no activity entry, not an AgentIslandSessionPhase.
+ mocks.islandActivity = new Map();
+ view.rerender(<TeammatesSection />);
+ expect(view.container.querySelector('[data-teammate-status="done"]')).not.toBeNull();
mocks.unread = {};
view.rerender(<TeammatesSection />);
expect(view.container.querySelector('[data-teammate-status]')).toBeNull();
diff --git a/apps/desktop/src/renderer/features/bots/teammateRosterStatus.ts b/apps/desktop/src/renderer/features/bots/teammateRosterStatus.ts
index bd911eadc1..a1efcbf513 100644
--- a/apps/desktop/src/renderer/features/bots/teammateRosterStatus.ts
+++ b/apps/desktop/src/renderer/features/bots/teammateRosterStatus.ts
@@ -7,7 +7,7 @@ import type { RemoteBot } from './remoteBotRoster';
export function localTeammateStatus(bot: BotProfile, activities: ReadonlyMap<string, AgentIslandSessionActivity>, unread: boolean) {
const canonical = activities.get(canonicalBotSessionId(bot) ?? '');
return resolveTeammateStatus({ unread, failed: bot.needsAttention,
- activities: [canonical && canonical.phase !== 'idle' ? canonical : (bot.lastMessageRole === 'assistant' ? { phase: 'completed' } : undefined),
+ activities: [canonical ?? (bot.lastMessageRole === 'assistant' ? { phase: 'completed' } : undefined),
...bot.sessions.filter(session => session.role === 'delegation' && session.status !== 'archived' && session.status !== 'deleted')
.map(session => activities.get(session.id))] });
}
diff --git a/apps/mobile/src/__tests__/BotGroupListUnread.test.tsx b/apps/mobile/src/__tests__/BotGroupListUnread.test.tsx
index a3478366ce..57d128c17a 100644
--- a/apps/mobile/src/__tests__/BotGroupListUnread.test.tsx
+++ b/apps/mobile/src/__tests__/BotGroupListUnread.test.tsx
@@ -7,6 +7,9 @@ vi.mock('react-native', async () => { const { createElement } = await import('re
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key, i18n: { language: 'en' } }) }));
vi.mock('@/auth/AuthContext', () => ({ useAuth: () => ({ user: { id: 'owner' } }) }));
vi.mock('@/session/BotGroupAvatars', () => ({ BotGroupDuoAvatar: () => null, useBotGroupIdentities: () => () => ({}) }));
+// This unit protects server read-sequence handling, not avatar rendering (covered
+// by BotGroupList.test.tsx). Keep the status component's runtime store out too.
+vi.mock('@/session/TeammateStatusDot', () => ({ TeammateStatusDot: () => null }));
vi.mock('@/session/messageMarkdown', () => ({ parseMobileMarkdownInlines: () => [], mobileMarkdownPreviewText: (value: string) => value }));
vi.mock('@/session/sessionList', () => ({ formatRemoteSessionSidebarTime: () => 'now' }));
vi.mock('@/theme', () => ({ useThemedStyles: () => ({}) }));