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): localize reserved market rejection

fmfsaisai770c61b567a9
diff --git a/apps/desktop/src/renderer/features/plugin/lib/__tests__/pluginMarketErrorKey.test.ts b/apps/desktop/src/renderer/features/plugin/lib/__tests__/pluginMarketErrorKey.test.ts
index 8b9198b850..49704a6352 100644
--- a/apps/desktop/src/renderer/features/plugin/lib/__tests__/pluginMarketErrorKey.test.ts
+++ b/apps/desktop/src/renderer/features/plugin/lib/__tests__/pluginMarketErrorKey.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import i18n from '../../../../i18n';
+import { GHOST_OFFICIAL_ID_PREFIXES } from '../../../../../shared/ghost';
import { pluginMarketErrorKey } from '../pluginMarketErrorKey';
function serializedIpcError(code: string): Error {
@@ -29,6 +30,31 @@ describe('pluginMarketErrorKey', () => {
);
});
+ it('maps a reserved id to the actionable shared install copy instead of generic retry guidance', () => {
+ const key = pluginMarketErrorKey(serializedIpcError('GHOST_ID_RESERVED'));
+
+ // This excludes keeping the default branch that tells users to retry a permanently rejected id.
+ expect(key).toBe('settings.ghosts.errors.idReserved');
+ expect(key).not.toBe('settings.ghosts.market.errors.generic');
+ });
+
+ it.each(['zh-CN', 'zh-TW', 'en', 'ja', 'ko'])(
+ 'renders the complete reserved-prefix authority in the %s market toast',
+ (locale) => {
+ const key = pluginMarketErrorKey(serializedIpcError('GHOST_ID_RESERVED'));
+ const rawMessage = i18n.getResource(locale, 'common', key);
+ const message = i18n.getFixedT(locale)(key).toString();
+
+ // The raw resource check excludes a missing locale being hidden by English fallback.
+ expect(rawMessage).toEqual(expect.any(String));
+ // These assertions exclude a broken defaultVariables path leaving a literal placeholder.
+ expect(message).toContain(GHOST_OFFICIAL_ID_PREFIXES.join(' / '));
+ expect(message).not.toContain('{{');
+ // This excludes the market channel silently falling back to its generic retry toast.
+ expect(message).not.toBe(i18n.getFixedT(locale)('settings.ghosts.market.errors.generic'));
+ },
+ );
+
it.each([
{ locale: 'zh-CN', publisherAction: '联系发布者' },
{ locale: 'zh-TW', publisherAction: '聯絡釋出者' },
diff --git a/apps/desktop/src/renderer/features/plugin/lib/pluginMarketErrorKey.ts b/apps/desktop/src/renderer/features/plugin/lib/pluginMarketErrorKey.ts
index 5d94f65409..738f1ecf07 100644
--- a/apps/desktop/src/renderer/features/plugin/lib/pluginMarketErrorKey.ts
+++ b/apps/desktop/src/renderer/features/plugin/lib/pluginMarketErrorKey.ts
@@ -17,6 +17,8 @@ export function pluginMarketErrorKey(error: unknown): string {
return 'settings.ghosts.market.errors.notConfigured';
case 'GHOST_FILE_INVALID':
return 'settings.ghosts.market.errors.invalidPackage';
+ case 'GHOST_ID_RESERVED':
+ return 'settings.ghosts.errors.idReserved';
case 'GHOST_BROKER_REDIRECT_PORT_REQUIRED':
return 'settings.ghosts.market.errors.brokerRedirectPortRequired';
default: