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
🚰 perf: Suppress No-Op Conversation Writes and Widen-Proof Atom Subscriptions (#14329)
Danny Avilad5e8c5c15e0b
diff --git a/client/src/components/SidePanel/Parameters/Panel.tsx b/client/src/components/SidePanel/Parameters/Panel.tsxindex cd33937af7..5475ca7bac 100644--- a/client/src/components/SidePanel/Parameters/Panel.tsx+++ b/client/src/components/SidePanel/Parameters/Panel.tsx@@ -104,6 +104,10 @@ export default function Parameters() {}});+ if (updatedKeys.length === 0) {+ return prev;+ }+logger.log('parameters', 'parameters effect, updated keys:', updatedKeys);return updatedConversation;diff --git a/client/src/components/UnifiedSidebar/ExpandedPanel.tsx b/client/src/components/UnifiedSidebar/ExpandedPanel.tsxindex 46aebd240e..8400310e83 100644--- a/client/src/components/UnifiedSidebar/ExpandedPanel.tsx+++ b/client/src/components/UnifiedSidebar/ExpandedPanel.tsx@@ -22,7 +22,7 @@ const NewChatButton = memo(function NewChatButton({const localize = useLocalize();const queryClient = useQueryClient();const { newConversation } = useNewConvo();- const conversation = useRecoilValue(store.conversationByIndex(0));+ const conversationId = useRecoilValue(store.conversationIdByIndex(0));const switchToHistory = useRecoilValue(store.newChatSwitchToHistory);const tooltipDescription = useShortcutHint('newChat', localize('com_ui_new_chat'));const ariaKey = useShortcutAriaKey('newChat');@@ -31,7 +31,7 @@ const NewChatButton = memo(function NewChatButton({(e: React.MouseEvent<HTMLAnchorElement>) => {if (e.button === 0 && !e.ctrlKey && !e.metaKey) {e.preventDefault();- clearMessagesCache(queryClient, conversation?.conversationId);+ clearMessagesCache(queryClient, conversationId);queryClient.invalidateQueries([QueryKeys.messages]);newConversation();if (switchToHistory) {@@ -39,7 +39,7 @@ const NewChatButton = memo(function NewChatButton({}}},- [queryClient, conversation?.conversationId, newConversation, switchToHistory, setActive],+ [queryClient, conversationId, newConversation, switchToHistory, setActive],);return (diff --git a/client/src/components/UnifiedSidebar/__tests__/ExpandedPanel.spec.tsx b/client/src/components/UnifiedSidebar/__tests__/ExpandedPanel.spec.tsxindex 73f17d3508..9ee7d83d63 100644--- a/client/src/components/UnifiedSidebar/__tests__/ExpandedPanel.spec.tsx+++ b/client/src/components/UnifiedSidebar/__tests__/ExpandedPanel.spec.tsx@@ -26,6 +26,8 @@ jest.mock('~/store', () => {default: {conversationByIndex: () =>atom({ key: `mock-conversationByIndex-${counter++}`, default: null }),+ conversationIdByIndex: () =>+ atom({ key: `mock-conversationIdByIndex-${counter++}`, default: null }),newChatSwitchToHistory: switchAtom,customShortcuts: customShortcutsAtom,},diff --git a/client/src/hooks/Conversations/useNavigateToConvo.tsx b/client/src/hooks/Conversations/useNavigateToConvo.tsxindex 4450991965..a5c2ad0999 100644--- a/client/src/hooks/Conversations/useNavigateToConvo.tsx+++ b/client/src/hooks/Conversations/useNavigateToConvo.tsx@@ -32,7 +32,7 @@ const useNavigateToConvo = (index = 0) => {const clearAllConversations = store.useClearConvoState();const applyModelSpecEffects = useApplyModelSpecEffects();const setSubmission = useSetRecoilState(store.submissionByIndex(index));- const { hasSetConversation, setConversation: setConvo } = store.useCreateConversationAtom(index);+ const { hasSetConversation, setConversation: setConvo } = store.useSetConversationAtom(index);const setConversation = useCallback((conversation: TConversation) => {diff --git a/client/src/hooks/Conversations/useSetIndexOptions.ts b/client/src/hooks/Conversations/useSetIndexOptions.tsindex 72b25d8035..b4cdffb98a 100644--- a/client/src/hooks/Conversations/useSetIndexOptions.ts+++ b/client/src/hooks/Conversations/useSetIndexOptions.ts@@ -47,13 +47,15 @@ const useSetIndexOptions: TUseSetOptions = (preset = false) => {}}- setConversation(- (prevState) =>- tConvoUpdateSchema.parse({- ...prevState,- ...update,- }) as TConversation,- );+ setConversation((prevState) => {+ if (prevState && Object.keys(update).every((key) => Object.is(prevState[key], update[key]))) {+ return prevState;+ }+ return tConvoUpdateSchema.parse({+ ...prevState,+ ...update,+ }) as TConversation;+ });};const setExample: TSetExample = (i, type, newValue = null) => {diff --git a/client/src/hooks/Nav/useUnifiedSidebarLinks.ts b/client/src/hooks/Nav/useUnifiedSidebarLinks.tsindex e4ad4b090a..7737320933 100644--- a/client/src/hooks/Nav/useUnifiedSidebarLinks.ts+++ b/client/src/hooks/Nav/useUnifiedSidebarLinks.ts@@ -13,8 +13,9 @@ import store from '~/store';const defaultInterface = getConfigDefaults().interface;export default function useUnifiedSidebarLinks() {- const conversation = useRecoilValue(store.conversationByIndex(0));- const endpoint = conversation?.endpoint;+ /** Selector instead of the full conversation atom: the links only depend on+ * the endpoint, so parameter edits and other conversation writes stay out. */+ const endpoint = useRecoilValue(store.conversationEndpointByIndex(0)) ?? undefined;const { data: startupConfig } = useGetStartupConfig();const { data: endpointsConfig = {} as TEndpointsConfig } = useGetEndpointsQuery();diff --git a/client/src/store/families.ts b/client/src/store/families.tsindex 5ae0e72565..b22f970afc 100644--- a/client/src/store/families.ts+++ b/client/src/store/families.ts@@ -454,10 +454,13 @@ const messagesSiblingIdxFamily = atomFamily<number, string | null | undefined>({default: 0,});-function useCreateConversationAtom(key: string | number) {+/** Setter-only access to the conversation atom: registers the key like+ * `useCreateConversationAtom` but never subscribes to the value, so callers+ * that only write (navigation, per-row actions) don't re-render on every+ * conversation update. */+function useSetConversationAtom(key: string | number) {const hasSetConversation = useSetConvoContext();const setKeys = useSetRecoilState(conversationKeysAtom);- const conversation = useRecoilValue(conversationByIndex(key));const setConversation = useSetRecoilState(conversationByIndex(key));useEffect(() => {@@ -469,12 +472,14 @@ function useCreateConversationAtom(key: string | number) {});}, [key, setKeys]);- return { hasSetConversation, conversation, setConversation };+ return { hasSetConversation, setConversation };}-function useSetConversationAtom(key: string | number) {- const { setConversation } = useCreateConversationAtom(key);- return { setConversation };+function useCreateConversationAtom(key: string | number) {+ const { hasSetConversation, setConversation } = useSetConversationAtom(key);+ const conversation = useRecoilValue(conversationByIndex(key));++ return { hasSetConversation, conversation, setConversation };}function useClearConvoState() {