Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(providers): preserve active speech catalog on refresh
JiangJiahao7e99f02add62
diff --git a/apps/desktop/src/main/bot-import/__tests__/files.test.ts b/apps/desktop/src/main/bot-import/__tests__/files.test.tsindex 6f9d8a9acc..214c2c795a 100644--- a/apps/desktop/src/main/bot-import/__tests__/files.test.ts+++ b/apps/desktop/src/main/bot-import/__tests__/files.test.ts@@ -209,8 +209,11 @@ it('accounts a near-budget binary snapshot without serializing or copying its buview: { id: `fixture-${index}`, name: 'Fixture', category: 'memory' as const, selected: true },asset: { name: `${index}.bin`, bytes },}));- const toJSON = vi.spyOn(Buffer.prototype, 'toJSON').mockImplementation(() => { throw new Error('buffer copied'); });+ const toJSON = vi.spyOn(bytes, 'toJSON').mockImplementation(() => { throw new Error('buffer copied'); });try {+ // #6928 Windows CI: Vitest serializes unrelated IPC buffers during awaits.+ // Check the same serialization path without spawning a process in this unit test.+ expect(JSON.parse(JSON.stringify(Buffer.from([1])))).toEqual({ type: 'Buffer', data: [1] });await reserveSnapshotItems(items, createImportBudget());expect(items.every(item => item.asset.bytes === bytes)).toBe(true);await expect(reserveSnapshotItems([...items, ...items.slice(0, 2)], createImportBudget())).rejects.toThrow('SOURCE_SNAPSHOT_TOO_LARGE');diff --git a/apps/desktop/src/renderer/__tests__/providersSectionUnavailableModels.test.tsx b/apps/desktop/src/renderer/__tests__/providersSectionUnavailableModels.test.tsxindex 3c7918f711..536db40823 100644--- a/apps/desktop/src/renderer/__tests__/providersSectionUnavailableModels.test.tsx+++ b/apps/desktop/src/renderer/__tests__/providersSectionUnavailableModels.test.tsx@@ -12,7 +12,7 @@ import React from 'react';import { MemoryRouter } from 'react-router-dom';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import type { CustomProviderConfig, ProviderView } from '@cindy/model-providers';+import type { CustomProviderConfig, ModelRegistry, ProviderView } from '@cindy/model-providers';import { createIpcError } from '../../shared/ipc-errors';import { toast } from '@/lib/toast';@@ -245,8 +245,11 @@ describe('ProvidersSection — 双栏管理', () => {models: [{ id: 'MiniMax-M3', name: 'My chat', defaultEnabled: false }] },},});- function selectSpeechProvider(config: CustomProviderConfig = miniMaxConfig()) {- const provider = buildUserProvider(config, { modelRegistry: BUNDLED_CATALOG.modelRegistry });+ function selectSpeechProvider(+ config: CustomProviderConfig = miniMaxConfig(),+ modelRegistry = BUNDLED_CATALOG.modelRegistry,+ ) {+ const provider = buildUserProvider(config, { modelRegistry });providerSnapshotState.customOverride = { ...provider, connected: true,availableMediaModelIds: provider.audioModels?.map(model => model.id) ?? [] };providerSnapshotState.order = [provider.id, 'xd'];@@ -290,6 +293,38 @@ describe('ProvidersSection — 双栏管理', () => {}},);+ // Unit regression for #6928: the real refresh/save path must recognize a saved+ // model classified only by the current Server Registry. Bundled/explicit-mode+ // cases above cannot catch an extra enabled reference beside a hidden model.+ it.each([+ ['codex', true, 'audio_speech'],+ ['codex', false, 'audio_speech'],+ ['pi', false, 'audio_speech'],+ ['codex', false, 'audio_transcription'],+ ] as const)('respects current Registry audio on %s (enabled=%s, mode=%s)', async (agent, defaultEnabled, mode) => {+ const config: CustomProviderConfig = miniMaxConfig();+ const savedAudio = { id: 'server-only-audio', name: 'My saved audio', defaultEnabled };+ const runtime = config.runtimes[agent] ??= { baseUrl: 'https://proxy.example/v1', models: [] };+ runtime.models.push(savedAudio);+ const modelRegistry: ModelRegistry = {+ schemaVersion: 5, updatedAt: '2026-10-23T00:00:00Z', models: [],+ baseModels: [{ id: savedAudio.id, aliases: [], defaults: { mode } }],+ };+ selectSpeechProvider(config, modelRegistry);+ expect(providerSnapshotState.customOverride!.audioModels).toEqual([+ expect.objectContaining({ id: savedAudio.id, mode, defaultEnabled, sourceAgent: agent }),+ ]);+ window.electronAPI.maker.fetchProviderModels = vi.fn(async () => ({ ok: true, models: [] }));+ render(<MemoryRouter><ProvidersSection /></MemoryRouter>);+ await act(async () => { fireEvent.click(await screen.findByRole('button', { name: 'settings.providers.models.refreshAria' })); });+ const saved = vi.mocked(updateCustomProvider).mock.lastCall![0];+ expect(saved.runtimes[agent]!.models.find(model => model.id === savedAudio.id)).toEqual(savedAudio);+ expect(saved.runtimes.codex!.models.some(model => model.id === 'speech-2.8-turbo'))+ .toBe(mode !== 'audio_speech');+ expect(buildUserProvider(saved, { modelRegistry }).audioModels)+ .toEqual(expect.arrayContaining([expect.objectContaining({ id: savedAudio.id, mode, defaultEnabled })]));+ expect(setModelVisibilities).not.toHaveBeenCalled();+ });it.each(['proxy', 'oauth', 'disabled-route'] as const)('does not offer or auto-add speech for an unconfirmed %s connection', async kind => {const config = miniMaxConfig();diff --git a/apps/desktop/src/shared/speechProviderSetup.ts b/apps/desktop/src/shared/speechProviderSetup.tsindex 47c78be15c..bff258c133 100644--- a/apps/desktop/src/shared/speechProviderSetup.ts+++ b/apps/desktop/src/shared/speechProviderSetup.ts@@ -196,7 +196,8 @@ export function missingSpeechReference(const models = Object.values(config.runtimes).flatMap(runtime => runtime?.models ?? []);// Hidden speech is still a saved choice. Never fill a different runtime or// override discovery/user classification of an existing reference ID.- if (models.some(isSpeechModel)) return;+ // Current Server-only classifications live in the projection, not userModelConfig.+ if (provider.audioModels?.some(model => model.mode === 'audio_speech') || models.some(isSpeechModel)) return;const runtime = config.runtimes[target.agent];if (!runtime) return;const model = speechReferenceModels(runtime.baseUrl).find(reference => reference.defaultEnabled);