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): preserve failed legacy recovery markers

Yuewei-LL0797835d8a56
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/legacyGhostRecoveryOrchestration.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/legacyGhostRecoveryOrchestration.test.ts
new file mode 100644
index 0000000000..e7c9ad1524
--- /dev/null
+++ b/apps/desktop/src/main/cindy-brain/__tests__/legacyGhostRecoveryOrchestration.test.ts
@@ -0,0 +1,26 @@
+import fs from 'node:fs';
+import path from 'node:path';
+
+import { describe, expect, it } from 'vitest';
+
+describe('legacy Ghost recovery acknowledgement orchestration', () => {
+ it('keeps both retry-pending and deterministic backfill failures in the durable marker', () => {
+ const source = fs.readFileSync(
+ path.resolve(process.cwd(), 'src/main/cindy-brain/index.ts'),
+ 'utf8',
+ ).replace(/\r\n?/g, '\n');
+ const start = source.indexOf(
+ 'const backfill = await getGhostManager().backfillRecoveredLegacyGhosts(',
+ );
+ const end = source.indexOf("log.warn('recovered legacy ghost backfill pass failed'", start);
+ const acknowledgementBlock = source.slice(start, end);
+
+ expect(start).toBeGreaterThanOrEqual(0);
+ expect(end).toBeGreaterThan(start);
+ expect(acknowledgementBlock).toContain('const pending = new Set(backfill.pending ?? []);');
+ expect(acknowledgementBlock).toContain('const failed = new Set(backfill.failed);');
+ expect(acknowledgementBlock).toContain(
+ 'recoveredLegacyIds.filter((id) => !pending.has(id) && !failed.has(id))',
+ );
+ });
+});
diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.ts
index dea4f09ffc..05b4d6f9a1 100644
--- a/apps/desktop/src/main/cindy-brain/index.ts
+++ b/apps/desktop/src/main/cindy-brain/index.ts
@@ -701,9 +701,10 @@ async function retryLegacyGhostRecoveryForActiveSession(): Promise<LegacyGhostRe
{ includePending: true },
);
const pending = new Set(backfill.pending ?? []);
+ const failed = new Set(backfill.failed);
await acknowledgeRecoveredLegacyGhosts(
expectedOwner.dataOwnerId,
- recoveredLegacyIds.filter((id) => !pending.has(id)),
+ recoveredLegacyIds.filter((id) => !pending.has(id) && !failed.has(id)),
);
} catch (err) {
log.warn('recovered legacy ghost backfill pass failed', {