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
🫗 feat: Field Fill and Ink Theme Roles (#16607)
Marco Beretta687f69e1879f
diff --git a/e2e/specs/mock/scenarios/field-fill.spec.ts b/e2e/specs/mock/scenarios/field-fill.spec.tsnew file mode 100644index 0000000000..cc2c67f3c6--- /dev/null+++ b/e2e/specs/mock/scenarios/field-fill.spec.ts@@ -0,0 +1,173 @@+import { expect, test } from '@playwright/test';+import type { Page } from '@playwright/test';+import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';+import { NEW_CHAT_PATH } from '../helpers';++/**+ * A shared field inks its value in `field-text` and, under `fieldFillStyle: 'fill'`, paints itself+ * in `field-fill`. The default theme keeps fields clear and inked in the primary text in both+ * modes; the ClickHouse theme fills them with Click UI's `field.color.background.default` and inks+ * them in `field.color.text.default`; a root themed `transparent` inside it keeps its fields clear.+ */++type Mode = 'light' | 'dark';++/** Fills fields but keeps the default dimmed disabled style, so no disabled fill paints over them. */+const FILL_DIM_THEME = {+ version: 1,+ name: 'e2e-fill-dim',+ modes: {+ light: { colors: { 'rgb-field-fill': '10 20 30' }, appearance: { fieldFillStyle: 'fill' } },+ dark: { colors: { 'rgb-field-fill': '10 20 30' }, appearance: { fieldFillStyle: 'fill' } },+ },+} as const;+type Paint = { fill: string; ink: string };++/** The fill and ink classes `fieldControl` composes (pinned to it in `semanticTokens.spec.ts`), so+ * nothing but those rules paints the probe. */+const FIELD_CLASSES =+ 'lc-field bg-transparent text-field-text theme-field-fill:bg-field-fill theme-field-fill:disabled:hover:bg-field-fill';++async function openChat(page: Page, mode: Mode, definition?: { name: string }) {+ await page.addInitScript(+ ([colorTheme, stored]) => {+ localStorage.setItem('color-theme', colorTheme as string);+ localStorage.removeItem('theme-colors');+ localStorage.removeItem('theme-name');+ if (stored) {+ localStorage.setItem('theme-definition', JSON.stringify(stored));+ localStorage.setItem('theme-source', 'definition');+ } else {+ localStorage.removeItem('theme-definition');+ localStorage.removeItem('theme-source');+ }+ },+ [mode, definition ?? null] as [string, unknown],+ );+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });+ await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({+ timeout: 30000,+ });+ await expect(page.locator('html')).toHaveClass(mode === 'dark' ? /\bdark\b/ : /\blight\b/);+ if (definition) {+ await expect(page.locator('html')).toHaveAttribute('data-theme', definition.name);+ }+}++/** A field probe at the document root, or under a nested root themed with `fillStyle`. */+function fieldPaint(page: Page, fillStyle?: 'transparent'): Promise<Paint> {+ return page.evaluate(+ ([classes, style]) => {+ const root = document.createElement('div');+ if (style) {+ root.style.setProperty('--theme-field-fill-style', style);+ }+ const field = document.createElement('input');+ field.className = classes;+ root.append(field);+ document.body.append(root);+ const computed = getComputedStyle(field);+ const paint = { fill: computed.backgroundColor, ink: computed.color };+ root.remove();+ return paint;+ },+ [FIELD_CLASSES, fillStyle ?? ''] as [string, string],+ );+}++const CASES: Array<{ title: string; mode: Mode; definition?: { name: string }; paint: Paint }> = [+ {+ title:+ 'default light fields stay clear in the primary ink @scenario:field-fill-default-light-unchanged',+ mode: 'light',+ paint: { fill: 'rgba(0, 0, 0, 0)', ink: 'rgb(33, 33, 33)' },+ },+ {+ title:+ 'default dark fields stay clear in the primary ink @scenario:field-fill-default-dark-unchanged',+ mode: 'dark',+ paint: { fill: 'rgba(0, 0, 0, 0)', ink: 'rgb(236, 236, 236)' },+ },+ {+ title:+ 'ClickHouse light fields take the Click UI field fill and ink @scenario:field-fill-clickhouse-light',+ mode: 'light',+ definition: clickHouseTheme,+ paint: { fill: 'rgb(251, 252, 255)', ink: 'rgb(48, 46, 50)' },+ },+ {+ title:+ 'ClickHouse dark fields take the Click UI field fill and ink @scenario:field-fill-clickhouse-dark',+ mode: 'dark',+ definition: clickHouseTheme,+ paint: { fill: 'rgb(45, 45, 45)', ink: 'rgb(230, 231, 233)' },+ },+];++test.describe('field fill and ink', () => {+ for (const { title, mode, definition, paint } of CASES) {+ test(title, async ({ page }) => {+ await openChat(page, mode, definition);++ expect(await fieldPaint(page)).toEqual(paint);+ });+ }++ test('an open field trigger paints its state fill over the field fill @scenario:field-fill-yields-to-state-fill', async ({+ page,+ }) => {+ await openChat(page, 'light', clickHouseTheme);++ const fills = await page.evaluate((classes) => {+ const paint = (state?: string) => {+ const field = document.createElement('button');+ field.className = `${classes} data-[state=open]:bg-surface-hover`;+ if (state) {+ field.dataset.state = state;+ }+ document.body.append(field);+ const fill = getComputedStyle(field).backgroundColor;+ field.remove();+ return fill;+ };+ const hover = document.createElement('div');+ hover.className = 'bg-surface-hover';+ document.body.append(hover);+ const surfaceHover = getComputedStyle(hover).backgroundColor;+ hover.remove();+ return { rest: paint(), open: paint('open'), surfaceHover };+ }, FIELD_CLASSES);++ expect(fills.rest).toBe('rgb(251, 252, 255)');+ expect(fills.open).toBe(fills.surfaceHover);+ expect(fills.open).not.toBe(fills.rest);+ });++ test('a disabled field keeps its fill under the pointer in a fill and dim theme @scenario:field-fill-disabled-hover', async ({+ page,+ }) => {+ await openChat(page, 'light', FILL_DIM_THEME);++ await page.evaluate((classes) => {+ const field = document.createElement('button');+ field.className = `${classes} hover:bg-surface-hover disabled:hover:bg-transparent`;+ field.disabled = true;+ field.textContent = 'Disabled field';+ field.id = 'disabled-field-probe';+ document.body.append(field);+ }, FIELD_CLASSES);+ const probe = page.locator('#disabled-field-probe');+ await probe.hover({ force: true });+ expect(await probe.evaluate((node) => getComputedStyle(node).backgroundColor)).toBe(+ 'rgb(10, 20, 30)',+ );+ });++ test('a transparent root nested in a filled one keeps its fields clear @scenario:field-fill-nested-transparent-root', async ({+ page,+ }) => {+ await openChat(page, 'light', clickHouseTheme);++ expect((await fieldPaint(page, 'transparent')).fill).toBe('rgba(0, 0, 0, 0)');+ });+});diff --git a/packages/client/src/components/Dropdown.spec.tsx b/packages/client/src/components/Dropdown.spec.tsxindex dd0630633b..32dcee22a2 100644--- a/packages/client/src/components/Dropdown.spec.tsx+++ b/packages/client/src/components/Dropdown.spec.tsx@@ -114,3 +114,26 @@ describe('Dropdown compact recipe', () => {expect(trigger).not.toHaveClass('px-3', 'py-2', 'text-sm', 'transition-all');});});++describe('Dropdown ink', () => {+ const trigger = (variant?: 'field') => {+ render(<Dropdown value="24h" options={OPTIONS} ariaLabel="Clock" variant={variant} />);+ return screen.getByRole('combobox');+ };++ it('keeps the field ink on a field trigger in every state', () => {+ const field = trigger('field');++ expect(field).toHaveClass('text-field-text');+ expect(field).not.toHaveClass('text-text-primary');+ expect(field).not.toHaveClass('hover:text-text-primary');+ expect(field).not.toHaveClass('disabled:hover:text-text-primary');+ });++ it('keeps the primary ink and its hover on a default trigger', () => {+ const plain = trigger();++ expect(plain).toHaveClass('text-text-primary', 'hover:text-text-primary');+ expect(plain).not.toHaveClass('text-field-text');+ });+});diff --git a/packages/client/src/components/Dropdown.tsx b/packages/client/src/components/Dropdown.tsxindex a47f3be83c..7da6b4887d 100644--- a/packages/client/src/components/Dropdown.tsx+++ b/packages/client/src/components/Dropdown.tsx@@ -166,9 +166,13 @@ const Dropdown: React.FC<DropdownProps> = ({store={selectProps}disabled={disabled}className={cn(- 'border-border-control text-text-primary hover:bg-surface-hover hover:text-text-primary relative inline-flex items-center justify-between border bg-transparent py-2 text-sm transition-all duration-200 ease-in-out',- variant !== 'field' && shapeClasses[shape],- 'disabled:hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent',+ 'border-border-control text-text-primary hover:bg-surface-hover relative inline-flex items-center justify-between border bg-transparent py-2 text-sm transition-all duration-200 ease-in-out',+ /** A field-variant trigger keeps the field ink from `fieldControl` in every state. */+ variant !== 'field' && [+ shapeClasses[shape],+ 'hover:text-text-primary disabled:hover:text-text-primary',+ ],+ 'disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent',disabledFillClasses,/** Horizontal padding would squeeze the icon, which flex-shrinks to fit */iconOnly ? 'size-10 justify-center px-0' : 'w-fit gap-2 px-3',diff --git a/packages/client/src/components/Field.ts b/packages/client/src/components/Field.tsindex 90b79f8731..2297e5f839 100644--- a/packages/client/src/components/Field.ts+++ b/packages/client/src/components/Field.ts@@ -9,9 +9,11 @@ import { disabledFillClasses } from '~/utils/theme';* palette can raise it to the 3:1 non-text floor without touching separators.* A theme whose `fieldFocusStyle` is `border` focuses the field by swapping that edge to* `border-field-focus`; keyboard focus adds a 1px ring in the same color, so the indicator keeps- * the 2px perimeter the app holds as its focus floor.+ * the 2px perimeter the app holds as its focus floor. The value inks in `field-text`, and a theme+ * whose `fieldFillStyle` is `fill` paints the field in `field-fill`, which a disabled field keeps+ * under the pointer too; by default it stays clear.*/-export const fieldBase: string = `lc-field flex w-full rounded-lg border border-border-control px-3 py-theme-field-y text-sm text-text-primary placeholder:text-text-secondary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control theme-field-border:focus:border-border-field-focus theme-field-border:focus-visible:ring-1 theme-field-border:focus-visible:ring-border-field-focus disabled:cursor-not-allowed disabled:opacity-50 ${disabledFillClasses}`;+export const fieldBase: string = `lc-field flex w-full rounded-lg border border-border-control px-3 py-theme-field-y text-sm text-field-text theme-field-fill:bg-field-fill theme-field-fill:disabled:hover:bg-field-fill placeholder:text-text-secondary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control theme-field-border:focus:border-border-field-focus theme-field-border:focus-visible:ring-1 theme-field-border:focus-visible:ring-border-field-focus disabled:cursor-not-allowed disabled:opacity-50 ${disabledFillClasses}`;/** A single-line control sized to sit in a form row, matching `Input`. */export const fieldControl: string = `${fieldBase} h-theme-field bg-transparent`;diff --git a/packages/client/src/components/TimePicker.spec.tsx b/packages/client/src/components/TimePicker.spec.tsxindex 2c03d779cf..c01989640c 100644--- a/packages/client/src/components/TimePicker.spec.tsx+++ b/packages/client/src/components/TimePicker.spec.tsx@@ -37,6 +37,14 @@ describe('TimePicker', () => {expect(screen.getByRole('radiogroup', { name: 'AM or PM' })).toBeInTheDocument();});+ it('inks its value in the field role like every other field', () => {+ render(<Harness />);++ const trigger = screen.getByRole('button', { name: 'Time 9:00 AM' });+ expect(trigger).toHaveClass('text-field-text');+ expect(trigger).not.toHaveClass('text-text-primary');+ });+it('announces the selected time, not just the field label', () => {// `aria-labelledby` REPLACES a button's child text, so pointing it at the field// label alone announced "Time" and left the selected value unreadable withoutdiff --git a/packages/client/src/components/TimePicker.tsx b/packages/client/src/components/TimePicker.tsxindex 517203c75a..f3c1f3f351 100644--- a/packages/client/src/components/TimePicker.tsx+++ b/packages/client/src/components/TimePicker.tsx@@ -172,7 +172,7 @@ function PickerShell({aria-labelledby={labelledBy == null ? valueId : `${labelledBy} ${valueId}`}className={cn(fieldControl,- 'text-text-primary items-center justify-between gap-2',+ 'items-center justify-between gap-2','hover:bg-surface-hover data-[state=open]:bg-surface-hover',className,)}diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.mdindex c3112de94e..3c8bc10a63 100644--- a/packages/client/src/theme/README.md+++ b/packages/client/src/theme/README.md@@ -358,6 +358,11 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a- Keyboard focus outline - The global `:focus-visible` outline is drawn in`focus-outline`, `focusRingWidth` wide and `focusRingOffset` off the edge (2pxeach by default). The contrast modes keep their own 3px outline.+- `bg-field-fill` / `text-field-text` - A form field's fill and typed value. The+ ink follows `text-primary` and the fill follows `surface-primary` when a theme+ names those and not these. Fields stay clear unless the theme's+ `fieldFillStyle` appearance role is `fill` (the default is `transparent`),+ read from the nearest themed root through the `theme-field-fill:` variant.- `border-border-field-focus` - A form field's edge while it holds focus, under`fieldFocusStyle: border`. Follows `focus-control` when a theme names only that.- Form fields and labels - `h-theme-field` (`fieldHeight`) sizes `Input`, `Dropdown`diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.cssindex 7c64438df0..d8b13fdd2c 100644--- a/packages/client/src/theme/defaults.css+++ b/packages/client/src/theme/defaults.css@@ -154,6 +154,8 @@ html {--border-destructive: var(--red-600);--border-control: var(--gray-200);--border-field-focus: var(--focus-control);+ --field-fill: var(--surface-primary);+ --field-text: var(--text-primary);--focus-control: var(--gray-800);--border-disabled: var(--gray-200);--status-success: var(--green-700);@@ -231,6 +233,7 @@ html {--theme-field-height: 2.5rem;--theme-field-padding-y: 0.5rem;--theme-field-focus-style: ring;+ --theme-field-fill-style: transparent;--theme-focus-ring-width: 2px;--theme-focus-ring-offset: 2px;--theme-label-size: var(--theme-text-sm, 0.875rem);@@ -384,6 +387,8 @@ html {--border-destructive: var(--red-500);--border-control: var(--gray-800);--border-field-focus: var(--focus-control);+ --field-fill: var(--surface-primary);+ --field-text: var(--text-primary);--focus-control: var(--gray-100);--border-disabled: var(--gray-650);--status-success: var(--green-300);diff --git a/packages/client/src/theme/defaults.spec.ts b/packages/client/src/theme/defaults.spec.tsindex f9fcbdd02f..8c204f9edc 100644--- a/packages/client/src/theme/defaults.spec.ts+++ b/packages/client/src/theme/defaults.spec.ts@@ -68,7 +68,7 @@ describe.each([const tokens = Object.keys(theme) as Array<keyof IThemeRGB>;it('covers every registry color', () => {- expect(tokens).toHaveLength(128);+ expect(tokens).toHaveLength(130);});it('resolves every registry color to the runtime theme value', () => {@@ -103,6 +103,8 @@ const colorAliases: Array<[string, string]> = [['--dialog-title', '--text-primary'],['--badge-label', '--text-primary'],['--border-field-focus', '--focus-control'],+ ['--field-fill', '--surface-primary'],+ ['--field-text', '--text-primary'],];describe('the stock color aliases', () => {diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.tsindex f4e9dbfdef..fa6029108c 100644--- a/packages/client/src/theme/registry.spec.ts+++ b/packages/client/src/theme/registry.spec.ts@@ -932,6 +932,62 @@ describe('theme registry', () => {});});+ describe('field fill and ink', () => {+ const fieldTheme = (modes: ThemeDefinition['modes']): ThemeDefinition => ({+ version: 1,+ name: 'field-fill-reference',+ modes,+ });++ it('keeps fields clear and inked in the primary text by default', () => {+ for (const mode of ['light', 'dark'] as const) {+ const { colors, appearance } = resolveTheme(fieldTheme({}), mode);+ const base = mode === 'dark' ? darkTheme : defaultTheme;+ expect(appearance.fieldFillStyle).toBe('transparent');+ expect(colors['rgb-field-text']).toBe(base['rgb-text-primary']);+ expect(colors['rgb-field-fill']).toBe(base['rgb-surface-primary']);+ }+ });++ it('keeps a theme that predates the roles on its own ink and canvas', () => {+ const { colors, appearance } = resolveTheme(+ fieldTheme({+ dark: { colors: { 'rgb-text-primary': '10 20 30', 'rgb-surface-primary': '40 50 60' } },+ }),+ 'dark',+ );+ expect(colors['rgb-field-text']).toBe('10 20 30');+ expect(colors['rgb-field-fill']).toBe('40 50 60');+ expect(appearance.fieldFillStyle).toBe('transparent');+ });++ it('paints fields from their own roles when a theme names them', () => {+ const { colors, appearance } = resolveTheme(+ fieldTheme({+ light: {+ colors: { 'rgb-field-fill': '251 252 255', 'rgb-field-text': '48 46 50' },+ appearance: { fieldFillStyle: 'fill' },+ },+ }),+ 'light',+ );+ expect(colors['rgb-field-fill']).toBe('251 252 255');+ expect(colors['rgb-field-text']).toBe('48 46 50');+ expect(colors['rgb-text-primary']).toBe(defaultTheme['rgb-text-primary']);+ expect(appearance.fieldFillStyle).toBe('fill');+ });++ it('rejects a fill style it does not know and a translucent field color', () => {+ const issues = (mode: ThemeDefinition['modes']['light']) =>+ validateThemeDefinition(fieldTheme({ light: mode }));+ expect(issues({ appearance: { fieldFillStyle: 'fill' } })).toEqual([]);+ expect(issues({ appearance: { fieldFillStyle: 'glass' as 'fill' } })).toEqual([+ 'Invalid appearance value for fieldFillStyle: glass',+ ]);+ expect(issues({ colors: { 'rgb-field-fill': '1 2 3 / 0.5' } })).toHaveLength(1);+ });+ });+it('rejects field and label values the shared validators refuse', () => {const issues = (appearance: Record<string, string>) =>validateThemeDefinition({diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.tsindex 116ce3d4e1..a8a391f51e 100644--- a/packages/client/src/theme/registry.ts+++ b/packages/client/src/theme/registry.ts@@ -118,12 +118,13 @@ export function primaryButtonFallbacks(colors: IThemeRGB): IThemeRGB {};}-/** Inks split out of the primary one: dialog titles, badge labels and the default avatar's glyph- * were all set in it. */+/** Inks split out of the primary one: dialog titles, badge labels, the default avatar's glyph and+ * a field's typed value were all set in it. */export const primaryInkRoles: ReadonlyArray<keyof IThemeRGB> = ['rgb-dialog-title','rgb-badge-label','rgb-avatar-text',+ 'rgb-field-text',];/** A theme that repaints the primary ink keeps the inks split out of it on it, unless it names them. */@@ -180,6 +181,7 @@ export const themeAppearanceProperties: Readonly<fieldHeight: '--theme-field-height',fieldPaddingY: '--theme-field-padding-y',fieldFocusStyle: '--theme-field-focus-style',+ fieldFillStyle: '--theme-field-fill-style',focusRingWidth: '--theme-focus-ring-width',focusRingOffset: '--theme-focus-ring-offset',labelSize: '--theme-label-size',@@ -255,6 +257,7 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({fieldHeight: '2.5rem',fieldPaddingY: '0.5rem',fieldFocusStyle: 'ring',+ fieldFillStyle: 'transparent',focusRingWidth: '2px',focusRingOffset: '2px',labelSize: '0.875rem',@@ -507,7 +510,9 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedTconst baseColors = mode === 'dark' ? darkTheme : defaultTheme;const definition = theme.modes[mode];const customColors = knownColors(definition?.colors);- const composerHoverFallback =+ /** Each fallback is typed as one `IThemeRGB`, not a `{ role } | {}` union: the colors below+ * spread them all, and every union spread would double the type checker's work. */+ const composerHoverFallback: IThemeRGB =customColors?.['rgb-surface-composer-hover'] === undefined &&customColors?.['rgb-surface-hover'] !== undefined? { 'rgb-surface-composer-hover': customColors['rgb-surface-hover'] }@@ -522,7 +527,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedTmode === 'dark'? customColors?.['rgb-presentation']: customColors?.['rgb-surface-primary-alt'];- const codeSurfaceFallback =+ const codeSurfaceFallback: IThemeRGB =customColors?.['rgb-surface-code'] === undefined && codeSurfaceSource !== undefined? { 'rgb-surface-code': codeSurfaceSource }: {};@@ -535,7 +540,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedTmode === 'dark'? customColors?.['rgb-surface-primary-alt']: customColors?.['rgb-surface-chat'];- const codeBodyFallback =+ const codeBodyFallback: IThemeRGB =customColors?.['rgb-surface-code-body'] === undefined && codeBodySource !== undefined? { 'rgb-surface-code-body': codeBodySource }: {};@@ -547,12 +552,12 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT* sweep alongside custom text still gets it by naming the stop, the way* `rgb-surface-composer-hover` opts out of its own fallback above.*/- const shimmerBaseFallback =+ const shimmerBaseFallback: IThemeRGB =customColors?.['rgb-shimmer-base'] === undefined &&customColors?.['rgb-text-primary'] !== undefined? { 'rgb-shimmer-base': customColors['rgb-text-primary'] }: {};- const textMutedFallback =+ const textMutedFallback: IThemeRGB =customColors?.['rgb-text-muted'] === undefined &&customColors?.['rgb-text-tertiary'] !== undefined? { 'rgb-text-muted': customColors['rgb-text-tertiary'] }@@ -565,7 +570,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedTconst proseLinkSource =customColors?.['rgb-link'] ??(mode === 'dark' ? customColors?.['rgb-text-primary'] : undefined);- const proseLinkFallback =+ const proseLinkFallback: IThemeRGB =customColors?.['rgb-link-prose'] === undefined && proseLinkSource !== undefined? { 'rgb-link-prose': proseLinkSource }: {};@@ -577,11 +582,11 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedTmode === 'dark'? customColors?.['rgb-surface-tertiary']: customColors?.['rgb-surface-secondary'];- const avatarPlaceholderFallback =+ const avatarPlaceholderFallback: IThemeRGB =customColors?.['rgb-avatar-placeholder'] === undefined && avatarPlaceholderSource !== undefined? { 'rgb-avatar-placeholder': avatarPlaceholderSource }: {};- const chartWidgetSurfaceFallback =+ const chartWidgetSurfaceFallback: IThemeRGB =customColors?.['rgb-chart-widget-surface'] === undefined &&customColors?.['rgb-surface-primary'] !== undefined? { 'rgb-chart-widget-surface': customColors['rgb-surface-primary'] }@@ -590,36 +595,43 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT* The thumb was painted `surface-primary` before it had a role, so a theme that repaints that* surface keeps the knob it drew against its tracks.*/- const switchThumbFallback =+ const switchThumbFallback: IThemeRGB =customColors?.['rgb-switch-thumb'] === undefined &&customColors?.['rgb-surface-primary'] !== undefined? { 'rgb-switch-thumb': customColors['rgb-surface-primary'] }: {};+ /** A field fill only shows under `fieldFillStyle: 'fill'`, on the theme's own canvas by default. */+ const fieldFillFallback: IThemeRGB =+ customColors?.['rgb-field-fill'] === undefined &&+ customColors?.['rgb-surface-primary'] !== undefined+ ? { 'rgb-field-fill': customColors['rgb-surface-primary'] }+ : {};/** Table column names were `text-secondary` before they had a role. */- const tableHeaderTextFallback =+ const tableHeaderTextFallback: IThemeRGB =customColors?.['rgb-table-header-text'] === undefined &&customColors?.['rgb-text-secondary'] !== undefined? { 'rgb-table-header-text': customColors['rgb-text-secondary'] }: {};/** Self-sticking table headers were the dialog surface before they had a role. */- const tableHeaderFillFallback =+ const tableHeaderFillFallback: IThemeRGB =customColors?.['rgb-table-header-fill'] === undefined &&customColors?.['rgb-surface-dialog'] !== undefined? { 'rgb-table-header-fill': customColors['rgb-surface-dialog'] }: {};- const chartWidgetStrokeFallback =+ const chartWidgetStrokeFallback: IThemeRGB =customColors?.['rgb-chart-widget-stroke'] === undefined &&customColors?.['rgb-border-light'] !== undefined? { 'rgb-chart-widget-stroke': customColors['rgb-border-light'] }: {};const borderControlSource =customColors != null ? controlBorderFallback(customColors) : undefined;- const borderControlFallback =+ const borderControlFallback: IThemeRGB =borderControlSource !== undefined ? { 'rgb-border-control': borderControlSource } : {};- const focusFallback = customColors != null ? focusFallbacks(customColors) : {};- const pressedFallback = customColors != null ? pressedFallbacks(customColors) : {};- const primaryButtonFallback = customColors != null ? primaryButtonFallbacks(customColors) : {};- const primaryInks = customColors != null ? primaryInkFallbacks(customColors) : {};+ const focusFallback: IThemeRGB = customColors != null ? focusFallbacks(customColors) : {};+ const pressedFallback: IThemeRGB = customColors != null ? pressedFallbacks(customColors) : {};+ const primaryButtonFallback: IThemeRGB =+ customColors != null ? primaryButtonFallbacks(customColors) : {};+ const primaryInks: IThemeRGB = customColors != null ? primaryInkFallbacks(customColors) : {};/*** Slot 8 arrived after the seven-slot scale shipped, so a stored or* environment theme that paints its own scale cannot name it. Filling the@@ -638,7 +650,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT([1, 2, 3, 4, 5, 6, 7] as const).some((slot) => customColors[`rgb-series-${slot}`] !== undefined,);- const seriesEightFallback =+ const seriesEightFallback: IThemeRGB =customColors?.['rgb-series-8'] === undefined && ownsSeriesScale? {'rgb-series-8': customColors?.['rgb-text-secondary'] ?? baseColors['rgb-text-secondary'],@@ -657,7 +669,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT*/const ownsMarkSurroundings =customColors != null && MARK_NEIGHBOURHOOD.some((token) => customColors[token] !== undefined);- const verifiedFallback =+ const verifiedFallback: IThemeRGB =ownsMarkSurroundings && customColors?.['rgb-status-verified'] === undefined? {'rgb-status-verified':@@ -682,6 +694,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT...chartWidgetSurfaceFallback,...chartWidgetStrokeFallback,...switchThumbFallback,+ ...fieldFillFallback,...tableHeaderTextFallback,...tableHeaderFillFallback,...borderControlFallback,diff --git a/packages/client/src/theme/semanticTokens.spec.ts b/packages/client/src/theme/semanticTokens.spec.tsindex 14eb1f2c45..2ef08f54fd 100644--- a/packages/client/src/theme/semanticTokens.spec.ts+++ b/packages/client/src/theme/semanticTokens.spec.ts@@ -3,6 +3,7 @@ import { readFileSync } from 'node:fs';import type { IThemeAppearance, IThemeRGB } from './types';import { clickHouseDarkTheme, clickHouseLightTheme, clickHouseTheme } from './themes/clickhouse';import { highContrastDarkTheme, highContrastLightTheme } from './themes/highContrast';+import { fieldControl } from '../components/Field';import { defaultTheme } from './themes/default';import { defaultAppearance } from './registry';import { darkTheme } from './themes/dark';@@ -126,6 +127,16 @@ describe('shared field and dropdown interaction styles', () => {expect(field).not.toMatch(/\bborder-border-(?:light|medium)\b/);expect(field).toMatch(/focus-visible:ring-2/);expect(field).toMatch(/focus-visible:ring-focus-control/);+ /** The fill and ink classes the field-fill e2e scenarios probe in the browser. */+ expect(fieldControl.split(' ')).toEqual(+ expect.arrayContaining([+ 'lc-field',+ 'bg-transparent',+ 'text-field-text',+ 'theme-field-fill:bg-field-fill',+ 'theme-field-fill:disabled:hover:bg-field-fill',+ ]),+ );const composers: Array<[string, RegExp]> = [['Input.tsx', /\bfieldControl\b/],diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.tsindex 38c9155329..a04deb746e 100644--- a/packages/client/src/theme/themes/clickhouse.ts+++ b/packages/client/src/theme/themes/clickhouse.ts@@ -109,6 +109,8 @@ export const clickHouseLightTheme: IThemeRGB = {'rgb-border-destructive': '193 0 0', // #c10000 (palette.danger.600)'rgb-border-control': '128 134 145', // #808691 (palette.slate.500, 3.42:1 on background.muted)'rgb-border-field-focus': '22 21 23', // #161517 (field.color.stroke.active)+ 'rgb-field-fill': '251 252 255', // #fbfcff (field.color.background.default)+ 'rgb-field-text': '48 46 50', // #302e32 (field.color.text.default)'rgb-surface-disabled': '223 223 223', // #dfdfdf (button.basic.color.primary.background.disabled)'rgb-text-disabled': '160 160 160', // #a0a0a0 (text.disabled)'rgb-border-disabled': '223 223 223', // #dfdfdf (field.color.stroke.disabled)@@ -268,6 +270,8 @@ export const clickHouseDarkTheme: IThemeRGB = {'rgb-border-destructive': '255 117 117', // #ff7575 (palette.danger.300)'rgb-border-control': '128 128 128', // #808080 (palette.neutral.500, 3.73:1 on background.muted)'rgb-border-field-focus': '250 255 105', // #faff69 (field.color.stroke.active)+ 'rgb-field-fill': '45 45 45', // rgb(17.794% 17.794% 17.794%) (field.color.background.default)+ 'rgb-field-text': '230 231 233', // #e6e7e9 (field.color.text.default)'rgb-surface-disabled': '65 65 65', // #414141 (button.basic.color.primary.background.disabled)'rgb-text-disabled': '128 128 128', // #808080 (text.disabled)'rgb-border-disabled': '65 65 65', // #414141 (field.color.stroke.disabled)@@ -420,6 +424,8 @@ const clickHouseShape = {fieldHeight: '2rem',fieldPaddingY: '0.2813rem', // field.space.yfieldFocusStyle: 'border' as const,+ /** Click UI fills its fields in `field.color.background.default`. */+ fieldFillStyle: 'fill' as const,/** Click UI's keyboard focus outline: 2px in `outline.default`, 2px off the edge* (BaseButton.module.css, IconButton, Dropdown and ContextMenu triggers). */focusRingWidth: '2px',diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.tsindex 1e94df675b..efa2604f3f 100644--- a/packages/client/src/theme/themes/clickui.spec.ts+++ b/packages/client/src/theme/themes/clickui.spec.ts@@ -121,6 +121,8 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>'rgb-border-destructive': 'palette.danger.600','rgb-border-control': 'palette.slate.500','rgb-border-field-focus': 'click.field.color.stroke.active',+ 'rgb-field-fill': 'click.field.color.background.default',+ 'rgb-field-text': 'click.field.color.text.default','rgb-surface-disabled': 'click.button.basic.color.primary.background.disabled','rgb-text-disabled': 'global.color.text.disabled','rgb-border-disabled': 'click.field.color.stroke.disabled',@@ -248,6 +250,8 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>'rgb-border-destructive': 'palette.danger.300','rgb-border-control': 'palette.neutral.500','rgb-border-field-focus': 'click.field.color.stroke.active',+ 'rgb-field-fill': 'click.field.color.background.default',+ 'rgb-field-text': 'click.field.color.text.default','rgb-surface-disabled': 'click.button.basic.color.primary.background.disabled','rgb-text-disabled': 'global.color.text.disabled','rgb-border-disabled': 'click.field.color.stroke.disabled',@@ -525,6 +529,12 @@ const appearanceDecisions: Partial<Record<keyof IThemeAppearance, AppearanceDecireason:'none: Click UI Tooltip.module.css draws its tooltip with no shadow; no token carries it',},+ fieldFillStyle: {+ value: 'fill',+ status: 'match',+ reason:+ 'fill: Click UI InputWrapper paints every field in field.color.background.default; LibreChat fields stay clear by default',+ },focusRingWidth: {value: '2px',status: 'match',@@ -1051,6 +1061,7 @@ const parityProbes: Record<string, ParityProbe> = {token: 'click.field.color.background.default',kind: 'color',utility: 'bg',+ variant: 'theme-field-fill:',element: inputProbe,},'Field stroke': {@@ -1294,14 +1305,7 @@ interface NotExpressible {* close it. Remove an entry when the change that closes it lands, and pin its decisions to what* they then measure.*/-const notExpressible: Record<string, NotExpressible> = {- 'Field fill and ink': {- decisions: { light: ['Field fill', 'Field text'], dark: ['Field fill', 'Field text'] },- reason:- 'the field is transparent and inks with text-primary; a color role is an opaque triplet, so no role can default to no fill, and no role holds field ink apart from body copy',- issue: 'https://github.com/berry-13/LibreChat/issues/206',- },-};+const notExpressible: Record<string, NotExpressible> = {};type Verdict = 'match' | 'near' | 'deviation' | 'not expressible';diff --git a/packages/client/src/theme/themes/dark.ts b/packages/client/src/theme/themes/dark.tsindex 6eedabd5ec..7918daaa17 100644--- a/packages/client/src/theme/themes/dark.ts+++ b/packages/client/src/theme/themes/dark.ts@@ -83,6 +83,8 @@ export const darkTheme: IThemeRGB = {'rgb-border-destructive': '239 68 68', // #ef4444 (red-500)'rgb-border-control': '33 33 33', // #212121 (gray-800), the stock field edge'rgb-border-field-focus': '236 236 236', // #ececec (gray-100, matching focus-control)+ 'rgb-field-fill': '13 13 13', // #0d0d0d (gray-900, matching surface-primary)+ 'rgb-field-text': '236 236 236', // #ececec (gray-100, matching text-primary)'rgb-surface-disabled': '47 47 47', // #2f2f2f (gray-700)'rgb-text-disabled': '153 150 150', // #999696 (gray-400)'rgb-border-disabled': '57 57 57', // #393939 (gray-650)diff --git a/packages/client/src/theme/themes/default.ts b/packages/client/src/theme/themes/default.tsindex 9243f50eb4..362f8549f0 100644--- a/packages/client/src/theme/themes/default.ts+++ b/packages/client/src/theme/themes/default.ts@@ -83,6 +83,8 @@ export const defaultTheme: IThemeRGB = {'rgb-border-destructive': '220 38 38', // #dc2626 (red-600)'rgb-border-control': '227 227 227', // #e3e3e3 (gray-200), the stock field edge'rgb-border-field-focus': '33 33 33', // #212121 (gray-800, matching focus-control)+ 'rgb-field-fill': '255 255 255', // #fff (white, matching surface-primary)+ 'rgb-field-text': '33 33 33', // #212121 (gray-800, matching text-primary)'rgb-surface-disabled': '236 236 236', // #ececec (gray-100)'rgb-text-disabled': '153 150 150', // #999696 (gray-400)'rgb-border-disabled': '227 227 227', // #e3e3e3 (gray-200)diff --git a/packages/client/src/theme/themes/highContrast.ts b/packages/client/src/theme/themes/highContrast.tsindex 32acb4bf06..ae96141a00 100644--- a/packages/client/src/theme/themes/highContrast.ts+++ b/packages/client/src/theme/themes/highContrast.ts@@ -119,6 +119,8 @@ export const highContrastLightTheme: IThemeRGB = {'rgb-border-destructive': '161 0 0', // #a10000'rgb-border-control': '0 0 0', // #000000'rgb-border-field-focus': '0 0 0', // #000000 (matching focus-control)+ 'rgb-field-fill': '255 255 255', // #ffffff (matching surface-primary)+ 'rgb-field-text': '0 0 0', // #000000 (matching text-primary)'rgb-surface-disabled': '255 255 255', // #ffffff'rgb-text-disabled': '87 87 87', // #575757'rgb-border-disabled': '87 87 87', // #575757@@ -296,6 +298,8 @@ export const highContrastDarkTheme: IThemeRGB = {'rgb-border-destructive': '255 143 143', // #ff8f8f'rgb-border-control': '255 255 255', // #ffffff'rgb-border-field-focus': '255 255 255', // #ffffff (matching focus-control)+ 'rgb-field-fill': '0 0 0', // #000000 (matching surface-primary)+ 'rgb-field-text': '255 255 255', // #ffffff (matching text-primary)'rgb-surface-disabled': '0 0 0', // #000000'rgb-text-disabled': '184 184 184', // #b8b8b8'rgb-border-disabled': '184 184 184', // #b8b8b8diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.cssindex 72cf284ddb..d8119d12bb 100644--- a/packages/client/src/theme/tokens.css+++ b/packages/client/src/theme/tokens.css@@ -120,6 +120,9 @@--color-border-control: rgb(var(--border-control));/* Falls back to the focus ring color, for a stylesheet that predates it. */--color-border-field-focus: rgb(var(--border-field-focus, var(--focus-control)));+ /* Follow the canvas and the primary ink, for a stylesheet that predates them. */+ --color-field-fill: rgb(var(--field-fill, var(--surface-primary)));+ --color-field-text: rgb(var(--field-text, var(--text-primary)));--color-border-disabled: rgb(var(--border-disabled));/* status */@@ -248,3 +251,13 @@}}}++/* A theme whose `fieldFillStyle` is `fill` paints its fields in `field-fill` instead of leaving+ * them on the surface they sit on, read like the focus style from the nearest themed root. The+ * default `transparent` style, and a browser without style queries, keep the fields clear. The+ * fill carries a single class's weight, so a hover, open or disabled fill still paints over it. */+@custom-variant theme-field-fill {+ @container style(--theme-field-fill-style: fill) {+ @slot;+ }+}diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.tsindex 3c9636afc2..05bba00ed0 100644--- a/packages/client/src/theme/types/index.ts+++ b/packages/client/src/theme/types/index.ts@@ -101,6 +101,11 @@ export interface IThemeRGB {/** A field's edge while it holds focus, under `fieldFocusStyle: 'border'`; follows* `rgb-focus-control` when a theme omits it. */'rgb-border-field-focus'?: string;+ /** A field's fill, painted only under `fieldFillStyle: 'fill'`; follows `rgb-surface-primary`+ * when a theme omits it. */+ 'rgb-field-fill'?: string;+ /** A field's typed value; follows `rgb-text-primary` when a theme omits it. */+ 'rgb-field-text'?: string;/** Disabled fill, ink and edge. Painted only under the `fill` disabled style. */'rgb-surface-disabled'?: string;'rgb-text-disabled'?: string;@@ -287,6 +292,8 @@ export interface IThemeVariables {'--border-destructive': string;'--border-control': string;'--border-field-focus': string;+ '--field-fill': string;+ '--field-text': string;'--surface-disabled': string;'--text-disabled': string;'--border-disabled': string;@@ -423,6 +430,8 @@ export interface IThemeColors {'border-destructive'?: string;'border-control'?: string;'border-field-focus'?: string;+ 'field-fill'?: string;+ 'field-text'?: string;'surface-disabled'?: string;'text-disabled'?: string;'border-disabled'?: string;@@ -526,6 +535,8 @@ export interface IThemeAppearance {/** The field's vertical padding, which has to leave its line room inside `fieldHeight`. */fieldPaddingY: string;fieldFocusStyle: 'ring' | 'border';+ /** `transparent` leaves a field on the surface it sits on; `fill` paints it `field-fill`. */+ fieldFillStyle: 'transparent' | 'fill';/** The keyboard focus outline's width and its offset from the element's edge, apart from the* heavier outline the contrast modes keep. */focusRingWidth: string;diff --git a/packages/client/src/theme/utils/applyTheme.spec.ts b/packages/client/src/theme/utils/applyTheme.spec.tsindex 52eca774e2..c487739a81 100644--- a/packages/client/src/theme/utils/applyTheme.spec.ts+++ b/packages/client/src/theme/utils/applyTheme.spec.ts@@ -496,6 +496,15 @@ describe('applyTheme', () => {expect(root.style.getPropertyValue('--border-field-focus')).toBe('30 31 32');});+ it('maps a legacy theme canvas and ink onto the field fill and ink', () => {+ const root = document.documentElement;++ applyTheme({ 'rgb-surface-primary': '20 21 22', 'rgb-text-primary': '1 2 3' }, root);++ expect(root.style.getPropertyValue('--field-fill')).toBe('20 21 22');+ expect(root.style.getPropertyValue('--field-text')).toBe('1 2 3');+ });+it('keeps the switch knob of a legacy theme on the surface it repainted', () => {const root = document.documentElement;diff --git a/packages/client/src/theme/utils/applyTheme.ts b/packages/client/src/theme/utils/applyTheme.tsindex c293f21def..981d0136bf 100644--- a/packages/client/src/theme/utils/applyTheme.ts+++ b/packages/client/src/theme/utils/applyTheme.ts@@ -77,6 +77,11 @@ function mapColors(colors: IThemeRGB, base?: IThemeRGB): Array<[string, string]>variables.push(['--switch-thumb', colors['rgb-surface-primary']]);}+ /** The field fill follows the canvas, as in `resolveTheme`. */+ if (colors['rgb-field-fill'] === undefined && colors['rgb-surface-primary'] !== undefined) {+ variables.push(['--field-fill', colors['rgb-surface-primary']]);+ }+if (colors['rgb-table-header-text'] === undefined && colors['rgb-text-secondary'] !== undefined) {variables.push(['--table-header-text', colors['rgb-text-secondary']]);}diff --git a/packages/data-provider/specs/theme.spec.ts b/packages/data-provider/specs/theme.spec.tsindex 7fe311c0de..411052bf7c 100644--- a/packages/data-provider/specs/theme.spec.ts+++ b/packages/data-provider/specs/theme.spec.ts@@ -47,3 +47,42 @@ describe('menu and tooltip shadow roles in a theme definition', () => {}});});++describe('field fill roles in a theme definition', () => {+ const theme = {+ version: 1,+ name: 'field-fill-reference',+ modes: {+ light: {+ colors: { 'rgb-field-fill': '251 252 255', 'rgb-field-text': '48 46 50' },+ appearance: { fieldFillStyle: 'fill' },+ },+ dark: { appearance: { fieldFillStyle: 'transparent' } },+ },+ };++ it('accepts the fill style and opaque field colors', () => {+ expect(deploymentThemeSchema.safeParse(theme).success).toBe(true);+ expect(messages(theme)).toEqual([]);+ });++ it('rejects an unknown fill style and a translucent field color', () => {+ const glass = { ...theme, modes: { light: { appearance: { fieldFillStyle: 'glass' } } } };+ expect(messages(glass)).toEqual(['Invalid appearance value for fieldFillStyle: glass']);++ const translucent = {+ ...theme,+ modes: { light: { colors: { 'rgb-field-fill': '1 2 3 / 0.5' } } },+ };+ expect(deploymentThemeSchema.safeParse(translucent).success).toBe(false);+ expect(messages(translucent)).toHaveLength(1);+ });++ it('keeps a definition that names a color token this reader does not know', () => {+ const newer = {+ ...theme,+ modes: { light: { colors: { 'rgb-field-fill': '251 252 255', 'rgb-field-hover': '1 2 3' } } },+ };+ expect(messages(newer)).toEqual([]);+ });+});diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.tsindex 2cee637fff..4ebc47d37e 100644--- a/packages/data-provider/src/theme.ts+++ b/packages/data-provider/src/theme.ts@@ -81,6 +81,8 @@ export const themeColorTokens = Object.freeze(['rgb-border-destructive','rgb-border-control','rgb-border-field-focus',+ 'rgb-field-fill',+ 'rgb-field-text','rgb-surface-disabled','rgb-text-disabled','rgb-border-disabled',@@ -360,6 +362,8 @@ const appearanceValidators = {fieldHeight: isLength,fieldPaddingY: isLength,fieldFocusStyle: (value: unknown) => value === 'ring' || value === 'border',+ /** Whether a field stays transparent or paints `field-fill`. */+ fieldFillStyle: (value: unknown) => value === 'transparent' || value === 'fill',/** The keyboard focus outline's width and offset. */focusRingWidth: isSwitchLength,focusRingOffset: isFocusRingOffset,