- {children}
-
{text}
- {/*
-
Regenerate response */}
-
- );
-}
diff --git a/client/src/components/Input/TextChat.jsx b/client/src/components/Input/TextChat.jsx
index e35caca9cbe..ec2a4f22650 100644
--- a/client/src/components/Input/TextChat.jsx
+++ b/client/src/components/Input/TextChat.jsx
@@ -10,22 +10,18 @@ import { cn } from '~/utils';
import store from '~/store';
export default function TextChat({ isSearchView = false }) {
- const inputRef = useRef(null);
- const isComposing = useRef(false);
-
- const [text, setText] = useRecoilState(store.text);
- const { theme } = useContext(ThemeContext);
+ const { ask, isSubmitting, handleStopGenerating, latestMessage, endpointsConfig } =
+ useMessageHandler();
const conversation = useRecoilValue(store.conversation);
- const latestMessage = useRecoilValue(store.latestMessage);
-
- const endpointsConfig = useRecoilValue(store.endpointsConfig);
- const isSubmitting = useRecoilValue(store.isSubmitting);
const setShowBingToneSetting = useSetRecoilState(store.showBingToneSetting);
+ const [text, setText] = useRecoilState(store.text);
+ const { theme } = useContext(ThemeContext);
+ const isComposing = useRef(false);
+ const inputRef = useRef(null);
// TODO: do we need this?
const disabled = false;
- const { ask, stopGenerating } = useMessageHandler();
const isNotAppendable = latestMessage?.unfinished & !isSubmitting || latestMessage?.error;
const { conversationId, jailbreak } = conversation || {};
@@ -60,11 +56,6 @@ export default function TextChat({ isSearchView = false }) {
setText('');
};
- const handleStopGenerating = (e) => {
- e.preventDefault();
- stopGenerating();
- };
-
const handleKeyDown = (e) => {
if (e.key === 'Enter' && isSubmitting) {
return;
diff --git a/client/src/components/Messages/HoverButtons.jsx b/client/src/components/Messages/HoverButtons.jsx
deleted file mode 100644
index 4d481c7a3e3..00000000000
--- a/client/src/components/Messages/HoverButtons.jsx
+++ /dev/null
@@ -1,87 +0,0 @@
-import React from 'react';
-import { cn } from '~/utils/';
-import Clipboard from '../svg/Clipboard';
-import CheckMark from '../svg/CheckMark';
-import EditIcon from '../svg/EditIcon';
-import RegenerateIcon from '../svg/RegenerateIcon';
-
-export default function HoverButtons({
- isEditting,
- enterEdit,
- copyToClipboard,
- conversation,
- isSubmitting,
- message,
- regenerate,
-}) {
- const { endpoint } = conversation;
- const [isCopied, setIsCopied] = React.useState(false);
-
- const branchingSupported =
- // azureOpenAI, openAI, chatGPTBrowser support branching, so edit enabled // 5/21/23: Bing is allowing editing and Message regenerating
- !![
- 'azureOpenAI',
- 'openAI',
- 'chatGPTBrowser',
- 'google',
- 'bingAI',
- 'gptPlugins',
- 'anthropic',
- ].find((e) => e === endpoint);
- // Sydney in bingAI supports branching, so edit enabled
-
- const editEnabled =
- !message?.error &&
- message?.isCreatedByUser &&
- !message?.searchResult &&
- !isEditting &&
- branchingSupported;
-
- // for now, once branching is supported, regerate will be enabled
- let regenerateEnabled =
- // !message?.error &&
- !message?.isCreatedByUser &&
- !message?.searchResult &&
- !isEditting &&
- !isSubmitting &&
- branchingSupported;
-
- return (
-
- {editEnabled ? (
-
- );
-}
diff --git a/client/src/components/Messages/HoverButtons.tsx b/client/src/components/Messages/HoverButtons.tsx
new file mode 100644
index 00000000000..5eec313ddba
--- /dev/null
+++ b/client/src/components/Messages/HoverButtons.tsx
@@ -0,0 +1,86 @@
+import { useState } from 'react';
+import type { TConversation, TMessage } from 'librechat-data-provider';
+import { Clipboard, CheckMark, EditIcon, RegenerateIcon, ContinueIcon } from '~/components/svg';
+import { useGenerations } from '~/hooks';
+import { cn } from '~/utils';
+
+type THoverButtons = {
+ isEditing: boolean;
+ enterEdit: () => void;
+ copyToClipboard: (setIsCopied: (isCopied: boolean) => void) => void;
+ conversation: TConversation;
+ isSubmitting: boolean;
+ message: TMessage;
+ regenerate: () => void;
+ handleContinue: (e: React.MouseEvent
) => void;
+};
+
+export default function HoverButtons({
+ isEditing,
+ enterEdit,
+ copyToClipboard,
+ conversation,
+ isSubmitting,
+ message,
+ regenerate,
+ handleContinue,
+}: THoverButtons) {
+ const { endpoint } = conversation;
+ const [isCopied, setIsCopied] = useState(false);
+ const { editEnabled, regenerateEnabled, continueSupported } = useGenerations({
+ isEditing,
+ isSubmitting,
+ message,
+ endpoint: endpoint ?? '',
+ });
+
+ return (
+
+
+ {/* */}
+
+
+ copyToClipboard(setIsCopied)}
+ type="button"
+ title={isCopied ? 'Copied to clipboard' : 'Copy to clipboard'}
+ >
+ {isCopied ? : }
+
+ {regenerateEnabled ? (
+
+ {/* */}
+
+
+ ) : null}
+ {continueSupported ? (
+
+
+
+ ) : null}
+
+ );
+}
diff --git a/client/src/components/Messages/Message.jsx b/client/src/components/Messages/Message.jsx
index 87ce0c40342..a27e6bbc43b 100644
--- a/client/src/components/Messages/Message.jsx
+++ b/client/src/components/Messages/Message.jsx
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useState, useEffect, useRef } from 'react';
-import { useRecoilValue, useSetRecoilState } from 'recoil';
+import { useSetRecoilState } from 'recoil';
import copy from 'copy-to-clipboard';
import Plugin from './Plugin';
import SubRow from './Content/SubRow';
@@ -25,13 +25,12 @@ export default function Message({
setSiblingIdx,
}) {
const { text, searchResult, isCreatedByUser, error, submitting, unfinished } = message;
- const isSubmitting = useRecoilValue(store.isSubmitting);
const setLatestMessage = useSetRecoilState(store.latestMessage);
const [abortScroll, setAbort] = useState(false);
const textEditor = useRef(null);
const last = !message?.children?.length;
const edit = message.messageId == currentEditId;
- const { ask, regenerate } = useMessageHandler();
+ const { isSubmitting, ask, regenerate, handleContinue } = useMessageHandler();
const { switchToConversation } = store.useConversation();
const blinker = submitting && isSubmitting;
const getConversationQuery = useGetConversationByIdQuery(message.conversationId, {
@@ -223,12 +222,13 @@ export default function Message({
)}