Skip to content

Add toast notification for successful API key save - #294

Open
sanskaraggarwal2025 wants to merge 1 commit into
mainfrom
fix/api-key-toast
Open

sanskaraggarwal2025 wants to merge 1 commit into
mainfrom
fix/api-key-toast

Conversation

@sanskaraggarwal2025

@sanskaraggarwal2025 sanskaraggarwal2025 commented Jan 23, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds a toast notification that appears after users successfully save their API key for cloud providers (OpenAI, Gemini, Claude).

Changes

  • Added toast import and handler function in models.tsx
  • Added onSaveSuccess callback prop to provider components (OpenaiProvider, ClaudeProvider, GeminiProvider)
  • Updated ProviderView to accept and call the onSaveSuccess callback
  • Toast message: 'API key has been successfully saved'

Testing

  • Save API keys for OpenAI, Claude, and Gemini providers
  • Verify that success toast appears after successful save

Summary by CodeRabbit

  • New Features
    • Added success and error notifications when saving API provider settings, providing users with immediate feedback on whether their configuration was saved successfully or encountered an error.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add toast import and handler in models.tsx
- Add onSaveSuccess callback prop to provider components
- Show success toast after API key is saved for OpenAI, Claude, and Gemini providers
- Toast message: 'API key has been successfully saved'
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @sanskaraggarwal2025, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the user experience by adding clear and concise toast notifications for API key save operations. Users will now receive instant feedback, whether an API key is successfully stored or if an error occurs during the process, enhancing the overall responsiveness and usability of the application's provider settings.

Highlights

  • Toast Notifications for API Key Saves: Implemented toast notifications to provide immediate visual feedback to users when API keys for cloud providers (OpenAI, Gemini, Claude) are successfully saved or if the save operation fails.
  • New onSaveSuccess Callback Prop: Introduced an onSaveSuccess callback prop to OpenaiProvider, ClaudeProvider, GeminiProvider, and ProviderView components, allowing for custom success handling after an API key is saved.
  • Centralized Toast Handling: The ProviderView component now conditionally calls the onSaveSuccess callback or displays a default success toast. Error toasts are also displayed upon failed save attempts.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@coderabbitai

coderabbitai Bot commented Jan 23, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes introduce an optional onSaveSuccess callback prop across the provider component hierarchy. Provider components (Claude, Gemini, OpenAI) now accept and forward this callback to ProviderView, which invokes it after a successful API key save or displays a fallback toast notification.

Changes

Cohort / File(s) Summary
Provider Prop Addition
frontend/src/components/providers/claude-provider.tsx, gemini-provider.tsx, openai-provider.tsx
Added optional onSaveSuccess?: () => void prop to each provider interface. Updated component signatures to accept and forward onSaveSuccess to ProviderView.
Core Callback Implementation
frontend/src/components/providers/provider-view.tsx
Added onSaveSuccess prop to ProviderViewProps. Wired handleSaveProvider to invoke onSaveSuccess() callback on successful save; falls back to toast notification ("API key has been successfully saved") if callback not provided. Shows error toast on save failure.
Integration Point
frontend/src/pages/models.tsx
Imported toast utility and created handleApiKeySaveSuccess handler. Updated all provider component render calls to pass onSaveSuccess={handleApiKeySaveSuccess}, enabling toast feedback on successful API key saves.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A callback flows through, prop by prop so true,
From Claude to Gemini, OpenAI's got it too!
Toast messages dance when keys are saved with care,
Success now whispers through the callback air! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding toast notifications for successful API key saves across multiple provider components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a toast notification for successful API key saves. The implementation works, but it can be simplified by centralizing the toast notification logic. Currently, it involves passing an onSaveSuccess callback through several component layers, which leads to prop drilling and code duplication of the notification message. My review includes suggestions to refactor this by handling the toast notification directly within the ProviderView component. This will make the code cleaner, more maintainable, and reduce redundancy.

Comment on lines 3 to 20
interface ClaudeProviderProps {
onApiKeyChange?: (key: string) => void;
onApiUrlChange?: (url: string) => void;
onSaveSuccess?: () => void;
}

