From d2e11ffd0af8809ee23d593482d01202c0ede114 Mon Sep 17 00:00:00 2001
From: Marco Beretta <81851188+berry-13@users.noreply.github.com>
Date: Thu, 1 Oct 2026 12:13:41 +0200
Subject: [PATCH] =?UTF-8?q?=F0=9F=96=BC=EF=B8=8F=20feat:=20Give=20Media=20?=
=?UTF-8?q?Overlays=20Their=20Own=20Theme=20Roles=20(#16596)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Chat/Input/Files/DragDropOverlay.tsx | 16 +-
.../Chat/Input/Files/ImagePreview.tsx | 10 +-
.../Chat/Input/Files/ProgressCircle.tsx | 4 +-
.../Chat/Input/Files/SourceIcon.tsx | 2 +-
.../Chat/Messages/Content/DialogImage.tsx | 20 +-
.../Chat/Messages/Content/Parts/BashCall.tsx | 2 +-
.../Messages/Content/Parts/ExecuteCode.tsx | 4 +-
.../Chat/Messages/MinimalMessages.tsx | 2 +-
.../src/components/Insights/InsightsView.tsx | 8 +-
.../Nav/SettingsTabs/Account/Avatar.tsx | 4 +-
client/src/components/Share/MessagesView.tsx | 2 +-
.../SidePanel/Agents/Tools/ToolCard.tsx | 2 +-
.../SidePanel/Builder/AssistantAvatar.tsx | 27 +-
.../components/SidePanel/Builder/Images.tsx | 85 +-----
e2e/specs/mock/db.ts | 2 +
.../scenarios/media-overlay-theme.spec.ts | 268 ++++++++++++++++++
eslint-suppressions.json | 21 +-
packages/client/src/components/Button.tsx | 7 +
packages/client/src/theme/README.md | 1 +
packages/client/src/theme/allowlist.md | 29 +-
packages/client/src/theme/defaults.css | 9 +-
packages/client/src/theme/defaults.spec.ts | 2 +-
.../client/src/theme/themes/clickhouse.ts | 4 +
.../client/src/theme/themes/clickui.spec.ts | 23 +-
packages/client/src/theme/themes/dark.ts | 2 +
packages/client/src/theme/themes/default.ts | 6 +-
.../client/src/theme/themes/highContrast.ts | 4 +
packages/client/src/theme/tokens.css | 2 +
packages/client/src/theme/types/index.ts | 9 +
packages/data-provider/src/theme.ts | 2 +
30 files changed, 407 insertions(+), 172 deletions(-)
create mode 100644 e2e/specs/mock/scenarios/media-overlay-theme.spec.ts
diff --git a/client/src/components/Chat/Input/Files/DragDropOverlay.tsx b/client/src/components/Chat/Input/Files/DragDropOverlay.tsx
index 43700206c3..6b568857c5 100644
--- a/client/src/components/Chat/Input/Files/DragDropOverlay.tsx
+++ b/client/src/components/Chat/Input/Files/DragDropOverlay.tsx
@@ -9,22 +9,18 @@ const DragDropOverlay = memo(({ isActive }: DragDropOverlayProps) => {
const localize = useLocalize();
return (
<>
- {/** Modal backdrop overlay */}
+ {/** Modal backdrop overlay: black at 40% in both modes, so the media role, not the page scrim */}
{/** Main content overlay */}
{
}}
>
{/** Content area with subtle background */}
-
+
{localize('com_ui_upload_files')}
- {localize('com_ui_drag_drop')}
+ {localize('com_ui_drag_drop')}
>
diff --git a/client/src/components/Chat/Input/Files/ImagePreview.tsx b/client/src/components/Chat/Input/Files/ImagePreview.tsx
index 8a3c947330..5241048242 100644
--- a/client/src/components/Chat/Input/Files/ImagePreview.tsx
+++ b/client/src/components/Chat/Input/Files/ImagePreview.tsx
@@ -148,13 +148,13 @@ const ImagePreview = ({
@@ -166,7 +166,7 @@ const ImagePreview = ({
handleOpenChange(false)}
- variant="ghost"
+ variant="media"
size="icon"
- className="absolute top-4 right-4 z-20 text-white hover:bg-white/10"
+ className="absolute top-4 right-4 z-20"
aria-label={localize('com_ui_close')}
>
diff --git a/client/src/components/Chat/Input/Files/ProgressCircle.tsx b/client/src/components/Chat/Input/Files/ProgressCircle.tsx
index 934bf06fbc..ac7e70e0e8 100644
--- a/client/src/components/Chat/Input/Files/ProgressCircle.tsx
+++ b/client/src/components/Chat/Input/Files/ProgressCircle.tsx
@@ -8,10 +8,10 @@ export default function ProgressCircle({
circleCSSProperties: React.CSSProperties;
}) {
return (
-
+
diff --git a/client/src/components/Insights/InsightsView.tsx b/client/src/components/Insights/InsightsView.tsx
index de4c230b12..19c82384d2 100644
--- a/client/src/components/Insights/InsightsView.tsx
+++ b/client/src/components/Insights/InsightsView.tsx
@@ -113,11 +113,9 @@ function Panel({ children, className }: { children: React.ReactNode; className?:
return (
diff --git a/client/src/components/Nav/SettingsTabs/Account/Avatar.tsx b/client/src/components/Nav/SettingsTabs/Account/Avatar.tsx
index 91a34f5a19..f9dc2b7362 100644
--- a/client/src/components/Nav/SettingsTabs/Account/Avatar.tsx
+++ b/client/src/components/Nav/SettingsTabs/Account/Avatar.tsx
@@ -231,8 +231,8 @@ function Avatar() {
/>
{!isDragging && (
-
)}
diff --git a/client/src/components/Share/MessagesView.tsx b/client/src/components/Share/MessagesView.tsx
index 2ccb002bf3..26edd760bc 100644
--- a/client/src/components/Share/MessagesView.tsx
+++ b/client/src/components/Share/MessagesView.tsx
@@ -40,7 +40,7 @@ export default function MessagesView({
>
)}
-
+
diff --git a/client/src/components/SidePanel/Agents/Tools/ToolCard.tsx b/client/src/components/SidePanel/Agents/Tools/ToolCard.tsx
index 10a0273e69..2cc82e077f 100644
--- a/client/src/components/SidePanel/Agents/Tools/ToolCard.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/ToolCard.tsx
@@ -56,7 +56,7 @@ function ItemIconView({ item, size }: ItemIconProps) {
return (
undefined;
+
function Avatar({
endpoint,
version,
@@ -39,7 +42,6 @@ function Avatar({
// console.log('Avatar', assistant_id, metadata, createMutation);
const queryClient = useQueryClient();
const assistantsMap = useAssistantsMapContext();
- const [menuOpen, setMenuOpen] = useState(false);
const [progress, setProgress] = useState(1);
const [input, setInput] = useState(null);
const [previewUrl, setPreviewUrl] = useState(null);
@@ -179,7 +181,6 @@ function Avatar({
}
setInput(file);
- setMenuOpen(false);
if (!assistant_id) {
// wait for successful form submission before uploading avatar
@@ -205,14 +206,12 @@ function Avatar({
status: 'error',
});
}
-
- setMenuOpen(false);
};
return (
-
-
-
+
- {}
-
+ }
+ handleFileChange={handleFileChange}
+ onReset={noReset}
+ canReset={false}
+ />
+
);
}
diff --git a/client/src/components/SidePanel/Builder/Images.tsx b/client/src/components/SidePanel/Builder/Images.tsx
index 715cad5ae6..c81e1e14f6 100644
--- a/client/src/components/SidePanel/Builder/Images.tsx
+++ b/client/src/components/SidePanel/Builder/Images.tsx
@@ -1,6 +1,4 @@
-import { useRef } from 'react';
-import * as Popover from '@radix-ui/react-popover';
-import useLocalize from '~/hooks/useLocalize';
+import ProgressCircle from '~/components/Chat/Input/Files/ProgressCircle';
export function NoImage() {
return (
@@ -52,84 +50,13 @@ export const AssistantAvatar = ({
style={{ opacity: progress < 1 ? 0.4 : 1 }}
/>
{progress < 1 && (
-
-
-
+
)}
);
};
-
-export function AvatarMenu({
- handleFileChange,
-}: {
- handleFileChange: (event: React.ChangeEvent) => void;
-}) {
- const fileInputRef = useRef(null);
- const localize = useLocalize();
-
- const onItemClick = () => {
- if (fileInputRef.current) {
- fileInputRef.current.value = '';
- }
- fileInputRef.current?.click();
- };
-
- return (
-
-
-
- {localize('com_ui_upload_image')}
-
- {/*
- Use DALL·E
- */}
-
-
-
- );
-}
diff --git a/e2e/specs/mock/db.ts b/e2e/specs/mock/db.ts
index ddf3819a9b..80516da780 100644
--- a/e2e/specs/mock/db.ts
+++ b/e2e/specs/mock/db.ts
@@ -93,6 +93,8 @@ export interface SeedMessage {
/** Why the turn stopped; the hover Continue is offered only for some values. */
finish_reason?: string;
model?: string;
+ /** Attachments on the turn, as the client renders them (an image opens the lightbox). */
+ files?: Record[];
}
/**
diff --git a/e2e/specs/mock/scenarios/media-overlay-theme.spec.ts b/e2e/specs/mock/scenarios/media-overlay-theme.spec.ts
new file mode 100644
index 0000000000..3e67a0a24a
--- /dev/null
+++ b/e2e/specs/mock/scenarios/media-overlay-theme.spec.ts
@@ -0,0 +1,268 @@
+import { randomUUID } from 'crypto';
+import { expect, test } from '@playwright/test';
+import type { Locator, Page } from '@playwright/test';
+import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
+import { deleteConversations, seedConversations, seedMessages } from '../db';
+import { getE2EUser } from '../../../setup/user';
+import { NEW_CHAT_PATH } from '../helpers';
+
+/**
+ * Scrims and controls drawn over the user's own media read `surface-media-overlay` and
+ * `text-on-media`. Every bundled theme keeps them black and white in both modes, so the
+ * lightbox, the composer image preview and the file-drop backdrop paint what they did
+ * before the roles existed, and a theme that sets the roles reaches all of them.
+ */
+
+type Mode = 'light' | 'dark';
+
+const MODES: Mode[] = ['light', 'dark'];
+const THEME_PARAM = 'e2eThemeMode';
+const IMAGE_URL = 'https://media.e2e.invalid/media.png';
+const IMAGE_NAME = 'media.png';
+const PNG_BASE64 =
+ 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAAHUlEQVQ4jWNwaDjwnxLMMGrA/9EwODAaBg3DIgwACY9/HwbtciYAAAAASUVORK5CYII=';
+const WHITE_INK = 'rgb(255, 255, 255)';
+
+/** A theme that moves both media roles off black and white, to prove they are reachable. */
+const MEDIA_THEME = {
+ version: 1,
+ name: 'media-reference',
+ modes: {
+ light: {
+ colors: { 'rgb-surface-media-overlay': '20 30 40', 'rgb-text-on-media': '250 240 200' },
+ },
+ dark: {
+ colors: { 'rgb-surface-media-overlay': '40 20 30', 'rgb-text-on-media': '200 240 250' },
+ },
+ },
+};
+
+test.use({ viewport: { width: 1280, height: 800 } });
+
+/** The mode rides in the URL so one init script can serve every navigation. */
+async function installThemeBridge(page: Page, definition: unknown) {
+ await page.addInitScript((stored) => {
+ const mode = new URL(location.href).searchParams.get('e2eThemeMode');
+ if (mode) {
+ localStorage.setItem('color-theme', mode);
+ }
+ 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');
+ }
+ }, definition ?? null);
+}
+
+async function serveImage(page: Page) {
+ await page.route(`${IMAGE_URL}*`, (route) =>
+ route.fulfill({ contentType: 'image/png', body: Buffer.from(PNG_BASE64, 'base64') }),
+ );
+}
+
+/** A conversation whose user turn carries one image, the lightbox's entry point. */
+async function seedImageChat(title: string): Promise {
+ const conversationId = randomUUID();
+ const { email } = getE2EUser();
+ await seedConversations(email, [{ conversationId, title, updatedAt: new Date() }]);
+ const userMessageId = randomUUID();
+ await seedMessages(email, conversationId, [
+ {
+ messageId: userMessageId,
+ parentMessageId: '00000000-0000-0000-0000-000000000000',
+ text: 'Here is the image.',
+ isCreatedByUser: true,
+ sender: 'User',
+ files: [
+ {
+ file_id: randomUUID(),
+ filename: IMAGE_NAME,
+ filepath: IMAGE_URL,
+ type: 'image/png',
+ width: 16,
+ height: 16,
+ },
+ ],
+ },
+ {
+ messageId: randomUUID(),
+ parentMessageId: userMessageId,
+ text: 'A small test image.',
+ isCreatedByUser: false,
+ sender: 'Mock Provider A',
+ },
+ ]);
+ return conversationId;
+}
+
+/** The lightbox's scrim is the overlay rendered just before its dialog content. */
+const scrimColor = (dialog: Locator) =>
+ dialog.evaluate((node) => {
+ const scrim = node.previousElementSibling;
+ return scrim ? getComputedStyle(scrim).backgroundColor : '';
+ });
+
+const inkOf = (control: Locator) => control.evaluate((node) => getComputedStyle(node).color);
+
+/**
+ * The RGBA a colour paints, whatever syntax the browser serialises it in: an alpha utility
+ * computes to `oklab(0 0 0 / 0.9)` where the same colour written by hand reads `rgba(...)`.
+ */
+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);
+
+/** Both colours paint the same pixel, within the one-step rounding of an oklab round trip. */
+async function expectSamePaint(page: Page, actual: string, expected: string) {
+ const [got, want] = await Promise.all([painted(page, actual), painted(page, expected)]);
+ expect(got).toHaveLength(4);
+ got.forEach((channel, index) => expect(Math.abs(channel - want[index])).toBeLessThanOrEqual(1));
+}
+
+/** Attaches what the page shows to the report, for the pull request's screenshots. */
+async function capture(page: Page, name: string) {
+ await test.info().attach(name, { body: await page.screenshot(), contentType: 'image/png' });
+}
+
+/** Opens the message image lightbox and reads its scrim and close control at rest and on hover. */
+async function lightboxPaint(page: Page, conversationId: string, mode: Mode, theme = 'default') {
+ await page.goto(`/c/${conversationId}?${THEME_PARAM}=${mode}`);
+ const trigger = page.getByRole('button', { name: `View ${IMAGE_NAME} in dialog` });
+ await expect(trigger).toBeVisible({ timeout: 20000 });
+ await trigger.click();
+
+ const dialog = page
+ .getByRole('dialog')
+ .filter({ has: page.getByRole('button', { name: 'Download', exact: true }) });
+ await expect(dialog).toBeVisible();
+ const close = dialog.getByRole('button', { name: 'Close', exact: true }).first();
+ await expect(close).toBeVisible();
+
+ const scrim = await scrimColor(dialog);
+ expect(scrim).not.toBe('');
+ await capture(page, `lightbox-${theme}-${mode}`);
+ const ink = await inkOf(close);
+ await close.hover();
+ const hoverInk = await inkOf(close);
+ await page.keyboard.press('Escape');
+ await expect(dialog).toBeHidden();
+ return { scrim, ink, hoverInk };
+}
+
+test.describe('media overlay roles', () => {
+ test('the image lightbox keeps a black scrim and white controls in both modes @scenario:media-lightbox-keeps-black-scrim-and-white-ink', async ({
+ page,
+ }) => {
+ test.setTimeout(90000);
+ const conversationId = await seedImageChat('Media lightbox');
+ await installThemeBridge(page, null);
+ await serveImage(page);
+
+ try {
+ for (const mode of MODES) {
+ const { scrim, ...controls } = await lightboxPaint(page, conversationId, mode);
+ await expectSamePaint(page, scrim, 'rgb(0 0 0 / 0.9)');
+ expect(controls).toEqual({ ink: WHITE_INK, hoverInk: WHITE_INK });
+ }
+ } finally {
+ await deleteConversations([conversationId]);
+ }
+ });
+
+ test('the ClickHouse definition keeps the lightbox black and white @scenario:clickhouse-media-lightbox-keeps-black-and-white', async ({
+ page,
+ }) => {
+ test.setTimeout(90000);
+ const conversationId = await seedImageChat('ClickHouse media lightbox');
+ await installThemeBridge(page, clickHouseTheme);
+ await serveImage(page);
+
+ try {
+ for (const mode of MODES) {
+ const { scrim, ...controls } = await lightboxPaint(
+ page,
+ conversationId,
+ mode,
+ 'clickhouse',
+ );
+ await expect(page.locator('html')).toHaveAttribute('data-theme', 'clickhouse');
+ await expectSamePaint(page, scrim, 'rgb(0 0 0 / 0.9)');
+ expect(controls).toEqual({ ink: WHITE_INK, hoverInk: WHITE_INK });
+ }
+ } finally {
+ await deleteConversations([conversationId]);
+ }
+ });
+
+ test('a theme that sets the media roles repaints the lightbox @scenario:media-overlay-follows-a-theme', async ({
+ page,
+ }) => {
+ test.setTimeout(90000);
+ const conversationId = await seedImageChat('Themed media lightbox');
+ await installThemeBridge(page, MEDIA_THEME);
+ await serveImage(page);
+
+ try {
+ for (const [mode, expectedScrim, ink] of [
+ ['light', 'rgb(20 30 40 / 0.9)', 'rgb(250, 240, 200)'],
+ ['dark', 'rgb(40 20 30 / 0.9)', 'rgb(200, 240, 250)'],
+ ] as const) {
+ const { scrim, ...controls } = await lightboxPaint(page, conversationId, mode, 'custom');
+ await expectSamePaint(page, scrim, expectedScrim);
+ expect(controls).toEqual({ ink, hoverInk: ink });
+ }
+ } finally {
+ await deleteConversations([conversationId]);
+ }
+ });
+
+ test('dragging a file over the chat dims the page with the media scrim @scenario:file-drop-backdrop-dims-in-both-modes', async ({
+ page,
+ }) => {
+ test.setTimeout(60000);
+ await installThemeBridge(page, null);
+
+ for (const mode of MODES) {
+ await page.goto(`${NEW_CHAT_PATH}?${THEME_PARAM}=${mode}`);
+ const input = page.getByRole('textbox', { name: 'Message input' });
+ await expect(input).toBeVisible({ timeout: 20000 });
+
+ const dataTransfer = await page.evaluateHandle(() => {
+ const transfer = new DataTransfer();
+ transfer.items.add(new File(['notes'], 'notes.txt', { type: 'text/plain' }));
+ return transfer;
+ });
+ await input.dispatchEvent('dragenter', { dataTransfer });
+ await input.dispatchEvent('dragover', { dataTransfer });
+
+ const prompt = page.getByText('Drop any file here to add it to the conversation', {
+ exact: true,
+ });
+ await expect(prompt).toBeVisible();
+ await capture(page, `drop-backdrop-${mode}`);
+ /* The backdrop is the fixed layer beneath the prompt's own overlay. */
+ const backdrop = await prompt.evaluate((node) => {
+ const overlay = node.closest('.fixed');
+ const layer = overlay?.previousElementSibling;
+ return layer ? getComputedStyle(layer).backgroundColor : '';
+ });
+ await expectSamePaint(page, backdrop, 'rgb(0 0 0 / 0.4)');
+
+ await input.dispatchEvent('dragleave', { dataTransfer });
+ }
+ });
+});
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index dfcb80aa3a..4e8e880675 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -215,7 +215,7 @@
},
"client/src/components/Chat/Input/Files/DragDropOverlay.tsx": {
"shadcn/no-inline-styles": {
- "count": 4
+ "count": 3
},
"shadcn/no-raw-colors": {
"count": 5
@@ -237,9 +237,6 @@
"client/src/components/Chat/Input/Files/ImagePreview.tsx": {
"shadcn/no-inline-styles": {
"count": 3
- },
- "shadcn/no-restyle": {
- "count": 2
}
},
"client/src/components/Chat/Input/Files/MyFilesModal.tsx": {
@@ -461,7 +458,7 @@
"count": 1
},
"shadcn/no-restyle": {
- "count": 13
+ "count": 5
}
},
"client/src/components/Chat/Messages/Content/EditContentParts.tsx": {
@@ -805,9 +802,6 @@
"client/src/components/Chat/Messages/MinimalMessages.tsx": {
"shadcn/no-inline-styles": {
"count": 1
- },
- "shadcn/no-raw-colors": {
- "count": 1
}
},
"client/src/components/Chat/Messages/PendingTurn.tsx": {
@@ -1490,9 +1484,6 @@
"client/src/components/Share/MessagesView.tsx": {
"shadcn/no-inline-styles": {
"count": 1
- },
- "shadcn/no-raw-colors": {
- "count": 1
}
},
"client/src/components/Share/ShareArtifacts.tsx": {
@@ -1860,14 +1851,8 @@
}
},
"client/src/components/SidePanel/Builder/Images.tsx": {
- "shadcn/no-arbitrary-values": {
- "count": 1
- },
"shadcn/no-inline-styles": {
- "count": 3
- },
- "shadcn/no-raw-colors": {
- "count": 6
+ "count": 1
}
},
"client/src/components/SidePanel/Builder/Knowledge.tsx": {
diff --git a/packages/client/src/components/Button.tsx b/packages/client/src/components/Button.tsx
index 86758bfff0..2fd22db344 100644
--- a/packages/client/src/components/Button.tsx
+++ b/packages/client/src/components/Button.tsx
@@ -17,6 +17,7 @@ type ButtonVariantOptions =
| 'destructive'
| 'secondary'
| 'ghost'
+ | 'media'
| 'row-action'
| 'row-action-reveal'
| 'section-header'
@@ -73,6 +74,12 @@ const buttonVariantRecipe = cva(
secondary:
'bg-surface-secondary text-text-primary hover:bg-surface-hover hover:active:bg-surface-pressed',
ghost: 'hover:bg-surface-hover hover:active:bg-surface-pressed hover:text-text-primary',
+ /**
+ * A control drawn over the user's own media (a lightbox toolbar, an image preview's close):
+ * ghost-shaped, with the media ink and a tint of it on hover, so it stays legible on the
+ * black media scrim whatever the page theme paints.
+ */
+ media: 'text-text-on-media hover:bg-text-on-media/10',
/**
* A compact action living inside a list row — a pinned row's unpin
* badge, a conversation's overflow trigger, a table row's controls. The
diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md
index e5bbcecce3..fecddc0c83 100644
--- a/packages/client/src/theme/README.md
+++ b/packages/client/src/theme/README.md
@@ -295,6 +295,7 @@ function MyComponent() {
- `bg-surface-destructive` - Destructive action background
- `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-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/allowlist.md b/packages/client/src/theme/allowlist.md
index b137fe1e73..673157f535 100644
--- a/packages/client/src/theme/allowlist.md
+++ b/packages/client/src/theme/allowlist.md
@@ -1,6 +1,6 @@
# Colours outside the theme
-Every colour in `client/src` and `packages/client/src` that the theme-leakage sweep reached comes from a semantic theme role, except the ones below. Each is a colour that must not follow the theme: a brand mark, artwork, media overlays, a third party's surface, a document that leaves the app, or the theme definitions themselves. An entry names the file, what the literal paints and why the theme does not own it.
+Every colour in `client/src` and `packages/client/src` that the theme-leakage sweep reached comes from a semantic theme role, except the ones below. Each is a colour that must not follow the theme: a brand mark, artwork, a third party's surface, a document that leaves the app, or the theme definitions themselves. Scrims, chips and progress drawn over the user's own media are not exceptions: they read `surface-media-overlay` and `text-on-media`, which every bundled theme keeps black and white. An entry names the file, what the literal paints and why the theme does not own it.
The sweep skipped files an open pull request was editing; those, with their counts, are listed in berry-13/LibreChat#195, and the avatar colours that still need roles in berry-13/LibreChat#194. Until those land, a file absent from this list is not evidence that it holds no literal colour.
@@ -43,21 +43,18 @@ is a role, not an exception.
## Chat: media, artwork and documents that leave the app
-| File | Why |
-| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| `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. |
+| File | Why |
+| ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `client/src/components/Chat/Input/Files/DragDropOverlay.tsx` | The drop-zone illustration's fills are artwork. Its backdrop is on `surface-media-overlay`. |
+| `client/src/components/Chat/Input/Files/SourceIcon.tsx` | The OpenAI file-source chip (white/75, black/65 in dark) behind OpenAI's mark, like the Azure chip in `mobile.css`. The code-execution badge is on `surface-media-overlay`. |
+| `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
-| File | Why |
-| ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
-| `client/src/components/Nav/SettingsTabs/Account/Avatar.tsx` | The move hint drawn over the user's photo in the avatar cropper: a media scrim with white ink, independent of the theme around the image. |
-| `client/src/hooks/Files/useSharePointPicker.ts` | Background of Microsoft's SharePoint file picker iframe, matched to that third party's own surface. |
+| File | Why |
+| ----------------------------------------------- | --------------------------------------------------------------------------------------------------- |
+| `client/src/hooks/Files/useSharePointPicker.ts` | Background of Microsoft's SharePoint file picker iframe, matched to that third party's own surface. |
diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.css
index 90c4695089..5bff62e109 100644
--- a/packages/client/src/theme/defaults.css
+++ b/packages/client/src/theme/defaults.css
@@ -108,8 +108,9 @@ html {
--surface-pressed: var(--gray-200);
--surface-composer-hover: var(--gray-200);
--surface-primary: var(--white);
- --chart-widget-surface: 255 255 255; /* Click UI dashboards.chartWidget.color.background.default #ffffff */
- --chart-widget-stroke: 230 231 233; /* Click UI dashboards.chartWidget.color.stroke.default #e6e7e9 */
+ /* Light widgets sit on the page surface and its light rule; dark mode lifts them (below). */
+ --chart-widget-surface: var(--surface-primary);
+ --chart-widget-stroke: var(--border-light);
--surface-primary-alt: var(--gray-50);
--surface-primary-contrast: var(--gray-100);
--surface-secondary: var(--gray-50);
@@ -119,6 +120,8 @@ html {
--surface-dialog: var(--white);
--dialog-title: var(--text-primary);
--surface-overlay: var(--gray-500);
+ --surface-media-overlay: 0 0 0;
+ --text-on-media: var(--white);
--surface-submit: var(--green-700);
--surface-submit-hover: var(--green-800);
--surface-destructive: var(--red-700);
@@ -336,6 +339,8 @@ html {
--surface-dialog: var(--gray-875);
--dialog-title: var(--text-primary);
--surface-overlay: 0 0 0;
+ --surface-media-overlay: 0 0 0;
+ --text-on-media: var(--white);
--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 3427b7c98e..04e12aa753 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(114);
+ expect(tokens).toHaveLength(116);
});
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 f3a44e2506..09e13aa9e6 100644
--- a/packages/client/src/theme/themes/clickhouse.ts
+++ b/packages/client/src/theme/themes/clickhouse.ts
@@ -79,6 +79,8 @@ export const clickHouseLightTheme: IThemeRGB = {
'rgb-surface-dialog': '255 255 255', // #ffffff (background.default)
'rgb-dialog-title': '30 29 31', // #1e1d1f (dialog.color.title.default, lch(11.126 1.374 305.43))
'rgb-surface-overlay': '21 21 21', // #151515 (dialog.color.opaqueBackground, lch(6.7738 0 none))
+ 'rgb-surface-media-overlay': '0 0 0', // #000000 (no Click UI media scrim)
+ 'rgb-text-on-media': '255 255 255', // #ffffff (palette.neutral.0)
'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)
@@ -225,6 +227,8 @@ export const clickHouseDarkTheme: IThemeRGB = {
* #606060 gray that lifts the page instead of dimming it. A bundled scrim never lifts the page
* (`semanticTokens.spec.ts`), so black keeps the dark scrim; the 0.75 alpha is Click UI's. */
'rgb-surface-overlay': '0 0 0', // #000000
+ 'rgb-surface-media-overlay': '0 0 0', // #000000 (no Click UI media scrim)
+ 'rgb-text-on-media': '255 255 255', // #ffffff (palette.neutral.0)
'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 5f8f476607..377f3d9e22 100644
--- a/packages/client/src/theme/themes/clickui.spec.ts
+++ b/packages/client/src/theme/themes/clickui.spec.ts
@@ -103,6 +103,7 @@ const colorSources: Record>>
'rgb-surface-code': 'click.codeblock.lightMode.color.background.default',
'rgb-surface-code-body': 'click.codeblock.lightMode.color.background.default',
'rgb-surface-qr': 'palette.neutral.0',
+ 'rgb-text-on-media': 'palette.neutral.0',
'rgb-surface-inverted': 'palette.neutral.900',
'rgb-surface-inverted-hover': 'palette.neutral.712',
'rgb-surface-inverted-pressed': 'click.button.basic.color.primary.background.active',
@@ -218,6 +219,7 @@ const colorSources: Record>>
'rgb-surface-code': 'click.codeblock.darkMode.color.background.default',
'rgb-surface-code-body': 'click.codeblock.darkMode.color.background.default',
'rgb-surface-qr': 'palette.neutral.0',
+ 'rgb-text-on-media': 'palette.neutral.0',
'rgb-surface-inverted': 'click.button.basic.color.primary.background.default',
'rgb-surface-inverted-hover': 'click.button.basic.color.primary.background.hover',
'rgb-surface-inverted-pressed': 'click.button.basic.color.primary.background.active',
@@ -287,12 +289,21 @@ const colorSources: Record>>
},
};
+/** Click UI has no scrim for media; a lightbox or preview frames the user's image in black. */
+const MEDIA_OVERLAY_REASON =
+ 'Click UI has no media scrim; the image frame stays black in both modes';
+const MEDIA_SCRIM_DEPARTURE =
+ 'the dialog scrim is the nearest Click UI job; a lightbox frames the user image in black instead';
+
/** Values the theme sets on purpose without a Click UI source, and why. */
const unsourcedColors: Record>> = {
- light: {},
+ light: {
+ 'rgb-surface-media-overlay': MEDIA_OVERLAY_REASON,
+ },
dark: {
'rgb-surface-overlay':
'Click UI dark dialog.color.opaqueBackground is a gray that leaves the dialog under 3:1',
+ 'rgb-surface-media-overlay': MEDIA_OVERLAY_REASON,
},
};
@@ -316,6 +327,11 @@ interface Departure {
*/
const departures: Record>> = {
light: {
+ 'rgb-surface-media-overlay': {
+ counterpart: 'click.dialog.color.opaqueBackground.default',
+ status: 'near',
+ reason: MEDIA_SCRIM_DEPARTURE,
+ },
'rgb-text-secondary': {
counterpart: 'global.color.text.muted',
status: 'mismatch',
@@ -408,6 +424,11 @@ const departures: Record>>
status: 'mismatch',
reason: 'the dark scrim is a #606060 gray that lifts the page instead of dimming it',
},
+ 'rgb-surface-media-overlay': {
+ counterpart: 'click.dialog.color.opaqueBackground.default',
+ status: 'mismatch',
+ reason: MEDIA_SCRIM_DEPARTURE,
+ },
},
};
diff --git a/packages/client/src/theme/themes/dark.ts b/packages/client/src/theme/themes/dark.ts
index 950fd5c328..4514d41ced 100644
--- a/packages/client/src/theme/themes/dark.ts
+++ b/packages/client/src/theme/themes/dark.ts
@@ -54,6 +54,8 @@ export const darkTheme: IThemeRGB = {
'rgb-surface-dialog': '18 18 18', // #121212 (legacy dark dialog)
'rgb-dialog-title': '236 236 236', // #ececec (gray-100, matching text-primary)
'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-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/client/src/theme/themes/default.ts b/packages/client/src/theme/themes/default.ts
index 870b1a6475..aab5e683d2 100644
--- a/packages/client/src/theme/themes/default.ts
+++ b/packages/client/src/theme/themes/default.ts
@@ -43,8 +43,8 @@ export const defaultTheme: IThemeRGB = {
'rgb-surface-pressed': '227 227 227', // #e3e3e3 (gray-200), the hover fill
'rgb-surface-composer-hover': '227 227 227', // #e3e3e3 (gray-200)
'rgb-surface-primary': '255 255 255', // #fff (white)
- 'rgb-chart-widget-surface': '255 255 255', // #fff (Click UI chart widget)
- 'rgb-chart-widget-stroke': '230 231 233', // #e6e7e9 (Click UI chart widget)
+ 'rgb-chart-widget-surface': '255 255 255', // #fff (matching surface-primary)
+ 'rgb-chart-widget-stroke': '227 227 227', // #e3e3e3 (gray-200, matching border-light)
'rgb-surface-primary-alt': '247 247 248', // #f7f7f8 (gray-50)
'rgb-surface-primary-contrast': '236 236 236', // #ececec (gray-100)
'rgb-surface-secondary': '247 247 248', // #f7f7f8 (gray-50)
@@ -54,6 +54,8 @@ export const defaultTheme: IThemeRGB = {
'rgb-surface-dialog': '255 255 255', // #fff (white)
'rgb-dialog-title': '33 33 33', // #212121 (gray-800, matching text-primary)
'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-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/client/src/theme/themes/highContrast.ts b/packages/client/src/theme/themes/highContrast.ts
index e78734e4a1..0fec39e8e4 100644
--- a/packages/client/src/theme/themes/highContrast.ts
+++ b/packages/client/src/theme/themes/highContrast.ts
@@ -90,6 +90,8 @@ export const highContrastLightTheme: IThemeRGB = {
'rgb-surface-dialog': '255 255 255', // #ffffff
'rgb-dialog-title': '0 0 0', // #000000 (matching text-primary)
'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-submit': '0 92 46', // #005c2e
'rgb-surface-submit-hover': '0 61 30', // #003d1e
'rgb-surface-destructive': '161 0 0', // #a10000
@@ -252,6 +254,8 @@ export const highContrastDarkTheme: IThemeRGB = {
'rgb-surface-dialog': '0 0 0', // #000000
'rgb-dialog-title': '255 255 255', // #ffffff (matching text-primary)
'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-submit': '127 240 179', // #7ff0b3
'rgb-surface-submit-hover': '163 245 204', // #a3f5cc
'rgb-surface-destructive': '255 143 143', // #ff8f8f
diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.css
index 544f5ef651..89c6e19b82 100644
--- a/packages/client/src/theme/tokens.css
+++ b/packages/client/src/theme/tokens.css
@@ -51,6 +51,8 @@
/* Falls back to the ink dialog titles were set in, for a stylesheet that predates it. */
--color-dialog-title: rgb(var(--dialog-title, var(--text-primary)));
--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));
/* 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/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.ts
index 9e350125f7..c1956440ec 100644
--- a/packages/client/src/theme/types/index.ts
+++ b/packages/client/src/theme/types/index.ts
@@ -60,6 +60,11 @@ export interface IThemeRGB {
/** An OGDialog title's ink; follows `rgb-text-primary` when a theme omits it. */
'rgb-dialog-title'?: string;
'rgb-surface-overlay'?: string;
+ /** Scrims, chips and progress drawn over the user's own media (a lightbox, an image preview,
+ * an upload in progress), and the ink and hover tint on them. They frame the image rather
+ * 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;
'rgb-surface-submit'?: string;
'rgb-surface-submit-hover'?: string;
'rgb-surface-destructive'?: string;
@@ -236,6 +241,8 @@ export interface IThemeVariables {
'--surface-dialog': string;
'--dialog-title': string;
'--surface-overlay': string;
+ '--surface-media-overlay': string;
+ '--text-on-media': string;
'--surface-submit': string;
'--surface-submit-hover': string;
'--surface-destructive': string;
@@ -362,6 +369,8 @@ export interface IThemeColors {
'surface-dialog'?: string;
'dialog-title'?: string;
'surface-overlay'?: string;
+ 'surface-media-overlay'?: string;
+ 'text-on-media'?: string;
'surface-submit'?: string;
'surface-submit-hover'?: string;
'surface-destructive'?: string;
diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.ts
index f964a5d717..f23d8920c5 100644
--- a/packages/data-provider/src/theme.ts
+++ b/packages/data-provider/src/theme.ts
@@ -54,6 +54,8 @@ export const themeColorTokens = Object.freeze([
'rgb-surface-dialog',
'rgb-dialog-title',
'rgb-surface-overlay',
+ 'rgb-surface-media-overlay',
+ 'rgb-text-on-media',
'rgb-surface-submit',
'rgb-surface-submit-hover',
'rgb-surface-destructive',