Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions ui/desktop/src/components/settings/dictation/DictationSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ export default function DictationSection() {
checkOpenAIKey();
}, [getProviders]);

const handleDropdownToggle = async () => {
const newShowState = !showProviderDropdown;
setShowProviderDropdown(newShowState);

if (newShowState) {
try {
const providers = await getProviders(true);
const openAIProvider = providers.find((p) => p.name === 'openai');
const isConfigured = !!openAIProvider?.is_configured;
setHasOpenAIKey(isConfigured);
} catch (error) {
console.error('Error checking OpenAI configuration:', error);
setHasOpenAIKey(false);
}
}
};

const saveSettings = (newSettings: DictationSettings) => {
setSettings(newSettings);
localStorage.setItem(DICTATION_SETTINGS_KEY, JSON.stringify(newSettings));
Expand Down Expand Up @@ -171,7 +188,7 @@ export default function DictationSection() {
</div>
<div className="relative">
<button
onClick={() => setShowProviderDropdown(!showProviderDropdown)}
onClick={handleDropdownToggle}
className="flex items-center gap-2 px-3 py-1.5 text-sm border border-borderSubtle rounded-md hover:border-borderStandard transition-colors text-textStandard bg-background-default"
>
{getProviderLabel(settings.provider)}
Expand All @@ -182,12 +199,7 @@ export default function DictationSection() {
<div className="absolute right-0 mt-1 w-48 bg-background-default border border-borderStandard rounded-md shadow-lg z-10">
<button
onClick={() => handleProviderChange('openai')}
disabled={!hasOpenAIKey}
className={`w-full px-3 py-2 text-left text-sm transition-colors first:rounded-t-md ${
hasOpenAIKey
? 'hover:bg-bgSubtle text-textStandard'
: 'text-textSubtle cursor-not-allowed'
}`}
className="w-full px-3 py-2 text-left text-sm transition-colors first:rounded-t-md hover:bg-bgSubtle text-textStandard"
>
OpenAI Whisper
{!hasOpenAIKey && <span className="text-xs ml-1">(not configured)</span>}
Expand Down
Loading