mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-21 10:50:14 +01:00
feat: support copy to clipboard
feat: move regenerate to all messages feat: move stop generate to replace submit button feat: make options' position more clear
This commit is contained in:
parent
bb1f8d731b
commit
b67af67433
10 changed files with 372 additions and 180 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { useRecoilValue, useSetRecoilState, useResetRecoilState } from 'recoil';
|
||||
import copy from 'copy-to-clipboard';
|
||||
import SubRow from './Content/SubRow';
|
||||
import Content from './Content/Content';
|
||||
import MultiMessage from './MultiMessage';
|
||||
|
|
@ -29,7 +30,7 @@ export default function Message({
|
|||
const textEditor = useRef(null);
|
||||
const last = !message?.children?.length;
|
||||
const edit = message.messageId == currentEditId;
|
||||
const { ask } = useMessageHandler();
|
||||
const { ask, regenerate } = useMessageHandler();
|
||||
const { switchToConversation } = store.useConversation();
|
||||
const blinker = submitting && isSubmitting;
|
||||
|
||||
|
|
@ -87,6 +88,14 @@ export default function Message({
|
|||
enterEdit(true);
|
||||
};
|
||||
|
||||
const regenerateMessage = () => {
|
||||
if (!isSubmitting && !message?.isCreatedByUser) regenerate(message);
|
||||
};
|
||||
|
||||
const copyToClipboard = () => {
|
||||
copy(message?.text);
|
||||
};
|
||||
|
||||
const clickSearchResult = async () => {
|
||||
if (!searchResult) return;
|
||||
const convoResponse = await fetchById('convos', message.conversationId);
|
||||
|
|
@ -177,9 +186,13 @@ export default function Message({
|
|||
)}
|
||||
</div>
|
||||
<HoverButtons
|
||||
endpoint={conversation?.endpoint}
|
||||
visible={!error && isCreatedByUser && !edit && !searchResult}
|
||||
onClick={() => enterEdit()}
|
||||
isEditting={edit}
|
||||
isSubmitting={isSubmitting}
|
||||
message={message}
|
||||
conversation={conversation}
|
||||
enterEdit={() => enterEdit()}
|
||||
regenerate={() => regenerateMessage()}
|
||||
copyToClipboard={() => copyToClipboard()}
|
||||
/>
|
||||
<SubRow subclasses="switch-container">
|
||||
<SiblingSwitch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue