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
import { useCallback } from 'react';
import { useRecoilValue } from 'recoil';
import { useIsSubmitting } from '@librechat/chat/react';
import { Constants, isForcedTemporaryRetention } from 'librechat-data-provider';
import { useChatSettings } from '~/Providers/ChatSettingsContext';
import store from '~/store';
export type UseTemporaryChatResult = {
/** Only offered before a conversation has any history, it cannot be toggled mid-thread. */
show: boolean;
isTemporary: boolean;
/** Temporary mode is locked in for the conversation in progress, leaving only a read-only indicator. */
isActive: boolean;
/** The administrator forces temporary mode, so the toggle is read-only rather than absent. */
isEnforced: boolean;
toggle: () => void;
};
export default function useTemporaryChat(): UseTemporaryChatResult {
const { isTemporary, setIsTemporary, config } = useChatSettings();
const conversation = useRecoilValue(store.conversationByIndex(0));
const isSubmitting = useIsSubmitting(0);
const isEnforced = isForcedTemporaryRetention(config.retentionMode);
const toggle = useCallback(() => {
if (isEnforced) {
return;
}
setIsTemporary((previous) => !previous);
}, [isEnforced, setIsTemporary]);
const conversationId = conversation?.conversationId;
const hasStarted = conversationId != null && conversationId !== Constants.NEW_CONVO;
const hasMessages = Array.isArray(conversation?.messages) && conversation.messages.length >= 1;
const show = !hasStarted && !hasMessages && !isSubmitting;
const isForced = isEnforced || isTemporary;
return {
show,
isTemporary: isForced,
isActive: isForced && !show,
isEnforced,
toggle,
};
}