-
Notifications
You must be signed in to change notification settings - Fork 2.7k
refactor: updated elevenLabs API module and remove button UX
#6781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Abhijay007 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Refactors the ElevenLabs API key settings UI in the desktop app by simplifying state management and removing some loading/validation UX.
Changes:
- Simplifies initial key detection to a single
useEffectcheck. - Switches save/remove flows to optimistic local state updates (no reload-based recheck).
- Adjusts the UI to show a dedicated “Remove API Key” action outside edit mode and removes inline validation/error messaging.
| await upsert(ELEVENLABS_API_KEY, trimmedKey, true); | ||
| setElevenLabsApiKey(''); | ||
| setIsEditing(false); | ||
| setHasElevenLabsKey(true); | ||
| setElevenLabsKeyCache(true); |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleSave no longer catches upsert failures, which will surface as an unhandled rejection and leaves the user with no feedback if saving fails; add try/catch and only flip hasElevenLabsKey/cache after a successful save (and consider surfacing an error message/toast on failure).
| await upsert(ELEVENLABS_API_KEY, trimmedKey, true); | |
| setElevenLabsApiKey(''); | |
| setIsEditing(false); | |
| setHasElevenLabsKey(true); | |
| setElevenLabsKeyCache(true); | |
| try { | |
| await upsert(ELEVENLABS_API_KEY, trimmedKey, true); | |
| setElevenLabsApiKey(''); | |
| setIsEditing(false); | |
| setHasElevenLabsKey(true); | |
| setElevenLabsKeyCache(true); | |
| } catch (error) { | |
| // eslint-disable-next-line no-console | |
| console.error('Failed to save ElevenLabs API key', error); | |
| if (typeof window !== 'undefined' && window.alert) { | |
| window.alert('Failed to save ElevenLabs API key. Please try again.'); | |
| } | |
| } |
| await remove(ELEVENLABS_API_KEY, true); | ||
| setElevenLabsApiKey(''); | ||
| setIsEditing(false); | ||
| setHasElevenLabsKey(false); | ||
| setElevenLabsKeyCache(false); |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleRemove now awaits remove without handling errors, so a backend/config failure will become an unhandled rejection and the UI won’t show why the key wasn’t removed; wrap this in try/catch and avoid updating hasElevenLabsKey/cache unless removal succeeds.
| await remove(ELEVENLABS_API_KEY, true); | |
| setElevenLabsApiKey(''); | |
| setIsEditing(false); | |
| setHasElevenLabsKey(false); | |
| setElevenLabsKeyCache(false); | |
| try { | |
| await remove(ELEVENLABS_API_KEY, true); | |
| setElevenLabsApiKey(''); | |
| setIsEditing(false); | |
| setHasElevenLabsKey(false); | |
| setElevenLabsKeyCache(false); | |
| } catch (error) { | |
| // Avoid updating local state/cache if removal fails so UI stays consistent with backend | |
| console.error('Failed to remove ElevenLabs API key:', error); | |
| } |
| const response = await read(ELEVENLABS_API_KEY, true); | ||
| const hasKey = isSecretKeyConfigured(response); | ||
| setHasElevenLabsKey(hasKey); | ||
| setElevenLabsKeyCache(hasKey); |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read(ELEVENLABS_API_KEY, true) is awaited inside an effect without any error handling, so a read failure will create an unhandled promise rejection and skip updating setElevenLabsKeyCache/state; wrap the async body in try/catch (or checkKey().catch(...)) and set the cache/state to false on error (similar to useDictationSettings).
| const response = await read(ELEVENLABS_API_KEY, true); | |
| const hasKey = isSecretKeyConfigured(response); | |
| setHasElevenLabsKey(hasKey); | |
| setElevenLabsKeyCache(hasKey); | |
| try { | |
| const response = await read(ELEVENLABS_API_KEY, true); | |
| const hasKey = isSecretKeyConfigured(response); | |
| setHasElevenLabsKey(hasKey); | |
| setElevenLabsKeyCache(hasKey); | |
| } catch { | |
| setHasElevenLabsKey(false); | |
| setElevenLabsKeyCache(false); | |
| } |
remove button UX
lifeizhou-ap
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Abhijay007 for this improvement!
|
@DOsinga, could you please take a look at this as well? I believe it’s ready to be merged. I’m asking since you had initially mentioned the refactor in the other PR |
ref : #6557 (comment), #6557 (comment)
PR Description
updated elevenLabs API module and remove UX
Type of Change
AI Assistance
Testing
Tested In Desktop UI
Screenshots/Demos (for UX changes)