🧹 chore: Remove Deprecated BingAI Code & Address Mobile Focus (#5565)

* chore: remove all bing code

* chore: remove bing code and auto-focus effects

* chore: add back escapeRegExp helper function for regex special character handling

* chore: remove deprecated fields from settings and conversation schema

* fix: ensure default endpoint is set correctly in conversation setup

* feat: add disableFocus option to newConversation for improved search behavior
This commit is contained in:
Danny Avila 2025-01-30 17:22:29 -05:00 committed by GitHub
parent 1226f56d0c
commit 19fa4d9f54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 52 additions and 1384 deletions

View file

@ -130,9 +130,6 @@ export default function useChatHelpers(index = 0, paramId?: string) {
setSiblingIdx(0);
};
const [showBingToneSetting, setShowBingToneSetting] = useRecoilState(
store.showBingToneSettingFamily(index),
);
const [showPopover, setShowPopover] = useRecoilState(store.showPopoverFamily(index));
const [abortScroll, setAbortScroll] = useRecoilState(store.abortScrollFamily(index));
const [preset, setPreset] = useRecoilState(store.presetByIndex(index));
@ -166,8 +163,6 @@ export default function useChatHelpers(index = 0, paramId?: string) {
setShowPopover,
abortScroll,
setAbortScroll,
showBingToneSetting,
setShowBingToneSetting,
preset,
setPreset,
optionSettings,

View file

@ -29,7 +29,6 @@ export default function useClearStates() {
reset(store.isSubmittingFamily(key));
reset(store.optionSettingsFamily(key));
reset(store.showAgentSettingsFamily(key));
reset(store.showBingToneSettingFamily(key));
reset(store.showPopoverFamily(key));
reset(store.showMentionPopoverFamily(key));
reset(store.showPlusPopoverFamily(key));

View file

@ -1,7 +1,6 @@
import debounce from 'lodash/debounce';
import { useEffect, useRef, useCallback } from 'react';
import { useRecoilValue, useRecoilState } from 'recoil';
import { Constants } from 'librechat-data-provider';
import type { TEndpointOption } from 'librechat-data-provider';
import type { KeyboardEvent } from 'react';
import {
@ -43,18 +42,11 @@ export default function useTextarea({
const checkHealth = useInteractionHealthCheck();
const enterToSend = useRecoilValue(store.enterToSend);
const {
index,
conversation,
isSubmitting,
filesLoading,
latestMessage,
setFilesLoading,
setShowBingToneSetting,
} = useChatContext();
const { index, conversation, isSubmitting, filesLoading, latestMessage, setFilesLoading } =
useChatContext();
const [activePrompt, setActivePrompt] = useRecoilState(store.activePromptByIndex(index));
const { conversationId, jailbreak = false, endpoint = '' } = conversation || {};
const { endpoint = '' } = conversation || {};
const { entity, isAgent, isAssistant } = getEntity({
endpoint,
agentsMap,
@ -78,33 +70,6 @@ export default function useTextarea({
}
}, [activePrompt, setActivePrompt, textAreaRef]);
// auto focus to input, when enter a conversation.
useEffect(() => {
const convoId = conversationId ?? '';
if (!convoId) {
return;
}
// Prevents Settings from not showing on new conversation, also prevents showing toneStyle change without jailbreak
if (convoId === Constants.NEW_CONVO || !jailbreak) {
setShowBingToneSetting(false);
}
if (convoId !== Constants.SEARCH) {
textAreaRef.current?.focus();
}
// setShowBingToneSetting is a recoil setter, so it doesn't need to be in the dependency array
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [conversationId, jailbreak]);
useEffect(() => {
const timeoutId = setTimeout(() => {
textAreaRef.current?.focus();
}, 100);
return () => clearTimeout(timeoutId);
}, [isSubmitting, textAreaRef]);
useEffect(() => {
const currentValue = textAreaRef.current?.value ?? '';
if (currentValue) {

View file

@ -53,7 +53,6 @@ export default function useGenerationsByLatest({
EModelEndpoint.bedrock,
EModelEndpoint.chatGPTBrowser,
EModelEndpoint.google,
EModelEndpoint.bingAI,
EModelEndpoint.gptPlugins,
EModelEndpoint.anthropic,
].find((e) => e === endpoint),

View file

@ -8,6 +8,7 @@ import { useNavigate } from 'react-router-dom';
import {
Constants,
FileSources,
EModelEndpoint,
isParamEndpoint,
LocalStorageKeys,
isAssistantsEndpoint,
@ -70,6 +71,7 @@ const useNewConvo = (index = 0) => {
buildDefault?: boolean,
keepLatestMessage?: boolean,
keepAddedConvos?: boolean,
disableFocus?: boolean,
) => {
const modelsConfig = modelsData ?? modelsQuery.data;
const { endpoint = null } = conversation;
@ -87,11 +89,15 @@ const useNewConvo = (index = 0) => {
: preset;
if (buildDefaultConversation) {
const defaultEndpoint = getDefaultEndpoint({
let defaultEndpoint = getDefaultEndpoint({
convoSetup: activePreset ?? conversation,
endpointsConfig,
});
if (!defaultEndpoint) {
defaultEndpoint = Object.keys(endpointsConfig ?? {})[0] as EModelEndpoint;
}
const endpointType = getEndpointField(endpointsConfig, defaultEndpoint, 'type');
if (!conversation.endpointType && endpointType) {
conversation.endpointType = endpointType;
@ -161,6 +167,9 @@ const useNewConvo = (index = 0) => {
}
clearTimeout(timeoutIdRef.current);
if (disableFocus === true) {
return;
}
timeoutIdRef.current = setTimeout(() => {
const textarea = document.getElementById(mainTextareaId);
if (textarea) {
@ -176,6 +185,7 @@ const useNewConvo = (index = 0) => {
template: _template = {},
preset: _preset,
modelsData,
disableFocus,
buildDefault = true,
keepLatestMessage = false,
keepAddedConvos = false,
@ -184,6 +194,7 @@ const useNewConvo = (index = 0) => {
preset?: Partial<TPreset>;
modelsData?: TModelsConfig;
buildDefault?: boolean;
disableFocus?: boolean;
keepLatestMessage?: boolean;
keepAddedConvos?: boolean;
} = {}) {
@ -254,6 +265,7 @@ const useNewConvo = (index = 0) => {
buildDefault,
keepLatestMessage,
keepAddedConvos,
disableFocus,
);
},
[