feat: Add Default Temporary Chat User Setting (#10731)

This commit is contained in:
Marco Beretta 2025-12-01 20:12:15 +01:00 committed by Danny Avila
parent 5fac4ffd1c
commit a725fb34da
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
4 changed files with 18 additions and 4 deletions

View file

@ -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() {

View file

@ -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.",

View file

@ -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.

View file

@ -1,7 +1,9 @@
import { atomWithLocalStorage } from '~/store/utils';
const isTemporary = atomWithLocalStorage('isTemporary', false);
const defaultTemporaryChat = atomWithLocalStorage('defaultTemporaryChat', false);
export default {
isTemporary,
defaultTemporaryChat,
};