Skip to content

Conversation

@adityakhare86
Copy link

@adityakhare86 adityakhare86 commented Dec 26, 2025

When no auth keys exist in the database, the API returns an error which caused the error state UI to render. This error state only showed an error message with no way to create a new auth key, effectively blocking users from creating their first key via the UI.

Fix: Updated the error state to include a button to create auth keys.

This ensures users can always create auth keys through the UI, even when the initial fetch fails.

Summary by CodeRabbit

  • New Features

    • Added a consistent header with back navigation and a prominent "Create Auth Key" action; empty-state and error panels now include the same create action and improved key controls (visibility toggle, copy-to-clipboard).
  • Style

    • Redesigned Auth Keys dashboard layout and visuals: styled error panel, centered dashed empty-state, and unified container for actions and messaging for a more polished, consistent experience.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 26, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

The AuthKeysView was refactored to use a consistent header (back button, title, "Create Auth Key") and to render error and empty states as styled in-layout panels; key list rendering and the create-key modal remain functional and integrated into the new layout.

Changes

Cohort / File(s) Summary
Auth Keys view UI
web/src/views/dashboard/authKeys/AuthKeysView.tsx
Replaced standalone/simple error and empty-state text with styled in-layout error and empty-state panels; added a shared header (back navigation, page title, "Create Auth Key" action); preserved key list rendering (visibility toggles, copy-to-clipboard, per-key UI) and create-key modal integration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibbled through the UI night,
Replaced plain warnings with a gentle light,
A header guides, a button plays,
Panels hug the keys in tidy arrays,
Hop, click, create — a rabbit’s delight. 🐇✨

Pre-merge checks and finishing touches

✅ 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 a create button to the auth keys error state, which aligns with the core objective of enabling users to create auth keys when the initial fetch fails.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Copy link

Summary of Changes

Hello @adityakhare86, 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 resolves a critical usability issue within the authentication key management interface. Previously, if no authentication keys were present, the UI would display an error without offering a way to create new keys, effectively blocking user progression. The changes introduce a 'Create Auth Key' button directly into this error state, along with improved styling and navigation, ensuring that users always have the necessary tools to manage their authentication keys.

Highlights

  • Error State Enhancement: The authentication keys error state UI has been significantly updated to include a 'Create Auth Key' button, addressing a previous limitation where users could not create their first key if none existed.
  • Improved User Experience: Users can now seamlessly create new authentication keys directly from the error screen, ensuring continuous access to key management functionality even when the initial data fetch fails.
  • UI Navigation: A back button has been added to the error state header, allowing users to easily navigate back to the dashboard.

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

Copy link

@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 addresses an issue where users were blocked from creating their first authentication key if the API returned an error for an empty list. The change updates the error state UI to include a 'Create Auth Key' button, which is a great improvement for the user experience. My main feedback is regarding code duplication. The new error view duplicates a significant portion of the page layout and header from the main success view. This will make the component harder to maintain in the long run. I've left a detailed comment with a suggestion to refactor the component to share the layout and conditionally render the content, which would eliminate the duplication and improve maintainability.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
web/src/views/dashboard/authKeys/AuthKeysView.tsx (1)

280-319: Consider extracting the duplicated header component.

The header section (back button, title, and "Create Auth Key" button) is duplicated between the error state and success state (lines 357-396). Extract this into a reusable component to improve maintainability.

🔎 Suggested refactor

Create a new component to eliminate duplication:

const AuthKeysHeader: React.FC<{ onCreateClick: () => void }> = ({ onCreateClick }) => (
    <Flex justifyContent="space-between" alignItems="center" mb={4}>
        <Flex alignItems="center">
            <Box
                as="button"
                aria-label="Back to dashboard"
                mr={3}
                sx={{
                    display: 'flex',
                    alignItems: 'center',
                    justifyContent: 'center',
                    height: '36px',
                    width: '36px',
                    border: '1px solid #e0e0e0',
                    borderRadius: '4px',
                    bg: 'transparent',
                    cursor: 'pointer',
                    '&:hover': {
                        bg: '#f7f7f7'
                    }
                }}
                onClick={() => navigate('/dashboard')}
            >
                <FaArrowLeft size={16} />
            </Box>
            <Text fontSize="28px" fontWeight="bold">
                Auth Keys
            </Text>
        </Flex>
        <Button
            onClick={onCreateClick}
            sx={{
                display: 'flex',
                alignItems: 'center',
            }}
        >
            <Box mr={1}>
                <FaPlus size={14} />
            </Box>
            Create Auth Key
        </Button>
    </Flex>
);

Then use <AuthKeysHeader onCreateClick={() => setShowModal(true)} /> in both error and success states.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d18c5fc and 33c921a.

📒 Files selected for processing (1)
  • web/src/views/dashboard/authKeys/AuthKeysView.tsx
🔇 Additional comments (3)
web/src/views/dashboard/authKeys/AuthKeysView.tsx (3)

269-279: LGTM: Consistent error state container.

The error state container styling matches the loading and success states, providing a consistent user experience.


307-318: Verify that key creation works when initial fetch fails.

