From fec19ca3f4e738e1943ea2bcf88ad5c324eaf4e7 Mon Sep 17 00:00:00 2001
From: Marco Beretta <81851188+berry-13@users.noreply.github.com>
Date: Sat, 31 Oct 2026 22:48:10 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20refactor:=20Paint=20the?=
=?UTF-8?q?=20Provider=20Badge=20Over=20Media=20Through=20a=20Theme=20Role?=
=?UTF-8?q?=20(#17681)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* test: Verify the Provider Badge Keeps Its Translucent Page Tone
* feat: Paint the Provider Badge Over Media With a Surface Media Chip Role
---
.../Providers/__tests__/themeCache.spec.ts | 2 +-
e2e/specs/mock/scenarios/source-chip.spec.ts | 85 +++++++++++++++++++
.../components/composer/files/SourceIcon.tsx | 2 +-
packages/client/src/theme/README.md | 1 +
packages/client/src/theme/defaults.css | 4 +
packages/client/src/theme/defaults.spec.ts | 2 +-
.../client/src/theme/themes/clickhouse.ts | 2 +
.../client/src/theme/themes/clickui.spec.ts | 3 +
packages/client/src/theme/tokens.css | 1 +
packages/data-provider/src/theme.ts | 1 +
packages/data-provider/src/themes/dark.ts | 1 +
packages/data-provider/src/themes/default.ts | 1 +
.../data-provider/src/themes/highContrast.ts | 2 +
packages/data-provider/src/themes/types.ts | 5 ++
14 files changed, 109 insertions(+), 3 deletions(-)
create mode 100644 e2e/specs/mock/scenarios/source-chip.spec.ts
diff --git a/client/src/Providers/__tests__/themeCache.spec.ts b/client/src/Providers/__tests__/themeCache.spec.ts
index 962b59ee9e..e1bfbcfcc5 100644
--- a/client/src/Providers/__tests__/themeCache.spec.ts
+++ b/client/src/Providers/__tests__/themeCache.spec.ts
@@ -224,7 +224,7 @@ describe('theme cache storage', () => {
* - definitions with one or both mode blocks absent.
* A new role, or a new fallback, joins by construction.
*/
-const PIN = { fingerprint: '1.5.1ln9dy9', digest: '1ohs8yp' };
+const PIN = { fingerprint: '1.5.11s6b78', digest: '1xfmtot' };
const digestOf = (text: string): string => {
let hash = 5381;
diff --git a/e2e/specs/mock/scenarios/source-chip.spec.ts b/e2e/specs/mock/scenarios/source-chip.spec.ts
new file mode 100644
index 0000000000..3d3eaca683
--- /dev/null
+++ b/e2e/specs/mock/scenarios/source-chip.spec.ts
@@ -0,0 +1,85 @@
+import { expect, test } from '@playwright/test';
+import { FileSources } from 'librechat-data-provider';
+import type { TFile } from 'librechat-data-provider';
+import type { Page } from '@playwright/test';
+
+/**
+ * The provider badge pinned over an uploaded image in My Files: the page's own tone, translucent,
+ * so the provider mark reads on any image. White at 75% in light and black at 65% in dark, the
+ * look it has always had. The account menu sits behind the mobile drawer on a phone-width
+ * viewport, so this scenario uses a desktop viewport.
+ */
+test.use({ viewport: { width: 1280, height: 800 }, deviceScaleFactor: 3 });
+
+const IMAGE_PATH = '/images/e2e-source-chip.svg';
+
+/** Bright, saturated stripes, so the badge's translucency shows in the screenshot. */
+const STRIPES = ``;
+
+const file: TFile = {
+ file_id: 'e2e-source-chip',
+ filename: 'Provider upload.svg',
+ filepath: IMAGE_PATH,
+ user: 'source-chip-user',
+ bytes: STRIPES.length,
+ object: 'file',
+ source: FileSources.openai,
+ type: 'image/svg+xml',
+ usage: 0,
+ embedded: false,
+ createdAt: '2026-10-31T00:00:00.000Z',
+ updatedAt: '2026-10-31T00:00:00.000Z',
+};
+
+/** The RGBA a colour paints, whatever syntax the browser serialises it in. */
+const painted = (page: Page, color: string): Promise =>
+ page.evaluate((value) => {
+ const canvas = document.createElement('canvas');
+ canvas.width = 1;
+ canvas.height = 1;
+ const context = canvas.getContext('2d');
+ if (!context) {
+ return [];
+ }
+ context.fillStyle = value;
+ context.fillRect(0, 0, 1, 1);
+ return Array.from(context.getImageData(0, 0, 1, 1).data);
+ }, color);
+
+test('the provider badge over an uploaded image keeps its translucent page tone @scenario:source-badge-keeps-its-tone', async ({
+ page,
+}, testInfo) => {
+ await page.route('**/api/files', (route) => route.fulfill({ json: [file] }));
+ await page.route(`**${IMAGE_PATH}`, (route) =>
+ route.fulfill({ contentType: 'image/svg+xml', body: STRIPES }),
+ );
+ const imageServed = page.waitForResponse((response) => response.url().endsWith(IMAGE_PATH));
+ await page.goto('/c/new', { timeout: 15_000 });
+ await page.getByTestId('nav-user').click();
+ await page.getByRole('menu').getByRole('menuitem', { name: 'My Files', exact: true }).click();
+ const dialog = page.getByRole('dialog', { name: 'My Files', exact: true });
+ const row = dialog.getByRole('row').filter({ hasText: file.filename });
+ await expect(row).toBeVisible({ timeout: 15_000 });
+
+ await imageServed;
+ const badge = row.locator('button div.rounded-full');
+ await expect(badge).toBeVisible();
+
+ const dark = await page.evaluate(() => document.documentElement.classList.contains('dark'));
+ const background = await badge.evaluate((element) => getComputedStyle(element).backgroundColor);
+ const [red, green, blue, alpha] = await painted(page, background);
+ const expected = dark
+ ? [0, 0, 0, Math.round(0.65 * 255)]
+ : [255, 255, 255, Math.round(0.75 * 255)];
+ expect([red, green, blue]).toEqual(expected.slice(0, 3));
+ expect(Math.abs(alpha - expected[3])).toBeLessThanOrEqual(1);
+
+ const cell = row.getByRole('cell').filter({ hasText: file.filename });
+ await testInfo.attach(`source-badge-${dark ? 'dark' : 'light'}`, {
+ body: await cell.screenshot(),
+ contentType: 'image/png',
+ });
+});
diff --git a/packages/chat/src/components/composer/files/SourceIcon.tsx b/packages/chat/src/components/composer/files/SourceIcon.tsx
index d1760315ad..17d499c1fa 100644
--- a/packages/chat/src/components/composer/files/SourceIcon.tsx
+++ b/packages/chat/src/components/composer/files/SourceIcon.tsx
@@ -11,7 +11,7 @@ const sourceToEndpoint = (): Partial> => ({
});
const sourceToClassname = (): Partial> => ({
- [FileSources.openai]: 'bg-white/75 dark:bg-black/65',
+ [FileSources.openai]: 'bg-surface-media-chip',
[FileSources.azure]: 'azure-bg-color',
[FileSources.azure_blob]: 'azure-bg-color',
[FileSources.execute_code]: 'bg-surface-media-overlay text-text-on-media opacity-85',
diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md
index 6f8f5f5881..22156d6b21 100644
--- a/packages/client/src/theme/README.md
+++ b/packages/client/src/theme/README.md
@@ -316,6 +316,7 @@ function MyComponent() {
- `bg-surface-dialog` - Dialog/modal background
- `bg-surface-overlay` - Dialog/modal scrim, adapted per theme
- `bg-surface-media-overlay` - Scrim, chip or progress drawn over the user's own media (lightbox, image preview, upload); `text-text-on-media` is its ink. Black and white in every bundled theme, since they frame the image rather than the page
+- `bg-surface-media-chip` - A source badge pinned over the user's media: the page tone, translucent (white at 75% in light, black at 65% in dark by default; the opacity is the `--surface-media-chip-alpha` property)
- `bg-surface-chat` - Chat interface background
- `bg-surface-code` - Code block chrome: toolbar, output and result switcher
- `bg-surface-code-body` - Code block pane behind the highlighted code
diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.css
index 650da5355e..7298e2418c 100644
--- a/packages/client/src/theme/defaults.css
+++ b/packages/client/src/theme/defaults.css
@@ -147,6 +147,8 @@ html {
--surface-overlay: var(--gray-500);
--surface-media-overlay: 0 0 0;
--text-on-media: var(--white);
+ --surface-media-chip: var(--white);
+ --surface-media-chip-alpha: 0.75;
--surface-submit: var(--green-700);
--surface-submit-hover: var(--green-800);
--surface-destructive: var(--red-700);
@@ -458,6 +460,8 @@ html {
--surface-overlay: 0 0 0;
--surface-media-overlay: 0 0 0;
--text-on-media: var(--white);
+ --surface-media-chip: 0 0 0;
+ --surface-media-chip-alpha: 0.65;
--surface-submit: var(--green-700);
--surface-submit-hover: var(--green-800);
--surface-destructive: var(--red-800);
diff --git a/packages/client/src/theme/defaults.spec.ts b/packages/client/src/theme/defaults.spec.ts
index 16fdb996a2..bee943dfa8 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;
it('covers every registry color', () => {
- expect(tokens).toHaveLength(169);
+ expect(tokens).toHaveLength(170);
});
it('resolves every registry color to the runtime theme value', () => {
diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.ts
index 8f306f4402..95cbc10907 100644
--- a/packages/client/src/theme/themes/clickhouse.ts
+++ b/packages/client/src/theme/themes/clickhouse.ts
@@ -81,6 +81,7 @@ export const clickHouseLightTheme: IThemeRGB = {
'rgb-surface-overlay': '21 21 21', // #151515 (dialog.color.opaqueBackground, lch(6.7738 0 none))
'rgb-surface-media-overlay': '0 0 0', // #000000 (Click UI has no media scrim; the image frame stays black)
'rgb-text-on-media': '255 255 255', // #ffffff (palette.neutral.0)
+ 'rgb-surface-media-chip': '255 255 255', // #ffffff (Click UI has no media chip; the stock white, at 0.75 alpha)
'rgb-surface-submit': '21 21 21', // #151515 (accent.default)
'rgb-surface-submit-hover': '50 50 50', // #323232 (palette.neutral.712)
'rgb-surface-destructive': '193 0 0', // #c10000 (palette.danger.600)
@@ -280,6 +281,7 @@ export const clickHouseDarkTheme: IThemeRGB = {
'rgb-surface-overlay': '96 96 96', // #606060 (dialog.color.opaqueBackground, lch(40.731 0 none), drawn at the 0.75 scrimOpacity)
'rgb-surface-media-overlay': '0 0 0', // #000000 (Click UI has no media scrim; the image frame stays black)
'rgb-text-on-media': '255 255 255', // #ffffff (palette.neutral.0)
+ 'rgb-surface-media-chip': '0 0 0', // #000000 (Click UI has no media chip; the stock black, at 0.65 alpha)
'rgb-surface-submit': '250 255 105', // #faff69 (accent.default)
'rgb-surface-submit-hover': '253 255 163', // #fdffa3 (palette.brand.200)
'rgb-surface-destructive': '255 117 117', // #ff7575 (palette.danger.300)
diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.ts
index d3e0bcb990..9cf47765c7 100644
--- a/packages/client/src/theme/themes/clickui.spec.ts
+++ b/packages/client/src/theme/themes/clickui.spec.ts
@@ -392,6 +392,8 @@ const colorSources: Record>>
/** Values the theme sets on purpose without a Click UI source, and why. */
const MEDIA_OVERLAY_REASON =
'Click UI has no media scrim; the image frame stays black in both modes';
+const MEDIA_CHIP_REASON =
+ 'Click UI has no source badge over media; the theme keeps the stock white and black chip';
const STYLESHEET_ROLE_REASON =
'Click UI has no scrollbar, secondary button fill or toast edge; the theme keeps the stock role';
const STROKE_INK_REASON =
@@ -399,6 +401,7 @@ const STROKE_INK_REASON =
const STYLESHEET_ROLES: Partial> = {
'rgb-surface-media-overlay': MEDIA_OVERLAY_REASON,
+ 'rgb-surface-media-chip': MEDIA_CHIP_REASON,
'rgb-scrollbar-thumb': STYLESHEET_ROLE_REASON,
'rgb-button-neutral-hover': STYLESHEET_ROLE_REASON,
'rgb-toast-edge': STYLESHEET_ROLE_REASON,
diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.css
index 80afdfdc6e..4fb2b472ac 100644
--- a/packages/client/src/theme/tokens.css
+++ b/packages/client/src/theme/tokens.css
@@ -77,6 +77,7 @@
--color-surface-overlay: rgb(var(--surface-overlay));
--color-surface-media-overlay: rgb(var(--surface-media-overlay));
--color-text-on-media: rgb(var(--text-on-media));
+ --color-surface-media-chip: rgb(var(--surface-media-chip) / var(--surface-media-chip-alpha, 1));
/* The dialog scrims: the overlay at the opacity each dialog family's appearance
* role sets (OGDialog, AlertDialog, Dialog), defaulting to the 80%, 90% and 65%
* the families have always drawn. */
diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.ts
index bdd8f4747e..e62e24f569 100644
--- a/packages/data-provider/src/theme.ts
+++ b/packages/data-provider/src/theme.ts
@@ -56,6 +56,7 @@ export const themeColorTokens = Object.freeze([
'rgb-surface-overlay',
'rgb-surface-media-overlay',
'rgb-text-on-media',
+ 'rgb-surface-media-chip',
'rgb-surface-submit',
'rgb-surface-submit-hover',
'rgb-surface-destructive',
diff --git a/packages/data-provider/src/themes/dark.ts b/packages/data-provider/src/themes/dark.ts
index 16b45e3d9b..4cf0e0fe08 100644
--- a/packages/data-provider/src/themes/dark.ts
+++ b/packages/data-provider/src/themes/dark.ts
@@ -56,6 +56,7 @@ export const darkTheme: IThemeRGB = {
'rgb-surface-overlay': '0 0 0', // #000 (black)
'rgb-surface-media-overlay': '0 0 0', // #000 (black, over the user's media in both modes)
'rgb-text-on-media': '255 255 255', // #fff (white)
+ 'rgb-surface-media-chip': '0 0 0', // #000 (black), carried at 0.65 alpha
'rgb-surface-submit': '4 120 87', // #047857 (green-700)
'rgb-surface-submit-hover': '6 95 70', // #065f46 (green-800)
'rgb-surface-destructive': '153 27 27', // #991b1b (red-800)
diff --git a/packages/data-provider/src/themes/default.ts b/packages/data-provider/src/themes/default.ts
index 54ca246c3c..5143454e3f 100644
--- a/packages/data-provider/src/themes/default.ts
+++ b/packages/data-provider/src/themes/default.ts
@@ -56,6 +56,7 @@ export const defaultTheme: IThemeRGB = {
'rgb-surface-overlay': '89 89 89', // #595959 (gray-500)
'rgb-surface-media-overlay': '0 0 0', // #000 (black, over the user's media in both modes)
'rgb-text-on-media': '255 255 255', // #fff (white)
+ 'rgb-surface-media-chip': '255 255 255', // #fff (white), carried at 0.75 alpha
'rgb-surface-submit': '4 120 87', // #047857 (green-700)
'rgb-surface-submit-hover': '6 95 70', // #065f46 (green-800)
'rgb-surface-destructive': '185 28 28', // #b91c1c (red-700)
diff --git a/packages/data-provider/src/themes/highContrast.ts b/packages/data-provider/src/themes/highContrast.ts
index 918728e09d..cf20d5a0d8 100644
--- a/packages/data-provider/src/themes/highContrast.ts
+++ b/packages/data-provider/src/themes/highContrast.ts
@@ -92,6 +92,7 @@ export const highContrastLightTheme: IThemeRGB = {
'rgb-surface-overlay': '0 0 0', // #000000
'rgb-surface-media-overlay': '0 0 0', // #000000
'rgb-text-on-media': '255 255 255', // #ffffff
+ 'rgb-surface-media-chip': '255 255 255', // #ffffff, carried at 0.75 alpha
'rgb-surface-submit': '0 92 46', // #005c2e
'rgb-surface-submit-hover': '0 61 30', // #003d1e
'rgb-surface-destructive': '161 0 0', // #a10000
@@ -310,6 +311,7 @@ export const highContrastDarkTheme: IThemeRGB = {
'rgb-surface-overlay': '0 0 0', // #000000
'rgb-surface-media-overlay': '0 0 0', // #000000
'rgb-text-on-media': '255 255 255', // #ffffff
+ 'rgb-surface-media-chip': '0 0 0', // #000000, carried at 0.65 alpha
'rgb-surface-submit': '127 240 179', // #7ff0b3
'rgb-surface-submit-hover': '163 245 204', // #a3f5cc
'rgb-surface-destructive': '255 143 143', // #ff8f8f
diff --git a/packages/data-provider/src/themes/types.ts b/packages/data-provider/src/themes/types.ts
index dfa5b0cb0c..3d893c64b7 100644
--- a/packages/data-provider/src/themes/types.ts
+++ b/packages/data-provider/src/themes/types.ts
@@ -68,6 +68,9 @@ export interface IThemeRGB {
* than the page, so every bundled theme keeps them black and white in both modes. */
'rgb-surface-media-overlay'?: string;
'rgb-text-on-media'?: string;
+ /** A source badge pinned over the user's media: the page's own tone, translucent, so the
+ * provider mark reads on any image. Its opacity stays in CSS as `--surface-media-chip-alpha`. */
+ 'rgb-surface-media-chip'?: string;
'rgb-surface-submit'?: string;
'rgb-surface-submit-hover'?: string;
'rgb-surface-destructive'?: string;
@@ -326,6 +329,7 @@ export interface IThemeVariables {
'--surface-overlay': string;
'--surface-media-overlay': string;
'--text-on-media': string;
+ '--surface-media-chip': string;
'--surface-submit': string;
'--surface-submit-hover': string;
'--surface-destructive': string;
@@ -507,6 +511,7 @@ export interface IThemeColors {
'surface-overlay'?: string;
'surface-media-overlay'?: string;
'text-on-media'?: string;
+ 'surface-media-chip'?: string;
'surface-submit'?: string;
'surface-submit-hover'?: string;
'surface-destructive'?: string;