diff --git a/src/components/AddWorker/index.tsx b/src/components/AddWorker/index.tsx index 073b7ada..d475aca0 100644 --- a/src/components/AddWorker/index.tsx +++ b/src/components/AddWorker/index.tsx @@ -16,7 +16,9 @@ import { RefreshCw, ChevronLeft, ArrowRight, - Edit, + Edit, + Eye, + EyeOff, } from "lucide-react"; import ToolSelect from "./ToolSelect"; import { Textarea } from "@/components/ui/textarea"; @@ -68,6 +70,7 @@ export function AddWorker({ const [showEnvConfig, setShowEnvConfig] = useState(false); const [activeMcp, setActiveMcp] = useState(null); const [envValues, setEnvValues] = useState<{ [key: string]: EnvValue }>({}); + const [secretVisible, setSecretVisible] = useState<{ [key: string]: boolean }>({}); const toolSelectRef = useRef<{ installMcp: (id: number, env?: any, activeMcp?: any) => Promise; } | null>(null); @@ -86,6 +89,7 @@ export function AddWorker({ console.log(mcp); if (mcp?.install_command?.env) { const initialValues: { [key: string]: EnvValue } = {}; + const initialVisibility: { [key: string]: boolean } = {}; for(const key of Object.keys(mcp.install_command.env)) { initialValues[key] = { value: "", @@ -95,8 +99,10 @@ export function AddWorker({ ?.replace(/{{/g, "") ?.replace(/}}/g, "") || "", }; + initialVisibility[key] = false; } setEnvValues(initialValues); + setSecretVisible(initialVisibility); } }; @@ -142,6 +148,7 @@ export function AddWorker({ setShowEnvConfig(false); setActiveMcp(null); setEnvValues({}); + setSecretVisible({}); }; const handleShowEnvConfig = (mcp: McpItem) => { @@ -150,6 +157,11 @@ export function AddWorker({ setShowEnvConfig(true); }; + const isSensitiveKey = (key: string) => /token|key|secret|password|id/i.test(key); + const toggleSecretVisibility = (key: string) => { + setSecretVisible((prev) => ({ ...prev, [key]: !prev[key] })); + }; + const handleSelectedToolsChange = (tools: McpItem[]) => { setSelectedTools(tools); }; @@ -364,18 +376,24 @@ export function AddWorker({ {Object.keys(activeMcp?.install_command?.env || {}).map( (key) => (
-
- {key}* -
updateEnvValue(key, e.target.value)} + note={envValues[key]?.tip} + backIcon={isSensitiveKey(key) ? ( + secretVisible[key] ? ( + + ) : ( + + ) + ) : undefined} + onBackIconClick={isSensitiveKey(key) ? () => toggleSecretVisibility(key) : undefined} /> -
- {envValues[key]?.tip} -
) )} @@ -392,7 +410,6 @@ export function AddWorker({ cancelButtonVariant="ghost" confirmButtonVariant="primary" > - {/* hidden but keep rendering ToolSelect component */}
diff --git a/utils/__pycache__/__init__.cpython-310.pyc b/utils/__pycache__/__init__.cpython-310.pyc index 10d1d4a6..177a6d91 100644 Binary files a/utils/__pycache__/__init__.cpython-310.pyc and b/utils/__pycache__/__init__.cpython-310.pyc differ diff --git a/utils/__pycache__/traceroot_wrapper.cpython-310.pyc b/utils/__pycache__/traceroot_wrapper.cpython-310.pyc index d695ee21..3aa22344 100644 Binary files a/utils/__pycache__/traceroot_wrapper.cpython-310.pyc and b/utils/__pycache__/traceroot_wrapper.cpython-310.pyc differ