Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(cindy-make): suppress hidden pending failure alerts
MagicLizi8443aea3b1c5
diff --git a/apps/desktop/src/main/__tests__/cindyMakePendingAlerts.test.ts b/apps/desktop/src/main/__tests__/cindyMakePendingAlerts.test.tsnew file mode 100644index 0000000000..2f0c8f9cbd--- /dev/null+++ b/apps/desktop/src/main/__tests__/cindyMakePendingAlerts.test.ts@@ -0,0 +1,102 @@+import { beforeEach, describe, expect, it, vi } from 'vitest';++const state = vi.hoisted(() => ({+ enabled: false,+ getDbClient: vi.fn(),+ errorRows: vi.fn(),+ makeRows: vi.fn(),+}));++vi.mock('@cindy/maker-shared/cindy-make-feature', async (importOriginal) => ({+ ...await importOriginal<typeof import('@cindy/maker-shared/cindy-make-feature')>(),+ get CINDY_MAKE_ENABLED() { return state.enabled; },+}));+vi.mock('../localDb/client/current.js', () => ({ getDbClient: state.getDbClient }));+vi.mock('../logger.js', () => ({ createLogger: () => ({ warn: vi.fn() }) }));+vi.mock('../maker-ipc/recoveryCoordinator.js', () => ({ boundedSummary: vi.fn() }));++import { listCindyMakePendingFailureSessionIds } from '../localDb/cindyMakeAttention.js';+import { listErrorTailPendingSessionIds } from '../localDb/sessionActiveTurn.js';++function nativeResult(sessionId: string, completion: unknown, content: unknown = '') {+ return {+ sessionId,+ role: 'assistant',+ content: JSON.stringify(content),+ agentMeta: JSON.stringify({ cindyMakeCompletion: completion }),+ };+}++describe('Cindy Make pending-alert recovery', () => {+ beforeEach(() => {+ vi.resetAllMocks();+ state.enabled = false;+ state.errorRows.mockResolvedValue([{ sessionId: 'ordinary-error', clientId: 'error-message' }]);+ state.makeRows.mockResolvedValue([+ nativeResult('make-build-failed', { reportedAt: 100, lastAction: 'build', personal: { status: 'failed' } }),+ nativeResult('make-test-failed', { reportedAt: 100, lastAction: 'test', test: { status: 'failed' } }),+ ]);+ state.getDbClient.mockReturnValue({+ drizzle: {+ select: (fields: Record<string, unknown>) => ({+ from: () => ({+ innerJoin: () => ({ where: 'role' in fields ? state.makeRows : state.errorRows }),+ }),+ }),+ },+ });+ });++ it('does not recover native Make failure ids while the feature is disabled', async () => {+ expect(await listCindyMakePendingFailureSessionIds()).toEqual([]);+ expect(state.getDbClient).not.toHaveBeenCalled();+ expect(state.makeRows).not.toHaveBeenCalled();+ });++ it('keeps ordinary error alerts without adding hidden Make ids to the badge projection', async () => {+ expect(await listErrorTailPendingSessionIds()).toEqual(['ordinary-error']);+ expect(state.errorRows).toHaveBeenCalledOnce();+ expect(state.makeRows).not.toHaveBeenCalled();+ });++ it('does not require the database to recover disabled Make alerts', async () => {+ state.getDbClient.mockImplementation(() => { throw new Error('database is not ready'); });+ await expect(listCindyMakePendingFailureSessionIds()).resolves.toEqual([]);+ expect(state.getDbClient).not.toHaveBeenCalled();+ });++ it('preserves unresolved native failure recovery when the feature is enabled', async () => {+ state.enabled = true;+ state.makeRows.mockResolvedValue([+ nativeResult('make-build-failed', { reportedAt: 100, lastAction: 'build', personal: { status: 'failed' } }),+ nativeResult('make-test-failed', { reportedAt: 100, lastAction: 'test', test: { status: 'failed' } }),+ nativeResult('make-interrupted', { reportedAt: 100, lastAction: 'test', test: { status: 'stopped', error: 'interrupted' } }),+ nativeResult('make-preparation', null, { __cindyMakeCard: { type: 'cindy-make', data: { report: { runId: 'run', status: 'failed' } } } }),+ nativeResult('make-continued', { reportedAt: 100, continuedAt: 101, personal: { status: 'failed' } }),+ nativeResult('make-cancelled', { reportedAt: 100, personal: { status: 'failed', error: 'cancelled' } }),+ nativeResult('make-retried', { reportedAt: 100, personal: { status: 'checking' } }),+ nativeResult('make-done', { reportedAt: 100, test: { status: 'ready' } }),+ ]);+ expect(await listCindyMakePendingFailureSessionIds()).toEqual([+ 'make-build-failed', 'make-test-failed', 'make-interrupted', 'make-preparation',+ ]);+ expect(state.makeRows).toHaveBeenCalledOnce();+ });++ it('still deduplicates native and ordinary errors when the feature is enabled', async () => {+ state.enabled = true;+ state.errorRows.mockResolvedValue([+ { sessionId: 'ordinary-error', clientId: 'error-message' },+ { sessionId: 'make-build-failed', clientId: 'old-error-message' },+ ]);+ expect(await listErrorTailPendingSessionIds()).toEqual([+ 'ordinary-error', 'make-build-failed', 'make-test-failed',+ ]);+ });++ it('does not swallow database failures for ordinary error alerts', async () => {+ state.errorRows.mockRejectedValue(new Error('database is not ready'));+ await expect(listErrorTailPendingSessionIds()).rejects.toThrow('database is not ready');+ expect(state.makeRows).not.toHaveBeenCalled();+ });+});diff --git a/apps/desktop/src/main/localDb/__tests__/sessionActiveTurn.test.ts b/apps/desktop/src/main/localDb/__tests__/sessionActiveTurn.test.tsindex 4a65784a98..185d6f4dcd 100644--- a/apps/desktop/src/main/localDb/__tests__/sessionActiveTurn.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/sessionActiveTurn.test.ts@@ -15,11 +15,18 @@ import type { DbClient } from '../client/DbClient.js';import { clearCurrentDbClient, setCurrentDbClient } from '../client/current.js';import * as schema from '../schema.js';+const feature = vi.hoisted(() => ({ enabled: false }));+vi.mock('@cindy/maker-shared/cindy-make-feature', async (importOriginal) => ({+ ...await importOriginal<typeof import('@cindy/maker-shared/cindy-make-feature')>(),+ get CINDY_MAKE_ENABLED() { return feature.enabled; },+}));+describe('sessionActiveTurn', () => {let currentClient: DbClient | null = null;let rawDb: Database.Database | null = null;afterEach(async () => {+ feature.enabled = false;const { _resetSessionActiveTurnStateForTests } = await import('../sessionActiveTurn.js');_resetSessionActiveTurnStateForTests();vi.restoreAllMocks();@@ -573,8 +580,9 @@ describe('sessionActiveTurn', () => {expect(await hasAssistantProgressAfterMessage('s-same-ms', 'c-user2')).toBe(true);});- it('restores native Make failures and drops them only when handled or no longer visible', async () => {+ it('restores native Make failures only while enabled and preserves hidden failure history', async () => {const { listErrorTailPendingSessionIds } = await import('../sessionActiveTurn.js');+ feature.enabled = true;const client = createTestDbClient();const at = Date.now();const insert = async (id: string, completion: unknown, options: {@@ -601,12 +609,19 @@ describe('sessionActiveTurn', () => {await insert('make-cleared', failed, { clearedAt: at });await insert('make-archived', failed, { status: 'archived' });await insert('ordinary-task', failed, { source: 'desktop' });+ await insert('make-merge-failed', failed, { source: 'cindy-make-merge' });await insert('make-later-user', failed);await client.exec('INSERT INTO messages (id, client_id, session_id, role, content, created_at) VALUES (?, ?, ?, ?, ?, ?)',['later', 'later', 'make-later-user', 'user', '{}', at]);expect((await listErrorTailPendingSessionIds()).sort()).toEqual(['make-failed', 'make-interrupted', 'make-preparation', 'make-test-failed',]);+ feature.enabled = false;+ expect(await listErrorTailPendingSessionIds()).toEqual([]);+ expect(await client.queryOne('SELECT agent_meta FROM messages WHERE id = ?', ['make-failed'])).toEqual({+ agent_meta: JSON.stringify({ cindyMakeCompletion: failed }),+ });+ feature.enabled = true;await client.exec('UPDATE messages SET agent_meta = ? WHERE id = ?', [JSON.stringify({ cindyMakeCompletion: { ...failed, personal: { status: 'waiting' } } }), 'make-failed',]);@@ -676,6 +691,11 @@ describe('sessionActiveTurn', () => {await seedSession(client, 's-hidden-err', { source: 'legacy-hidden' });await insert('s-hidden-err', 'e10-err', 'error', '{"message":"boom"}', base + 100);+ for (const source of ['cindy-make', 'cindy-make-merge']) {+ await seedSession(client, source, { source });+ await insert(source, source + '-error', 'error', '{"message":"boom"}', base + 100);+ }+// 不命中:/clear 越过了该 error 行 —— 消息读取路径靠 cleared_at 把它挡在视图外,// 横幅根本不显示,红点若还挂着就永远无法处置(PR #879 review P1)。await seedSession(client, 's-cleared-err', { clearedAt: base + 500 });diff --git a/apps/desktop/src/main/localDb/cindyMakeAttention.ts b/apps/desktop/src/main/localDb/cindyMakeAttention.tsindex 4103d6bdca..65abbcc677 100644--- a/apps/desktop/src/main/localDb/cindyMakeAttention.ts+++ b/apps/desktop/src/main/localDb/cindyMakeAttention.ts@@ -1,10 +1,12 @@import { and, eq, gt, isNull, sql } from 'drizzle-orm';+import { CINDY_MAKE_ENABLED } from '@cindy/maker-shared/cindy-make-feature';import { getCindyMakeMessageAttention } from '../../shared/cindyMakeAttention.js';import { getDbClient } from './client/current.js';import { messages, sessions } from './schema.js';/** Restore unresolved native Make failures even when their task has never been opened. */export async function listCindyMakePendingFailureSessionIds(): Promise<string[]> {+ if (!CINDY_MAKE_ENABLED) return [];const rows = await getDbClient().drizzle.select({sessionId: messages.sessionId,