Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge upstream/main and preserve speech settings regressions
JiangJiahao0bee5a83756e
diff --cc apps/desktop/scripts/fixtures/voice-settings/ui-page.mjsindex e3337a4043,22992eca75..855425d239--- a/apps/desktop/scripts/fixtures/voice-settings/ui-page.mjs+++ b/apps/desktop/scripts/fixtures/voice-settings/ui-page.mjs@@@ -30,8 -80,39 +80,41 @@@ export defaultabout: 'Eleven v3 keeps voice and preview but does not offer a speed slider',data: { modelId: 'eleven_v3' },},+ hidden: { about: 'A saved hidden model remains displayed without offering other unchecked speech models', data: { hidden: true } },+ 'hidden-empty': { about: 'Hidden models are not selected automatically without a saved preference', data: { hidden: true, noPreference: true } },+ 'qwen-catalog': {+ about: 'Complete Qwen3 system catalog with official display names and keyboard navigation',+ data: {+ protocol: 'qwen-tts',+ modelId: 'qwen3-tts-flash',+ voiceId: 'Cherry',+ systemCatalog: true,+ menu: true,+ },+ },+ 'cosy-catalog': {+ about: 'Complete CosyVoice system catalog plus a matching account voice in a narrow drawer',+ viewport: { width: 320, height: 900 },+ data: {+ protocol: 'dashscope-tts',+ modelId: 'cosyvoice-v3-flash',+ voiceId: 'longanyang',+ systemCatalog: true,+ customCatalog: true,+ menu: true,+ },+ },+ 'cosy-custom-failure': {+ about: 'Account catalog failure preserves system choices, selected voice, and refresh',+ viewport: { width: 320, height: 900 },+ data: {+ protocol: 'dashscope-tts',+ modelId: 'cosyvoice-v3-flash',+ voiceId: 'longanyang',+ systemCatalog: true,+ customCatalogFailure: true,+ },+ },empty: {about: 'No models keeps only the existing setup introduction and provider link',data: { empty: true },@@@ -54,9 -135,23 +137,23 @@@about: 'Failed preview stays in the menu without replacing the saved voice',data: { menu: true, previewFailure: true, speed: 0.95 },},+ 'menu-timeout': {+ about: 'Preview timeout keeps the selected voice and reports only the known cause',+ data: { menu: true, previewTimeout: true, speed: 0.95 },+ },+ 'manual-timeout': {+ about: 'Manual audition timeout stays beside the input without saving the draft',+ viewport: { width: 320, height: 900 },+ data: { manual: true, previewTimeout: true, speed: 0.95 },+ },+ 'manual-error': {+ about: 'Unknown manual audition failure does not blame model or voice configuration',+ viewport: { width: 320, height: 900 },+ data: { manual: true, previewFailure: true, speed: 0.95 },+ },},async ready(page) {- const empty = await page.evaluate(() => window.__uiPage.ctx.data.empty);+ const empty = await page.evaluate(() => window.__uiPage.ctx.data.empty || window.__uiPage.ctx.data.noPreference);if (empty) await page.getByRole('button').first().waitFor();else if (await page.evaluate(() => window.__uiPage.ctx.data.manual)) {const label = await page.evaluate(() => window.__uiPage.t('bots.voiceMode.voiceId'));@@@ -112,22 -252,73 +254,89 @@@return;}assert.equal(await standalonePreview.count(), 0);+ if (ui.data.hidden) {+ const model = page.getByRole('combobox', { name: await ui.t('bots.voiceMode.model'), exact: true });+ if (ui.data.noPreference) {+ assert.equal(await model.count(), 0);+ await page.getByText(await ui.t('bots.voiceMode.noModels'), { exact: true }).waitFor();+ await ui.capture('hidden-empty');+ } else {+ assert.ok((await model.textContent()).includes('eleven_flash_v2_5'));+ await model.click();+ await page.getByRole('option', { name: /Visible speech/ }).waitFor();+ assert.equal(await page.getByRole('option', { name: /Unchecked speech/ }).count(), 0);+ await ui.capture('hidden-selection');+ await page.keyboard.press('Escape');+ }+ return;+ }+ if (ui.data.gatewayReference) {+ const label = await ui.t('bots.voiceMode.voice');+ const trigger = page.getByRole('button', { name: label, exact: true });+ const menu = page.getByRole('dialog', { name: label });+ const voices = await page.evaluate(() => window.__uiPage.ctx.data.gatewayVoices);+ const choice = voices[1];+ await page.getByText(await ui.t('bots.voiceMode.voicesReference'), { exact: true }).waitFor();+ await menu.getByRole('button', { name: choice.name, exact: true }).focus();+ await page.keyboard.press('Tab');+ const preview = menu.getByRole('button', {+ name: await ui.t('bots.voiceMode.previewVoice', { voice: choice.name }),+ exact: true,+ });+ assert.equal(await preview.evaluate((el) => el === document.activeElement), true);+ await ui.capture('reference-menu');+ await page.keyboard.press('Enter');+ await page.waitForFunction(() => window.__uiPage.ctx.data.previewRequests.length === 1);+ const request = await page.evaluate(() => window.__uiPage.ctx.data.previewRequests[0]);+ assert.equal(request.providerId, 'xd');+ assert.equal(request.modelId, ui.data.modelId);+ assert.equal(request.voice, choice.id);+ assert.equal(await page.evaluate(() => window.__uiPage.ctx.data.savedVoice), voices[0].id);+ await page.keyboard.press('Escape');+ await menu.waitFor({ state: 'hidden' });+ assert.equal(await trigger.evaluate((el) => el === document.activeElement), true);+ await page+ .getByRole('button', { name: await ui.t('bots.voiceMode.refreshVoices'), exact: true })+ .click();+ assert.equal(await page.evaluate(() => window.__uiPage.ctx.data.previewRequests.length), 1);+ assert.equal(await page.evaluate(() => window.__uiPage.ctx.data.savedVoice), voices[0].id);+ await trigger.click();+ return;+ }+ if (ui.data.systemCatalog) {+ const label = await ui.t('bots.voiceMode.voice');+ const trigger = page.getByRole('button', { name: label, exact: true });+ const menu = page.getByRole('dialog', { name: label });+ if (ui.data.customCatalogFailure) {+ await page.getByText(await ui.t('bots.voiceMode.voicesCustomError')).waitFor();+ await page+ .getByRole('button', { name: await ui.t('bots.voiceMode.refreshVoices'), exact: true })+ .click();+ await trigger.click();+ }+ await menu.waitFor();+ const firstName = ui.data.protocol === 'qwen-tts' ? '芊悦' : '龙安洋';+ const lastName = ui.data.customCatalog+ ? 'My Custom Voice'+ : ui.data.protocol === 'qwen-tts'+ ? '粤语-阿清'+ : 'Bella3.0';+ await menu.getByRole('button', { name: firstName, exact: true }).focus();+ await page.keyboard.press('End');+ // Manual entry is the final action after all provider/system voices.+ await page.keyboard.press('ArrowUp');+ const last = menu.getByRole('button', { name: lastName, exact: true });+ assert.equal(await last.evaluate((el) => el === document.activeElement), true);+ await ui.capture('catalog-end');+ await page.keyboard.press('Home');+ await ui.capture('catalog-start');+ assert.equal(await page.evaluate(() => window.__uiPage.ctx.data.savedVoice), ui.data.voiceId);+ assert.equal(await page.evaluate(() => window.__uiPage.ctx.data.previewRequests.length), 0);+ await page.keyboard.press('Escape');+ await menu.waitFor({ state: 'hidden' });+ assert.equal(await trigger.evaluate((el) => el === document.activeElement), true);+ return;+ }if (ui.data.menu) {const label = await ui.t('bots.voiceMode.voice');const trigger = page.getByRole('button', { name: label, exact: true });diff --cc apps/desktop/scripts/fixtures/voice-settings/voice-settings-fixture.tsxindex 4c05e9fdde,4ad05b1dbc..171812b69f--- a/apps/desktop/scripts/fixtures/voice-settings/voice-settings-fixture.tsx+++ b/apps/desktop/scripts/fixtures/voice-settings/voice-settings-fixture.tsx@@@ -47,40 -61,59 +62,62 @@@ mountPage(: [{id: modelId,+ ...(ctx.data.hidden ? { pickerVisible: false } : {}),name: modelId,- providerId: 'fixture',- providerName:- protocol === 'elevenlabs'+ providerId,+ providerName: ctx.data.gatewayReference+ ? 'XD Gateway'+ : protocol === 'elevenlabs'? 'ElevenLabs': protocol === 'minimax'? 'MiniMax'- : 'OpenAI',- agent: 'codex',- protocol,- protocolLocked: true,- defaultVoice: 'river',+ : protocol === 'qwen-tts' || protocol === 'dashscope-tts'+ ? 'Alibaba Cloud'+ : 'OpenAI',+ agent,+ protocol: ctx.data.custom ? undefined : protocol,+ protocolLocked: !ctx.data.custom,+ defaultVoice: referenceVoice,},+ ...(ctx.data.hidden ? [{ id: 'unchecked', name: 'Unchecked speech', providerId: 'fixture', agent: 'codex' as const, pickerVisible: false }] : []),+ ...(ctx.data.hidden && !ctx.data.noPreference ? [{ id: 'visible', name: 'Visible speech', providerId: 'fixture', agent: 'codex' as const, protocol, protocolLocked: true, defaultVoice: 'river' }] : []),],- voices: async () => ({- source: 'provider',- voices: [- { id: 'river', name: 'River — Relaxed, Neutral, Informative' },- ...(ctx.data.menu- ? [- { id: 'bella', name: 'Bella — Professional, Bright, Warm' },- { id: 'sarah', name: 'Sarah — Mature, Reassuring, Confident' },- { id: 'roger', name: 'Roger — Laid-Back, Casual, Resonant' },- { id: 'laura', name: 'Laura — Enthusiast, Quirky Attitude' },- { id: 'charlie', name: 'Charlie — Deep, Confident, Energetic' },- { id: 'george', name: 'George — Warm, Captivating Storyteller' },- { id: 'callum', name: 'Callum — Husky, Trickster' },- ]- : []),- ],- }),+ voices: async () =>+ ctx.data.gatewayReference+ ? { source: 'reference', voices: gatewayVoices.map((voice) => ({ ...voice })) }+ : ctx.data.systemCatalog+ ? {+ source: ctx.data.customCatalog ? 'mixed' : 'reference',+ ...(ctx.data.customCatalogFailure ? { customVoicesUnavailable: true } : {}),+ voices: [+ ...systemVoices,+ ...(ctx.data.customCatalog+ ? [{ id: 'account-clone', name: 'My Custom Voice' }]+ : []),+ ],+ }+ : {+ source: ctx.data.voiceId ? 'reference' : 'provider',+ voices: [+ {+ id: referenceVoice,+ name: ctx.data.voiceId+ ? referenceVoice+ : 'River — Relaxed, Neutral, Informative',+ },+ ...(ctx.data.menu+ ? [+ { id: 'bella', name: 'Bella — Professional, Bright, Warm' },+ { id: 'sarah', name: 'Sarah — Mature, Reassuring, Confident' },+ { id: 'roger', name: 'Roger — Laid-Back, Casual, Resonant' },+ { id: 'laura', name: 'Laura — Enthusiast, Quirky Attitude' },+ { id: 'charlie', name: 'Charlie — Deep, Confident, Energetic' },+ { id: 'george', name: 'George — Warm, Captivating Storyteller' },+ { id: 'callum', name: 'Callum — Husky, Trickster' },+ ]+ : []),+ ],+ },preference: async () => preference,setPreference: async (_botId: string,diff --cc apps/desktop/src/main/voice-conversation/__tests__/ipc.test.tsindex e077141999,041427aed8..0f5c02b82a--- a/apps/desktop/src/main/voice-conversation/__tests__/ipc.test.ts+++ b/apps/desktop/src/main/voice-conversation/__tests__/ipc.test.ts@@@ -111,19 -108,66 +111,79 @@@ const start = () =voice: 'alloy',});+// PR #6768 unit regression: model discovery must wait for current-owner display+// preferences. Existing IPC tests start with ready state and cannot catch this race.+it('waits for display preferences before returning the speech picker catalog', async () => {+ clearModelVisibilityMirror();+ const ready = vi.fn();+ const pending = call('models') as Promise<unknown>;+ void pending.then(ready);+ await Promise.resolve();+ expect(ready).not.toHaveBeenCalled();+ setModelVisibilityMirror({});+ await expect(pending).resolves.toEqual([expect.objectContaining({ id: 'voice-test' })]);+});++ // Oct 21 TTS stall: transport tests did not cover the IPC catch-all losing its+ // timeout cause. Unit: real handlers/service/transport, stalled fetch or PCM read.+ it.each(['headers', 'read'] as const)(+ 'exposes only a safe timeout code for stalled speech %s',+ async (stage) => {+ vi.useFakeTimers();+ try {+ await start();+ if (stage === 'headers') {+ vi.mocked(outboundFetch).mockImplementation(+ (_url, init) =>+ new Promise((_resolve, reject) => {+ init?.signal?.addEventListener(+ 'abort',+ () => reject(new Error('private network detail')),+ { once: true },+ );+ }),+ );+ } else {+ vi.mocked(outboundFetch).mockResolvedValue(+ new Response(+ new ReadableStream({+ start(controller) {+ controller.enqueue(new Uint8Array([1, 2]));+ },+ }),+ { headers: { 'Content-Type': 'audio/pcm' } },+ ),+ );+ }+ const speech = call('speak', { callId: 'call', requestId: 'one', text: 'hello' });+ let pending = speech;+ if (stage === 'read') {+ await speech;+ await call('read-speech', 'call', 'one');+ pending = call('read-speech', 'call', 'one');+ }+ const result = expect(pending).rejects.toThrow(+ '[VOICE_SPEECH_TIMEOUT] Speech response timed out.',+ );+ await vi.advanceTimersByTimeAsync(stage === 'headers' ? 30_000 : 15_000);+ await result;+ expect(outboundFetch).toHaveBeenCalledOnce();+ } finally {+ vi.useRealTimers();+ }+ },+ );++ it('keeps untrusted upstream errors generic rather than forwarding their text or claimed timeout code', async () => {+ await start();+ vi.mocked(outboundFetch).mockRejectedValue(+ new Error('[VOICE_SPEECH_TIMEOUT] private upstream detail'),+ );+ await expect(call('speak', { callId: 'call', requestId: 'one', text: 'hello' })).rejects.toThrow(+ '[PRECONDITION_FAILED] Voice conversation is unavailable.',+ );+ });+it('patches playback without replacing the saved route and validates boolean overrides', async () => {const choice = { modelId: 'voice-test', voice: 'alloy', speed: 1.15 };await call('set-preference', 'bot-a', choice);diff --cc apps/desktop/src/renderer/features/bots/voice/CompanionVoiceSettings.tsxindex c1924d4770,dd70daf0b7..aaa736e504--- a/apps/desktop/src/renderer/features/bots/voice/CompanionVoiceSettings.tsx+++ b/apps/desktop/src/renderer/features/bots/voice/CompanionVoiceSettings.tsx@@@ -338,12 -336,20 +339,20 @@@ export function CompanionVoiceSettings({...control}label={t('bots.voiceMode.model')}value={selectedModel ? voiceModelKey(selectedModel) : ''}- options={models.map((model) => ({+ options={pickerModels.map((model) => ({value: voiceModelKey(model),- label: [model.name, model.providerName].filter(Boolean).join(' · '),+ label: [+ model.name,+ providerDisplayName(+ { id: model.providerId ?? 'xd', name: model.providerName ?? '' },+ t,+ ),+ ]+ .filter(Boolean)+ .join(' · '),}))}onValueChange={chooseModel}- disabled={loading || !ready || saving || models.length === 0}+ disabled={loading || !ready || saving || pickerModels.length === 0}className="flex-1"/><Buttondiff --cc apps/desktop/src/renderer/features/bots/voice/__tests__/CompanionVoiceSettings.test.tsxindex 91cf4c02fd,62e86cc5c6..1a9b755428--- a/apps/desktop/src/renderer/features/bots/voice/__tests__/CompanionVoiceSettings.test.tsx+++ b/apps/desktop/src/renderer/features/bots/voice/__tests__/CompanionVoiceSettings.test.tsx@@@ -1192,31 -1366,63 +1367,92 @@@ it('blocks preview while the companionexpect(start).not.toHaveBeenCalled();});+// Review regression: visibility is picker policy, not saved-route eligibility.+// Existing UI tests had only visible or missing routes (Renderer unit, mock bridge).+it('does not default to or offer unchecked speech models, while restoring a saved hidden selection', async () => {+ models = [+ { id: 'hidden', name: 'Saved hidden speech', pickerVisible: false, defaultVoice: 'alloy' },+ { id: 'unchecked', name: 'Unchecked speech', pickerVisible: false, defaultVoice: 'alloy' },+ { id: 'visible', name: 'Visible speech', defaultVoice: 'alloy' },+ ];+ expect(resolveVoiceConfiguration(models, null).selection?.modelId).toBe('visible');+ const saved = { modelId: 'hidden', voice: 'nova' };+ expect(resolveVoiceConfiguration(models, saved).selection).toEqual(saved);+ vi.mocked(window.electronAPI.voiceConversation.preference).mockResolvedValue({ selection: saved, customized: true });+ renderSettings();+ const field = await screen.findByRole('combobox', { name: 'bots.voiceMode.model' });+ await waitFor(() => expect((field as HTMLSelectElement).value).toBe(voiceModelKey(saved)));+ // The saved value remains displayed; other unchecked models are not offered.+ expect(within(field).queryByRole('option', { name: 'Unchecked speech' })).toBeNull();+ expect(screen.queryByText('bots.voiceMode.modelUnavailable')).toBeNull();+ expect(window.electronAPI.voiceConversation.setPreference).not.toHaveBeenCalled();+});++it('shows setup guidance when all speech models are hidden and there is no saved choice', async () => {+ models = [{ id: 'unchecked', name: 'Unchecked speech', pickerVisible: false, defaultVoice: 'alloy' }];+ expect(resolveVoiceConfiguration(models, null).selection).toBeNull();+ renderSettings();+ await screen.findByText('bots.voiceMode.noModels');+ expect(screen.queryByRole('combobox', { name: 'bots.voiceMode.model' })).toBeNull();+});+++ // Unit tier, actual settings/preview entry with the host boundary mocked: switching+ // to Qwen must discard an unsupported speed without losing the selected connection.+ it.each([+ ['qwen-tts', 'qwen3-tts-flash', 'Cherry', undefined],+ ['dashscope-tts', 'cosyvoice-v3-flash', 'longanyang', 1.5],+ ] as const)(+ 'saves and previews the %s proxy override with native parameter limits',+ async (protocol, modelId, voice, speed) => {+ models = [{ id: modelId, name: modelId, providerId: 'proxy', agent: 'codex' }];+ vi.mocked(window.electronAPI.voiceConversation.preference).mockResolvedValue({+ selection: {+ providerId: 'proxy',+ agent: 'codex',+ modelId,+ protocol: 'openai',+ voice: 'old-voice',+ speed: 1.5,+ },+ customized: true,+ });+ renderSettings();+ const field = await screen.findByLabelText('bots.voiceMode.protocol');+ await waitFor(() => expect((field as HTMLSelectElement).disabled).toBe(false));+ await act(async () => {+ fireEvent.change(field, { target: { value: protocol } });+ });+ await waitFor(() =>+ expect(window.electronAPI.voiceConversation.setPreference).toHaveBeenLastCalledWith('bot', {+ providerId: 'proxy',+ agent: 'codex',+ modelId,+ protocol,+ voice,+ ...(speed === undefined ? {} : { speed }),+ }),+ );+ const slider = screen.queryByRole('slider', { name: 'bots.voiceMode.speed' });+ if (speed === undefined) expect(slider).toBeNull();+ else {+ expect(slider?.getAttribute('aria-valuemin')).toBe('0.5');+ expect(slider?.getAttribute('aria-valuemax')).toBe('2');+ }+ fireEvent.click(await screen.findByRole('button', { name: 'bots.voiceMode.preview' }));+ await waitFor(() =>+ expect(window.electronAPI.voiceConversation.preview).toHaveBeenCalledWith(+ expect.objectContaining({+ providerId: 'proxy',+ agent: 'codex',+ modelId,+ protocol,+ voice,+ }),+ ),+ );+ expect(vi.mocked(window.electronAPI.voiceConversation.preview).mock.calls[0][0].speed).toBe(+ speed,+ );+ expect(audio.start).not.toHaveBeenCalled();+ },+ );