From 11fdcf4f43fb1f4b7e536092c4e40de858c03d52 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Sun, 15 Nov 2026 02:15:39 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A9=20refactor:=20Move=20Phase=20Label?= =?UTF-8?q?=20Ticker=20Into=20Chat=20Package=20(#18179)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - refactor: Move Phase Label Ticker Into Chat Package - test: Give Phase Entrance Scenarios Unique IDs --- .../Messages/Content/ActivityPhaseGroup.tsx | 129 +----------------- .../__tests__/ActivityPhaseGroup.test.tsx | 48 ++++++- .../published-consumer-appearance.spec.ts | 92 +++++++++++++ eslint-suppressions.json | 3 - packages/chat/src/components.ts | 2 + .../chat/src/components/parts/PhaseLabel.tsx | 124 +++++++++++++++++ .../parts/__tests__/PhaseLabel.spec.tsx | 112 +++++++++++++++ packages/client/src/theme/tailwind.spec.js | 14 ++ packages/client/tailwind.preset.cjs | 12 ++ 9 files changed, 407 insertions(+), 129 deletions(-) create mode 100644 packages/chat/src/components/parts/PhaseLabel.tsx create mode 100644 packages/chat/src/components/parts/__tests__/PhaseLabel.spec.tsx diff --git a/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx b/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx index e2afae6b48..d789e35fdf 100644 --- a/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx +++ b/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx @@ -1,6 +1,5 @@ -import { memo, useId, useCallback, useEffect, useMemo, useRef, useState, useContext } from 'react'; +import { useId, useCallback, useEffect, useMemo, useRef, useState, useContext } from 'react'; import { useAtomValue } from 'jotai'; -import { Shimmer } from '@librechat/client'; import { ContentTypes } from 'librechat-data-provider'; import { Check, CircleX, Lightbulb, ChevronDown, TriangleAlert } from 'lucide-react'; import { @@ -15,6 +14,8 @@ import { useThrottledValue, } from '@librechat/chat/react'; import { + PhaseLabel, + FOLD_EASING, FOLD_RAIL_CLASSES, ROW_GLYPH_SLOT, TOOL_ROW_CLASSES, @@ -53,17 +54,7 @@ import { AttachmentGroup } from './Parts'; import SearchVerticals from './verticals'; import { cn } from '~/utils'; -/** Matches `EXPAND_TRANSITION` so the panel and the label ticker resolve on - * the same curve: two properties animating on two different easings is what - * makes a fold read as two separate movements. - * - * Written as an arbitrary PROPERTY, not `ease-[…]`: `tailwindcss-animate` - * registers its own `ease` utility for `animation-timing-function` alongside - * Tailwind's `transition-timing-function` one, so an arbitrary value matches - * both, and Tailwind resolves that ambiguity by emitting NOTHING. The class - * this replaces had been inert since the plugin landed — the curve it names - * never reached the fold. */ -const FOLD_EASING = 'duration-300 [animation-timing-function:cubic-bezier(0.16,1,0.3,1)]'; +export { PhaseLabel } from '@librechat/chat/components'; type ActivityPhasePart = Extract & { activity_label_type?: 'phase'; @@ -115,118 +106,6 @@ function PhaseGlyph({ failed, partial = false }: { failed: boolean; partial?: bo ); } -/** - * The phase header is a ticker, not a title. A client-synthesized card - * re-titles itself every time it absorbs another finished block, and swapping - * that text instantly is what makes the absorbed row look like it simply - * vanished from under the reader. The retired line rises out of the clipped - * row while the new summary comes up from below, so the work visibly moves - * into the line that now stands for it. - */ -/** - * The shimmering text of a live line, on its own element. `.shimmer` declares - * `position` and `display`, so sharing an element with the ticker would undo - * the slide's absolute placement — the retired line would sit inline beside - * its successor. `align-top` keeps the inline box from adding descender space, - * which made a live row 2px taller than the settled row it becomes. - */ -function LiveLine({ text }: { text: string }) { - return {text}; -} - -export const PhaseLabel = memo(function PhaseLabel({ - text, - animate, - source, - live = false, - grow = true, - lineId, -}: { - text: string; - animate: boolean; - /** Identity of what produced `text`. A streamed sentence keeps its source - * while it grows, and sliding a line out to bring a longer copy of itself - * in would read as flicker, so an unchanged source extends in place. */ - source?: string; - live?: boolean; - /** Claim the row's free space, the default. Cleared when something has to - * sit immediately after the text — the box then measures the line itself, - * so its neighbour reads as part of it instead of drifting to the margin. */ - grow?: boolean; - /** Id for the current line, so a live disclosure can be named by it alone. */ - lineId?: string; -}) { - const [lines, setLines] = useState<{ - current: string; - retired: string | null; - entered: boolean; - source?: string; - }>({ current: text, retired: null, entered: false, source }); - - /** Adjusted during render rather than in an effect. A passive effect runs - * after paint, so a swap with no animation would leave the previous summary - * on screen for a frame while the button's `aria-label` already carried the - * new one. React re-renders this component immediately instead. */ - if (lines.current !== text || lines.source !== source) { - const moved = source == null || source !== lines.source; - const swaps = animate && lines.current.length > 0 && moved; - setLines({ - current: text, - retired: swaps ? lines.current : null, - entered: swaps || (lines.entered && source != null && source === lines.source), - source, - }); - } - - /** Clears only the retired line. `entered` outlives it on purpose: dropping - * the incoming line's animation class the moment its partner's - * `animationend` fires would snap a still-running slide back to its resting - * position. The class is inert once the animation has finished, and the - * element is keyed by its text, so it cannot replay. */ - const clearRetired = useCallback(() => { - setLines((previous) => (previous.retired == null ? previous : { ...previous, retired: null })); - }, []); - - return ( - - {lines.retired != null && ( - event.target === event.currentTarget && clearRetired()} - aria-hidden="true" - > - {live ? : lines.retired} - - )} - - {live ? : lines.current} - - - ); -}); - /** Glyphs a span header shows: up to this many, of which at most `SPAN_SITES` * are the sites a web search read. */ const SPAN_ICONS = 4; diff --git a/client/src/components/Chat/Messages/Content/__tests__/ActivityPhaseGroup.test.tsx b/client/src/components/Chat/Messages/Content/__tests__/ActivityPhaseGroup.test.tsx index 3f1010a51d..328908e59b 100644 --- a/client/src/components/Chat/Messages/Content/__tests__/ActivityPhaseGroup.test.tsx +++ b/client/src/components/Chat/Messages/Content/__tests__/ActivityPhaseGroup.test.tsx @@ -1,11 +1,13 @@ import { useContext } from 'react'; +import fs from 'fs'; import { ContentTypes, Tools } from 'librechat-data-provider'; import { GeneratedToolLabelContext } from '@librechat/chat/react'; import { act, fireEvent, render, screen, within } from '@testing-library/react'; +import { PhaseLabel as PackagePhaseLabel, FOLD_EASING } from '@librechat/chat/components'; import { ROW_GLYPH_SLOT, TOOL_ROW_CLASSES, useFailedReveal } from '@librechat/chat/components'; import type { TAttachment, TMessageContentParts } from 'librechat-data-provider'; +import ActivityPhaseGroup, { PhaseLabel } from '../ActivityPhaseGroup'; import { MessageSurfaceContext } from '../../ui/surface'; -import ActivityPhaseGroup from '../ActivityPhaseGroup'; const mockUseSmoothStreaming = jest.fn(() => true); const mockScheduleLayoutReconcile = jest.fn((_target: HTMLElement | null) => jest.fn()); @@ -79,6 +81,44 @@ const searchAttachment = { } as unknown as TAttachment; describe('ActivityPhaseGroup', () => { + test('preserves the package ticker export for existing tool group consumers', () => { + expect(PhaseLabel).toBe(PackagePhaseLabel); + }); + + test('exports real phase consumers for the browser cascade checks', () => { + const ticker = render(); + ticker.rerender(); + expect(ticker.container.querySelector('.animate-out')).toHaveAttribute('aria-hidden', 'true'); + const tickerMarkup = ticker.container.innerHTML; + ticker.unmount(); + + const entrance = render( + +
+ , + ); + for (const name of FOLD_EASING.split(' ')) { + expect(screen.getByTestId('activity-phase-card')).toHaveClass(name); + } + const entranceMarkup = entrance.container.innerHTML; + entrance.unmount(); + + const reduced = render(); + reduced.rerender(); + expect(reduced.container.querySelector('.animate-in, .animate-out')).toBeNull(); + const fixturePath = process.env.E2E_PHASE_CASCADE_FIXTURE; + if (fixturePath) { + fs.writeFileSync( + fixturePath, + JSON.stringify({ + ticker: tickerMarkup, + entrance: entranceMarkup, + reduced: reduced.container.innerHTML, + }), + ); + } + }); + let frames: Array; const originalRequestAnimationFrame = window.requestAnimationFrame; const originalCancelAnimationFrame = window.cancelAnimationFrame; @@ -283,6 +323,9 @@ describe('ActivityPhaseGroup', () => { * new one comes up from below — the absorbed block is the thing that * moved, so it has to be visible while it moves. */ const retired = screen.getByText(LABEL); + for (const easingClass of FOLD_EASING.split(' ')) { + expect(retired).toHaveClass(easingClass); + } expect(retired).toHaveClass('animate-out', 'slide-out-to-top-5'); expect(retired).toHaveAttribute('aria-hidden', 'true'); expect( @@ -379,6 +422,9 @@ describe('ActivityPhaseGroup', () => { expect(screen.queryByRole('button')).not.toBeInTheDocument(); expect(screen.getByText(LABEL)).toHaveClass('text-start'); + for (const easingClass of FOLD_EASING.split(' ')) { + expect(screen.getByTestId('activity-phase-card')).toHaveClass(easingClass); + } expect(pendingFrames()).toBe(0); }); diff --git a/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts b/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts index 96406b927f..34c92fda0a 100644 --- a/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts +++ b/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts @@ -1,6 +1,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; import { join, resolve } from 'node:path'; import { expect, test } from '@playwright/test'; +import { spawnSync } from 'node:child_process'; import { repoRoot, run } from './lint.helpers'; /** @@ -196,3 +197,94 @@ Promise.all(${JSON.stringify([ expect((await read('disabled', ['cursor'])).cursor).toBe('not-allowed'); }); }); + +/** The client test renders both real consumers. Only this browser lane asks it to save markup, + * so ordinary Jest needs neither a browser binary nor the browser lane's services. */ +test.describe('phase label animation cascade', () => { + let fixture: { ticker: string; entrance: string; reduced: string }; + let css: string; + + test.beforeAll(async ({ browserName }, testInfo) => { + const fixturePath = testInfo.outputPath(`phase-label-${browserName}.json`); + mkdirSync(resolve(fixturePath, '..'), { recursive: true }); + const rendered = spawnSync( + process.execPath, + [ + resolve(repoRoot, 'node_modules/jest/bin/jest.js'), + 'src/components/Chat/Messages/Content/__tests__/ActivityPhaseGroup.test.tsx', + '--maxWorkers=2', + '-t', + 'exports real phase consumers for the browser cascade checks', + ], + { + cwd: resolve(repoRoot, 'client'), + env: { ...process.env, E2E_PHASE_CASCADE_FIXTURE: fixturePath }, + encoding: 'utf8', + }, + ); + expect(rendered.status, rendered.stdout + rendered.stderr).toBe(0); + fixture = JSON.parse(readFileSync(fixturePath, 'utf8')); + const compilerPath = testInfo.outputPath('compile.cjs'); + const compiledPath = testInfo.outputPath('app.css'); + writeFileSync( + compilerPath, + `const {readFileSync, writeFileSync} = require('node:fs'); +const postcss = require(${JSON.stringify(require.resolve('postcss'))}); +const tailwind = require(${JSON.stringify(require.resolve('@tailwindcss/postcss'))}); +const input = ${JSON.stringify(resolve(repoRoot, 'client/src/style.css'))}; +postcss([tailwind()]).process(readFileSync(input, 'utf8'), {from: input}) + .then(result => writeFileSync(${JSON.stringify(compiledPath)}, result.css)) + .catch(error => { console.error(error); process.exitCode = 1; });`, + ); + const compiled = run(process.execPath, [compilerPath]); + expect(compiled.status, compiled.output).toBe(0); + css = `${readFileSync(DIST_STYLESHEET, 'utf8')}\n${readFileSync(compiledPath, 'utf8')}`; + }); + + test('keeps the ticker curve, duration and retired fill @scenario:phase-label-ticker-cascade', async ({ + page, + }) => { + await page.setContent(`${fixture.ticker}`); + await expect(page.locator('.animate-in')).toHaveCSS( + 'animation-timing-function', + 'cubic-bezier(0.16, 1, 0.3, 1)', + ); + await expect(page.locator('.animate-out')).toHaveCSS( + 'animation-timing-function', + 'cubic-bezier(0.16, 1, 0.3, 1)', + ); + await expect(page.locator('.animate-in')).toHaveCSS('animation-duration', '0.3s'); + await expect(page.locator('.animate-out')).toHaveCSS('animation-duration', '0.3s'); + await expect(page.locator('.animate-in')).toHaveCSS('animation-fill-mode', 'none'); + await expect(page.locator('.animate-out')).toHaveCSS('animation-fill-mode', 'forwards'); + }); + + for (const { reduced, scenario } of [ + { reduced: false, scenario: '@scenario:phase-label-entrance-normal-cascade' }, + { reduced: true, scenario: '@scenario:phase-label-entrance-reduced-cascade' }, + ]) { + test(`keeps the phase entrance with reduced motion ${reduced} ${scenario}`, async ({ + page, + }) => { + await page.emulateMedia({ reducedMotion: reduced ? 'reduce' : 'no-preference' }); + await page.setContent(`${fixture.entrance}`); + const card = page.getByTestId('activity-phase-card'); + await expect(card).toHaveCSS( + 'animation-timing-function', + reduced ? 'ease' : 'cubic-bezier(0.16, 1, 0.3, 1)', + ); + await expect(card).toHaveCSS('animation-duration', reduced ? '0s' : '0.3s'); + await expect(card).toHaveCSS('animation-fill-mode', 'none'); + await expect(card).toHaveCSS('animation-name', reduced ? 'none' : 'enter'); + }); + } + + test('calms the ticker and shimmer for reduced motion @scenario:phase-label-reduced-motion', async ({ + page, + }) => { + await page.emulateMedia({ reducedMotion: 'reduce' }); + await page.setContent(`${fixture.reduced}`); + await expect(page.locator('.shimmer-clip')).toHaveCSS('display', 'none'); + await expect(page.locator('.animate-in, .animate-out')).toHaveCount(0); + }); +}); diff --git a/eslint-suppressions.json b/eslint-suppressions.json index e28f7132f9..c5056eccdc 100644 --- a/eslint-suppressions.json +++ b/eslint-suppressions.json @@ -130,9 +130,6 @@ } }, "client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx": { - "shadcn/no-arbitrary-values": { - "count": 2 - }, "shadcn/no-inline-styles": { "count": 2 } diff --git a/packages/chat/src/components.ts b/packages/chat/src/components.ts index 81a45a8340..d75694e8f8 100644 --- a/packages/chat/src/components.ts +++ b/packages/chat/src/components.ts @@ -124,6 +124,8 @@ export { default as MessageNav } from './components/messages/MessageNav'; export type { MessageFooterProps } from './components/messages/MessageFooter'; export { getMessageAriaLabel, getHeaderPrefixForScreenReader } from './components/messages/labels'; +export { default as PhaseLabel, FOLD_EASING } from './components/parts/PhaseLabel'; + /** Parts: the leaf components and row classes tool cards share. */ export { default as Stdout } from './components/parts/Stdout'; export { default as BareStatus } from './components/parts/BareStatus'; diff --git a/packages/chat/src/components/parts/PhaseLabel.tsx b/packages/chat/src/components/parts/PhaseLabel.tsx new file mode 100644 index 0000000000..ce9a511fb8 --- /dev/null +++ b/packages/chat/src/components/parts/PhaseLabel.tsx @@ -0,0 +1,124 @@ +import { memo, useCallback, useState } from 'react'; +import { cn, Shimmer } from '@librechat/client'; +import type { NamedExoticComponent } from 'react'; + +/** Matches `EXPAND_TRANSITION` so the panel and ticker follow the same curve. + * The shared class sets animation timing: Tailwind's `ease-*` also names + * transition timing, which makes an arbitrary easing value ambiguous. */ +export const FOLD_EASING = 'duration-300 animation-ease-fold'; + +/** + * The phase header is a ticker, not a title. A client-synthesized card + * re-titles itself every time it absorbs another finished block, and swapping + * that text instantly is what makes the absorbed row look like it simply + * vanished from under the reader. The retired line rises out of the clipped + * row while the new summary comes up from below, so the work visibly moves + * into the line that now stands for it. + */ +/** + * The shimmering text of a live line, on its own element. `.shimmer` declares + * `position` and `display`, so sharing an element with the ticker would undo + * the slide's absolute placement; the retired line would sit inline beside + * its successor. `align-top` keeps the inline box from adding descender space, + * which made a live row 2px taller than the settled row it becomes. + */ +function LiveLine({ text }: { text: string }) { + return {text}; +} + +type PhaseLabelProps = { + text: string; + animate: boolean; + /** Identity of what produced `text`. A streamed sentence keeps its source + * while it grows, and sliding a line out to bring a longer copy of itself + * in would read as flicker, so an unchanged source extends in place. */ + source?: string; + live?: boolean; + /** Claim the row's free space, the default. Cleared when something has to + * sit immediately after the text; the box then measures the line itself, + * so its neighbour reads as part of it instead of drifting to the margin. */ + grow?: boolean; + /** Id for the current line, so a live disclosure can be named by it alone. */ + lineId?: string; +}; + +const PhaseLabel: NamedExoticComponent = memo(function PhaseLabel({ + text, + animate, + source, + live = false, + grow = true, + lineId, +}: PhaseLabelProps) { + const [lines, setLines] = useState<{ + current: string; + retired: string | null; + entered: boolean; + source?: string; + }>({ current: text, retired: null, entered: false, source }); + + /** Adjusted during render rather than in an effect. A passive effect runs + * after paint, so a swap with no animation would leave the previous summary + * on screen for a frame while the button's `aria-label` already carried the + * new one. React re-renders this component immediately instead. */ + if (lines.current !== text || lines.source !== source) { + const moved = source == null || source !== lines.source; + const swaps = animate && lines.current.length > 0 && moved; + setLines({ + current: text, + retired: swaps ? lines.current : null, + entered: swaps || (lines.entered && source != null && source === lines.source), + source, + }); + } + + /** Clears only the retired line. `entered` outlives it on purpose: dropping + * the incoming line's animation class the moment its partner's + * `animationend` fires would snap a still-running slide back to its resting + * position. The class is inert once the animation has finished, and the + * element is keyed by its text, so it cannot replay. */ + const clearRetired = useCallback(() => { + setLines((previous) => (previous.retired == null ? previous : { ...previous, retired: null })); + }, []); + + return ( + + {lines.retired != null && ( + event.target === event.currentTarget && clearRetired()} + aria-hidden="true" + > + {live ? : lines.retired} + + )} + + {live ? : lines.current} + + + ); +}); + +export default PhaseLabel; diff --git a/packages/chat/src/components/parts/__tests__/PhaseLabel.spec.tsx b/packages/chat/src/components/parts/__tests__/PhaseLabel.spec.tsx new file mode 100644 index 0000000000..9cde5fca1e --- /dev/null +++ b/packages/chat/src/components/parts/__tests__/PhaseLabel.spec.tsx @@ -0,0 +1,112 @@ +/** @jest-environment jsdom */ +import { fireEvent, render, screen } from '@testing-library/react'; +import PhaseLabel, { FOLD_EASING } from '../PhaseLabel'; + +const first = 'Compared both release paths'; +const next = 'Confirmed the rollback path is clean'; + +describe('PhaseLabel', () => { + test('renders the initial line without replaying a slide', () => { + render(); + + expect(screen.getByText(first)).toHaveAttribute('id', 'phase-line'); + expect(screen.getByText(first)).not.toHaveClass('animate-in'); + expect(screen.getByTitle(first)).toHaveClass('tool-status-text', 'flex-1'); + }); + + test('retires the old summary with the same easing as the incoming line', () => { + const { rerender } = render(); + rerender(); + + const retired = screen.getByText(first); + const current = screen.getByText(next); + expect(retired).toHaveAttribute('aria-hidden', 'true'); + expect(retired).toHaveClass('absolute', 'animate-out', 'slide-out-to-top-5'); + expect(current).toHaveClass('animate-in', 'slide-in-from-bottom-5'); + for (const easingClass of FOLD_EASING.split(' ')) { + expect(retired).toHaveClass(easingClass); + expect(current).toHaveClass(easingClass); + } + + fireEvent.animationEnd(retired); + + expect(screen.queryByText(first)).not.toBeInTheDocument(); + expect(screen.getByText(next)).toBe(current); + expect(current).toHaveClass('animate-in'); + }); + + test('replaces the summary immediately when animation is disabled', () => { + const { rerender } = render(); + rerender(); + + expect(screen.queryByText(first)).not.toBeInTheDocument(); + expect(screen.getByText(next)).not.toHaveClass('animate-in'); + expect(screen.getByTitle(next)).toBeInTheDocument(); + }); + + test('does not animate the first nonempty summary', () => { + const { rerender } = render(); + rerender(); + + expect(screen.getByText(first)).not.toHaveClass('animate-in'); + }); + + test('extends a streamed sentence in place while its source stays the same', () => { + const { rerender } = render(); + const line = screen.getByText('Checking').parentElement; + rerender(); + + expect(screen.queryByText('Checking')).not.toBeInTheDocument(); + expect(screen.getByText('Checking both release paths').parentElement).toBe(line); + expect(line).not.toHaveClass('animate-in'); + expect(screen.getByText('Checking both release paths')).toHaveClass('shimmer', 'align-top'); + }); + + test('keeps a slide on the same element as the incoming streamed sentence grows', () => { + const { rerender } = render(); + rerender(); + const current = screen.getByText('Checking').parentElement; + expect(current).toHaveClass('animate-in'); + + rerender(); + + expect(screen.getByText('Checking both paths').parentElement).toBe(current); + expect(current).toHaveClass('animate-in'); + }); + + test('ignores a bubbled shimmer animation ending before the retired slide ends', () => { + const { rerender } = render(); + rerender(); + const retiredText = screen.getByText(first); + const retired = retiredText.parentElement; + expect(retired).toHaveAttribute('aria-hidden', 'true'); + expect(retiredText).toHaveClass('shimmer'); + expect(retiredText).not.toHaveClass('absolute'); + + fireEvent.animationEnd(retiredText); + expect(screen.getByText(first)).toBeInTheDocument(); + + if (retired == null) { + throw new Error('The retired line must wrap its shimmering text.'); + } + fireEvent.animationEnd(retired); + expect(screen.queryByText(first)).not.toBeInTheDocument(); + expect(screen.getByText(next).parentElement).toHaveClass('animate-in'); + }); + + test('keeps only the latest retired line across successive summary changes', () => { + const { rerender } = render(); + rerender(); + rerender(); + + expect(screen.queryByText(first)).not.toBeInTheDocument(); + expect(screen.getByText(next)).toHaveAttribute('aria-hidden', 'true'); + expect(screen.getByText('Finished')).not.toHaveAttribute('aria-hidden'); + }); + + test('can size to the label so the multiplier sits immediately after it', () => { + render(); + + expect(screen.getByTitle(first)).not.toHaveClass('flex-1'); + }); +}); diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.js index a9b2bf3605..7ae15b12a7 100644 --- a/packages/client/src/theme/tailwind.spec.js +++ b/packages/client/src/theme/tailwind.spec.js @@ -87,6 +87,20 @@ function tailwindDefault(variable) { } describe('LibreChat Tailwind preset', () => { + it('ships the phase ticker animation properties without changing transition easing', async () => { + const css = await generate([ + 'animation-ease-fold', + 'animation-fill-forwards', + 'fill-mode-forwards', + ]); + + expect(rule(css, 'animation-ease-fold')).toBe( + 'animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);', + ); + expect(rule(css, 'animation-fill-forwards')).toBe('animation-fill-mode: forwards;'); + expect(rule(css, 'animation-fill-forwards')).toBe(rule(css, 'fill-mode-forwards')); + }); + it('owns the loading-dot delay with a zero-delay fallback for plain preset consumers', async () => { const css = await generate(['animate-loading-dot']); diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjs index 1e77dc9910..b0c5223ea1 100644 --- a/packages/client/tailwind.preset.cjs +++ b/packages/client/tailwind.preset.cjs @@ -242,6 +242,18 @@ module.exports = { * Declared as a peer dependency so the consumer's install provides it. */ require('tailwindcss-animate'), + /** The fold's animation properties need distinct names: `ease-*` also controls transitions, + * and the design parser reads the plugin's `fill-mode-*` utilities as SVG fill colors. */ + { + handler: ({ addUtilities }) => { + addUtilities({ + '.animation-ease-fold': { + animationTimingFunction: 'cubic-bezier(0.16, 1, 0.3, 1)', + }, + '.animation-fill-forwards': { animationFillMode: 'forwards' }, + }); + }, + }, /** * A bare function rather than `plugin()` from `tailwindcss/plugin`, because * this preset ships as a raw file through the `./tailwind-preset` export and