Skip to content

Commit 448ae40

Browse files
claude-code-besttinyplan
authored andcommitted
fix: 修复 voice provider 的问题
1 parent 1ce5064 commit 448ae40

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/state/AppState.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,24 @@ import { applySettingsChange } from '../utils/settings/applySettingsChange.js';
1111
import type { SettingSource } from '../utils/settings/constants.js';
1212
import { createStore } from './store.js';
1313

14-
// DCE: voice context is ant-only. External builds get a passthrough.
14+
// DCE: voice context is ant-only. External builds get a noop provider that
15+
// still wraps children in VoiceContext so useVoiceState never throws.
1516
/* eslint-disable @typescript-eslint/no-require-imports */
1617
const VoiceProvider: (props: { children: React.ReactNode }) => React.ReactNode = feature('VOICE_MODE')
1718
? require('../context/voice.js').VoiceProvider
18-
: ({ children }) => children;
19+
: (() => {
20+
const { VoiceContext } = require('../context/voice.js');
21+
const noopStore = createStore({
22+
voiceState: 'idle' as const,
23+
voiceError: null as string | null,
24+
voiceInterimTranscript: '',
25+
voiceAudioLevels: [] as number[],
26+
voiceWarmingUp: false,
27+
});
28+
return ({ children }: { children: React.ReactNode }) => (
29+
<VoiceContext.Provider value={noopStore}>{children}</VoiceContext.Provider>
30+
);
31+
})();
1932

2033
/* eslint-enable @typescript-eslint/no-require-imports */
2134
import { type AppState, type AppStateStore, getDefaultAppState } from './AppStateStore.js';

0 commit comments

Comments
 (0)