From 84a36630a0573248619ad70ddafa2e6e01ffecaa Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Thu, 5 Nov 2026 22:36:51 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=8A=20refactor:=20Move=20the=20Context?= =?UTF-8?q?=20Usage=20Popover=20Into=20@librechat/chat=20(#17799)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: Move the Context Usage Popover Pieces Into @librechat/chat * test: Cover the Context Usage Pieces in the Chat Package * fix: Ship the Collapsible Animations With the Shared Tailwind Preset * test: Keep the Expanded Breakdown Choice Across Remounts * test: Assert the Absent Compaction Hint by Its Fixed Copy * refactor: Give Collapsible and HoverCard the Breakdown Disclosure Styles * test: Cover the Breakdown Roll and Remembered Choice in the Browser * chore: Retest Against Current Dev --- .../Chat/Input/TokenUsage/index.spec.tsx | 42 +++- .../Chat/Input/TokenUsage/index.tsx | 15 +- .../Input/__tests__/appearanceTokens.spec.ts | 2 +- client/src/utils/tokens.spec.ts | 60 ----- client/src/utils/tokens.ts | 100 +------- client/tailwind.config.cjs | 14 -- .../scenarios/persisted-context-usage.spec.ts | 88 +++++++ eslint-suppressions.json | 5 - packages/chat/src/components.ts | 10 + .../components/composer/usage}/Breakdown.tsx | 43 ++-- .../composer/usage}/CompactAction.tsx | 16 +- .../src/components/composer/usage}/Gauge.tsx | 17 +- .../components/composer/usage}/Popover.tsx | 10 +- .../src/components/composer/usage}/Usage.tsx | 18 +- .../usage/__tests__}/Breakdown.spec.tsx | 214 +++++++++--------- .../composer/usage/__tests__}/Usage.spec.tsx | 41 ++-- .../src/core/usage/__tests__/format.spec.ts | 61 ++++- packages/chat/src/core/usage/format.ts | 106 +++++++++ .../src/components/Collapsible.spec.tsx | 47 ++++ .../client/src/components/Collapsible.tsx | 34 ++- .../client/src/components/HoverCard.spec.tsx | 16 ++ packages/client/src/components/HoverCard.tsx | 2 +- packages/client/tailwind.preset.cjs | 15 ++ 23 files changed, 609 insertions(+), 367 deletions(-) delete mode 100644 client/src/utils/tokens.spec.ts rename {client/src/components/Chat/Input/TokenUsage => packages/chat/src/components/composer/usage}/Breakdown.tsx (94%) rename {client/src/components/Chat/Input/TokenUsage => packages/chat/src/components/composer/usage}/CompactAction.tsx (80%) rename {client/src/components/Chat/Input/TokenUsage => packages/chat/src/components/composer/usage}/Gauge.tsx (84%) rename {client/src/components/Chat/Input/TokenUsage => packages/chat/src/components/composer/usage}/Popover.tsx (96%) rename {client/src/components/Chat/Input/TokenUsage => packages/chat/src/components/composer/usage}/Usage.tsx (91%) rename {client/src/components/Chat/Input/TokenUsage => packages/chat/src/components/composer/usage/__tests__}/Breakdown.spec.tsx (81%) rename {client/src/components/Chat/Input/TokenUsage => packages/chat/src/components/composer/usage/__tests__}/Usage.spec.tsx (76%) create mode 100644 packages/client/src/components/Collapsible.spec.tsx diff --git a/client/src/components/Chat/Input/TokenUsage/index.spec.tsx b/client/src/components/Chat/Input/TokenUsage/index.spec.tsx index a776599ad4..061a83a59a 100644 --- a/client/src/components/Chat/Input/TokenUsage/index.spec.tsx +++ b/client/src/components/Chat/Input/TokenUsage/index.spec.tsx @@ -36,9 +36,22 @@ jest.mock('~/hooks/Chat/useCompactConversation', () => ({ supportsCompaction: () => false, })); -jest.mock('./Breakdown', () => ({ - __esModule: true, - default: () =>
, +jest.mock('@librechat/chat/components', () => ({ + ...jest.requireActual('@librechat/chat/components'), + ContextBreakdown: ({ + expanded, + onExpandedChange, + }: { + expanded: boolean; + onExpandedChange: (expanded: boolean) => void; + }) => ( +