Skip to content

Conversation

@yyhhyyyyyy
Copy link
Collaborator

@yyhhyyyyyy yyhhyyyyyy commented Aug 17, 2025

add eye icon button to toggle password visibility in API key fields

image

Summary by CodeRabbit

  • New Features
    • Added a show/hide toggle for API key fields across provider settings, improving visibility control and entry accuracy.
    • Enhanced Anthropic and Ollama provider settings with an eye/eye-off toggle to reveal or conceal the API key.
    • Updated the general provider API configuration to support dynamic visibility for the API key input.
    • Improved the Welcome setup flow with an API key visibility toggle for easier onboarding while maintaining privacy.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 17, 2025

Walkthrough

Adds a show/hide (eye/eye-off) toggle to API key inputs across multiple Vue components. Each input switches between password and text types via a new reactive showApiKey flag, with adjusted padding and a trailing ghost-styled button. Existing handlers and public interfaces remain unchanged.

Changes

Cohort / File(s) Summary
Settings: Anthropic & Ollama
src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue, src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue
Wrapped API key inputs with a relative container; added a ghost toggle button with eye/eye-off icon; introduced showApiKey state to switch input type between password/text; adjusted input padding; preserved existing blur/Enter handlers.
Shared Provider Config
src/renderer/src/components/settings/ProviderApiConfig.vue
Replaced plain password input with a wrapper containing an in-input toggle button; added showApiKey ref to control input type; updated padding and icon rendering; existing props and emits unchanged.
Onboarding View
src/renderer/src/views/WelcomeView.vue
Added show/hide toggle for API key input in provider setup; implemented showApiKey flag, dynamic input type, right-side ghost button with icons; adjusted padding; no public API changes.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant C as Vue Component
  participant I as API Key Input

  U->>C: Click eye/eye-off toggle
  C->>C: Toggle showApiKey (false ⇄ true)
  C->>I: Update :type (password ⇄ text)
  I-->>U: Render input with updated visibility
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • zerob13

Poem

A twitch of the whiskers, a blink of an eye,
Secrets once hidden now peek at the sky.
Click goes the toggle, night turns to day—
Keys softly shimmer in text’s bright array.
I thump with delight, secure yet spry,
Hop-hop, show-hide—now watch me try! 🐇👁️‍🗨️

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/api-key-visibility-toggle

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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

🧹 Nitpick comments (8)
src/renderer/src/views/WelcomeView.vue (2)

115-115: Prefer boolean naming: isApiKeyVisible over showApiKey

Aligns with the guideline “Use descriptive variable names with auxiliary verbs.” Consider renaming to isApiKeyVisible for clarity and consistency across the PR.


297-316: Accessibility + i18n + Tailwind: replace inline style, add aria labels, and avoid hardcoded placeholder

  • Replace inline style with Tailwind (pr-10).
  • Add explicit type="button" to prevent potential form submission.
  • Add aria-label/title for screen readers (use i18n).
  • Disable autocomplete/spellcheck for secrets.
  • Use i18n for the placeholder instead of a hardcoded string.

Apply:

-                  <Input
-                    id="api-key"
-                    v-model="apiKey"
-                    :type="showApiKey ? 'text' : 'password'"
-                    placeholder="Enter API Key"
-                    style="padding-right: 2.5rem !important"
-                  />
+                  <Input
+                    id="api-key"
+                    v-model="apiKey"
+                    :type="showApiKey ? 'text' : 'password'"
+                    :placeholder="t('settings.provider.keyPlaceholder')"
+                    class="pr-10"
+                    autocomplete="off"
+                    autocapitalize="off"
+                    autocorrect="off"
+                    spellcheck="false"
+                    inputmode="text"
+                  />
-                    <Button
+                    <Button
+                      type="button"
                       variant="ghost"
                       size="sm"
                       class="absolute right-2 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0 hover:bg-transparent"
                       @click="showApiKey = !showApiKey"
+                      :aria-label="showApiKey ? t('settings.provider.hideApiKey') : t('settings.provider.showApiKey')"
+                      :title="showApiKey ? t('settings.provider.hideApiKey') : t('settings.provider.showApiKey')"
+                      :aria-pressed="showApiKey"
                     >
src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue (2)

298-298: Prefer boolean naming: isApiKeyVisible over showApiKey

For consistency with the repo’s naming guideline (“Use descriptive variable names with auxiliary verbs”), consider isApiKeyVisible.


26-47: Improve a11y and styling: Tailwind padding, button type, aria-label/title, and disable autofill

  • Use Tailwind pr-10 instead of inline style.
  • Add type="button" to the toggle Button.
  • Add aria-label/title (i18n) and aria-pressed for accessibility.
  • Turn off autocomplete/spellcheck for API keys.
