From a725fb34dab8c716afbc0a41933a1f977af77baa Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Mon, 1 Dec 2025 20:12:15 +0100 Subject: [PATCH] =?UTF-8?q?=E2=8C=9B=20feat:=20Add=20Default=20Temporary?= =?UTF-8?q?=20Chat=20User=20Setting=20(#10731)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Nav/SettingsTabs/Chat/Chat.tsx | 7 +++++++ client/src/locales/en/translation.json | 2 ++ client/src/routes/ChatRoute.tsx | 11 +++++++---- client/src/store/temporary.ts | 2 ++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/client/src/components/Nav/SettingsTabs/Chat/Chat.tsx b/client/src/components/Nav/SettingsTabs/Chat/Chat.tsx index 5c703922fc..fe36c52f85 100644 --- a/client/src/components/Nav/SettingsTabs/Chat/Chat.tsx +++ b/client/src/components/Nav/SettingsTabs/Chat/Chat.tsx @@ -77,6 +77,13 @@ const toggleSwitchConfigs = [ hoverCardText: undefined, key: 'modularChat', }, + { + stateAtom: store.defaultTemporaryChat, + localizationKey: 'com_nav_default_temporary_chat', + switchId: 'defaultTemporaryChat', + hoverCardText: 'com_nav_info_default_temporary_chat', + key: 'defaultTemporaryChat', + }, ]; function Chat() { diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.json index 3aa64da011..6f1890154f 100644 --- a/client/src/locales/en/translation.json +++ b/client/src/locales/en/translation.json @@ -447,6 +447,7 @@ "com_nav_conversation_mode": "Conversation Mode", "com_nav_convo_menu_options": "Conversation Menu Options", "com_nav_db_sensitivity": "Decibel sensitivity", + "com_nav_default_temporary_chat": "Temporary Chat by default", "com_nav_delete_account": "Delete account", "com_nav_delete_account_button": "Permanently delete my account", "com_nav_delete_account_confirm": "Delete account - are you sure?", @@ -480,6 +481,7 @@ "com_nav_info_code_artifacts": "Enables the display of experimental code artifacts next to the chat", "com_nav_info_code_artifacts_agent": "Enables the use of code artifacts for this agent. By default, additional instructions specific to the use of artifacts are added, unless \"Custom Prompt Mode\" is enabled.", "com_nav_info_custom_prompt_mode": "When enabled, the default artifacts system prompt will not be included. All artifact-generating instructions must be provided manually in this mode.", + "com_nav_info_default_temporary_chat": "When enabled, new chats will start with temporary chat mode activated by default. Temporary chats are not saved to your history.", "com_nav_info_enter_to_send": "When enabled, pressing `ENTER` will send your message. When disabled, pressing Enter will add a new line, and you'll need to press `CTRL + ENTER` / `⌘ + ENTER` to send your message.", "com_nav_info_fork_change_default": "`Visible messages only` includes just the direct path to the selected message. `Include related branches` adds branches along the path. `Include all to/from here` includes all connected messages and branches.", "com_nav_info_fork_split_target_setting": "When enabled, forking will commence from the target message to the latest message in the conversation, according to the behavior selected.", diff --git a/client/src/routes/ChatRoute.tsx b/client/src/routes/ChatRoute.tsx index 240b5583b9..72433bca46 100644 --- a/client/src/routes/ChatRoute.tsx +++ b/client/src/routes/ChatRoute.tsx @@ -1,6 +1,7 @@ import { useEffect } from 'react'; import { Spinner } from '@librechat/client'; import { useParams } from 'react-router-dom'; +import { useRecoilCallback, useRecoilValue } from 'recoil'; import { Constants, EModelEndpoint } from 'librechat-data-provider'; import { useGetModelsQuery } from 'librechat-data-provider/react-query'; import type { TPreset } from 'librechat-data-provider'; @@ -11,13 +12,13 @@ import { ToolCallsMapProvider } from '~/Providers'; import ChatView from '~/components/Chat/ChatView'; import useAuthRedirect from './useAuthRedirect'; import temporaryStore from '~/store/temporary'; -import { useRecoilCallback } from 'recoil'; import store from '~/store'; export default function ChatRoute() { const { data: startupConfig } = useGetStartupConfig(); const { isAuthenticated, user } = useAuthRedirect(); + const defaultTemporaryChat = useRecoilValue(temporaryStore.defaultTemporaryChat); const setIsTemporary = useRecoilCallback( ({ set }) => (value: boolean) => { @@ -47,12 +48,14 @@ export default function ChatRoute() { const isTemporaryChat = conversation && conversation.expiredAt ? true : false; useEffect(() => { - if (conversationId !== Constants.NEW_CONVO && !isTemporaryChat) { - setIsTemporary(false); + if (conversationId === Constants.NEW_CONVO) { + setIsTemporary(defaultTemporaryChat); } else if (isTemporaryChat) { setIsTemporary(isTemporaryChat); + } else { + setIsTemporary(false); } - }, [conversationId, isTemporaryChat, setIsTemporary]); + }, [conversationId, isTemporaryChat, setIsTemporary, defaultTemporaryChat]); /** This effect is mainly for the first conversation state change on first load of the page. * Adjusting this may have unintended consequences on the conversation state. diff --git a/client/src/store/temporary.ts b/client/src/store/temporary.ts index cddea06155..60f5626920 100644 --- a/client/src/store/temporary.ts +++ b/client/src/store/temporary.ts @@ -1,7 +1,9 @@ import { atomWithLocalStorage } from '~/store/utils'; const isTemporary = atomWithLocalStorage('isTemporary', false); +const defaultTemporaryChat = atomWithLocalStorage('defaultTemporaryChat', false); export default { isTemporary, + defaultTemporaryChat, };