export const ClaudeProvider = ({ onApiKeyChange, onApiUrlChange }: ClaudeProviderProps) => {
export const ClaudeProvider = ({ onApiKeyChange, onApiUrlChange, onSaveSuccess }: ClaudeProviderProps) => {
return (
<ProviderView
providerName="claude"
displayName="Claude"
defaultApiUrl="https://api.anthropic.com/v1/messages"
onApiKeyChange={onApiKeyChange}
onApiUrlChange={onApiUrlChange}
onSaveSuccess={onSaveSuccess}
/>
);
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The onSaveSuccess prop is no longer needed. Please remove it from the props interface, the function signature, and the ProviderView component call.

interface ClaudeProviderProps {
    onApiKeyChange?: (key: string) => void;
    onApiUrlChange?: (url: string) => void;
}

export const ClaudeProvider = ({ onApiKeyChange, onApiUrlChange }: ClaudeProviderProps) => {
    return (
        <ProviderView
            providerName="claude"
            displayName="Claude"
            defaultApiUrl="https://api.anthropic.com/v1/messages"
            onApiKeyChange={onApiKeyChange}
            onApiUrlChange={onApiUrlChange}
        />
    );
};

Comment on lines 3 to 20
interface GeminiProviderProps {
onApiKeyChange?: (key: string) => void;
onApiUrlChange?: (url: string) => void;
onSaveSuccess?: () => void;
}

export const GeminiProvider = ({ onApiKeyChange, onApiUrlChange }: GeminiProviderProps) => {
export const GeminiProvider = ({ onApiKeyChange, onApiUrlChange, onSaveSuccess }: GeminiProviderProps) => {
return (
<ProviderView
providerName="gemini"
displayName="Gemini"
defaultApiUrl="https://generativelanguage.googleapis.com/v1beta/openai/chat/completions"
onApiKeyChange={onApiKeyChange}
onApiUrlChange={onApiUrlChange}
onSaveSuccess={onSaveSuccess}
/>
);
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The onSaveSuccess prop is no longer needed. Please remove it from the props interface, the function signature, and the ProviderView component call.

interface GeminiProviderProps {
    onApiKeyChange?: (key: string) => void;
    onApiUrlChange?: (url: string) => void;
}

export const GeminiProvider = ({ onApiKeyChange, onApiUrlChange }: GeminiProviderProps) => {
    return (
        <ProviderView
            providerName="gemini"
            displayName="Gemini"
            defaultApiUrl="https://generativelanguage.googleapis.com/v1beta/openai/chat/completions"
            onApiKeyChange={onApiKeyChange}
            onApiUrlChange={onApiUrlChange}
        />
    );
};

Comment on lines 3 to 20
interface OpenaiProviderProps {
onApiKeyChange?: (key: string) => void;
onApiUrlChange?: (url: string) => void;
onSaveSuccess?: () => void;
}

export const OpenaiProvider = ({ onApiKeyChange, onApiUrlChange }: OpenaiProviderProps) => {
export const OpenaiProvider = ({ onApiKeyChange, onApiUrlChange, onSaveSuccess }: OpenaiProviderProps) => {
return (
<ProviderView
providerName="openai"
displayName="OpenAI"
defaultApiUrl="https://api.openai.com/v1/chat/completions"
onApiKeyChange={onApiKeyChange}
onApiUrlChange={onApiUrlChange}
onSaveSuccess={onSaveSuccess}
/>
);
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The onSaveSuccess prop is no longer needed. Please remove it from the props interface, the function signature, and the ProviderView component call.

interface OpenaiProviderProps {
    onApiKeyChange?: (key: string) => void;
    onApiUrlChange?: (url: string) => void;
}

export const OpenaiProvider = ({ onApiKeyChange, onApiUrlChange }: OpenaiProviderProps) => {
    return (
        <ProviderView
            providerName="openai"
            displayName="OpenAI"
            defaultApiUrl="https://api.openai.com/v1/chat/completions"
            onApiKeyChange={onApiKeyChange}
            onApiUrlChange={onApiUrlChange}
        />
    );
};

defaultApiUrl?: string;
onApiKeyChange?: (key: string) => void;
onApiUrlChange?: (url: string) => void;
onSaveSuccess?: () => void;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The onSaveSuccess prop is no longer needed in the props interface as part of the suggested refactoring.

defaultApiUrl = '',
onApiKeyChange,
onApiUrlChange,
onSaveSuccess,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

With the onSaveSuccess prop being removed, it should also be removed from the props destructuring.

Comment on lines +77 to +81
if (onSaveSuccess) {
onSaveSuccess();
} else {
toast.success('API key has been successfully saved');
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic can be simplified by removing the conditional check for onSaveSuccess. The component can take full responsibility for showing the success notification.

            toast.success('API key has been successfully saved');

Comment on lines +30 to +33
// Handler for successful API key save
const handleApiKeySaveSuccess = () => {
toast.success('API key has been successfully saved');
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This handler function for showing a toast is redundant. The ProviderView component, which handles the save operation, is a better place to trigger this notification. Removing this and the related onSaveSuccess prop will simplify the code and avoid prop drilling. You can also remove the toast import on line 4 as it will no longer be used in this file after the refactoring.

Comment on lines 69 to 80
switch (selectedProvider) {
case 'openai':
return <OpenaiProvider />;
return <OpenaiProvider onSaveSuccess={handleApiKeySaveSuccess} />;
case 'claude':
return <ClaudeProvider />;
return <ClaudeProvider onSaveSuccess={handleApiKeySaveSuccess} />;
case 'gemini':
return <GeminiProvider />;
return <GeminiProvider onSaveSuccess={handleApiKeySaveSuccess} />;
case 'local':
return <LocalProvider />;
default:
return <ProviderView providerName={selectedProvider} />;
return <ProviderView providerName={selectedProvider} onSaveSuccess={handleApiKeySaveSuccess} />;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Following the suggestion to centralize the toast logic in ProviderView, the onSaveSuccess prop should be removed from these component calls.

Suggested change
switch (selectedProvider) {
case 'openai':
return <OpenaiProvider />;
return <OpenaiProvider onSaveSuccess={handleApiKeySaveSuccess} />;
case 'claude':
return <ClaudeProvider />;
return <ClaudeProvider onSaveSuccess={handleApiKeySaveSuccess} />;
case 'gemini':
return <GeminiProvider />;
return <GeminiProvider onSaveSuccess={handleApiKeySaveSuccess} />;
case 'local':
return <LocalProvider />;
default:
return <ProviderView providerName={selectedProvider} />;
return <ProviderView providerName={selectedProvider} onSaveSuccess={handleApiKeySaveSuccess} />;
}
switch (selectedProvider) {
case 'openai':
return <OpenaiProvider />;
case 'claude':
return <ClaudeProvider />;
case 'gemini':
return <GeminiProvider />;
case 'local':
return <LocalProvider />;
default:
return <ProviderView providerName={selectedProvider} />;
}

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.

1 participant