-        <Input
+        <Input
           :id="`${provider.id}-apikey`"
           v-model="apiKey"
           :type="showApiKey ? 'text' : 'password'"
           :placeholder="t('settings.provider.keyPlaceholder')"
-          style="padding-right: 2.5rem !important"
+          class="pr-10"
+          autocomplete="off"
+          autocapitalize="off"
+          autocorrect="off"
+          spellcheck="false"
+          inputmode="text"
           @blur="handleApiKeyChange(String($event.target.value))"
           @keyup.enter="handleApiKeyEnter(apiKey)"
         />
-        <Button
+        <Button
+          type="button"
           variant="ghost"
           size="sm"
           class="absolute right-2 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0 hover:bg-transparent"
           @click="showApiKey = !showApiKey"
+          :aria-label="showApiKey ? t('settings.provider.hideApiKey') : t('settings.provider.showApiKey')"
+          :title="showApiKey ? t('settings.provider.hideApiKey') : t('settings.provider.showApiKey')"
+          :aria-pressed="showApiKey"
         >
src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue (2)

374-374: Prefer boolean naming: isApiKeyVisible over showApiKey

Use of an auxiliary-verb boolean improves readability: isApiKeyVisible.


56-77: A11y + Tailwind + form semantics: add aria support, remove inline style, set button type, and disable autofill

  • Replace inline right padding with pr-10.
  • Add type="button" to the toggle.
  • Add i18n-backed aria-label/title and aria-pressed.
  • Disable autocomplete/spellcheck for secret inputs.
-        <Input
+        <Input
           :id="`${provider.id}-apikey`"
           v-model="apiKey"
           :type="showApiKey ? 'text' : 'password'"
           :placeholder="t('settings.provider.keyPlaceholder')"
-          style="padding-right: 2.5rem !important"
+          class="pr-10"
+          autocomplete="off"
+          autocapitalize="off"
+          autocorrect="off"
+          spellcheck="false"
+          inputmode="text"
           @blur="handleApiKeyChange(String($event.target.value))"
           @keyup.enter="handleApiKeyEnter(apiKey)"
         />
-        <Button
+        <Button
+          type="button"
           variant="ghost"
           size="sm"
           class="absolute right-2 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0 hover:bg-transparent"
           @click="showApiKey = !showApiKey"
+          :aria-label="showApiKey ? t('settings.provider.hideApiKey') : t('settings.provider.showApiKey')"
+          :title="showApiKey ? t('settings.provider.hideApiKey') : t('settings.provider.showApiKey')"
+          :aria-pressed="showApiKey"
         >
src/renderer/src/components/settings/ProviderApiConfig.vue (2)

170-170: Prefer boolean naming: isApiKeyVisible over showApiKey

Recommend renaming to isApiKeyVisible per the naming guideline (“Use descriptive variable names with auxiliary verbs”). If you want, I can propose a codemod to update all usages across the PR.


45-67: Consolidate a11y and styling improvements; consider DRYing the pattern into a shared ApiKeyInput

  • Replace inline style with Tailwind pr-10.
  • Add type="button" to the toggle.
  • Add i18n-backed aria-label/title and aria-pressed.
  • Disable browser autofill/spellcheck for API keys.

Also, this show/hide pattern is duplicated across multiple files in this PR. Consider a small reusable ApiKeyInput to keep things DRY and consistent.

-      <div class="relative w-full">
+      <div class="relative w-full">
         <Input
           :id="`${provider.id}-apikey`"
           :model-value="apiKey"
           :type="showApiKey ? 'text' : 'password'"
           :placeholder="t('settings.provider.keyPlaceholder')"
-          style="padding-right: 2.5rem !important"
+          class="pr-10"
+          autocomplete="off"
+          autocapitalize="off"
+          autocorrect="off"
+          spellcheck="false"
+          inputmode="text"
           @blur="handleApiKeyChange($event.target.value)"
           @keyup.enter="$emit('validate-key', apiKey)"
           @update:model-value="apiKey = String($event)"
         />
-        <Button
+        <Button
+          type="button"
           variant="ghost"
           size="sm"
           class="absolute right-2 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0 hover:bg-transparent"
           @click="showApiKey = !showApiKey"
+          :aria-label="showApiKey ? t('settings.provider.hideApiKey') : t('settings.provider.showApiKey')"
+          :title="showApiKey ? t('settings.provider.hideApiKey') : t('settings.provider.showApiKey')"
+          :aria-pressed="showApiKey"
         >

