-
Notifications
You must be signed in to change notification settings - Fork 614
feat: add password visibility toggle for API key inputs #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds 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
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
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
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 showApiKeyAligns 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 showApiKeyFor 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 showApiKeyUse 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 showApiKeyRecommend 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.
📒 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.vuesrc/renderer/src/components/settings/ProviderApiConfig.vuesrc/renderer/src/views/WelcomeView.vuesrc/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 componentsUse scoped styles to prevent CSS conflicts between components
Files:
src/renderer/src/components/settings/OllamaProviderSettingsDetail.vuesrc/renderer/src/components/settings/ProviderApiConfig.vuesrc/renderer/src/views/WelcomeView.vuesrc/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.vuesrc/renderer/src/components/settings/ProviderApiConfig.vuesrc/renderer/src/views/WelcomeView.vuesrc/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.vuesrc/renderer/src/components/settings/ProviderApiConfig.vuesrc/renderer/src/views/WelcomeView.vuesrc/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.vuesrc/renderer/src/components/settings/ProviderApiConfig.vuesrc/renderer/src/views/WelcomeView.vuesrc/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.vuesrc/renderer/src/components/settings/ProviderApiConfig.vuesrc/renderer/src/views/WelcomeView.vuesrc/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.vuesrc/renderer/src/components/settings/ProviderApiConfig.vuesrc/renderer/src/views/WelcomeView.vuesrc/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.vuesrc/renderer/src/components/settings/ProviderApiConfig.vuesrc/renderer/src/views/WelcomeView.vuesrc/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.vuesrc/renderer/src/components/settings/ProviderApiConfig.vuesrc/renderer/src/views/WelcomeView.vuesrc/renderer/src/components/settings/AnthropicProviderSettingsDetail.vue
add eye icon button to toggle password visibility in API key fields
Summary by CodeRabbit