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: Paint Freed Feature Surfaces From Theme Roles (#16517)
Marco Berettafdef598853d2
diff --git a/client/src/components/Chat/Messages/Content/Parts/ExecuteCode.tsx b/client/src/components/Chat/Messages/Content/Parts/ExecuteCode.tsxindex 6c85dc0f63..8d438e9e87 100644--- a/client/src/components/Chat/Messages/Content/Parts/ExecuteCode.tsx+++ b/client/src/components/Chat/Messages/Content/Parts/ExecuteCode.tsx@@ -185,7 +185,7 @@ export default function ExecuteCode({<preref={codePaneRef}onScroll={onCodePaneScroll}- className="bg-surface-chat dark:bg-surface-primary-alt max-h-[300px] overflow-auto p-4 font-mono text-xs"+ className="bg-surface-code-body max-h-[300px] overflow-auto p-4 font-mono text-xs"><code className={`hljs language-${lang} !whitespace-pre`}>{highlighted ?? code}diff --git a/client/src/components/Chat/Messages/Content/Parts/FileAuthoringCall.tsx b/client/src/components/Chat/Messages/Content/Parts/FileAuthoringCall.tsxindex 549bbd5970..72b33dae48 100644--- a/client/src/components/Chat/Messages/Content/Parts/FileAuthoringCall.tsx+++ b/client/src/components/Chat/Messages/Content/Parts/FileAuthoringCall.tsx@@ -249,7 +249,7 @@ export default function FileAuthoringCall({<preref={previewPaneRef}onScroll={onPreviewPaneScroll}- className="bg-surface-chat dark:bg-surface-primary-alt max-h-[300px] overflow-auto p-4 font-mono text-xs"+ className="bg-surface-code-body max-h-[300px] overflow-auto p-4 font-mono text-xs"><code className={`hljs language-${previewLang} !whitespace-pre`}>{highlighted ?? preview}diff --git a/client/src/components/Chat/Messages/Content/Parts/ReadFileCall.tsx b/client/src/components/Chat/Messages/Content/Parts/ReadFileCall.tsxindex 23a9cdd00f..70a8ed104d 100644--- a/client/src/components/Chat/Messages/Content/Parts/ReadFileCall.tsx+++ b/client/src/components/Chat/Messages/Content/Parts/ReadFileCall.tsx@@ -141,7 +141,7 @@ export default function ReadFileCall({)}><CodeWindowHeader language={fileName} code={output} />- <pre className="bg-surface-chat dark:bg-surface-primary-alt max-h-[300px] overflow-auto p-4 font-mono text-xs">+ <pre className="bg-surface-code-body max-h-[300px] overflow-auto p-4 font-mono text-xs"><code className={`hljs language-${lang} !whitespace-pre`}>{highlighted ?? output}</code>diff --git a/client/src/components/Chat/Messages/Content/ToolApproval.tsx b/client/src/components/Chat/Messages/Content/ToolApproval.tsxindex a75d05ecdf..cce54f4d30 100644--- a/client/src/components/Chat/Messages/Content/ToolApproval.tsx+++ b/client/src/components/Chat/Messages/Content/ToolApproval.tsx@@ -1,4 +1,4 @@-import { useContext, useEffect, useMemo } from 'react';+import { useId, useEffect, useMemo } from 'react';import { Button, TextareaAutosize } from '@librechat/client';import { Check, X, Pencil, MessageSquare, ShieldQuestion, TriangleAlert } from 'lucide-react';import type { Agents } from 'librechat-data-provider';@@ -89,6 +89,7 @@ export default function ToolApproval({surface?: 'thread' | 'composer';}) {const localize = useLocalize();+ const invalidJsonId = useId();const { actionId, allowed_decisions: allowedDecisions, description } = approval;const conversationId = useContext(ChatContext)?.conversation?.conversationId;const composerPresents = useComposerPresentsApproval(conversationId, actionId);@@ -239,11 +240,13 @@ export default function ToolApproval({return (<div- className="my-2 flex w-full flex-col gap-2 rounded-lg border border-border-light bg-surface-secondary p-3"+ className="border-border-light bg-surface-secondary my-2 flex w-full flex-col gap-2 rounded-lg border p-3"data-testid="tool-approval"data-tool-call-id={toolCallId}>- {descriptionNode}+ {safeDescription != null && safeDescription.length > 0 && (+ <p className="text-text-secondary text-sm">{safeDescription}</p>+ )}<div className="flex flex-wrap gap-2">{allowedDecisions.map((decision) => {const Icon = DECISION_ICON[decision];@@ -272,11 +275,15 @@ export default function ToolApproval({onChange={(e) => updateDecisionDraft({ editText: e.target.value })}minRows={3}maxRows={16}- className={cn(fieldClasses, 'font-mono text-xs', !editIsValid && 'border-red-500')}+ className={cn(fieldClasses, 'font-mono text-xs')}aria-label={localize('com_ui_edit')}+ aria-invalid={!editIsValid}+ aria-describedby={editIsValid ? undefined : invalidJsonId}/>{!editIsValid && (- <span className="text-xs text-text-warning">{localize('com_ui_invalid_json')}</span>+ <span id={invalidJsonId} className="text-text-warning text-xs">+ {localize('com_ui_invalid_json')}+ </span>)}</div>)}@@ -318,13 +325,13 @@ export default function ToolApproval({{submitLabel}</Button>{status === 'expired' && (- <span className="flex items-center text-xs text-text-warning">+ <span className="text-text-warning flex items-center text-xs"><TriangleAlert className="mr-1.5 h-4 w-4" aria-hidden="true" />{localize('com_ui_approval_expired')}</span>)}{status === 'error' && (- <span className="flex items-center text-xs text-text-warning">+ <span className="text-text-warning flex items-center text-xs"><TriangleAlert className="mr-1.5 h-4 w-4" aria-hidden="true" />{localize('com_ui_approval_error')}</span>diff --git a/client/src/components/Chat/Messages/Content/__tests__/ToolApproval.test.tsx b/client/src/components/Chat/Messages/Content/__tests__/ToolApproval.test.tsxindex 7938114a31..45f60ff99b 100644--- a/client/src/components/Chat/Messages/Content/__tests__/ToolApproval.test.tsx+++ b/client/src/components/Chat/Messages/Content/__tests__/ToolApproval.test.tsx@@ -114,16 +114,15 @@ describe('ToolApproval', () => {}});- test('invalid edit JSON replaces the field border rather than doubling it', () => {+ test('invalid edit JSON marks the field invalid and names the error', () => {renderCards(<ToolApproval approval={approval(['edit'])} toolCallId="call-1" args={{ a: 1 }} />);fireEvent.click(screen.getByRole('button', { name: 'Edit' }));const field = screen.getByRole('textbox', { name: 'Edit' });fireEvent.change(field, { target: { value: '{' } });- expect(field).toHaveClass('border-red-500');- expect(field).not.toHaveClass('border-border-xheavy');- expect(screen.getByText('Invalid JSON')).toBeInTheDocument();+ expect(field).toHaveAttribute('aria-invalid', 'true');+ expect(field).toHaveAccessibleDescription('Invalid JSON');});test('multiple paused calls share one Submit that requires every decision', () => {diff --git a/client/src/components/MCP/McpOAuthDialog.tsx b/client/src/components/MCP/McpOAuthDialog.tsxindex 45049ab67c..7102829190 100644--- a/client/src/components/MCP/McpOAuthDialog.tsx+++ b/client/src/components/MCP/McpOAuthDialog.tsx@@ -52,7 +52,7 @@ export default function McpOAuthDialog({<div className="flex items-center gap-2">{iconUrl && !iconError && (<span- className="flex size-6 shrink-0 items-center justify-center overflow-hidden rounded-md bg-white"+ className="bg-surface-fixed flex size-6 shrink-0 items-center justify-center overflow-hidden rounded-md"aria-hidden="true"><img@@ -88,7 +88,7 @@ export default function McpOAuthDialog({showQR ? 'opacity-100' : 'opacity-0',)}>- <div className="rounded-2xl bg-white p-4 shadow-lg">+ <div className="bg-surface-qr rounded-2xl p-4 shadow-lg"><QRCodeSVGvalue={oauthUrl}size={180}diff --git a/e2e/specs/mock/scenarios/mcp-oauth-tiles.spec.ts b/e2e/specs/mock/scenarios/mcp-oauth-tiles.spec.tsnew file mode 100644index 0000000000..d346151bfb--- /dev/null+++ b/e2e/specs/mock/scenarios/mcp-oauth-tiles.spec.ts@@ -0,0 +1,88 @@+import { expect, test } from '@playwright/test';++const SERVER_NAME = 'e2e-memory';+const SERVER_TITLE = 'E2E Memory';+const FLOW_ID = 'e2e-user:e2e-memory';++/**+ * The QR backdrop stays white in every mode so the code scans, and it reads the `surface-qr`+ * role rather than a literal. The server logo tile needs a server icon, which the mock server+ * does not configure, so only the QR backdrop is asserted here.+ */+/** Set up through the MCP Settings panel that opens the OAuth dialog, which the mobile layout keeps in its drawer; the mobile project runs it at desktop size. */+test.use({ viewport: { width: 1280, height: 860 }, hasTouch: false, isMobile: false });++test('the OAuth QR backdrop stays white in every mode @scenario:mcp-oauth-qr-tile-stays-white', async ({+ page,+}) => {+ test.setTimeout(60000);++ await page.route('**/api/mcp/connection/status', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ success: true,+ oauthTimeout: 30000,+ connectionStatus: {+ [SERVER_NAME]: {+ connectionState: 'error',+ requiresOAuth: true,+ authorizationState: 'error',+ },+ },+ }),+ });+ });+ await page.route(`**/api/mcp/${SERVER_NAME}/reinitialize`, async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ success: true,+ message: 'OAuth authorization required',+ serverName: SERVER_NAME,+ oauthRequired: true,+ oauthUrl: 'https://oauth.example.test/authorize',+ flowId: FLOW_ID,+ oauthTimeout: 30000,+ }),+ });+ });+ await page.route('**/api/mcp/oauth/status/**', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({ status: 'PENDING', completed: false, failed: false }),+ });+ });++ await page.goto('/c/new', { timeout: 10000 });+ const nav = page.getByRole('button', { name: 'MCP Settings' });+ if ((await nav.getAttribute('aria-pressed')) !== 'true') {+ await nav.click();+ }+ const card = page.getByLabel(new RegExp(`^${SERVER_TITLE} - `));+ await card.hover();+ await card.getByRole('button', { name: 'Connect', exact: true }).click();++ const dialog = page.getByRole('dialog', { name: `Connect ${SERVER_NAME}`, exact: true });+ await expect(dialog).toBeVisible({ timeout: 10000 });+ await dialog.getByRole('button', { name: 'Show QR Code' }).click();++ const code = dialog.getByRole('img', { name: /QR/i }).first();+ await expect(code).toBeVisible();++ const paint = await code.evaluate((svg) => {+ const backdrop = svg.parentElement as HTMLElement;+ const probe = document.createElement('div');+ probe.style.backgroundColor = 'rgb(var(--surface-qr))';+ document.body.appendChild(probe);+ const role = getComputedStyle(probe).backgroundColor;+ probe.remove();+ return { backdrop: getComputedStyle(backdrop).backgroundColor, role };+ });++ expect(paint.backdrop).toBe(paint.role);+ expect(paint.backdrop).toBe('rgb(255, 255, 255)');+});diff --git a/e2e/specs/mock/scenarios/tool-approval-invalid-json.spec.ts b/e2e/specs/mock/scenarios/tool-approval-invalid-json.spec.tsnew file mode 100644index 0000000000..27b42ec71a--- /dev/null+++ b/e2e/specs/mock/scenarios/tool-approval-invalid-json.spec.ts@@ -0,0 +1,121 @@+import { expect, test } from '@playwright/test';+import type { Page } from '@playwright/test';+import type { AgentDetail } from '../agents.helpers';+import { cleanupAgent, openAgentBuilder, uniqueAgentName } from '../agents.helpers';+import {+ MOCK_ENDPOINTS,+ NEW_CHAT_PATH,+ fetchJson,+ getAccessToken,+ messagesView,+ requestJson,+ sendMessage,+} from '../helpers';++const MCP_SERVER_NAME = 'e2e-memory';+const MCP_SERVER_TOOL_ID = `sys__server__sys_mcp_${MCP_SERVER_NAME}`;+const APPROVAL_TOOL_ID = `approval_probe_mcp_${MCP_SERVER_NAME}`;+const APPROVAL_PROMPT_MARKER = 'E2E_TOOL_APPROVAL:';++type MCPToolsResponse = {+ servers?: Record<string, { tools?: Array<{ pluginKey: string }> }>;+};++async function waitForApprovalTool(page: Page) {+ const token = await getAccessToken(page);+ await expect+ .poll(+ async () => {+ const tools = await fetchJson<MCPToolsResponse>(page, '/api/mcp/tools', token);+ return (tools.servers?.[MCP_SERVER_NAME]?.tools ?? []).some(+ (tool) => tool.pluginKey === APPROVAL_TOOL_ID,+ );+ },+ { timeout: 15000 },+ )+ .toBe(true);+}++async function createAndSelectApprovalAgent(page: Page): Promise<string> {+ await page.goto(NEW_CHAT_PATH, { timeout: 10000 });+ await waitForApprovalTool(page);++ const token = await getAccessToken(page);+ const agentName = uniqueAgentName('E2E Invalid JSON Agent');+ const agent = await requestJson<AgentDetail>(page, {+ path: '/api/agents',+ token,+ method: 'POST',+ body: {+ name: agentName,+ description: 'Verifies the invalid state of the tool approval edit field.',+ instructions: 'Use the requested approval probe tools and report their results.',+ provider: MOCK_ENDPOINTS[0].label,+ model: MOCK_ENDPOINTS[0].model,+ tools: [MCP_SERVER_TOOL_ID, APPROVAL_TOOL_ID],+ },+ });++ const form = await openAgentBuilder(page);+ await form.getByRole('combobox', { name: 'Agent', exact: true }).click();+ await page.getByRole('option', { name: agentName }).click();+ await expect(form.getByLabel('Agent name')).toHaveValue(agentName);+ await form.getByRole('button', { name: 'Select Agent' }).click();+ return agent.id;+}++/** Set up through the agent builder that selects the approval agent, which the mobile layout keeps in its drawer; the mobile project runs it at desktop size. */+test.use({ viewport: { width: 1280, height: 860 }, hasTouch: false, isMobile: false });++test('an invalid edit is announced and drawn destructive @scenario:tool-approval-invalid-json-is-announced', async ({+ page,+}) => {+ test.setTimeout(120000);+ const label = `${Date.now()}-${Math.floor(Math.random() * 1e4)}`;+ let agentId: string | undefined;++ try {+ agentId = await createAndSelectApprovalAgent(page);+ const response = await sendMessage(page, `${APPROVAL_PROMPT_MARKER}${label}`);+ expect(response.ok()).toBeTruthy();+ await expect(page).toHaveURL(/\/c\/(?!new)/, { timeout: 15000 });++ const card = messagesView(page).getByTestId('tool-approval').first();+ await expect(card).toBeVisible({ timeout: 30000 });++ /** The composer review opens over the timeline card, so collapse it as the approval specs do. */+ const panel = page.locator('#pending-tool-approval-panel');+ await expect(panel).toBeVisible({ timeout: 30000 });+ await panel.getByRole('button', { name: 'Collapse', exact: true }).click();+ await expect(panel).toHaveCount(0);++ await card.getByRole('button', { name: 'Edit' }).click();+ const editor = card.getByRole('textbox', { name: 'Edit' });+ await expect(editor).toHaveValue(new RegExp(`original-${label}`));++ const destructiveBorder = () =>+ editor.evaluate((node) => {+ const probe = document.createElement('div');+ probe.style.borderStyle = 'solid';+ probe.style.borderColor = 'rgb(var(--border-destructive))';+ document.body.appendChild(probe);+ const role = getComputedStyle(probe).borderTopColor;+ probe.remove();+ return { field: getComputedStyle(node).borderTopColor, role };+ });++ await editor.fill('{');+ await expect(editor).toHaveAttribute('aria-invalid', 'true');+ await expect(editor).toHaveAccessibleDescription(/Invalid JSON/);+ const invalid = await destructiveBorder();+ expect(invalid.field).toBe(invalid.role);++ await editor.fill(JSON.stringify({ value: `edited-${label}` }));+ await expect(editor).toHaveAttribute('aria-invalid', 'false');+ await expect(editor).not.toHaveAccessibleDescription(/Invalid JSON/);+ const valid = await destructiveBorder();+ expect(valid.field).not.toBe(valid.role);+ } finally {+ await cleanupAgent(page, agentId);+ }+});diff --git a/e2e/specs/mock/scenarios/tool-output-pane.spec.ts b/e2e/specs/mock/scenarios/tool-output-pane.spec.tsnew file mode 100644index 0000000000..f1776ddd0e--- /dev/null+++ b/e2e/specs/mock/scenarios/tool-output-pane.spec.ts@@ -0,0 +1,69 @@+import { expect, test } from '@playwright/test';+import {+ MOCK_ENDPOINTS,+ NEW_CHAT_PATH,+ enableSkills,+ fetchJson,+ getAccessToken,+ messagesView,+ requestJson,+ selectMockEndpoint,+ sendMessage,+} from '../helpers';++/**+ * The output panes of code execution, file authoring and file reads paint the `surface-code-body`+ * role instead of a per-mode pair of surfaces. A skill file created by the model opens a+ * file-authoring card, whose preview pane is one of the three.+ */+type SkillSummary = { _id: string; name: string };++test('the tool output pane paints the code body role @scenario:tool-output-pane-follows-code-body', async ({+ page,+}) => {+ test.setTimeout(120_000);+ const skillName = `e2e-output-pane-${Date.now()}-${Math.floor(Math.random() * 1e4)}`;+ await page.goto(NEW_CHAT_PATH, { timeout: 10_000 });+ await selectMockEndpoint(page, MOCK_ENDPOINTS[0]);+ await enableSkills(page);++ const response = await sendMessage(+ page,+ [`E2E_CREATE_SKILL:${skillName}`, 'Create the skill file using host file authoring only.'].join(+ '\n',+ ),+ );+ expect(response.ok()).toBeTruthy();++ try {+ const card = messagesView(page).getByRole('button', { name: /^Created / });+ await expect(card).toBeVisible({ timeout: 30_000 });+ await card.click();++ const pane = messagesView(page).locator('pre:has(code.hljs)').first();+ await expect(pane).toBeVisible({ timeout: 15_000 });++ const role = await page.evaluate(() => {+ const probe = document.createElement('div');+ probe.style.backgroundColor = 'rgb(var(--surface-code-body))';+ document.body.appendChild(probe);+ const color = getComputedStyle(probe).backgroundColor;+ probe.remove();+ return { color, dark: document.documentElement.classList.contains('dark') };+ });++ expect(role.color).toBe(role.dark ? 'rgb(23, 23, 23)' : 'rgb(255, 255, 255)');+ await expect(pane).toHaveCSS('background-color', role.color);+ } finally {+ const token = await getAccessToken(page);+ const listed = await fetchJson<{ skills?: SkillSummary[] }>(+ page,+ `/api/skills?search=${encodeURIComponent(skillName)}&limit=10`,+ token,+ );+ const skill = listed.skills?.find((item) => item.name === skillName);+ if (skill) {+ await requestJson(page, { path: `/api/skills/${skill._id}`, token, method: 'DELETE' });+ }+ }+});diff --git a/eslint-suppressions.json b/eslint-suppressions.jsonindex a8f7e5c572..7c8a050a87 100644--- a/eslint-suppressions.json+++ b/eslint-suppressions.json@@ -677,11 +677,8 @@}},"client/src/components/Chat/Messages/Content/ToolApproval.tsx": {- "shadcn/no-raw-colors": {- "count": 1- },"shadcn/no-restyle": {- "count": 27+ "count": 26}},"client/src/components/Chat/Messages/Content/ToolCall.tsx": {diff --git a/packages/client/src/components/TextareaAutosize.tsx b/packages/client/src/components/TextareaAutosize.tsxindex 2bdafc7487..83752beea8 100644--- a/packages/client/src/components/TextareaAutosize.tsx+++ b/packages/client/src/components/TextareaAutosize.tsx@@ -17,6 +17,9 @@ type BaseTextareaAutosizeProps = Omit<TextareaAutosizeProps, 'aria-label' | 'arifocusOutline?: FocusOutline;};+/** A field marked `aria-invalid` draws its border in the destructive role, over the caller's border colour. */+const invalidBorder = 'aria-invalid:border-border-destructive';+export type TextareaAutosizePropsWithAria =| (BaseTextareaAutosizeProps & {'aria-label': string;@@ -38,7 +41,9 @@ export const TextareaAutosize: ForwardRefExoticComponent<<ReactTextareaAutosizedir={chatDirection}{...props}- className={cx(focusOutlineVariants({ focusOutline }), className) || undefined}+ className={+ cx(focusOutlineVariants({ focusOutline }), invalidBorder, className) || undefined+ }ref={ref}/>);diff --git a/packages/client/src/theme/allowlist.md b/packages/client/src/theme/allowlist.mdindex 53155448f3..b137fe1e73 100644--- a/packages/client/src/theme/allowlist.md+++ b/packages/client/src/theme/allowlist.md@@ -32,6 +32,7 @@ is a role, not an exception.| `packages/client/src/svgs/BirthdayIcon.tsx` | A multicolour illustration; the palette is artwork, not a UI role. || `packages/client/src/components/PixelCard.tsx` | The `blue`, `yellow` and `pink` presets are decorative palettes a caller opts into, like the `colors` prop; the app renders only the default, which reads theme roles. || `packages/client/src/icons/provider/registry.ts`, `icons/provider/Avatar.tsx` | Provider brand colours, each already behind a `--provider-*` variable a deployment can override; the literal is only the fallback. |+| `client/src/mobile.css` | `.azure-bg-color`, the Azure file-source chip's blue gradient, fixed by Azure's brand. |## Elevation ink in library stylesheets@@ -47,9 +48,11 @@ is a role, not an exception.| `client/src/components/Chat/Input/Files/DragDropOverlay.tsx` | The drop-zone illustration's fills are artwork. Its backdrop is black at 40% in both modes; the theme scrim is gray-500 in default light, so it moves to `surface-overlay` once a theme can set scrim opacity per mode (berry-13/LibreChat#181). || `client/src/components/Chat/Input/Files/SourceIcon.tsx` | The OpenAI chip (white/75, black/65 in dark) and the code-execution badge (a black terminal mark with white ink) sit over the file's own preview: media overlays, like the upload progress. || `client/src/components/Chat/Input/Files/ProgressCircle.tsx` | Upload progress drawn over the user's own image: a media scrim, so it stays black and white whatever the theme paints around the image. |+| `client/src/components/Chat/Input/Files/ImagePreview.tsx` | The expand hint over the thumbnail (black/20 with white ink) and the full-screen lightbox (black/90 with a white close control) frame the user's own image, so they stay black and white whatever the theme paints around it. || `client/src/utils/markdown.ts` | The downloaded HTML document's GitHub Primer stylesheet; it is read outside the app, where no theme variables exist. Its high-contrast branch already reads the roles. || `client/src/utils/mermaid.ts` | The mermaid artifact document and its zoom controls render in a sandboxed iframe without theme variables; the token reads' fallbacks and the luminance repair ink are literals by necessity. || `client/src/utils/richtext.ts` | Inline styles on HTML copied to the clipboard for pasting into other apps, which must not carry the sender's theme. |+| `client/src/utils/artifacts.ts` | The scrollbar thumb inside the sandboxed artifact document, which renders in its own iframe and never reads the app's theme. || `client/src/utils/officePreview.ts`, `client/src/hooks/ScreenshotContext.tsx` | Fallbacks for a theme role read at runtime, used only when the variable is unset. |## Panels: media and third-party surfaces