Skip to content

feat: add copy url button on api key dialog, close 1072#1079

Merged
looplj merged 1 commit intorelease/v0.9.xfrom
dev-tmp
Mar 16, 2026
Merged

feat: add copy url button on api key dialog, close 1072#1079
looplj merged 1 commit intorelease/v0.9.xfrom
dev-tmp

Conversation

@looplj
Copy link
Copy Markdown
Owner

@looplj looplj commented Mar 16, 2026

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 introduces a significant usability improvement to the API key management interface. Users can now quickly copy the base URL for different SDKs directly from the API key view dialog, streamlining the process of configuring API clients. This change enhances the developer experience by providing immediate access to crucial setup information, reducing manual effort and potential errors.

Highlights

  • New Feature: Copy Base URL Button: A new button has been added to the API key dialog, allowing users to easily copy the base URL for various SDK code examples.
  • Enhanced API Key Masking: The display format for masked API keys has been updated to show the first three and last four characters (e.g., 'XXX...YYYY') for improved clarity and security.
  • Base URL Integration in Code Examples: Base URLs have been explicitly added to the codex, claudeCode, anthropicSDK, openAISDK, and geminiSDK code examples within the API key dialog.
  • Internationalization Support: New translation keys for 'Base URL copied to clipboard' have been added for English and Chinese locales.
Changelog
  • frontend/src/features/apikeys/components/apikeys-view-dialog.tsx
    • Imported the Link icon from lucide-react for the new copy URL button.
    • Created a new CopyBaseUrlButton component to handle copying the provided base URL to the clipboard and display a success toast.
    • Modified the API key masking logic to display the first three and last four characters of the key.
    • Added a baseUrl property to the codex, claudeCode, anthropicSDK, openAISDK, and geminiSDK objects within the codeExamples memo.
    • Integrated the CopyBaseUrlButton into the MaskedCodeBlock components for all relevant SDK tabs, passing the respective base URL.
  • frontend/src/locales/en/apikeys.json
    • Added a new translation key apikeys.messages.baseUrlCopied with the value 'Base URL copied to clipboard'.
  • frontend/src/locales/zh-CN/apikeys.json
    • Added a new translation key apikeys.messages.baseUrlCopied with the Chinese translation 'Base URL 已复制到剪贴板'.
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.

Copy link
Copy Markdown
Contributor

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

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 helpful "Copy Base URL" button to the API key view dialog. The implementation is solid, but I've identified a couple of opportunities to enhance component robustness and user interface consistency. My recommendations include using a useEffect hook for safer timer management and adopting the CheckIcon for the copy success state to align with existing patterns in the application.

@@ -1,22 +1,46 @@
import { useState, useEffect, useMemo } from 'react';
import { Copy, Eye, EyeOff, AlertTriangle } from 'lucide-react';
import { Copy, Eye, EyeOff, AlertTriangle, Link } from 'lucide-react';
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

To improve UI consistency, it's better to use a CheckIcon to indicate a successful copy operation. To do so, you'll need to import it from lucide-react.

Suggested change
import { Copy, Eye, EyeOff, AlertTriangle, Link } from 'lucide-react';
import { Copy, Eye, EyeOff, AlertTriangle, Link, CheckIcon } from 'lucide-react';

Comment on lines +17 to +22
const handleCopy = async () => {
await navigator.clipboard.writeText(baseUrl);
setIsCopied(true);
toast.success(t('apikeys.messages.baseUrlCopied'));
setTimeout(() => setIsCopied(false), 2000);
};
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 setTimeout call inside handleCopy can lead to a memory leak and a React warning ("Can't perform a React state update on an unmounted component") if the component unmounts before the timeout completes. A more robust approach is to manage this side effect using a useEffect hook with a cleanup function. This ensures the timer is cleared when the component unmounts.

Here's a suggested refactoring:

const [isCopied, setIsCopied] = useState(false);

useEffect(() => {
  if (isCopied) {
    const timerId = setTimeout(() => {
      setIsCopied(false);
    }, 2000);

    return () => clearTimeout(timerId);
  }
}, [isCopied]);

const handleCopy = async () => {
  await navigator.clipboard.writeText(baseUrl);
  toast.success(t('apikeys.messages.baseUrlCopied'));
  setIsCopied(true);
};

<Tooltip>
<TooltipTrigger asChild>
<Button size='icon' variant='ghost' className='shrink-0' onClick={handleCopy}>
{isCopied ? <Copy className='h-3.5 w-3.5 text-green-500' /> : <Link className='h-3.5 w-3.5' />}
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

For better UI consistency, consider using a CheckIcon to indicate a successful copy, similar to other copy buttons in the application (e.g., for code blocks). The Copy icon is typically associated with the action of copying, not the success state.

Suggested change
{isCopied ? <Copy className='h-3.5 w-3.5 text-green-500' /> : <Link className='h-3.5 w-3.5' />}
{isCopied ? <CheckIcon className='h-3.5 w-3.5 text-green-500' /> : <Link className='h-3.5 w-3.5' />}

@looplj looplj merged commit 57b594e into release/v0.9.x Mar 16, 2026
2 checks passed
@looplj
Copy link
Copy Markdown
Owner Author

looplj commented Mar 16, 2026

close #1072

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