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(plugins): preserve structured errors for unstable installation scans

DavidShen1f1d57f74891
diff --git a/apps/desktop/src/main/plugin-market/__tests__/ipcErrorBoundary.test.ts b/apps/desktop/src/main/plugin-market/__tests__/ipcErrorBoundary.test.ts
index 6b37cb38cc..652c2589e4 100644
--- a/apps/desktop/src/main/plugin-market/__tests__/ipcErrorBoundary.test.ts
+++ b/apps/desktop/src/main/plugin-market/__tests__/ipcErrorBoundary.test.ts
@@ -136,9 +136,9 @@ describe('Plugin Market IPC error boundary', () => {
expect(serviceSource).toContain("const outcome = completed ? 'completed' : 'failed';");
expect(serviceSource).toContain('options.onDefaultReconciliationOutcome?.(outcome);');
expect(serviceSource).toContain(
- 'await this.applyDefaultInstalls(plugins, currentOrganization, owner, ledger)',
+ 'await this.applyDefaultInstalls(plugins, currentOrganization, owner, ledger, refresh)',
);
- expect(serviceSource).toContain('await this.applyAutomaticUpgrades(plugins, customDiscovery.entries, owner, ledger)');
+ expect(serviceSource).toContain('await this.applyAutomaticUpgrades(plugins, customDiscovery.entries, owner, ledger, refresh)');
expect(serviceSource).toContain('if (error instanceof SilentUpgradeBusyError) {');
// Capability boundary: catalog readers cannot initiate install/update/removal maintenance.
diff --git a/apps/desktop/src/main/plugin-market/__tests__/service.test.ts b/apps/desktop/src/main/plugin-market/__tests__/service.test.ts
index 1e78d7144b..519ce97696 100644
--- a/apps/desktop/src/main/plugin-market/__tests__/service.test.ts
+++ b/apps/desktop/src/main/plugin-market/__tests__/service.test.ts
@@ -1077,6 +1077,30 @@ describe('PluginMarketService migration and defaultInstall', () => {
}
});
+ // IPC error contract / CI regression: exhausting async identity retries must
+ // remain a retryable PRECONDITION_FAILED, not become an unstructured INTERNAL.
+ // Unit: one plugin toggles during each of three manifest reads; ordinary
+ // snapshot tests cannot reach this bounded-retry failure branch.
+ it('returns a structured precondition error when installations keep changing during identity reads', async () => {
+ const item = summary();
+ const h = harness([item]);
+ runtime.ghosts = [ghostEntry(item.ghostId)];
+ const open = fs.promises.open;
+ const read = vi.spyOn(fs.promises, 'open').mockImplementation(async (...args) => {
+ const handle = await open(...args);
+ if (path.basename(String(args[0])) === 'ghost.json') {
+ runtime.ghosts[0] = { ...runtime.ghosts[0]!, enabled: !runtime.ghosts[0]!.enabled };
+ }
+ return handle;
+ });
+ try {
+ await expect(h.service.snapshot({ discoveryOnly: true })).rejects.toThrow('[PRECONDITION_FAILED]');
+ expect(runtime.install).not.toHaveBeenCalled();
+ } finally {
+ read.mockRestore();
+ }
+ });
+
// Even a reused installation view must let the native message pump run
// between reconciliation phases; one unchanged refresh scans only once.
it('lets a queued event run while sharing one market reconciliation scan', async () => {
diff --git a/apps/desktop/src/main/plugin-market/service.ts b/apps/desktop/src/main/plugin-market/service.ts
index 42aad9ad34..381ae9a5ad 100644
--- a/apps/desktop/src/main/plugin-market/service.ts
+++ b/apps/desktop/src/main/plugin-market/service.ts
@@ -3780,7 +3780,7 @@ export class PluginMarketService {
// their locks. Only this refresh's read-only installation view is shared.
return this.projectLocalInstallSnapshot(ghosts, installations ?? ledger.read().installations, refresh.identities.values);
}
- throw new Error('Plugin installations changed repeatedly while reading market identities');
+ throwIpcError('PRECONDITION_FAILED', 'Plugin installations changed repeatedly while reading market identities');
}
private projectLocalInstallSnapshot(