Skip to content

Commit a0022e9

Browse files
authored
🤖 feat: add show password toggle for secret fields in provider settings (#1023)
Adds an eye icon toggle to reveal/hide secret values when editing API keys and other secrets in Settings → Providers. _Generated with `mux`_
1 parent 2711ae2 commit a0022e9

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

‎src/browser/components/Settings/sections/ProvidersSection.tsx‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useCallback } from "react";
2-
import { ChevronDown, ChevronRight, Check, X } from "lucide-react";
2+
import { ChevronDown, ChevronRight, Check, X, Eye, EyeOff } from "lucide-react";
33
import { createEditKeyHandler } from "@/browser/utils/ui/keybinds";
44
import { SUPPORTED_PROVIDERS } from "@/common/constants/providers";
55
import type { ProviderName } from "@/common/constants/providers";
@@ -79,6 +79,7 @@ export function ProvidersSection() {
7979
field: string;
8080
} | null>(null);
8181
const [editValue, setEditValue] = useState("");
82+
const [showPassword, setShowPassword] = useState(false);
8283

8384
const handleToggleProvider = (provider: string) => {
8485
setExpandedProvider((prev) => (prev === provider ? null : provider));
@@ -96,6 +97,7 @@ export function ProvidersSection() {
9697
const handleCancelEdit = () => {
9798
setEditingField(null);
9899
setEditValue("");
100+
setShowPassword(false);
99101
};
100102

101103
const handleSaveEdit = useCallback(() => {
@@ -114,6 +116,7 @@ export function ProvidersSection() {
114116

115117
setEditingField(null);
116118
setEditValue("");
119+
setShowPassword(false);
117120

118121
// Save in background
119122
void api.providers.setProviderConfig({ provider, keyPath: [field], value: editValue });
@@ -257,7 +260,9 @@ export function ProvidersSection() {
257260
{isEditing ? (
258261
<div className="flex gap-2">
259262
<input
260-
type={fieldConfig.type === "secret" ? "password" : "text"}
263+
type={
264+
fieldConfig.type === "secret" && !showPassword ? "password" : "text"
265+
}
261266
value={editValue}
262267
onChange={(e) => setEditValue(e.target.value)}
263268
placeholder={fieldConfig.placeholder}
@@ -268,6 +273,21 @@ export function ProvidersSection() {
268273
onCancel: handleCancelEdit,
269274
})}
270275
/>
276+
{fieldConfig.type === "secret" && (
277+
<Button
278+
variant="ghost"
279+
size="icon"
280+
onClick={() => setShowPassword(!showPassword)}
281+
className="text-muted hover:text-foreground h-6 w-6"
282+
title={showPassword ? "Hide password" : "Show password"}
283+
>
284+
{showPassword ? (
285+
<EyeOff className="h-4 w-4" />
286+
) : (
287+
<Eye className="h-4 w-4" />
288+
)}
289+
</Button>
290+
)}
271291
<Button
272292
variant="ghost"
273293
size="icon"

0 commit comments

Comments
 (0)