diff --git a/client/src/components/Chat/Input/Composer/Palette.tsx b/client/src/components/Chat/Input/Composer/Palette.tsx
index 7c1ecefe49..e5f23781a8 100644
--- a/client/src/components/Chat/Input/Composer/Palette.tsx
+++ b/client/src/components/Chat/Input/Composer/Palette.tsx
@@ -925,17 +925,13 @@ function Palette({
aria-selected={isActive}
className="min-w-0 flex-1"
>
-
);
@@ -967,11 +963,7 @@ function Palette({
aria-selected={isActive}
className="min-w-0 flex-1"
>
-
+
{/* The wrapper carries the fallback tile color; the image itself
hides on error so an unreachable thumbnail (remote storage,
expired links) degrades to an empty tile instead of a broken
@@ -1007,7 +999,7 @@ function Palette({
{formatFileDate(file)}
-
+
);
@@ -1060,14 +1052,14 @@ function Palette({
className="bg-text-primary absolute inset-y-1 left-0 w-0.5 rounded-full"
/>
)}
-
{icon}
@@ -1091,7 +1083,7 @@ function Palette({
{description}
)}
-
+
{modes != null && modes.length > 0 && (
@@ -1118,23 +1110,17 @@ function Palette({
) : (
- {
event.stopPropagation();
mode.onSelect();
}}
- className={cn(
- 'focus-visible:ring-text-primary min-h-6 shrink-0 rounded-full border px-2 py-0.5 text-xs transition-colors focus-visible:ring-2 focus-visible:outline-hidden',
- mode.active
- ? 'bg-surface-active-alt text-text-primary border-transparent'
- : 'border-border-medium text-text-secondary hover:bg-surface-hover hover:text-text-primary',
- )}
>
{mode.label}
-
+
),
)}
diff --git a/client/src/components/Chat/Input/Composer/Thinking.tsx b/client/src/components/Chat/Input/Composer/Thinking.tsx
index 7239a86450..43ec3c3c24 100644
--- a/client/src/components/Chat/Input/Composer/Thinking.tsx
+++ b/client/src/components/Chat/Input/Composer/Thinking.tsx
@@ -1,7 +1,7 @@
import { memo, useRef, useMemo, useState, useLayoutEffect } from 'react';
import * as Ariakit from '@ariakit/react';
import { ChevronDown } from 'lucide-react';
-import { TooltipAnchor, useMediaQuery } from '@librechat/client';
+import { Button, TooltipAnchor, useMediaQuery } from '@librechat/client';
import type { SettingDefinition, TConversation, TReasoningOverride } from 'librechat-data-provider';
import { ReasoningControl, useComposerReasoning } from '../Reasoning';
import Effort, { effortRank, resolveEffortLabel } from './Effort';
@@ -124,19 +124,10 @@ function ThinkingControl({
render={
- }
+ render={}
/>
}
- className="flex h-8 shrink-0 items-center"
+ className="flex shrink-0"
>
{/* Closed, the button hugs its label so it takes no more room in the bar
than it needs. Open, it widens to the longest label and the text
diff --git a/client/src/components/Chat/Input/Reasoning.tsx b/client/src/components/Chat/Input/Reasoning.tsx
index 21fba225ec..c6ad392a7f 100644
--- a/client/src/components/Chat/Input/Reasoning.tsx
+++ b/client/src/components/Chat/Input/Reasoning.tsx
@@ -114,19 +114,16 @@ export function ReasoningControl({
return (
- {/* Styled as the composer control it sits beside (the Thinking pill in
- `Composer/Thinking.tsx`) rather than as a restyled `Button`: the
- open state keeps it lit while its popover is up, which no `Button`
- variant expresses. */}
-
-
+
{retrySafe && (
- retry(steer.steerId)}
- className={ACTION_CLASS}
- >
+ retry(steer.steerId)} variant="text-action">
{localize('com_ui_retry')}
-
+
)}
{!deliveryUncertain && (
- editFailedSteer(steer)}
- className={ACTION_CLASS}
+ variant="text-action"
>
{localize('com_ui_edit')}
-
+
)}
{!deliveryUncertain && (
- sendAsNew(steer.steerId)}
- className={ACTION_CLASS}
+ variant="text-action"
>
{localize('com_ui_send_as_new')}
-
+
)}
) : (
diff --git a/e2e/specs/mock/scenarios/composer-buttons.spec.ts b/e2e/specs/mock/scenarios/composer-buttons.spec.ts
new file mode 100644
index 0000000000..72deed4d9d
--- /dev/null
+++ b/e2e/specs/mock/scenarios/composer-buttons.spec.ts
@@ -0,0 +1,235 @@
+import { expect, test } from '@playwright/test';
+import type { Locator, Page } from '@playwright/test';
+import {
+ messagesView,
+ MOCK_ENDPOINTS,
+ NEW_CHAT_PATH,
+ selectMockEndpoint,
+ sendMessage,
+} from '../helpers';
+import { probeStyle } from './style.helpers';
+
+/**
+ * The composer's own controls (the Thinking pill and its effort rail, the palette rows and
+ * their mode chips, the numeric reasoning trigger and the pending steer actions) are drawn by
+ * the shared Button. Each keeps the box, ink and fill it had as a local recipe, so these
+ * assertions hold on the base as well as on the change; the colors resolve through probes
+ * of the semantic utilities, which keeps them true in light and dark mode.
+ */
+test.describe.configure({ timeout: 120_000 });
+
+const box = (locator: Locator) =>
+ locator.evaluate((node: HTMLElement) => {
+ const style = getComputedStyle(node);
+ return {
+ height: node.offsetHeight,
+ radius: parseFloat(style.borderTopLeftRadius) >= 9999 ? 'full' : style.borderTopLeftRadius,
+ paddingLeft: style.paddingLeft,
+ gap: style.columnGap,
+ fontSize: style.fontSize,
+ fontWeight: style.fontWeight,
+ };
+ });
+
+const paint = (locator: Locator) =>
+ locator.evaluate((node: HTMLElement) => {
+ const style = getComputedStyle(node);
+ return { color: style.color, background: style.backgroundColor };
+ });
+
+async function expectPaint(page: Page, locator: Locator, classes: string) {
+ await page.mouse.move(0, 0);
+ await expect
+ .poll(() => paint(locator))
+ .toEqual({
+ color: await probeStyle(page, classes, 'color'),
+ background: await probeStyle(page, classes, 'background-color'),
+ });
+}
+
+/** Paint of a pressed state whose classes exist only behind the `aria-pressed:` variant. */
+async function expectPressedPaint(page: Page, locator: Locator, classes: string) {
+ const expected = await page.evaluate((className) => {
+ const probe = document.createElement('button');
+ probe.className = className;
+ probe.setAttribute('aria-pressed', 'true');
+ document.body.append(probe);
+ const style = getComputedStyle(probe);
+ const value = { color: style.color, background: style.backgroundColor };
+ probe.remove();
+ return value;
+ }, classes);
+ await page.mouse.move(0, 0);
+ await expect.poll(() => paint(locator)).toEqual(expected);
+}
+
+async function openComposer(page: Page) {
+ await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
+ await selectMockEndpoint(page, MOCK_ENDPOINTS[0]);
+}
+
+test.describe('composer controls on the shared Button', () => {
+ test('Thinking pill and effort rail keep their look and keyboard @scenario:thinking-pill-and-effort-rail-keep-their-look', async ({
+ page,
+ }) => {
+ await openComposer(page);
+ const thinking = page.getByRole('button', { name: /^Thinking: / });
+ await expect(thinking).toBeVisible();
+ expect(await box(thinking)).toEqual({
+ height: 32,
+ radius: 'full',
+ paddingLeft: '10px',
+ gap: '4px',
+ fontSize: '14px',
+ fontWeight: '400',
+ });
+ await expectPaint(page, thinking, 'text-text-primary');
+
+ await thinking.focus();
+ await page.keyboard.press('Enter');
+ const popover = page.getByRole('dialog', { name: /^Thinking: / });
+ await expect(popover).toBeVisible();
+ await expect(thinking).toHaveAttribute('aria-expanded', 'true');
+ await expectPaint(page, thinking, 'bg-surface-hover text-text-primary');
+
+ const auto = popover.getByRole('button', { name: 'Auto', exact: true });
+ await expect(auto).toHaveAttribute('aria-pressed', 'true');
+ expect(await box(auto)).toMatchObject({
+ radius: 'full',
+ paddingLeft: '8px',
+ fontSize: '12px',
+ fontWeight: '400',
+ });
+ await expectPressedPaint(
+ page,
+ auto,
+ 'aria-pressed:bg-accent-primary/15 aria-pressed:text-accent-primary',
+ );
+
+ await auto.click();
+ await expect(auto).toHaveAttribute('aria-pressed', 'false');
+ await expectPaint(page, auto, 'text-text-secondary');
+
+ const checked = popover.getByRole('radio', { checked: true });
+ await expect(checked).toHaveCount(1);
+ const radios = popover.getByRole('radio');
+ const count = await radios.count();
+ const names = await radios.evaluateAll((nodes) =>
+ nodes.map((node) => node.getAttribute('aria-label')),
+ );
+ const start = names.indexOf(await checked.getAttribute('aria-label'));
+ const target = start === count - 1 ? start - 1 : start + 1;
+ await checked.focus();
+ await page.keyboard.press(target > start ? 'ArrowRight' : 'ArrowLeft');
+ const moved = radios.nth(target);
+ await expect(moved).toHaveAttribute('aria-checked', 'true');
+ await expect(moved).toBeFocused();
+ const ring = await moved.evaluate((node) => getComputedStyle(node).boxShadow);
+ expect(ring).toContain('inset');
+ await expect
+ .poll(() => moved.evaluate((node) => getComputedStyle(node).backgroundColor))
+ .toBe('rgba(0, 0, 0, 0)');
+
+ await page.keyboard.press('Escape');
+ await expect(popover).toBeHidden();
+ await expect(thinking).toBeFocused();
+ await expect(thinking).toHaveAttribute('aria-expanded', 'false');
+ await expectPaint(page, thinking, 'text-text-primary');
+ });
+
+ test('Palette rows and mode chips keep their look and toggle @scenario:palette-rows-and-mode-chips-keep-their-look', async ({
+ page,
+ }) => {
+ await openComposer(page);
+ await page.getByRole('button', { name: 'Attach and tools' }).click();
+ const palette = page.getByRole('dialog', { name: 'Attach and tools' });
+ const runCode = palette.getByRole('button', { name: 'Run Code', exact: true });
+ await expect(runCode).toBeVisible();
+ expect(await box(runCode)).toMatchObject({
+ radius: '8px',
+ paddingLeft: '8px',
+ gap: '10px',
+ fontWeight: '400',
+ });
+ const inherited = await runCode.evaluate((node: HTMLElement) => ({
+ own: getComputedStyle(node).color,
+ cell: getComputedStyle(node.parentElement as HTMLElement).color,
+ background: getComputedStyle(node).backgroundColor,
+ }));
+ expect(inherited.own).toBe(inherited.cell);
+ expect(inherited.background).toBe('rgba(0, 0, 0, 0)');
+
+ const artifacts = palette.getByRole('button', { name: 'Artifacts', exact: true });
+ await artifacts.click();
+ await expect(artifacts).toHaveAttribute('aria-pressed', 'true');
+ const standard = palette.getByRole('button', { name: 'Default', exact: true });
+ const shadcn = palette.getByRole('button', { name: 'shadcn/ui', exact: true });
+ await expect(standard).toHaveAttribute('aria-pressed', 'true');
+ await expect(shadcn).toHaveAttribute('aria-pressed', 'false');
+ expect(await box(shadcn)).toMatchObject({
+ height: 24,
+ radius: 'full',
+ paddingLeft: '8px',
+ fontSize: '12px',
+ fontWeight: '400',
+ });
+ await expectPaint(page, standard, 'bg-surface-active-alt text-text-primary');
+ await expectPaint(page, shadcn, 'text-text-secondary');
+ expect(await shadcn.evaluate((node) => getComputedStyle(node).borderTopColor)).toBe(
+ await probeStyle(page, 'border border-border-medium', 'border-top-color'),
+ );
+
+ await shadcn.click();
+ await expect(shadcn).toHaveAttribute('aria-pressed', 'true');
+ await expect(standard).toHaveAttribute('aria-pressed', 'false');
+ await expectPaint(page, shadcn, 'bg-surface-active-alt text-text-primary');
+ });
+
+ test('Reasoning trigger keeps its look @scenario:reasoning-trigger-keeps-its-look', async ({
+ page,
+ }) => {
+ await page.route('**/api/endpoints', async (route) => {
+ const response = await route.fetch();
+ const endpoints = await response.json();
+ endpoints['Mock Provider A'].customParams = {
+ defaultParamsEndpoint: 'google',
+ paramDefinitions: [
+ {
+ key: 'thinkingBudget',
+ type: 'number',
+ default: -1,
+ range: { min: -1, positiveMin: 128, max: 32768, step: 128 },
+ },
+ ],
+ };
+ await route.fulfill({ response, json: endpoints });
+ });
+ await openComposer(page);
+ const response = await sendMessage(page, `E2E_SLOW_REPLY:composer-buttons-${Date.now()}`);
+ expect(response.ok()).toBeTruthy();
+ await expect(messagesView(page).getByText('chunk-010')).toBeVisible({ timeout: 15000 });
+
+ /** The popover is modal, so Radix hides its trigger from the accessibility tree while open. */
+ const reasoning = page.getByRole('button', {
+ name: /Reasoning for next message/i,
+ includeHidden: true,
+ });
+ await expect(reasoning).toBeVisible();
+ expect(await box(reasoning)).toEqual({
+ height: 32,
+ radius: '12px',
+ paddingLeft: '8px',
+ gap: '6px',
+ fontSize: '14px',
+ fontWeight: '500',
+ });
+ await expectPaint(page, reasoning, 'text-text-secondary');
+ await reasoning.click();
+ await expect(page.getByRole('spinbutton')).toBeVisible();
+ await expect(reasoning).toHaveAttribute('aria-expanded', 'true');
+ await expectPaint(page, reasoning, 'bg-surface-hover text-text-primary');
+ await page.keyboard.press('Escape');
+ await expect(reasoning).toBeFocused();
+ await expectPaint(page, reasoning, 'text-text-secondary');
+ });
+});
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index db8ac1437f..96b54a023e 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -191,11 +191,6 @@
"count": 1
}
},
- "client/src/components/Chat/Input/Reasoning.tsx": {
- "design/disabled-recipe": {
- "count": 1
- }
- },
"client/src/components/Chat/Input/TokenUsage/Breakdown.tsx": {
"shadcn/no-restyle": {
"count": 10
diff --git a/packages/client/src/components/Button.tsx b/packages/client/src/components/Button.tsx
index 6e1ea51fcb..b65ef75f93 100644
--- a/packages/client/src/components/Button.tsx
+++ b/packages/client/src/components/Button.tsx
@@ -38,6 +38,13 @@ type ButtonVariantOptions =
| 'card'
| 'disclosure'
| 'option'
+ | 'text-action'
+ | 'row-content'
+ | 'chip-toggle'
+ | 'pill-toggle'
+ | 'composer-pill'
+ | 'composer-trigger'
+ | 'hit-area'
| null
| undefined;
size?:
@@ -227,6 +234,32 @@ const buttonVariantRecipe = cva(
option:
'w-full select-none justify-start gap-2.5 whitespace-normal text-left font-normal text-text-primary transition-opacity enabled:duration-500 disabled:duration-500 disabled:transition-all motion-reduce:transition-none motion-reduce:disabled:transition-none hover:bg-surface-hover hover:active:bg-surface-pressed data-[selected=true]:bg-surface-active data-[selected=true]:hover:bg-surface-active',
card: 'justify-start whitespace-normal rounded-2xl text-left font-normal hover:bg-surface-hover focus-visible:ring-inset focus-visible:ring-offset-0',
+ /** A small text action in the secondary ink beside a status line, such as a failed
+ * steer's Retry or a pending one's Cancel; it rises to the primary ink under the pointer. */
+ 'text-action':
+ 'rounded text-xs text-text-secondary hover:text-text-primary focus-visible:ring-offset-0',
+ /** The content of a list row whose row owns the highlight, such as a composer palette
+ * entry: it lays the row out and takes the pointer, and leaves fill and ink to the row. */
+ 'row-content':
+ 'flex cursor-pointer justify-start gap-2.5 px-2 text-left font-normal transition-none',
+ /** An outlined chip that toggles a mode, its pressed state marked with `aria-pressed`. */
+ 'chip-toggle':
+ 'min-h-theme-target shrink-0 rounded-full border border-border-medium text-xs font-normal text-text-secondary hover:bg-surface-hover hover:text-text-primary focus-visible:ring-offset-0 aria-pressed:border-transparent aria-pressed:bg-surface-active-alt aria-pressed:text-text-primary aria-pressed:hover:bg-surface-active-alt',
+ /** A borderless pill that toggles a mode, lit in the accent while `aria-pressed`. */
+ 'pill-toggle':
+ 'rounded-full text-xs font-normal text-text-secondary hover:bg-surface-hover hover:text-text-primary aria-pressed:bg-accent-primary/15 aria-pressed:text-accent-primary aria-pressed:hover:bg-accent-primary/15 aria-pressed:hover:text-accent-primary',
+ /** A composer pill that opens a popover with its value, such as Thinking: primary ink,
+ * and kept lit while the popover it controls is expanded. */
+ 'composer-pill':
+ 'gap-1 rounded-theme-control-round font-normal text-text-primary hover:bg-surface-hover focus-visible:ring-offset-0 aria-expanded:bg-surface-hover',
+ /** A composer control that opens a popover from an icon, such as the reasoning menu: it
+ * rests in the secondary ink and takes the primary one while hovered or expanded. */
+ 'composer-trigger':
+ 'gap-1.5 rounded-xl text-text-secondary hover:bg-surface-hover hover:text-text-primary focus-visible:ring-offset-0 aria-expanded:bg-surface-hover aria-expanded:text-text-primary',
+ /** An invisible target laid over a custom-drawn control, such as a stop on a slider rail:
+ * it draws only its focus ring, inside its own box. */
+ 'hit-area':
+ 'rounded-full bg-transparent focus-visible:ring-inset focus-visible:ring-offset-0',
},
size: {
default: 'h-theme-button px-theme-button-x py-2',
@@ -335,6 +368,14 @@ const buttonVariantRecipe = cva(
shape: 'unset',
class: 'rounded-xl',
},
+ /* These carry their own box, which the default size's height and padding would otherwise win. */
+ { variant: 'text-action', size: 'default', class: 'h-auto p-0' },
+ { variant: 'row-content', size: 'default', class: 'h-auto px-2 py-0' },
+ { variant: 'chip-toggle', size: 'default', class: 'h-auto px-2 py-0.5' },
+ { variant: 'pill-toggle', size: 'default', class: 'h-auto px-2 py-0.5' },
+ { variant: 'composer-pill', size: 'default', class: 'h-theme-button-compact px-2.5 py-0' },
+ { variant: 'composer-trigger', size: 'default', class: 'h-theme-button-compact px-2 py-0' },
+ { variant: 'hit-area', size: 'default', class: 'h-auto p-0' },
],
defaultVariants: {
variant: 'default',