Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

📏 feat: Click UI Spacing and Mono Stack for the ClickHouse Theme (#16616)

Marco Beretta557038bd6be6
diff --git a/e2e/specs/mock/scenarios/clickhouse-spacing-mono.spec.ts b/e2e/specs/mock/scenarios/clickhouse-spacing-mono.spec.ts
new file mode 100644
index 0000000000..a27823b103
--- /dev/null
+++ b/e2e/specs/mock/scenarios/clickhouse-spacing-mono.spec.ts
@@ -0,0 +1,71 @@
+import { expect, test } from '@playwright/test';
+import type { Page } from '@playwright/test';
+import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
+import { NEW_CHAT_PATH } from '../helpers';
+import { probeStyle } from './style.helpers';
+
+/**
+ * The shared spacing and the mono stack under the default and ClickHouse themes. The default
+ * theme keeps its 6px compact and 12px normal spacing; ClickHouse takes Click UI's `spaces.2` and
+ * `spaces.3` (8px and 12px) and Click UI's mono stack verbatim.
+ */
+
+type Mode = 'light' | 'dark';
+
+async function openChat(page: Page, mode: Mode, definition?: { name: string }) {
+ await page.addInitScript(
+ ([colorTheme, stored]) => {
+ localStorage.setItem('color-theme', colorTheme as string);
+ localStorage.removeItem('theme-colors');
+ localStorage.removeItem('theme-name');
+ if (stored) {
+ localStorage.setItem('theme-definition', JSON.stringify(stored));
+ localStorage.setItem('theme-source', 'definition');
+ } else {
+ localStorage.removeItem('theme-definition');
+ localStorage.removeItem('theme-source');
+ }
+ },
+ [mode, definition ?? null] as [string, unknown],
+ );
+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
+ await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({
+ timeout: 30000,
+ });
+ await expect(page.locator('html')).toHaveClass(mode === 'dark' ? /\bdark\b/ : /\blight\b/);
+ if (definition) {
+ await expect(page.locator('html')).toHaveAttribute('data-theme', definition.name);
+ }
+}
+
+const spacing = async (page: Page) => ({
+ compact: await probeStyle(page, 'p-theme-compact', 'padding-top'),
+ normal: await probeStyle(page, 'p-theme-normal', 'padding-top'),
+});
+
+test.describe('ClickHouse spacing and mono stack', () => {
+ test('the default theme keeps its shared spacing in both modes @scenario:shared-spacing-default-unchanged', async ({
+ page,
+ }) => {
+ for (const mode of ['light', 'dark'] as const) {
+ const modePage = mode === 'light' ? page : await page.context().newPage();
+ await openChat(modePage, mode);
+
+ expect(await spacing(modePage)).toEqual({ compact: '6px', normal: '12px' });
+ }
+ });
+
+ test('the ClickHouse theme spaces and sets mono text from Click UI in both modes @scenario:clickhouse-spacing-and-mono-stack', async ({
+ page,
+ }) => {
+ for (const mode of ['light', 'dark'] as const) {
+ const modePage = mode === 'light' ? page : await page.context().newPage();
+ await openChat(modePage, mode, clickHouseTheme);
+
+ expect(await spacing(modePage)).toEqual({ compact: '8px', normal: '12px' });
+ expect(await probeStyle(modePage, 'font-mono', 'font-family')).toBe(
+ 'Inconsolata, Consolas, "SFMono Regular", monospace',
+ );
+ }
+ });
+});
diff --git a/e2e/specs/mock/scenarios/control-spacing.spec.ts b/e2e/specs/mock/scenarios/control-spacing.spec.ts
index d786c0b600..6b03595c2f 100644
--- a/e2e/specs/mock/scenarios/control-spacing.spec.ts
+++ b/e2e/specs/mock/scenarios/control-spacing.spec.ts
@@ -109,9 +109,10 @@ test.describe('theme control spacing', () => {
/** `button.basic.space.x` and `button.basic.space.gap`. */
expect(await spacing(chip)).toEqual({ paddingLeft: '16px', paddingRight: '16px', gap: '8px' });
- /** Message bubbles and the send button keep the shared spacing roles. */
+ /** Message bubbles keep `spaceNormal`, which Click UI's `spaces.3` matches, and the compact
+ * spacing takes `spaces.2`. */
expect(await bubblePadding(page)).toBe('12px');
- expect(await probeStyle(page, 'p-theme-compact', 'padding-top')).toBe('6px');
+ expect(await probeStyle(page, 'p-theme-compact', 'padding-top')).toBe('8px');
await leaveTemporaryChat(page);
});
diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.js
index c55a42d655..1af2f218e0 100644
--- a/packages/client/src/theme/tailwind.spec.js
+++ b/packages/client/src/theme/tailwind.spec.js
@@ -387,3 +387,47 @@ describe('radius, font and shadow scales', () => {
expect(defaultAppearance.elevationSurface).toBe(defaultAppearance.shadowLg);
});
});
+
+describe('Click UI spaces drawn by Tailwind steps', () => {
+ /** The steps of Click UI's `spaces` scale that no spacing role carries, each with the Tailwind
+ * spacing step the application draws at the same size. */
+ const steps = {
+ 'spaces.0': 0,
+ 'spaces.1': 1,
+ 'spaces.4': 4,
+ 'spaces.5': 6,
+ 'spaces.6': 8,
+ 'spaces.7': 10,
+ 'spaces.8': 16,
+ };
+
+ it('compiles each step to the Click UI space of the same size in every mode', async () => {
+ const snapshot = require('./themes/clickui.json');
+ const css = (
+ await generateApplication(Object.values(steps).map((step) => `p-${step}`))
+ ).replace(/\s+/g, ' ');
+ const base = /--spacing: ([0-9.]+)rem;/.exec(css)?.[1];
+
+ expect(base).toBe('0.25');
+ /** The size the last `.p-N` rule draws, in rem: `0px`, the base step, or a multiple of it. */
+ const drawn = (step) => {
+ const rules = [...css.matchAll(new RegExp(`\\.p-${step} \\{ padding: ([^;]+); \\}`, 'g'))];
+ const value = rules.at(-1)?.[1];
+ if (value === '0px') {
+ return 0;
+ }
+ if (value === 'var(--spacing)') {
+ return Number(base);
+ }
+ const multiple = /^calc\(var\(--spacing\) \* ([0-9.]+)\)$/.exec(value ?? '')?.[1];
+ return multiple === undefined ? undefined : Number(multiple) * Number(base);
+ };
+ Object.entries(steps).forEach(([token, step]) => {
+ ['light', 'dark'].forEach((mode) => {
+ const source = snapshot[mode][token];
+ const rem = source === '0' ? 0 : parseFloat(source);
+ expect([token, mode, drawn(step)]).toEqual([token, mode, rem]);
+ });
+ });
+ });
+});
diff --git a/packages/client/src/theme/themes/clickhouse.spec.tsx b/packages/client/src/theme/themes/clickhouse.spec.tsx
index 992958bb55..4f29c10f56 100644
--- a/packages/client/src/theme/themes/clickhouse.spec.tsx
+++ b/packages/client/src/theme/themes/clickhouse.spec.tsx
@@ -320,8 +320,8 @@ describe('clickhouse theme definition', () => {
roundControlRadius: '9999px',
});
expect(resolved.appearance.fontFamily).toMatch(/^"Inter", "SF Pro Display"/);
- expect(resolved.appearance.monoFontFamily).toMatch(
- /^"Inconsolata", ui-monospace, .*monospace$/,
+ expect(resolved.appearance.monoFontFamily).toBe(
+ '"Inconsolata", Consolas, "SFMono Regular", monospace',
);
/** Click UI's `border.radii` 1, 2 and 3. */
expect(resolved.appearance).toMatchObject({
@@ -379,10 +379,9 @@ describe('clickhouse theme definition', () => {
).toEqual([]);
});
- /** Click UI's control height, button padding and gap, and `transition.default`. The shared
- * spacing roles keep LibreChat's values: they also pad message bubbles and the composer's send
- * button, and 0.75rem is already Click UI's field padding. */
- it('sizes theme controls from Click UI and leaves the shared spacing alone', () => {
+ /** Click UI's control height, button padding and gap, `transition.default`, and the two steps of
+ * its `spaces` scale the shared spacing takes. */
+ it('sizes theme controls and the shared spacing from Click UI', () => {
const { appearance } = resolveTheme(clickHouseTheme, 'light');
expect(appearance).toMatchObject({
controlHeight: '2rem',
@@ -393,7 +392,7 @@ describe('clickhouse theme definition', () => {
buttonHeightSm: '2rem',
motionFast: '100ms',
});
- expect(appearance.spaceCompact).toBe(defaultAppearance.spaceCompact);
+ expect(appearance.spaceCompact).toBe('0.5rem');
expect(appearance.spaceNormal).toBe(defaultAppearance.spaceNormal);
});
diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.ts
index a04deb746e..992877c78e 100644
--- a/packages/client/src/theme/themes/clickhouse.ts
+++ b/packages/client/src/theme/themes/clickhouse.ts
@@ -358,8 +358,8 @@ export const clickHouseDarkTheme: IThemeRGB = {
* `radii.1`, which LibreChat's `sm` also renders at on a 16px root; every larger step tightens.
*
* Click UI's mono family is Inconsolata, which the component library ships in `theme/fonts.css`
- * (latin 400 and 700). The tail is the same metric-matched stack the default theme uses (Click
- * UI's own tail names `"SFMono Regular"`, which no platform installs).
+ * (latin 400 and 700), and the stack is Click UI's verbatim. Its `"SFMono Regular"` matches no
+ * installed face, so where Inconsolata has no glyph a browser falls to Consolas or `monospace`.
*
* Click UI's display family leads with Basier Square, a commercial face ClickHouse licenses for
* its own sites. It is named here but not self-hosted: a browser that has it installed renders
@@ -390,8 +390,7 @@ const clickHouseShape = {
radius3xl: '0.75rem', // border.radii.3
fontFamily:
'"Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif',
- monoFontFamily:
- '"Inconsolata", ui-monospace, SFMono-Regular, Menlo, "Cascadia Mono", "Liberation Mono", Consolas, monospace',
+ monoFontFamily: '"Inconsolata", Consolas, "SFMono Regular", monospace', // typography.font.families.mono
displayFontFamily:
'\'Basier Square\', "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif', // typography.font.families.display
textXs: '0.75rem', // typography.font.sizes.1
@@ -453,6 +452,10 @@ const clickHouseShape = {
switchHeight: '1rem', // switch.size.height
/** Click UI's own sizes halve like LibreChat's: `md` is this full space, and the compact tables
* every in-repo consumer draws land on `sm` (0.5rem), the size Click UI tables default to. */
+ /** The shared spacing takes two steps of Click UI's `spaces` scale: its 0.5rem gap step, the
+ * one its buttons and fields space icon and label by, and 0.75rem, which already matched. */
+ spaceCompact: '0.5rem', // spaces.2
+ spaceNormal: '0.75rem', // spaces.3
tableCellSpaceY: '1rem', // table.body.cell.space.md.y
tableRowStroke: '1px', // table.cell.stroke
motionFast: '100ms', // transition.duration.medium, the step transition.default runs at
diff --git a/packages/client/src/theme/themes/clickui.json b/packages/client/src/theme/themes/clickui.json
index bbe6731ebc..34700a82d5 100644
--- a/packages/client/src/theme/themes/clickui.json
+++ b/packages/client/src/theme/themes/clickui.json
@@ -126,6 +126,15 @@
"palette.warning.700": "#a33c00",
"shadow.1": "0 4px 6px -1px lch(6.7738 0 none / 0.15), 0 2px 4px -1px lch(6.7738 0 none / 0.15)",
"shadow.5": "0 2px 2px 0 rgba(0, 0, 0, 0.03)",
+ "spaces.0": "0",
+ "spaces.1": "0.25rem",
+ "spaces.2": "0.5rem",
+ "spaces.3": "0.75rem",
+ "spaces.4": "1rem",
+ "spaces.5": "1.5rem",
+ "spaces.6": "2rem",
+ "spaces.7": "2.5rem",
+ "spaces.8": "4rem",
"transition.duration.medium": "100ms",
"transition.duration.smooth": "150ms",
"typography.font.families.display": "'Basier Square', \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",
@@ -258,6 +267,15 @@
"palette.warning.700": "#a33c00",
"shadow.1": "0 4px 6px -1px rgb(8.2353% 8.2353% 8.2353% / 0.6), 0 2px 4px -1px rgb(8.2353% 8.2353% 8.2353% / 0.6)",
"shadow.5": "0 2px 2px 0 rgba(0, 0, 0, 0.03)",
+ "spaces.0": "0",
+ "spaces.1": "0.25rem",
+ "spaces.2": "0.5rem",
+ "spaces.3": "0.75rem",
+ "spaces.4": "1rem",
+ "spaces.5": "1.5rem",
+ "spaces.6": "2rem",
+ "spaces.7": "2.5rem",
+ "spaces.8": "4rem",
"transition.duration.medium": "100ms",
"transition.duration.smooth": "150ms",
"typography.font.families.display": "'Basier Square', \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",
diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.ts
index efa2604f3f..bf8f3e8d9b 100644
--- a/packages/client/src/theme/themes/clickui.spec.ts
+++ b/packages/client/src/theme/themes/clickui.spec.ts
@@ -560,6 +560,8 @@ const appearanceSources: Partial<Record<keyof IThemeAppearance, string>> = {
largeSurfaceRadius: 'border.radii.3',
radius3xl: 'border.radii.3',
roundControlRadius: 'border.radii.full',
+ spaceCompact: 'spaces.2',
+ spaceNormal: 'spaces.3',
menuRadius: 'click.genericMenu.panel.radii.all',
tooltipRadius: 'click.tooltip.radii.all',
tabRadius: 'click.tabs.radii.all',
@@ -613,6 +615,26 @@ const appearanceSources: Partial<Record<keyof IThemeAppearance, string>> = {
motionNormal: 'transition.duration.smooth',
};
+/**
+ * Click UI's spacing scale, each step with the LibreChat surface that draws it: a spacing role
+ * the theme sets, or the Tailwind spacing step of the same size, which every theme shares and
+ * `tailwind.spec.js` checks against the compiled stylesheet.
+ */
+const clickSpaces: Record<string, keyof IThemeAppearance | `p-${number}`> = {
+ 'spaces.0': 'p-0',
+ 'spaces.1': 'p-1',
+ 'spaces.2': 'spaceCompact',
+ 'spaces.3': 'spaceNormal',
+ 'spaces.4': 'p-4',
+ 'spaces.5': 'p-6',
+ 'spaces.6': 'p-8',
+ 'spaces.7': 'p-10',
+ 'spaces.8': 'p-16',
+};
+
+/** A length in rem, for a value written in rem or as a bare `0`. */
+const remOf = (value: string) => (value.trim() === '0' ? 0 : parseFloat(value));
+
/** Click UI's gray `lch()` stops, converted through CIE L* to an sRGB channel. Chroma must be zero. */
function lchGray(lightness: number): number {
const y = lightness > 8 ? ((lightness + 16) / 116) ** 3 : lightness / 903.2962962;
@@ -756,8 +778,6 @@ const normalizeShadow = (value: string) =>
.replace(/\s+/g, ' ')
.trim();
-const firstFamily = (value: string) => value.split(',')[0].trim();
-
/** How a Click UI appearance token compares with the theme value that cites it. */
const scrimKeys: ReadonlySet<keyof IThemeAppearance> = new Set([
'scrimOpacity',
@@ -787,11 +807,6 @@ function comparable(key: keyof IThemeAppearance, raw: string | number): string {
if (/shadow/i.test(key) || key === 'elevationSurface' || key === 'elevationDrag') {
return normalizeShadow(value);
}
- /** Click UI's mono tail names `"SFMono Regular"`, which no platform installs; the theme keeps
- * the default theme's metric-matched tail, so only the face it leads with is Click UI's. */
- if (key === 'monoFontFamily') {
- return firstFamily(value);
- }
/** Click UI writes the label as a `font` shorthand; the role is its leading weight. */
if (key === 'controlFontWeight') {
return value.trim().split(/\s+/)[0];
@@ -1559,9 +1574,7 @@ function appearanceStatuses(mode: ThemeMode): Array<[keyof IThemeAppearance, Rol
if (comparable(key, theme) !== comparable(key, source)) {
return [key, 'mismatch', token];
}
- /** The mono stack leads with Click UI's face and keeps the default theme's tail. */
- const verbatim = theme.replace(/;$/, '').trim() === source.replace(/;$/, '').trim();
- return [key, verbatim || key !== 'monoFontFamily' ? 'match' : 'near', token];
+ return [key, 'match', token];
});
}
@@ -1628,11 +1641,28 @@ describe('ClickHouse theme drift against Click UI', () => {
expect({ unsourced, drift }).toEqual({ unsourced: [], drift: [] });
});
+ it.each(modes)('draws the %s Click UI spaces a role carries from that role', (mode) => {
+ const appearance = resolveTheme(clickHouseTheme, mode).appearance;
+ const drift = Object.entries(clickSpaces).flatMap(([token, counterpart]) => {
+ if (counterpart.startsWith('p-')) {
+ return [];
+ }
+ const role = counterpart as keyof IThemeAppearance;
+ const source = remOf(clickToken(mode, token));
+ return remOf(appearance[role]) === source
+ ? []
+ : [`${token} ${source}rem: ${role} draws ${appearance[role]}`];
+ });
+
+ expect(drift).toEqual([]);
+ });
+
it.each(modes)('keeps only the %s tokens the theme cites in the snapshot', (mode) => {
const cited = new Set([
...Object.values(colorSources[mode]),
...Object.values(departures[mode]).map((departure) => departure.counterpart),
...Object.values(appearanceSources),
+ ...Object.keys(clickSpaces),
...Object.values(appearanceDecisions).flatMap(({ token }) => (token ? [token] : [])),
...Object.values(parityProbes).flatMap((probe) => (probe.token ? [probe.token] : [])),
]);
@@ -1749,8 +1779,6 @@ describe('ClickHouse primitive parity against Click UI components', () => {
expect(statuses.filter(([, status]) => status === 'mismatch').map(([key]) => key)).toEqual([
'text2xl',
]);
- expect(statuses.filter(([, status]) => status === 'near').map(([key]) => key)).toEqual([
- 'monoFontFamily',
- ]);
+ expect(statuses.filter(([, status]) => status === 'near').map(([key]) => key)).toEqual([]);
});
});