If you’d like, I can scaffold a lightweight ApiKeyInput.vue (props: modelValue, id, placeholderKey, onBlur/onEnter) and swap it in here and in the other updated files.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 97546cc and fa7e7a1.

📒 Files selected for processing (4)
  • src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue (2 hunks)
  • src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue (2 hunks)
  • src/renderer/src/components/settings/ProviderApiConfig.vue (2 hunks)
  • src/renderer/src/views/WelcomeView.vue (2 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Use English for logs and comments

Files:

  • src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue
  • src/renderer/src/components/settings/ProviderApiConfig.vue
  • src/renderer/src/views/WelcomeView.vue
  • src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue
src/renderer/src/**/*.vue

📄 CodeRabbit Inference Engine (CLAUDE.md)

src/renderer/src/**/*.vue: Use Composition API for all Vue 3 components
Use Tailwind CSS with scoped styles for styling
Organize components by feature in src/renderer/src/
Follow existing component patterns in src/renderer/src/ when creating new UI components
Use Composition API with proper TypeScript typing for new UI components
Implement responsive design with Tailwind CSS for new UI components
Add proper error handling and loading states for new UI components

Use scoped styles to prevent CSS conflicts between components

Files:

  • src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue
  • src/renderer/src/components/settings/ProviderApiConfig.vue
  • src/renderer/src/views/WelcomeView.vue
  • src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue
src/renderer/src/**/*.{ts,tsx,vue}

📄 CodeRabbit Inference Engine (CLAUDE.md)

src/renderer/src/**/*.{ts,tsx,vue}: Use Pinia for frontend state management
Renderer to Main: Use usePresenter.ts composable for direct presenter method calls

Files:

  • src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue
  • src/renderer/src/components/settings/ProviderApiConfig.vue
  • src/renderer/src/views/WelcomeView.vue
  • src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue
src/renderer/src/**/*

📄 CodeRabbit Inference Engine (.cursor/rules/i18n.mdc)

src/renderer/src/**/*: All user-facing strings must use i18n keys (avoid hardcoded user-visible text in code)
Use the 'vue-i18n' framework for all internationalization in the renderer
Ensure all user-visible text in the renderer uses the translation system

Files:

  • src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue
  • src/renderer/src/components/settings/ProviderApiConfig.vue
  • src/renderer/src/views/WelcomeView.vue
  • src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue
src/renderer/**/*.{vue,ts,js,tsx,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

渲染进程代码放在 src/renderer

Files:

  • src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue
  • src/renderer/src/components/settings/ProviderApiConfig.vue
  • src/renderer/src/views/WelcomeView.vue
  • src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-best-practices.mdc)

src/renderer/src/**/*.{vue,ts,tsx,js,jsx}: Use the Composition API for better code organization and reusability
Implement proper state management with Pinia
Utilize Vue Router for navigation and route management
Leverage Vue's built-in reactivity system for efficient data handling

Files:

  • src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue
  • src/renderer/src/components/settings/ProviderApiConfig.vue
  • src/renderer/src/views/WelcomeView.vue
  • src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue
src/renderer/**/*.{ts,tsx,vue}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-shadcn.mdc)

src/renderer/**/*.{ts,tsx,vue}: Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
Use TypeScript for all code; prefer types over interfaces.
Avoid enums; use const objects instead.
Use arrow functions for methods and computed properties.
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.

Files:

  • src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue
  • src/renderer/src/components/settings/ProviderApiConfig.vue
  • src/renderer/src/views/WelcomeView.vue
  • src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue
src/renderer/**/*.{vue,ts}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-shadcn.mdc)

Implement lazy loading for routes and components.

Files:

  • src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue
  • src/renderer/src/components/settings/ProviderApiConfig.vue
  • src/renderer/src/views/WelcomeView.vue
  • src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue
src/renderer/**/*.{ts,vue}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-shadcn.mdc)

src/renderer/**/*.{ts,vue}: Use useFetch and useAsyncData for data fetching.
Implement SEO best practices using Nuxt's useHead and useSeoMeta.

Files:

  • src/renderer/src/components/settings/OllamaProviderSettingsDetail.vue
  • src/renderer/src/components/settings/ProviderApiConfig.vue
  • src/renderer/src/views/WelcomeView.vue
  • src/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue

@zerob13 zerob13 merged commit 5560a13 into dev Aug 18, 2025
2 checks passed
@zerob13 zerob13 deleted the feat/api-key-visibility-toggle branch November 23, 2025 13:15
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.

3 participants