Skip to content

Conversation

@Abhijay007
Copy link
Collaborator

ref : #6557 (comment), #6557 (comment)

PR Description

updated elevenLabs API module and remove UX

Type of Change

  • Refactor / Code quality

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

Tested In Desktop UI

Screenshots/Demos (for UX changes)

updateUXAPI

Signed-off-by: Abhijay007 <[email protected]>
Copy link
Contributor

Copilot AI left a 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 useEffect check.
  • 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.

Comment on lines +28 to +32
await upsert(ELEVENLABS_API_KEY, trimmedKey, true);
setElevenLabsApiKey('');
setIsEditing(false);
setHasElevenLabsKey(true);
setElevenLabsKeyCache(true);
Copy link

Copilot AI Jan 28, 2026

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).

Suggested change
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.');
}
}

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +40
await remove(ELEVENLABS_API_KEY, true);
setElevenLabsApiKey('');
setIsEditing(false);
setHasElevenLabsKey(false);
setElevenLabsKeyCache(false);
Copy link

Copilot AI Jan 28, 2026

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.

Suggested change
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);
}

Copilot uses AI. Check for mistakes.
Comment on lines 16 to 19
const response = await read(ELEVENLABS_API_KEY, true);
const hasKey = isSecretKeyConfigured(response);
setHasElevenLabsKey(hasKey);
setElevenLabsKeyCache(hasKey);
Copy link

Copilot AI Jan 28, 2026

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).

Suggested change
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);
}

Copilot uses AI. Check for mistakes.
@Abhijay007 Abhijay007 changed the title refactor: updated elevenLabs API module and remove UX refactor: updated elevenLabs API module and remove button UX Jan 28, 2026
Copy link
Collaborator

@lifeizhou-ap lifeizhou-ap left a 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!

@Abhijay007
Copy link
Collaborator Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants