From 919bf9914341dbcc705a59df5e0804295d2b3c86 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Sat, 31 Oct 2026 22:47:57 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=96=BC=EF=B8=8F=20refactor:=20Assemble=20?= =?UTF-8?q?the=20Chat=20Screen=20in=20@librechat/chat=20(#17671)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Derive the Chat Pane's Heading, Footers, Project and Read-Only State in @librechat/chat * refactor: Lay Out the Chat View Through the Package ChatScreen --- client/src/components/Chat/ChatView.tsx | 103 +++------- .../Chat/__tests__/ChatView.subagent.spec.tsx | 1 + packages/chat/src/components.ts | 4 + packages/chat/src/components/pane/Screen.tsx | 132 ++++++++++++ .../components/pane/__tests__/Screen.spec.tsx | 148 ++++++++++++++ .../components/pane/__tests__/chrome.spec.ts | 190 ++++++++++++++++++ packages/chat/src/components/pane/chrome.ts | 62 ++++++ packages/chat/test/consumer.spec.tsx | 45 +++++ 8 files changed, 609 insertions(+), 76 deletions(-) create mode 100644 packages/chat/src/components/pane/Screen.tsx create mode 100644 packages/chat/src/components/pane/__tests__/Screen.spec.tsx create mode 100644 packages/chat/src/components/pane/__tests__/chrome.spec.ts create mode 100644 packages/chat/src/components/pane/chrome.ts diff --git a/client/src/components/Chat/ChatView.tsx b/client/src/components/Chat/ChatView.tsx index e1504af643..61d67cd9f8 100644 --- a/client/src/components/Chat/ChatView.tsx +++ b/client/src/components/Chat/ChatView.tsx @@ -1,10 +1,10 @@ -import { memo, useMemo } from 'react'; +import { memo } from 'react'; import { useAtomValue } from 'jotai'; import { useRecoilValue } from 'recoil'; import { useForm } from 'react-hook-form'; import { useParams } from 'react-router-dom'; -import { Constants, buildTree } from 'librechat-data-provider'; -import { ChatPane, getChatPaneView, QueuedTurnPortalProvider } from '@librechat/chat/components'; +import { Constants } from 'librechat-data-provider'; +import { ChatScreen, QueuedTurnPortalProvider } from '@librechat/chat/components'; import { submissionByIndex, ChatSessionProvider, @@ -22,8 +22,8 @@ import ApprovalProvider from './Messages/Content/ApprovalContext'; import ConversationStarters from './Input/ConversationStarters'; import ProjectBadge from '~/components/Projects/ProjectBadge'; import { OwnerTextProvider } from './Messages/PrivateText'; -import { useAddedResponse, useLocalize } from '~/hooks'; import MessagesView from './Messages/MessagesView'; +import { useAddedResponse } from '~/hooks'; import Presentation from './Presentation'; import ChatForm from './Input/ChatForm'; import { TraceSurface } from './Trace'; @@ -51,7 +51,6 @@ function ChatViewPane({ messages: TMessage[] | null; isLoading: boolean; }) { - const localize = useLocalize(); const rootSubmission = useAtomValue(submissionByIndex(index)); const { saveDrafts } = useChatSettings(); const enterToSend = useRecoilValue(store.enterToSend); @@ -67,7 +66,7 @@ function ChatViewPane({ useScrollbarGutterSeed(); /** A conversation carries a footer only for configured content, and the - * composer's clearance has to account for the bar when it does — including + * composer's clearance has to account for the bar when it does, including * before the config answers, so a cold load does not jump. */ const configuredFooter = useConfiguredFooter(); const landingFooter = useLandingFooter(); @@ -77,49 +76,9 @@ function ChatViewPane({ }); const fileMap = useFileMapContext(); - - const messagesTree = useMemo(() => { - const dataTree = buildTree({ messages, fileMap }); - return dataTree?.length === 0 ? null : (dataTree ?? null); - }, [messages, fileMap]); - const chat = useChatContext(); const addedChatHelpers = useAddedResponse(); - const activeConversation = - chat.conversation?.conversationId === conversationId ? chat.conversation : undefined; - const activeSubagentThread = activeConversation?.subagentThread; - const chatProjectId = activeConversation?.chatProjectId || undefined; - - const view = getChatPaneView({ - conversationId, - isLoading, - hasMessages: messagesTree != null && messagesTree.length > 0, - }); - const { isLanding: isLandingPage } = view; - - /** The welcome screen carries the full footer unless the deployment turned it - * off; otherwise a footer bar renders only for configured content. */ - const fullFooter = isLandingPage && landingFooter; - const footerBelow = fullFooter || configuredFooter; - const isProjectLandingPage = isLandingPage && project != null; - - const chatFormPlaceholder = - isProjectLandingPage && project - ? localize('com_ui_new_chat_in_project', { name: project.name }) - : undefined; - - // Recoil conversation can lag the route during navigation; only announce a - // title that belongs to the conversation currently in the URL. - const conversationTitle = activeConversation?.title?.trim(); - const pageHeading = - isLandingPage || !conversationTitle ? localize('com_ui_new_chat') : conversationTitle; - const parentConversationId = activeSubagentThread?.parentConversationId; - /** Durable child threads are an execution record owned by their parent agent. - * Human continuation is a separate future fork/promotion flow, never an - * in-place mutation of this canonical child transcript. */ - const isSubagentThreadReadOnly = activeSubagentThread != null; - return ( @@ -129,18 +88,20 @@ function ChatViewPane({ - - } - badge={chatProjectId ? : null} - messages={} + conversationId={conversationId} + messages={messages} + fileMap={fileMap} + isLoading={isLoading} + project={project} + landingFooter={landingFooter} + configuredFooter={configuredFooter} + renderHeader={({ parentConversationId, readOnly }) => ( +
+ )} + renderBadge={(projectId) => } + renderMessages={(thread) => } landing={} renderColumn={(column) => ( )} starters={} - readOnlyNote={ - isSubagentThreadReadOnly - ? localize('com_ui_subagent_thread_read_only') - : undefined - } - composer={ + renderComposer={({ isLanding, footerBelow, project, placeholder }) => ( - } + )} /* The generic disclaimer and the policy links are the welcome screen's; a deployment's own footer stays with the conversation that always showed it. */ - bandFooter={ - !fullFooter && configuredFooter ?