From cb92a34d76b4e1d267b7cddcd7eee49b2864def3 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Wed, 28 Oct 2026 13:27:38 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=9B=EF=B8=8F=20refactor:=20Move=20Comp?= =?UTF-8?q?oser=20Leaf=20Controls=20and=20Steering=20Into=20the=20Chat=20P?= =?UTF-8?q?ackage=20(#17521)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Chat/ChatView.tsx | 9 ++- .../Chat/Input/AskUserQuestionPopover.tsx | 2 +- client/src/components/Chat/Input/ChatForm.tsx | 10 ++-- .../components/Chat/Input/Composer/Bar.tsx | 2 +- .../Chat/Input/Composer/Palette.tsx | 2 +- .../components/Chat/Input/Composer/Queue.tsx | 2 +- .../components/Chat/Input/Composer/Tray.tsx | 2 +- .../Input/Composer/__tests__/Palette.spec.tsx | 2 +- .../Input/Composer/__tests__/Queue.spec.tsx | 5 +- .../Composer/__tests__/semanticTokens.spec.ts | 7 ++- .../components/Chat/Input/Composer/state.ts | 5 -- client/src/components/Chat/Input/Mention.tsx | 2 +- .../components/Chat/Input/PromptsCommand.tsx | 2 +- .../components/Chat/Input/SkillsCommand.tsx | 5 +- .../__tests__/AskUserQuestionPopover.test.tsx | 3 +- .../Input/__tests__/QueuedTurnPortal.spec.tsx | 5 +- .../Input/__tests__/SkillsCommand.spec.tsx | 3 - .../Input/__tests__/appearanceTokens.spec.ts | 9 ++- .../Chat/Input/__tests__/panelRadius.spec.ts | 5 ++ .../src/components/Chat/Input/skillsState.ts | 4 -- .../Messages/Content/Parts/PendingSteers.tsx | 2 +- .../Chat/Messages/Content/Parts/SteerPart.tsx | 4 +- .../Parts/__tests__/PendingSteers.test.tsx | 1 + .../Parts/__tests__/SteerPart.test.tsx | 7 ++- .../components/Chat/Messages/PendingTurn.tsx | 2 +- .../components/Chat/Messages/ScrollButton.tsx | 2 +- .../Messages/__tests__/ScrollButton.spec.tsx | 2 +- .../Chat/Steering/__tests__/Receipt.spec.tsx | 9 +-- .../Chat/Subagents/SubagentActivity.test.tsx | 6 +- .../Chat/Subagents/SubagentActivity.tsx | 2 +- .../src/components/Chat/approval/Review.tsx | 2 +- .../Chat/approval/__tests__/Review.test.tsx | 2 +- client/src/hooks/Config/useClearStates.ts | 2 +- client/src/hooks/Input/useHandleKeyUp.spec.ts | 3 +- client/src/hooks/Input/useHandleKeyUp.ts | 2 +- packages/chat/components.json | 8 +++ packages/chat/src/components.ts | 18 ++++++ .../src/components/composer}/CollapseChat.tsx | 21 ++++--- .../src/components/composer}/MentionItem.tsx | 4 +- .../src/components/composer}/StopButton.tsx | 22 ++++--- .../composer/__tests__/CollapseChat.spec.tsx | 34 +++++++++++ .../composer/__tests__/MentionItem.spec.tsx | 37 ++++++++++++ .../composer}/__tests__/StopButton.spec.tsx | 6 +- .../composer}/__tests__/clearance.spec.ts | 0 .../composer}/__tests__/submit.spec.ts | 0 .../src/components/composer/bar}/Chip.tsx | 8 ++- .../src/components/composer}/clearance.ts | 0 .../composer/steering}/QueuedTurnPortal.tsx | 7 ++- .../components/composer/steering}/Receipt.tsx | 29 +++++----- .../__tests__/QueuedTurnPortal.spec.tsx | 35 +++++++++++ .../steering/__tests__/Receipt.spec.tsx | 58 +++++++++++++++++++ .../components/composer/steering}/identity.ts | 0 .../chat/src/components/composer}/submit.ts | 0 packages/chat/src/react.ts | 3 + .../src/react}/__tests__/overlay.spec.tsx | 3 + packages/chat/src/react/lift.ts | 9 +++ .../chat/src/react}/overlay.ts | 5 +- packages/chat/src/react/skills.ts | 10 ++++ 58 files changed, 345 insertions(+), 106 deletions(-) delete mode 100644 client/src/components/Chat/Input/Composer/state.ts delete mode 100644 client/src/components/Chat/Input/skillsState.ts create mode 100644 packages/chat/components.json rename {client/src/components/Chat/Input => packages/chat/src/components/composer}/CollapseChat.tsx (78%) rename {client/src/components/Chat/Input => packages/chat/src/components/composer}/MentionItem.tsx (94%) rename {client/src/components/Chat/Input => packages/chat/src/components/composer}/StopButton.tsx (86%) create mode 100644 packages/chat/src/components/composer/__tests__/CollapseChat.spec.tsx create mode 100644 packages/chat/src/components/composer/__tests__/MentionItem.spec.tsx rename {client/src/components/Chat/Input => packages/chat/src/components/composer}/__tests__/StopButton.spec.tsx (94%) rename {client/src/components/Chat/Input => packages/chat/src/components/composer}/__tests__/clearance.spec.ts (100%) rename {client/src/components/Chat/Input => packages/chat/src/components/composer}/__tests__/submit.spec.ts (100%) rename {client/src/components/Chat/Input/Composer => packages/chat/src/components/composer/bar}/Chip.tsx (85%) rename {client/src/components/Chat/Input => packages/chat/src/components/composer}/clearance.ts (100%) rename {client/src/components/Chat/Steering => packages/chat/src/components/composer/steering}/QueuedTurnPortal.tsx (85%) rename {client/src/components/Chat/Steering => packages/chat/src/components/composer/steering}/Receipt.tsx (89%) create mode 100644 packages/chat/src/components/composer/steering/__tests__/QueuedTurnPortal.spec.tsx create mode 100644 packages/chat/src/components/composer/steering/__tests__/Receipt.spec.tsx rename {client/src/components/Chat/Steering => packages/chat/src/components/composer/steering}/identity.ts (100%) rename {client/src/components/Chat/Input => packages/chat/src/components/composer}/submit.ts (100%) rename {client/src/components/Chat/Input => packages/chat/src/react}/__tests__/overlay.spec.tsx (98%) create mode 100644 packages/chat/src/react/lift.ts rename {client/src/components/Chat/Input => packages/chat/src/react}/overlay.ts (88%) create mode 100644 packages/chat/src/react/skills.ts diff --git a/client/src/components/Chat/ChatView.tsx b/client/src/components/Chat/ChatView.tsx index 417d017228..42bf58264c 100644 --- a/client/src/components/Chat/ChatView.tsx +++ b/client/src/components/Chat/ChatView.tsx @@ -5,19 +5,22 @@ import { useForm } from 'react-hook-form'; import { Spinner } from '@librechat/client'; import { useParams } from 'react-router-dom'; import { Constants, buildTree } from 'librechat-data-provider'; -import { submissionByIndex, ComposerRestoreProvider } from '@librechat/chat/react'; +import { QueuedTurnPortalProvider } from '@librechat/chat/components'; +import { + submissionByIndex, + ComposerRestoreProvider, + composerLiftFamily, +} from '@librechat/chat/react'; import type { TChatProject, TMessage } from 'librechat-data-provider'; import type { ChatFormValues } from '~/common'; import { AddedChatContext, ChatFormProvider, useChatContext, useFileMapContext } from '~/Providers'; import { useScrollbarGutterSeed, useAddedResponse, useLocalize } from '~/hooks'; import Footer, { useLandingFooter, useConfiguredFooter } from './Footer'; -import { QueuedTurnPortalProvider } from './Steering/QueuedTurnPortal'; import { useChatSettings } from '~/Providers/ChatSettingsContext'; import ApprovalProvider from './Messages/Content/ApprovalContext'; import ConversationStarters from './Input/ConversationStarters'; import { pendingApprovalActionFamily } from './approval/state'; import ProjectBadge from '~/components/Projects/ProjectBadge'; -import { composerLiftFamily } from './Input/Composer/state'; import { ChatSessionProvider } from '~/hooks/Chat/provider'; import { OwnerTextProvider } from './Messages/PrivateText'; import { AskAnswerHostProvider } from './ask/state'; diff --git a/client/src/components/Chat/Input/AskUserQuestionPopover.tsx b/client/src/components/Chat/Input/AskUserQuestionPopover.tsx index 2f469e3791..2285020b82 100644 --- a/client/src/components/Chat/Input/AskUserQuestionPopover.tsx +++ b/client/src/components/Chat/Input/AskUserQuestionPopover.tsx @@ -1,13 +1,13 @@ import { memo, useCallback, useEffect, useRef } from 'react'; import { useWatch } from 'react-hook-form'; import { Button, TooltipAnchor } from '@librechat/client'; +import { useComposerOverlay } from '@librechat/chat/react'; import { ChevronDown, CornerDownLeft, TriangleAlert } from 'lucide-react'; import AskUserQuestions from '~/components/Chat/Messages/Content/AskUserQuestions'; import useAskAnswerMode from '~/hooks/Input/useAskAnswerMode'; import AskOptions from '~/components/Chat/ask/options'; import { useChatFormContext } from '~/Providers'; import { isCancelKey } from '~/utils/shortcuts'; -import { useComposerOverlay } from './overlay'; import { useLocalize } from '~/hooks'; /** diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsx index 11aa8e135a..0555e73e9d 100644 --- a/client/src/components/Chat/Input/ChatForm.tsx +++ b/client/src/components/Chat/Input/ChatForm.tsx @@ -5,6 +5,12 @@ import { useAtom, useAtomValue } from 'jotai'; import { useNavigate } from 'react-router-dom'; import { useDirection } from '@radix-ui/react-direction'; import { useSteering, showStopButtonByIndex, useComposerRestoreHost } from '@librechat/chat/react'; +import { + submitFromComposer, + composerClearance, + CollapseChat, + StopButton, +} from '@librechat/chat/components'; import { composerSurfaceClasses, composerSurfaceShadow, @@ -74,16 +80,12 @@ import CodeWorkspaceMenu from './CodeWorkspaceMenu'; import CodeApprovalMenu from './CodeApprovalMenu'; import TextareaHeader from './TextareaHeader'; import PromptsCommand from './PromptsCommand'; -import { submitFromComposer } from './submit'; import SkillsCommand from './SkillsCommand'; import AutoPlayAudio from './AutoPlayAudio'; -import composerClearance from './clearance'; import Waveform from './Composer/Waveform'; import { mainTextareaId } from '~/common'; -import CollapseChat from './CollapseChat'; import QuoteButton from './QuoteButton'; import ToolDialogs from './ToolDialogs'; -import StopButton from './StopButton'; import SendButton from './SendButton'; import Queue from './Composer/Queue'; import Tray from './Composer/Tray'; diff --git a/client/src/components/Chat/Input/Composer/Bar.tsx b/client/src/components/Chat/Input/Composer/Bar.tsx index 7df732d6fb..705527b2a1 100644 --- a/client/src/components/Chat/Input/Composer/Bar.tsx +++ b/client/src/components/Chat/Input/Composer/Bar.tsx @@ -1,5 +1,6 @@ import React, { memo, useMemo, useState, useCallback } from 'react'; import * as Ariakit from '@ariakit/react'; +import { ComposerChip as Chip } from '@librechat/chat/components'; import { Mic, Plus, Check, Square, ChevronDown } from 'lucide-react'; import { IconButton, TooltipAnchor, SendIcon } from '@librechat/client'; import type { TConversation, EModelEndpoint, EndpointFileConfig } from 'librechat-data-provider'; @@ -17,7 +18,6 @@ import { useLocalize } from '~/hooks'; import Thinking from './Thinking'; import Palette from './Palette'; import { cn } from '~/utils'; -import Chip from './Chip'; /** Stable identity so the memo below is not defeated when tools are hidden. */ const EMPTY_ENTRIES: PaletteEntry[] = []; diff --git a/client/src/components/Chat/Input/Composer/Palette.tsx b/client/src/components/Chat/Input/Composer/Palette.tsx index ed6bbac80d..30a0e47ed5 100644 --- a/client/src/components/Chat/Input/Composer/Palette.tsx +++ b/client/src/components/Chat/Input/Composer/Palette.tsx @@ -10,6 +10,7 @@ import React, { import { useSetAtom } from 'jotai'; import * as Ariakit from '@ariakit/react'; import { AutoSizer, List } from 'react-virtualized'; +import { composerLiftFamily } from '@librechat/chat/react'; import { Star, Plus, Search, ChevronDown } from 'lucide-react'; import { Button, FileUpload, IconButton, TooltipAnchor, useMediaQuery } from '@librechat/client'; import type { @@ -34,7 +35,6 @@ import useAttachItems from '~/hooks/Input/useAttachItems'; import { useMCPRefresh } from '~/hooks/MCP/useMCPRefresh'; import { isMacPlatform } from '~/utils/shortcuts'; import { useBadgeRowContext } from '~/Providers'; -import { composerLiftFamily } from './state'; import { useLocalize } from '~/hooks'; import Catalog from './Catalog'; diff --git a/client/src/components/Chat/Input/Composer/Queue.tsx b/client/src/components/Chat/Input/Composer/Queue.tsx index 53dbacec89..4eb1be24c3 100644 --- a/client/src/components/Chat/Input/Composer/Queue.tsx +++ b/client/src/components/Chat/Input/Composer/Queue.tsx @@ -4,6 +4,7 @@ import { createPortal } from 'react-dom'; import * as Ariakit from '@ariakit/react'; import { useDrag, useDrop } from 'react-dnd'; import { queuedMessagesByConvoId } from '@librechat/chat/react'; +import { useQueuedTurnPortal } from '@librechat/chat/components'; import { AnimatePresence, motion, useReducedMotion } from 'framer-motion'; import { claimQueuedIntent, releaseQueuedIntent, hasQueuedIntent } from '@librechat/chat'; import { @@ -35,7 +36,6 @@ import type { RestoreToComposer } from '@librechat/chat/react'; import type { SteeringControls } from '@librechat/chat/react'; import type { MenuItemProps } from '@librechat/client'; import type { QueuedMessage } from '@librechat/chat'; -import { useQueuedTurnPortal } from '~/components/Chat/Steering/QueuedTurnPortal'; import EscalateNowButton from '~/components/Chat/Input/EscalateNowButton'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; diff --git a/client/src/components/Chat/Input/Composer/Tray.tsx b/client/src/components/Chat/Input/Composer/Tray.tsx index c39ba79184..8e5ebd98df 100644 --- a/client/src/components/Chat/Input/Composer/Tray.tsx +++ b/client/src/components/Chat/Input/Composer/Tray.tsx @@ -1,11 +1,11 @@ import { memo, useCallback, useEffect, useRef } from 'react'; import { TextQuote, WandSparkles } from 'lucide-react'; +import { ComposerChip as Chip } from '@librechat/chat/components'; import type { TConversation } from 'librechat-data-provider'; import type { ComposerItem, ComposerItemKind } from '~/hooks/Input/useComposerItems'; import type { ExtendedFile, FileSetter } from '~/common'; import { useFileHandlingNoChatContext, useLocalize } from '~/hooks'; import FileRow from '../Files/FileRow'; -import Chip from './Chip'; const KIND_ICON: Record = { quote: