🧽 fix: Paint Freed Feature Surfaces From Theme Roles (#16517)

* fix: Paint Tool Output Panes With the Code Body Role

The output panes of code execution, file authoring and file reads painted
surface-chat in light and surface-primary-alt in dark. surface-code-body is
that same pair in the default, dark and high-contrast themes, and a theme
that styles its code blocks now styles these panes with them.

* fix: Draw the MCP OAuth Logo and QR Tiles From Fixed Roles

The server logo tile and the QR backdrop were bg-white. They take
surface-fixed and surface-qr, both white in every bundled theme, so a theme
can own them without the QR losing its quiet zone.

* fix: Give TextareaAutosize an Invalid State and Use It for Tool Arguments

The tool-approval edit field flagged invalid JSON with border-red-500, a raw
colour the primitive's owner rule rejects in any semantic form. TextareaAutosize
now draws its border in border-destructive when aria-invalid is set, the
attribute the Skills description fields already pass. ToolApproval sets
aria-invalid and points aria-describedby at the Invalid JSON message, so a
screen reader announces the error as well.

* docs: Record the Image Preview, Artifact Scrollbar and Azure Chip Colours

Adds the image preview's media overlays, the sandboxed artifact document's
scrollbar and the Azure file-source gradient to the theme allowlist.

* test: Cover the Tool Output Pane, Invalid Tool Arguments and OAuth QR Tile

Scenarios for the code-body pane behind a file-authoring card, the
announced invalid state of the tool-approval edit field, and the MCP OAuth
QR backdrop staying white in both modes.

* test: Retry the Output Pane Colour and Set Up the Approval and OAuth Scenarios at Desktop Size

The pane is read with a retrying assertion against the resolved role, since
the card re-renders as highlighting lands. The approval agent and the MCP
Settings panel are reached through side panels the mobile layout keeps in its
drawer, so those two scenarios run at desktop size on the mobile project.

(cherry picked from commit 2f16e6b37b)

Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16517
This commit is contained in:
Marco Beretta 2026-09-29 22:23:48 +02:00 • committed by Lia
parent d8797b227c
commit fdef598853
12 changed files with 310 additions and 21 deletions

View file

@ -185,7 +185,7 @@ export default function ExecuteCode({
<pre
ref={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}

View file

@ -249,7 +249,7 @@ export default function FileAuthoringCall({
<pre
ref={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}

View file

@ -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>

View file

@ -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>

View file

@ -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', () => {

View file

@ -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">
<QRCodeSVG
value={oauthUrl}
size={180}