Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🔏 fix: Prevent Browser Autofill From Silently Dropping MCP CustomUserVars on Save (#12770)
jschmetzer40742f919178
diff --git a/client/src/components/MCP/CustomUserVarsSection.tsx b/client/src/components/MCP/CustomUserVarsSection.tsxindex 339b78f6b9..a986a2786f 100644--- a/client/src/components/MCP/CustomUserVarsSection.tsx+++ b/client/src/components/MCP/CustomUserVarsSection.tsx@@ -85,7 +85,12 @@ function AuthField({ name, config, hasValue, control, errors, autoFocus }: AuthFrender={({ field }) => (<Inputid={name}- type="text"+ // Prevent autofill: browser DOM mutations bypass React's synthetic+ // onChange, silently emptying react-hook-form state on submit.+ type="new-password"+ autoComplete="new-password"+ data-lpignore="true"+ data-1p-ignore="true"/* autoFocus is generally disabled due to the fact that it can disorient users,* but in this case, the required field would logically be immediately navigated to anyways, and the component's* functionality emulates that of a new modal opening, where users would expect focus to be shifted to the new content */diff --git a/client/src/components/MCP/__tests__/CustomUserVarsSection.test.tsx b/client/src/components/MCP/__tests__/CustomUserVarsSection.test.tsxnew file mode 100644index 0000000000..67b934e31c--- /dev/null+++ b/client/src/components/MCP/__tests__/CustomUserVarsSection.test.tsx@@ -0,0 +1,34 @@+import { render, screen } from '@testing-library/react';+import '@testing-library/jest-dom/extend-expect';+import CustomUserVarsSection from '../CustomUserVarsSection';++jest.mock('~/data-provider/Tools/queries', () => ({+ useMCPAuthValuesQuery: () => ({ data: { authValueFlags: {} } }),+}));++jest.mock('~/hooks', () => ({+ useLocalize: () => (key: string) => key,+}));++describe('CustomUserVarsSection', () => {+ const fields = {+ api_key: { title: 'My API Key', description: 'Your API key' },+ };++ it('renders autofill-prevention attributes on credential inputs', () => {+ render(+ <CustomUserVarsSection+ serverName="test-server"+ fields={fields}+ onSave={jest.fn()}+ onRevoke={jest.fn()}+ />,+ );++ const input = screen.getByLabelText(/My API Key/);+ expect(input).toHaveAttribute('autocomplete', 'new-password');+ expect(input).toHaveAttribute('type', 'new-password');+ expect(input).toHaveAttribute('data-lpignore', 'true');+ expect(input).toHaveAttribute('data-1p-ignore', 'true');+ });+});