The error state provides a "Create Auth Key" button, which is the intended fix. However, ensure that the createAuthKey function can succeed even when the initial fetch of auth keys fails. If both operations share the same API endpoint or authentication mechanism, the create operation might also fail due to the same underlying issue (network, auth, server error).

Consider testing scenarios where:

  1. The database is empty (no keys exist) - this should now work with your fix
  2. The API is unreachable or returns 5xx errors - key creation might also fail
  3. Authentication/authorization issues - create might also be blocked

If key creation can fail for the same reason as the fetch, consider adding error handling feedback to guide users (e.g., "Please check your connection" or "Contact support if this persists").


336-340: LGTM: Modal correctly enables key creation in error state.

The CreateAuthKeyModal is appropriately rendered in the error state, allowing users to create their first auth key even when the initial fetch fails. This directly addresses the PR objective.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/views/dashboard/authKeys/AuthKeysView.tsx (1)

10-111: Add ARIA attributes and focus management to modal.

The modal lacks proper accessibility attributes. Add role="dialog", aria-modal="true", and aria-labelledby to the modal container. Consider implementing keyboard trap and focus management to ensure the modal is accessible to keyboard and screen reader users.

🔎 Proposed accessibility enhancements
+    const modalTitleId = 'create-auth-key-modal-title';
+
     if (!isOpen) return null;

     return (
         <Box
             sx={{
                 position: 'fixed',
                 top: 0,
                 left: 0,
                 right: 0,
                 bottom: 0,
                 backgroundColor: 'rgba(0, 0, 0, 0.5)',
                 display: 'flex',
                 alignItems: 'center',
                 justifyContent: 'center',
                 zIndex: 1000,
             }}
             onClick={onClose}
         >
             <Box
+                role="dialog"
+                aria-modal="true"
+                aria-labelledby={modalTitleId}
                 sx={{
                     backgroundColor: 'white',
                     borderRadius: '8px',
                     padding: '24px',
                     width: '400px',
                     maxWidth: '90vw',
                 }}
                 onClick={(e) => e.stopPropagation()}
             >
-                <Text fontSize="20px" fontWeight="bold" mb={3}>
+                <Text id={modalTitleId} fontSize="20px" fontWeight="bold" mb={3}>
                     Create New Auth Key
                 </Text>

Additionally, consider using a library like react-focus-lock or implementing custom focus trap logic to prevent keyboard users from tabbing out of the modal.

♻️ Duplicate comments (2)
web/src/views/dashboard/authKeys/AuthKeysView.tsx (2)

282-302: Add accessible label to back button.

The back button uses only a visual icon without an accessible label for screen readers.

🔎 Proposed fix
 <Box
     as="button"
+    aria-label="Back to dashboard"
     mr={3}
     sx={{
         display: 'flex',
         alignItems: 'center',
         justifyContent: 'center',
         height: '36px',
         width: '36px',
         border: '1px solid #e0e0e0',
         borderRadius: '4px',
         bg: 'transparent',
         cursor: 'pointer',
         '&:hover': {
             bg: '#f7f7f7'
         }
     }}
     onClick={() => navigate('/dashboard')}
 >
     <FaArrowLeft size={16} />
 </Box>

332-334: Avoid exposing raw API error messages to users.

Displaying the raw error message from the API may expose sensitive implementation details or technical information. Consider providing a user-friendly error message instead.

🔎 Proposed fix
-<Text fontSize="18px" fontWeight="bold" mb={2} color="#d32f2f">
-    Error: {error}
-</Text>
+<Text fontSize="18px" fontWeight="bold" mb={2} color="#d32f2f">
+    Unable to load auth keys
+</Text>
 <Text fontSize="16px" color="#666" mb={3}>
     There was an error loading auth keys. You can still create a new auth key.
 </Text>

Consider logging the actual error for debugging: console.error('Failed to load auth keys:', error);

🧹 Nitpick comments (1)
web/src/views/dashboard/authKeys/AuthKeysView.tsx (1)

429-473: Add aria-label attributes to icon-only buttons.

While the title attributes provide tooltips on hover, adding aria-label attributes to the visibility toggle and copy buttons will improve screen reader accessibility.

🔎 Proposed enhancement
 <Box
     as="button"
+    aria-label={showKeys[authKey.key] ? 'Hide key' : 'Show key'}
     mr={1}
     sx={{
         display: 'flex',
         alignItems: 'center',
         justifyContent: 'center',
         height: '32px',
         width: '32px',
         border: '1px solid #e0e0e0',
         borderRadius: '4px',
         bg: 'transparent',
         cursor: 'pointer',
         '&:hover': {
             bg: '#f0f0f0'
         }
     }}
     onClick={() => toggleKeyVisibility(authKey.key)}
     title={showKeys[authKey.key] ? 'Hide key' : 'Show key'}
 >
     {showKeys[authKey.key] ? <FaEyeSlash size={14} /> : <FaEye size={14} />}
 </Box>
 {showKeys[authKey.key] && (
     <Box
         as="button"
+        aria-label="Copy to clipboard"
         sx={{
             display: 'flex',
             alignItems: 'center',
             justifyContent: 'center',
             height: '32px',
             width: '32px',
             border: '1px solid #e0e0e0',
             borderRadius: '4px',
             bg: 'transparent',
             cursor: 'pointer',
             '&:hover': {
                 bg: '#f0f0f0'
             }
         }}
         onClick={() => copyToClipboard(authKey.key)}
         title="Copy to clipboard"
     >
         <FaCopy size={14} />
     </Box>
 )}
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33c921a and 07075d0.

📒 Files selected for processing (1)
  • web/src/views/dashboard/authKeys/AuthKeysView.tsx
🔇 Additional comments (2)
web/src/views/dashboard/authKeys/AuthKeysView.tsx (2)

279-319: Excellent refactoring to eliminate code duplication.

The introduction of a common header successfully addresses the code duplication concern raised in previous reviews. The layout, header, and modal are no longer duplicated across different states, making the code more maintainable.


322-346: PR objective successfully achieved.

The error state now includes a "Create Auth Key" button, addressing the PR's objective of allowing users to create their first auth key even when the initial fetch fails. The layout is consistent with the empty state styling.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/views/dashboard/authKeys/AuthKeysView.tsx (1)

41-109: Add ARIA attributes and focus management to modal.

The modal is missing critical accessibility features that prevent proper usage with assistive technologies:

  1. No role="dialog" and aria-modal="true" to announce the modal to screen readers
  2. No aria-labelledby connecting to the modal title
  3. No focus trap to prevent keyboard users from tabbing to background content
  4. No focus restoration when the modal closes
🔎 Recommended accessibility improvements
 return (
     <Box
         sx={{
             position: 'fixed',
             top: 0,
             left: 0,
             right: 0,
             bottom: 0,
             backgroundColor: 'rgba(0, 0, 0, 0.5)',
             display: 'flex',
             alignItems: 'center',
             justifyContent: 'center',
             zIndex: 1000,
         }}
         onClick={onClose}
+        role="dialog"
+        aria-modal="true"
+        aria-labelledby="modal-title"
     >
         <Box
             sx={{
                 backgroundColor: 'white',
                 borderRadius: '8px',
                 padding: '24px',
                 width: '400px',
                 maxWidth: '90vw',
             }}
             onClick={(e) => e.stopPropagation()}
         >
-            <Text fontSize="20px" fontWeight="bold" mb={3}>
+            <Text id="modal-title" fontSize="20px" fontWeight="bold" mb={3}>
                 Create New Auth Key
             </Text>

Additionally, consider:

  • Adding ESC key handler: useEffect(() => { const handleEsc = (e) => { if (e.key === 'Escape') onClose(); }; if (isOpen) document.addEventListener('keydown', handleEsc); return () => document.removeEventListener('keydown', handleEsc); }, [isOpen, onClose]);
  • Implementing a focus trap library like focus-trap-react or react-focus-lock
  • Storing and restoring focus: const previousFocus = useRef(); useEffect(() => { if (isOpen) previousFocus.current = document.activeElement; else previousFocus.current?.focus(); }, [isOpen]);
🧹 Nitpick comments (2)
web/src/views/dashboard/authKeys/AuthKeysView.tsx (2)

132-135: Consider adding error handling for clipboard operations.

The navigator.clipboard.writeText() method can fail in certain contexts (non-HTTPS, permissions denied, etc.) and returns a Promise that may reject. Adding error handling would improve robustness.

🔎 Proposed error handling
 const copyToClipboard = (text: string) => {
-    navigator.clipboard.writeText(text);
-    toast.success('Auth key copied to clipboard!');
+    navigator.clipboard.writeText(text)
+        .then(() => {
+            toast.success('Auth key copied to clipboard!');
+        })
+        .catch(() => {
+            toast.error('Failed to copy auth key to clipboard');
+        });
 };

137-145: Consider parameterizing the locale for better internationalization.

The formatDate function hard-codes the 'en-US' locale, which may not match all users' preferences. If your application supports multiple locales, consider accepting a locale parameter or using the browser's default locale.

🔎 Proposed parameterization
-const formatDate = (dateString: string) => {
-    return new Date(dateString).toLocaleDateString('en-US', {
+const formatDate = (dateString: string, locale = navigator.language) => {
+    return new Date(dateString).toLocaleDateString(locale, {
         year: 'numeric',
         month: 'short',
         day: 'numeric',
         hour: '2-digit',
         minute: '2-digit',
     });
 };

Alternatively, use undefined as the locale to let the browser choose: .toLocaleDateString(undefined, { ... })

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07075d0 and 0122c27.

📒 Files selected for processing (1)
  • web/src/views/dashboard/authKeys/AuthKeysView.tsx
🔇 Additional comments (1)
web/src/views/dashboard/authKeys/AuthKeysView.tsx (1)

279-319: Unified header successfully eliminates duplication.

The refactor to extract a common header that applies to all states (error, empty, list) successfully addresses the code duplication concern raised in previous reviews. The Create Auth Key button is now always accessible, ensuring users can create their first key even when the API returns an error.

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