🎨 style: Semantic Colour Roles for Builder, Tools and Sharing Surfaces (#16294)

* style: move builder, tools and sharing surfaces onto semantic colour roles

Replace raw palette utilities and dark: colour overrides in the Assistants
builder, agent tool rows, principal avatars, SharePoint picker, code-analysis
block, in-flight steers, prompt variables and the skill file editor with
theme roles, so custom themes repaint them. Where a shared primitive owns
its colour, the local override is dropped so the primitive's tokens apply.

* test: cover semantic colour roles on builder, tools and sharing surfaces under a reference theme

* fix: keep the theme focus ring, let steer text beat prose, clean up seeded messages

Restore the ring-ring-primary focus role on the actions panel buttons so a
theme's own focus colour applies, give the in-flight steer body an important
text role so the unlayered .prose colour no longer wins, delete the messages
the code-analysis scenarios seed, and read the v4 placeholder reference from
the root --gray-400 triplet now that no source generates text-gray-400.

(cherry picked from commit 5960f84a21)

Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16294
This commit is contained in:
Marco Beretta 2026-09-24 16:44:58 +02:00 • committed by Lia
parent 55f3187296
commit 55ca9116a3
23 changed files with 429 additions and 174 deletions

View file

@ -90,7 +90,7 @@ export const columns: ColumnDef<TFile>[] = [
render={
<Button
variant="ghost"
className="px-2 py-0 text-xs hover:bg-surface-hover sm:px-2 sm:py-2 sm:text-sm"
className="hover:bg-surface-hover px-2 py-0 text-xs sm:px-2 sm:py-2 sm:text-sm"
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
aria-sort={ariaSort}
aria-label={localize('com_ui_name_sort')}
@ -150,7 +150,7 @@ export const columns: ColumnDef<TFile>[] = [
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
className="px-2 py-0 text-xs hover:bg-surface-hover sm:px-2 sm:py-2 sm:text-sm"
className="hover:bg-surface-hover px-2 py-0 text-xs sm:px-2 sm:py-2 sm:text-sm"
aria-sort={ariaSort}
aria-label={localize('com_ui_date_sort')}
aria-hidden="true"
@ -199,21 +199,21 @@ export const columns: ColumnDef<TFile>[] = [
if (source === FileSources.openai) {
return (
<div className="flex flex-wrap items-center gap-2">
<OpenAIMinimalIcon className="icon-sm text-green-600/50" />
<OpenAIMinimalIcon className="icon-sm" />
{'OpenAI'}
</div>
);
} else if (source === FileSources.azure) {
return (
<div className="flex flex-wrap items-center gap-2">
<AzureMinimalIcon className="icon-sm text-cyan-700" />
<AzureMinimalIcon className="icon-sm" />
{'Azure'}
</div>
);
}
return (
<div className="flex flex-wrap items-center gap-2">
<Database className="icon-sm text-cyan-700" aria-hidden="true" />
<Database className="icon-sm" aria-hidden="true" />
{localize('com_ui_host')}
</div>
);
@ -268,7 +268,7 @@ export const columns: ColumnDef<TFile>[] = [
render={
<Button
variant="ghost"
className="px-2 py-0 text-xs hover:bg-surface-hover sm:px-2 sm:py-2 sm:text-sm"
className="hover:bg-surface-hover px-2 py-0 text-xs sm:px-2 sm:py-2 sm:text-sm"
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
aria-sort={ariaSort}
aria-label={localize('com_ui_size_sort')}

View file

@ -540,7 +540,7 @@ const InFlightSteer = memo(function InFlightSteer({
<div
className={cn(
'markdown prose message-content dark:prose-invert light min-w-0 break-words',
'dark:text-gray-20',
'text-text-primary!',
!enableUserMsgMarkdown && 'whitespace-pre-wrap',
)}
>

View file

@ -71,7 +71,7 @@ export default function CodeAnalyze({
icon={
<Terminal
className={cn(
'size-4 shrink-0 text-text-secondary',
'text-text-secondary size-4 shrink-0',
phase === 'running' && 'animate-pulse',
)}
aria-hidden="true"
@ -80,18 +80,13 @@ export default function CodeAnalyze({
/>
</div>
{showCode && (
<div className="code-analyze-block mb-3 mt-0.5 overflow-hidden rounded-xl bg-black">
<div className="code-analyze-block bg-surface-code mt-0.5 mb-3 overflow-hidden rounded-xl">
<MarkdownLite content={code ? `\`\`\`python\n${code}\n\`\`\`` : ''} />
{logs && (
<div className="bg-gray-700 p-4 text-xs">
<div className="mb-1 text-gray-400">{localize('com_ui_result')}</div>
<div
className="prose flex flex-col-reverse text-white"
style={{
color: 'white',
}}
>
<pre className="shrink-0">{logs}</pre>
<div className="bg-surface-tertiary p-4 text-xs">
<div className="text-text-secondary mb-1">{localize('com_ui_result')}</div>
<div className="prose flex flex-col-reverse">
<pre className="text-text-primary! shrink-0">{logs}</pre>
</div>
</div>
)}

View file

@ -5,7 +5,7 @@ export const CodeVariableGfm: React.ElementType = ({ children }: { children: Rea
return (
<code
onDoubleClick={handleDoubleClick}
className="rounded-md bg-surface-primary-alt p-1 text-xs text-text-secondary md:text-sm"
className="bg-surface-primary-alt text-text-secondary rounded-md p-1 text-xs md:text-sm"
>
{children}
</code>
@ -21,7 +21,7 @@ const highlightVariables = (text: string): React.ReactNode[] => {
return (
<b
key={index}
className="ml-[0.5] rounded-lg bg-amber-100 p-[1px] font-medium text-text-warning dark:bg-transparent"
className="bg-status-warning-subtle text-text-warning ml-[0.5] rounded-lg p-[1px] font-medium"
>
{`{{${part}}}`}
</b>

View file

@ -74,10 +74,10 @@ export default function SharePointPickerDialog({
{/* SharePoint iframe will be injected here by the hook */}
{isDownloading && (
<div className="absolute inset-0 z-10 flex items-center justify-center rounded-lg bg-black/30 backdrop-blur-xs">
<div className="bg-surface-overlay/30 absolute inset-0 z-10 flex items-center justify-center rounded-lg backdrop-blur-xs">
<div className="bg-surface-primary mx-4 w-full max-w-sm rounded-lg p-6 shadow-lg">
<div className="text-center">
<div className="mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-b-2 border-blue-600"></div>
<div className="border-status-info mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-b-2"></div>
<h3 className="text-text-primary mb-2 text-lg font-semibold">
{localize('com_files_downloading')}
</h3>
@ -96,7 +96,7 @@ export default function SharePointPickerDialog({
)}
<div className="bg-surface-tertiary h-2 w-full rounded-full">
<div
className="h-2 rounded-full bg-blue-600 transition-all duration-300"
className="bg-status-info h-2 rounded-full transition-all duration-300"
style={{
width: `${Math.round((downloadProgress.completed / downloadProgress.total) * 100)}%`,
}}

View file

@ -39,20 +39,20 @@ export default function PrincipalAvatar({
case PrincipalType.USER:
return {
Icon: User,
containerClass: 'bg-blue-100 dark:bg-blue-900',
iconClass: 'text-blue-600 dark:text-blue-400',
containerClass: 'bg-series-1/15',
iconClass: 'text-series-1',
};
case PrincipalType.GROUP:
return {
Icon: Users,
containerClass: 'bg-green-100 dark:bg-green-900',
iconClass: 'text-green-600 dark:text-green-400',
containerClass: 'bg-series-7/15',
iconClass: 'text-series-7',
};
case PrincipalType.ROLE:
return {
Icon: Shield,
containerClass: 'bg-purple-100 dark:bg-purple-900',
iconClass: 'text-purple-600 dark:text-purple-400',
containerClass: 'bg-series-6/15',
iconClass: 'text-series-6',
};
default:
return {

View file

@ -66,7 +66,7 @@ export default function AgentTool({
return (
<OGDialog>
<div
className="group relative flex w-full items-center gap-1 rounded-lg p-1 text-sm hover:bg-gray-50 dark:hover:bg-gray-800/50"
className="group hover:bg-surface-secondary relative flex w-full items-center gap-1 rounded-lg p-1 text-sm"
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
onFocus={() => setIsFocused(true)}
@ -81,7 +81,7 @@ export default function AgentTool({
<div className="flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full">
{currentTool.icon ? (
<div
className="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full bg-center bg-no-repeat dark:bg-white/20"
className="bg-surface-tertiary flex h-6 w-6 items-center justify-center overflow-hidden rounded-full bg-center bg-no-repeat"
style={{
backgroundImage: `url(${currentTool.icon})`,
backgroundSize: 'cover',

View file

@ -27,7 +27,7 @@ function RowIcon({ item }: { item: AgentItem }) {
if (iconUrl && !imgError) {
return (
<span
className="flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-md bg-white"
className="bg-surface-fixed flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-md"
aria-hidden="true"
>
<img
@ -59,24 +59,24 @@ function ToolRowImpl({ item, onInfo, onRemove }: Props) {
const DetailIcon = configurable ? Settings : Info;
return (
<div className="group relative flex w-full items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-surface-secondary">
<div className="group hover:bg-surface-secondary relative flex w-full items-center gap-2 rounded-lg px-2 py-1.5">
<div className="flex min-w-0 flex-1 items-center gap-2.5">
<RowIcon item={item} />
<span className="flex min-w-0 items-center gap-1 truncate text-sm text-text-primary">
<span className="text-text-primary flex min-w-0 items-center gap-1 truncate text-sm">
<span className="truncate font-medium">{displayName}</span>
{suffix && <span className="text-text-secondary">{suffix}</span>}
</span>
</div>
{item.status === 'needs_setup' && (
<span role="status" className="flex shrink-0 items-center">
<span className="size-1.5 rounded-full bg-red-500" aria-hidden="true" />
<span className="bg-status-error size-1.5 rounded-full" aria-hidden="true" />
<span className="sr-only">{localize('com_ui_tools_needs_setup')}</span>
</span>
)}
<div
className={cn(
'flex shrink-0 items-center gap-0.5',
'group-focus-within:opacity-100 group-hover:opacity-100 no-touch:opacity-0',
'no-touch:opacity-0 group-focus-within:opacity-100 group-hover:opacity-100',
)}
>
<Button
@ -87,7 +87,7 @@ function ToolRowImpl({ item, onInfo, onRemove }: Props) {
configurable ? localize('com_ui_tools_configure') : localize('com_ui_tools_info')
}
className={cn(
'rounded-md text-text-secondary',
'text-text-secondary rounded-md',
'hover:text-text-secondary focus-visible:opacity-100',
)}
>
@ -99,7 +99,7 @@ function ToolRowImpl({ item, onInfo, onRemove }: Props) {
onClick={() => onRemove(item)}
aria-label={localize('com_ui_tools_remove')}
className={cn(
'rounded-md text-text-secondary',
'text-text-secondary rounded-md',
'hover:text-text-secondary focus-visible:opacity-100',
)}
>

View file

@ -13,10 +13,10 @@ describe('getIconForItem', () => {
};
const result = getIconForItem(item);
expect(result.Icon).toBeDefined();
expect(result.colorClass).toMatch(/emerald|green/);
expect(result.colorClass).toMatch(/series-7/);
});
test('returns the Brain icon + indigo color for built-in memory', () => {
test('returns the Brain icon + series color for built-in memory', () => {
const item: AgentItem = {
kind: 'builtin',
id: 'memory',
@ -26,7 +26,7 @@ describe('getIconForItem', () => {
};
const result = getIconForItem(item);
expect(result.Icon).toBeDefined();
expect(result.colorClass).toMatch(/indigo/);
expect(result.colorClass).toMatch(/series-8/);
});
test('returns a distinct color class per kind', () => {

View file

@ -24,54 +24,54 @@ export interface ItemIcon {
const BUILTIN_ICONS: Record<string, ItemIcon> = {
execute_code: {
Icon: Code,
colorClass: 'bg-emerald-500/15 text-emerald-600 dark:text-emerald-300',
colorClass: 'bg-series-7/15 text-series-7',
},
web_search: {
Icon: Globe,
colorClass: 'bg-blue-500/15 text-blue-600 dark:text-blue-300',
colorClass: 'bg-series-1/15 text-series-1',
},
artifacts: {
Icon: Sparkles,
colorClass: 'bg-purple-500/15 text-purple-600 dark:text-purple-300',
colorClass: 'bg-series-6/15 text-series-6',
},
context: {
Icon: FileText,
colorClass: 'bg-amber-500/15 text-amber-600 dark:text-amber-300',
colorClass: 'bg-series-4/15 text-series-4',
},
file_search: {
Icon: FileSearch,
colorClass: 'bg-pink-500/15 text-pink-600 dark:text-pink-300',
colorClass: 'bg-series-5/15 text-series-5',
},
memory: {
Icon: Brain,
colorClass: 'bg-indigo-500/15 text-indigo-600 dark:text-indigo-300',
colorClass: 'bg-series-8/15 text-series-8',
},
ask_user_question: {
Icon: MessageCircleQuestion,
colorClass: 'bg-teal-500/15 text-teal-600 dark:text-teal-300',
colorClass: 'bg-series-3/15 text-series-3',
},
};
const KIND_FALLBACK_ICONS: Record<AgentItem['kind'], ItemIcon> = {
builtin: {
Icon: Layers,
colorClass: 'bg-emerald-500/15 text-emerald-600 dark:text-emerald-300',
colorClass: 'bg-series-7/15 text-series-7',
},
tool: {
Icon: Wrench,
colorClass: 'bg-sky-500/15 text-sky-600 dark:text-sky-300',
colorClass: 'bg-series-1/15 text-series-1',
},
mcp: {
Icon: Server,
colorClass: 'bg-violet-500/15 text-violet-600 dark:text-violet-300',
colorClass: 'bg-series-6/15 text-series-6',
},
skill: {
Icon: Zap,
colorClass: 'bg-amber-500/15 text-amber-600 dark:text-amber-300',
colorClass: 'bg-series-4/15 text-series-4',
},
action: {
Icon: Workflow,
colorClass: 'bg-rose-500/15 text-rose-600 dark:text-rose-300',
colorClass: 'bg-series-2/15 text-series-2',
},
};

View file

@ -118,7 +118,7 @@ export default function ActionsPanel({
type="button"
disabled={!(assistant_id ?? '') || !action.action_id}
aria-label={localize('com_ui_delete_action')}
className="border-border-light hover:bg-surface-secondary focus-visible:ring-ring-primary inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border text-red-500 transition-colors focus:outline-hidden focus-visible:ring-2 disabled:opacity-50"
className="border-border-light hover:bg-surface-secondary focus-visible:ring-ring-primary text-text-destructive inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border transition-colors focus:outline-hidden focus-visible:ring-2 disabled:opacity-50"
>
<TrashIcon className="h-4 w-4" />
</button>

View file

@ -45,7 +45,7 @@ export default function AppendDateCheckbox({ control, setValue }: AppendDateChec
/>
)}
/>
<div className="flex items-center space-x-2">
<div className="text-text-tertiary flex items-center space-x-2">
<label
id="append-date-label"
htmlFor="append_current_datetime"
@ -55,7 +55,7 @@ export default function AppendDateCheckbox({ control, setValue }: AppendDateChec
</label>
<HoverCardTrigger>
<CircleHelpIcon
className="h-5 w-5 text-gray-500"
className="h-5 w-5"
aria-label={localize('com_assistants_append_date_tooltip')}
/>
</HoverCardTrigger>
@ -63,7 +63,7 @@ export default function AppendDateCheckbox({ control, setValue }: AppendDateChec
<HoverCardPortal>
<HoverCardContent side={ESide.Top} className="w-80">
<div className="space-y-2">
<p className="text-sm text-gray-600 dark:text-gray-300">
<p className="text-text-secondary text-sm">
{localize('com_assistants_append_date_tooltip')}
</p>
</div>

View file

@ -41,7 +41,7 @@ import Action from './Action';
const labelClass = 'mb-2 text-text-primary block font-medium';
const inputClass = cn(
defaultTextProps,
'flex w-full px-3 py-2 dark:border-gray-800 dark:bg-gray-800 rounded-xl mb-2',
'flex w-full px-3 py-2 bg-surface-secondary rounded-xl mb-2',
removeFocusOutlines,
);
@ -293,7 +293,7 @@ export default function AssistantPanel({
</button>
)}
</div>
<div className="bg-surface-primary h-auto px-4 pt-3 pb-8 dark:bg-transparent">
<div className="bg-surface-primary h-auto px-4 pt-3 pb-8">
{/* Avatar & Name */}
<div className="mb-4">
<AssistantAvatar

View file

@ -259,24 +259,19 @@ export default function AssistantSelect({
showLabel={false}
emptyTitle={true}
containerClassName="grow"
searchClassName="dark:from-gray-850"
searchPlaceholder={localize('com_assistants_search_name')}
optionsClass="hover:bg-gray-20/50 dark:border-gray-700"
optionsListClass="rounded-lg shadow-lg dark:bg-gray-850 dark:border-gray-700 dark:last:border"
currentValueClass={cn(
'text-base font-semibold text-gray-900 dark:text-white',
value === '' ? 'text-gray-500' : '',
)}
optionsListClass="rounded-lg shadow-lg dark:last:border"
currentValueClass="text-base font-semibold"
className={cn(
'dark:bg-gray-850 mt-1 rounded-md dark:border-gray-700',
'z-50 flex h-[40px] w-full flex-none items-center justify-center px-4 hover:cursor-pointer hover:border-green-500 focus:border-gray-400',
'mt-1 rounded-md',
'z-50 flex h-[40px] w-full flex-none items-center justify-center px-4 hover:cursor-pointer',
)}
renderOption={() => (
<span className="flex items-center gap-1.5 truncate">
<span className="absolute inset-y-0 left-0 flex items-center pl-2 text-gray-800 dark:text-gray-100">
<span className="text-text-primary absolute inset-y-0 left-0 flex items-center pl-2">
<Plus className="w-[16px]" />
</span>
<span className={cn('ml-4 flex h-6 items-center gap-1 text-gray-800 dark:text-gray-100')}>
<span className={cn('text-text-primary ml-4 flex h-6 items-center gap-1')}>
{createAssistant}
</span>
</span>

View file

@ -65,7 +65,7 @@ export default function AssistantTool({
{currentTool.icon && (
<div className="flex h-9 w-9 items-center justify-center overflow-hidden rounded-full">
<div
className="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full bg-center bg-no-repeat dark:bg-white/20"
className="bg-surface-tertiary flex h-6 w-6 items-center justify-center overflow-hidden rounded-full bg-center bg-no-repeat"
style={{ backgroundImage: `url(${currentTool.icon})`, backgroundSize: 'cover' }}
/>
</div>
@ -82,7 +82,7 @@ export default function AssistantTool({
<OGDialogTrigger asChild>
<button
type="button"
className="flex h-9 w-9 min-w-9 items-center justify-center rounded-lg transition-colors duration-200 hover:bg-gray-200 dark:hover:bg-gray-700"
className="hover:bg-surface-hover flex h-9 w-9 min-w-9 items-center justify-center rounded-lg transition-colors duration-200"
>
<TrashIcon />
</button>

View file

@ -37,7 +37,7 @@ export default function Code({ version }: { version: number | string }) {
/>
<button
type="button"
className="flex items-center space-x-2"
className="text-text-tertiary flex items-center space-x-2"
onClick={() =>
setValue(Capabilities.code_interpreter, !getValues(Capabilities.code_interpreter), {
shouldDirty: true,
@ -52,13 +52,13 @@ export default function Code({ version }: { version: number | string }) {
{localize('com_assistants_code_interpreter')}
</label>
<HoverCardTrigger>
<CircleHelpIcon className="h-5 w-5 text-gray-500" />
<CircleHelpIcon className="h-5 w-5" />
</HoverCardTrigger>
</button>
<HoverCardPortal>
<HoverCardContent side={ESide.Top} className="w-80">
<div className="space-y-2">
<p className="text-sm text-gray-600 dark:text-gray-300">
<p className="text-text-secondary text-sm">
{version == 2 && localize('com_assistants_code_interpreter_info')}
</p>
</div>

View file

@ -94,7 +94,7 @@ export default function ContextButton({
)}
type="button"
>
<div className="flex w-full items-center justify-center gap-2 text-red-500">
<div className="text-text-destructive flex w-full items-center justify-center gap-2">
<TrashIcon />
</div>
</button>

View file

@ -55,7 +55,7 @@ export default function Retrieval({
/>
)}
/>
<div className="flex items-center space-x-2">
<div className="text-text-tertiary flex items-center space-x-2">
<label
id={Capabilities.retrieval}
className={cn(
@ -75,13 +75,13 @@ export default function Retrieval({
: localize('com_assistants_file_search')}
</label>
<HoverCardTrigger>
<CircleHelpIcon className="h-5 w-5 text-gray-500" />
<CircleHelpIcon className="h-5 w-5" />
</HoverCardTrigger>
</div>
<HoverCardPortal>
<HoverCardContent side={ESide.Top} disabled={isDisabled} className="ml-16 w-80">
<div className="space-y-2">
<p className="text-sm text-gray-600 dark:text-gray-300">
<p className="text-text-secondary text-sm">
{version == 2 && localize('com_assistants_file_search_info')}
</p>
</div>

View file

@ -109,7 +109,6 @@ export default function SkillFileEditor({ skillId, nodeId, fileName }: SkillFile
className={cn(
'text-text-primary size-full resize-none rounded-none border-0 bg-transparent px-4 py-3 font-mono text-[13px] leading-6',
'focus-visible:ring-ring-primary focus:ring-0 focus:ring-offset-0 focus-visible:ring-2 focus-visible:ring-inset',
'selection:bg-blue-500/20',
)}
aria-label={`${localize('com_ui_edit')} ${fileName}`}
/>

View file

@ -0,0 +1,351 @@
import { randomUUID } from 'crypto';
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import type { IThemeRGB } from '../../../../packages/client/src/theme/types';
import {
deleteConversations,
deleteMessagesByConversation,
seedConversations,
withMongo,
} from '../db';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
import { openAgentBuilder, uniqueAgentName, cleanupAgent } from '../agents.helpers';
import { MOCK_ENDPOINTS, getAccessToken, requestJson } from '../helpers';
import { getE2EUser } from '../../../setup/user';
import { probeStyle } from './style.helpers';
/**
* The builder, tools, sharing and message surfaces used to paint with palette
* utilities and `dark:` twins, which no theme reaches. Each scenario hands the
* app the ClickHouse reference definition and reads what the browser paints,
* comparing it with the value the definition sets for the role the surface
* should use, in both modes.
*/
type Mode = 'light' | 'dark';
type Rgb = [number, number, number];
const MODES: Mode[] = ['light', 'dark'];
const THEME_PARAM = 'e2eThemeMode';
const WCAG_AA_NORMAL = 4.5;
const CODE_INPUT = 'print(21 * 2)';
const CODE_LOGS = 'forty-two-result';
async function installThemeBridge(page: Page) {
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');
localStorage.setItem('theme-definition', JSON.stringify(stored));
localStorage.setItem('theme-source', 'definition');
}, clickHouseTheme);
}
const colorsFor = (mode: Mode): IThemeRGB => clickHouseTheme.modes[mode]?.colors ?? {};
const rgbCss = (triplet: string | undefined) => `rgb(${(triplet ?? '').split(' ').join(', ')})`;
function parseRgb(value: string): Rgb {
const channels = value.match(/\d+(\.\d+)?/g)?.map(Number) ?? [];
return [channels[0], channels[1], channels[2]];
}
function channel(value: number): number {
const c = value / 255;
return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
}
function contrast(a: Rgb, b: Rgb): number {
const luminance = ([r, g, b]: Rgb) =>
0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
const [lighter, darker] = [luminance(a), luminance(b)].sort((x, y) => y - x);
return (lighter + 0.05) / (darker + 0.05);
}
const painted = (locator: Locator) =>
locator.evaluate((node) => {
const style = getComputedStyle(node);
return { color: style.color, background: style.backgroundColor };
});
async function createAgent(page: Page, name: string, tools: string[]): Promise<string> {
const token = await getAccessToken(page);
const agent = await requestJson<{ id: string }>(page, {
path: '/api/agents',
token,
method: 'POST',
body: {
name,
provider: MOCK_ENDPOINTS[0].label,
model: MOCK_ENDPOINTS[0].model,
tools,
},
});
return agent.id;
}
async function selectAgentInBuilder(page: Page, name: string) {
const form = await openAgentBuilder(page);
await form.getByRole('combobox', { name: 'Agent', exact: true }).click();
await page.getByRole('option', { name, exact: true }).click();
await expect(form.getByLabel('Agent name')).toHaveValue(name);
return form;
}
async function seedCodeAnalysis(title: string, logs?: string): Promise<string> {
const conversationId = randomUUID();
const { email } = getE2EUser();
await seedConversations(email, [{ conversationId, title, updatedAt: new Date() }]);
await withMongo(async (db) => {
const user = await db.collection('users').findOne({ email });
const userId = String(user?._id);
const userMessageId = randomUUID();
const now = Date.now();
await db.collection('messages').insertMany([
{
messageId: userMessageId,
parentMessageId: '00000000-0000-0000-0000-000000000000',
conversationId,
user: userId,
endpoint: 'agents',
text: 'Run the numbers',
isCreatedByUser: true,
sender: 'User',
error: false,
unfinished: false,
createdAt: new Date(now),
updatedAt: new Date(now),
__v: 0,
},
{
messageId: randomUUID(),
parentMessageId: userMessageId,
conversationId,
user: userId,
endpoint: 'agents',
text: '',
isCreatedByUser: false,
sender: 'Mock Provider A',
error: false,
unfinished: false,
content: [
{
type: 'tool_call',
tool_call: {
id: `ci-${conversationId}`,
type: 'code_interpreter',
progress: 1,
code_interpreter: {
input: CODE_INPUT,
outputs: logs == null ? [] : [{ type: 'logs', logs }],
},
},
},
{ type: 'text', text: 'Done.' },
],
createdAt: new Date(now + 1000),
updatedAt: new Date(now + 1000),
__v: 0,
},
]);
});
return conversationId;
}
async function openCodeAnalysis(page: Page, conversationId: string, mode: Mode) {
await page.goto(`/c/${conversationId}?${THEME_PARAM}=${mode}`);
await expect(page.locator('html')).toHaveClass(new RegExp(`\\b${mode}\\b`));
await page.getByRole('button', { name: 'Finished analyzing' }).first().click();
const block = page.locator('.code-analyze-block').first();
await expect(block).toBeVisible({ timeout: 20000 });
return block;
}
test.describe('semantic colour roles on builder, tools and sharing surfaces', () => {
test('agent tool rows paint their icon chips with the theme series roles @scenario:agent-tool-row-chips-follow-theme-series-roles', async ({
page,
}) => {
test.setTimeout(120000);
await installThemeBridge(page);
await page.goto('/c/new');
const name = uniqueAgentName('Theme Tool Rows');
const agentId = await createAgent(page, name, ['execute_code', 'file_search']);
try {
for (const mode of MODES) {
await page.goto(`/c/new?${THEME_PARAM}=${mode}`);
const form = await selectAgentInBuilder(page, name);
const colors = colorsFor(mode);
const runCode = form.getByText('Run Code', { exact: true }).first();
await expect(runCode).toBeVisible();
const chip = runCode
.locator('xpath=ancestor::div[contains(@class,"group")][1]')
.locator('span[aria-hidden="true"]')
.first();
const chipPaint = await painted(chip);
expect(chipPaint.color).toBe(rgbCss(colors['rgb-series-7']));
expect(chipPaint.background).toBe(
await probeStyle(page, 'bg-series-7/15', 'background-color'),
);
const fileSearch = form.getByText('File Search', { exact: true }).first();
const fileChip = fileSearch
.locator('xpath=ancestor::div[contains(@class,"group")][1]')
.locator('span[aria-hidden="true"]')
.first();
expect((await painted(fileChip)).color).toBe(rgbCss(colors['rgb-series-5']));
}
} finally {
await cleanupAgent(page, agentId);
}
});
test('the share dialog paints a user principal with the theme series role @scenario:share-dialog-user-avatar-follows-theme-series-role', async ({
page,
}) => {
test.setTimeout(120000);
await installThemeBridge(page);
await page.goto('/c/new');
const name = uniqueAgentName('Theme Share Avatar');
const agentId = await createAgent(page, name, []);
try {
for (const mode of MODES) {
await page.goto(`/c/new?${THEME_PARAM}=${mode}`);
await selectAgentInBuilder(page, name);
await page.getByRole('button', { name: `Share ${name}` }).click();
const dialog = page.getByRole('dialog').filter({ hasText: `Share ${name}` });
await expect(dialog).toBeVisible();
const icon = dialog.locator('svg.lucide-user').first();
await expect(icon).toBeVisible();
const colors = colorsFor(mode);
expect((await painted(icon)).color).toBe(rgbCss(colors['rgb-series-1']));
const container = icon.locator('xpath=..');
expect((await painted(container)).background).toBe(
await probeStyle(page, 'bg-series-1/15', 'background-color'),
);
}
} finally {
await cleanupAgent(page, agentId);
}
});
test('a code-analysis block paints the theme code surface and keeps its output readable @scenario:code-analysis-block-follows-theme-code-surface', async ({
page,
}) => {
test.setTimeout(90000);
const conversationId = await seedCodeAnalysis('Theme code analysis', CODE_LOGS);
await installThemeBridge(page);
try {
for (const mode of MODES) {
const colors = colorsFor(mode);
const block = await openCodeAnalysis(page, conversationId, mode);
expect((await painted(block)).background).toBe(rgbCss(colors['rgb-surface-code']));
const output = block.getByText(CODE_LOGS, { exact: true });
await expect(output).toBeVisible();
const pane = block.getByText('Result', { exact: true }).locator('xpath=..');
const panePaint = await painted(pane);
expect(panePaint.background).toBe(rgbCss(colors['rgb-surface-tertiary']));
const outputColor = (await painted(output)).color;
expect(outputColor).toBe(rgbCss(colors['rgb-text-primary']));
expect(contrast(parseRgb(outputColor), parseRgb(panePaint.background))).toBeGreaterThan(
WCAG_AA_NORMAL,
);
}
} finally {
await deleteMessagesByConversation([conversationId]);
await deleteConversations([conversationId]);
}
});
test('a code-analysis block without output shows the code alone @scenario:code-analysis-block-without-output-has-no-result-pane', async ({
page,
}) => {
test.setTimeout(90000);
const conversationId = await seedCodeAnalysis('Theme code analysis empty');
await installThemeBridge(page);
try {
for (const mode of MODES) {
const colors = colorsFor(mode);
const block = await openCodeAnalysis(page, conversationId, mode);
expect((await painted(block)).background).toBe(rgbCss(colors['rgb-surface-code']));
await expect(block.getByText('print', { exact: false }).first()).toBeVisible();
await expect(block.getByText('Result', { exact: true })).toHaveCount(0);
}
} finally {
await deleteMessagesByConversation([conversationId]);
await deleteConversations([conversationId]);
}
});
test('a prompt variable paints the theme warning roles @scenario:prompt-variable-chip-follows-theme-warning-role', async ({
page,
}) => {
test.setTimeout(120000);
await installThemeBridge(page);
const groupIds: string[] = [];
try {
for (const mode of MODES) {
await page.goto(`/c/new?${THEME_PARAM}=${mode}`);
await expect(page.locator('html')).toHaveClass(new RegExp(`\\b${mode}\\b`));
const promptsButton = page.getByRole('button', { name: 'Prompts', exact: true });
if ((await promptsButton.getAttribute('aria-pressed')) !== 'true') {
await promptsButton.click();
}
/** Prompts open on their own page only from inside the app, and creating
* one is the path that lands there. */
await page.getByRole('button', { name: 'Create Prompt' }).click();
const dialog = page.getByRole('dialog');
await expect(dialog).toBeVisible();
await dialog
.getByRole('textbox', { name: 'Prompt Name' })
.fill(`Theme variable ${mode} ${randomUUID().slice(0, 8)}`);
await dialog
.getByRole('textbox', { name: 'Prompt text input field' })
.fill('Summarize {{topic}} for the team.');
const [created] = await Promise.all([
page.waitForResponse(
(response) =>
response.request().method() === 'POST' &&
new URL(response.url()).pathname === '/api/prompts' &&
response.ok(),
{ timeout: 30000 },
),
dialog.getByRole('button', { name: 'Create Prompt' }).click(),
]);
const body = (await created.json()) as { group?: { _id: string } };
const groupId = body.group?._id ?? '';
expect(groupId).not.toBe('');
groupIds.push(groupId);
await expect(page).toHaveURL(new RegExp(`/prompts/${groupId}$`));
const chip = page.locator('b').filter({ hasText: '{{topic}}' }).first();
await expect(chip).toBeVisible({ timeout: 20000 });
const colors = colorsFor(mode);
const chipPaint = await painted(chip);
expect(chipPaint.background).toBe(rgbCss(colors['rgb-status-warning-subtle']));
expect(chipPaint.color).toBe(rgbCss(colors['rgb-text-warning']));
}
} finally {
const token = await getAccessToken(page);
for (const groupId of groupIds) {
await requestJson<{ message?: string }>(page, {
path: `/api/prompts/groups/${encodeURIComponent(groupId)}`,
token,
method: 'DELETE',
});
}
}
});
});

View file

@ -149,11 +149,13 @@ test.describe('Tailwind v4 rendering', () => {
expect(bare).not.toBe(inherited);
/** And v4 would paint a placeholder as the field's own colour at half
* opacity. The app restores gray-400, which `text-gray-400` paints from the
* same CSS. The composer sets its own `placeholder:` role, so the probe is
* a plain field — which is what the preflight rule governs. */
* opacity. The app restores gray-400, read from the root `--gray-400`
* triplet for the same reason as the border: no source writes
* `text-gray-400` any more, so a probe carrying it generates no CSS. The
* composer sets its own `placeholder:` role, so the probe is a plain
* field, which is what the preflight rule governs. */
const placeholder = await probePlaceholderColor(page);
const gray400 = await probeStyle(page, 'text-gray-400', 'color');
const gray400 = await normalizeColor(page, `rgb(${await themeValue(page, '--gray-400')})`);
const body = await probeStyle(page, '', 'color');
expect(placeholder).toBe(gray400);
expect(placeholder).not.toBe(body);

View file

@ -304,11 +304,8 @@
}
},
"client/src/components/Chat/Input/Files/Table/Columns.tsx": {
"shadcn/no-raw-colors": {
"count": 3
},
"shadcn/no-restyle": {
"count": 23
"count": 21
}
},
"client/src/components/Chat/Input/Files/Table/DataTable.tsx": {
@ -325,9 +322,6 @@
}
},
"client/src/components/Chat/Input/InFlightSteers.tsx": {
"shadcn/no-raw-colors": {
"count": 1
},
"shadcn/no-unknown-classes": {
"count": 1
},
@ -554,14 +548,6 @@
"count": 10
}
},
"client/src/components/Chat/Messages/Content/CodeAnalyze.tsx": {
"shadcn/no-inline-styles": {
"count": 1
},
"shadcn/no-raw-colors": {
"count": 2
}
},
"client/src/components/Chat/Messages/Content/Container.tsx": {
"shadcn/no-raw-colors": {
"count": 1
@ -1695,9 +1681,6 @@
"client/src/components/Prompts/editor/Markdown.tsx": {
"shadcn/no-arbitrary-values": {
"count": 1
},
"shadcn/no-raw-colors": {
"count": 1
}
},
"client/src/components/Prompts/editor/PromptEditor.tsx": {
@ -1808,9 +1791,6 @@
}
},
"client/src/components/SharePoint/SharePointPickerDialog.tsx": {
"shadcn/no-raw-colors": {
"count": 2
},
"shadcn/no-restyle": {
"count": 6
}
@ -1922,9 +1902,6 @@
"shadcn/no-inline-styles": {
"count": 5
},
"shadcn/no-raw-colors": {
"count": 2
},
"shadcn/no-restyle": {
"count": 9
}
@ -2082,9 +2059,6 @@
}
},
"client/src/components/SidePanel/Agents/Tools/ToolRow.tsx": {
"shadcn/no-raw-colors": {
"count": 1
},
"shadcn/no-restyle": {
"count": 8
}
@ -2142,19 +2116,6 @@
"count": 4
}
},
"client/src/components/SidePanel/Builder/ActionsPanel.tsx": {
"shadcn/no-raw-colors": {
"count": 1
}
},
"client/src/components/SidePanel/Builder/AppendDateCheckbox.tsx": {
"shadcn/no-raw-colors": {
"count": 3
},
"shadcn/no-restyle": {
"count": 1
}
},
"client/src/components/SidePanel/Builder/AssistantConversationStarters.tsx": {
"shadcn/no-inline-styles": {
"count": 3
@ -2164,9 +2125,6 @@
}
},
"client/src/components/SidePanel/Builder/AssistantPanel.tsx": {
"shadcn/no-raw-colors": {
"count": 2
},
"shadcn/no-restyle": {
"count": 4
},
@ -2175,27 +2133,13 @@
}
},
"client/src/components/SidePanel/Builder/AssistantSelect.tsx": {
"shadcn/no-raw-colors": {
"count": 15
},
"shadcn/no-restyle": {
"count": 19
"count": 7
}
},
"client/src/components/SidePanel/Builder/AssistantTool.tsx": {
"shadcn/no-inline-styles": {
"count": 5
},
"shadcn/no-raw-colors": {
"count": 2
}
},
"client/src/components/SidePanel/Builder/Code.tsx": {
"shadcn/no-raw-colors": {
"count": 3
},
"shadcn/no-restyle": {
"count": 1
}
},
"client/src/components/SidePanel/Builder/CodeFiles.tsx": {
@ -2203,11 +2147,6 @@
"count": 1
}
},
"client/src/components/SidePanel/Builder/ContextButton.tsx": {
"shadcn/no-raw-colors": {
"count": 1
}
},
"client/src/components/SidePanel/Builder/Images.tsx": {
"shadcn/no-arbitrary-values": {
"count": 1
@ -2224,14 +2163,6 @@
"count": 1
}
},
"client/src/components/SidePanel/Builder/Retrieval.tsx": {
"shadcn/no-raw-colors": {
"count": 3
},
"shadcn/no-restyle": {
"count": 1
}
},
"client/src/components/SidePanel/Files/PanelColumns.tsx": {
"shadcn/no-restyle": {
"count": 4
@ -2446,11 +2377,8 @@
"shadcn/no-arbitrary-values": {
"count": 4
},
"shadcn/no-raw-colors": {
"count": 1
},
"shadcn/no-restyle": {
"count": 19
"count": 18
}
},
"client/src/components/Skills/tree/SkillFilePreview.tsx": {

View file

@ -29,19 +29,4 @@ const InputNumber: React.ForwardRefExoticComponent<
);
InputNumber.displayName = 'Input';
// console.log(_InputNumber);
// const InputNumber = React.forwardRef(({ className, ...props }, ref) => {
// return (
// <NumericFormat
// className={cn(
// 'flex h-10 w-full rounded-md border border-gray-300 bg-transparent py-2 px-3 text-sm placeholder:text-gray-400 focus:outline-hidden focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-700 dark:text-gray-50 dark:focus:ring-gray-400 dark:focus:ring-offset-gray-900',
// className
// )}
// ref={ref}
// {...props}
// />
// );
// });
export { InputNumber };