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
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
📝 refactor: Read ChatView's Save-Drafts Setting From the Host Chat Settings (#16952)
Marco Berettac5f398accadf
diff --git a/client/src/components/Chat/ChatView.tsx b/client/src/components/Chat/ChatView.tsxindex 0f24310eb0..ead33f83d1 100644--- a/client/src/components/Chat/ChatView.tsx+++ b/client/src/components/Chat/ChatView.tsx@@ -25,6 +25,7 @@ import {ComposerRestoreProvider,} from '~/Providers';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';@@ -68,7 +69,7 @@ function ChatView({const localize = useLocalize();const rootSubmission = useRecoilValue(store.submissionByIndex(index));const isSubmitting = useRecoilValue(store.isSubmittingFamily(index));- const saveDrafts = useRecoilValue(store.saveDrafts);+ const { saveDrafts } = useChatSettings();const enterToSend = useRecoilValue(store.enterToSend);const autoSendText = useRecoilValue(store.autoSendText);const speechSettingsInitialized = useRecoilValue(store.speechSettingsInitialized);diff --git a/client/src/components/Chat/__tests__/ChatView.spec.tsx b/client/src/components/Chat/__tests__/ChatView.spec.tsxindex bac4646a2f..ab56e2927a 100644--- a/client/src/components/Chat/__tests__/ChatView.spec.tsx+++ b/client/src/components/Chat/__tests__/ChatView.spec.tsx@@ -1,11 +1,13 @@import React from 'react';import '@testing-library/jest-dom';+import { ChatSettingsContext, defaultChatSettings } from '~/Providers/ChatSettingsContext';import { render, screen } from 'test/layout-test-utils';import ChatView from '../ChatView';const mockParams = jest.fn();const mockConversation = jest.fn();const mockChatFormProps = jest.fn();+const mockAskHostSaveDrafts = jest.fn();jest.mock('react-router-dom', () => ({...jest.requireActual('react-router-dom'),@@ -56,6 +58,7 @@ jest.mock('../Input/ChatForm', () => ({__esModule: true,default: (props: Record<string, unknown>) => {mockChatFormProps(props);+ mockAskHostSaveDrafts(jest.requireActual('../ask/state').useAskAnswerHost());return <div />;},}));@@ -191,3 +194,22 @@ describe('ChatView composer column', () => {expect(composerColumn).toHaveClass('relative', 'z-10');});});++describe('ChatView draft saving', () => {+ beforeEach(() => {+ mockParams.mockReturnValue({});+ mockConversation.mockReturnValue(null);+ mockAskHostSaveDrafts.mockReset();+ });++ /** A host that supplies its own chat settings drives ask-answer draft saving too. */+ test.each([true, false])('hands the host saveDrafts=%s to ask-answer drafts', (saveDrafts) => {+ render(+ <ChatSettingsContext.Provider value={{ ...defaultChatSettings, saveDrafts }}>+ <ChatView />+ </ChatSettingsContext.Provider>,+ );++ expect(mockAskHostSaveDrafts).toHaveBeenLastCalledWith(saveDrafts);+ });+});