From fb14785cadf2055818bd4ff9c6064b59e53c2700 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sat, 15 Apr 2023 02:28:30 +0800 Subject: [PATCH 1/2] fix: #804 disable auto scroll in textarea --- app/components/chat.tsx | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index b9ae13926..b0deb5a51 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -442,16 +442,6 @@ export function Chat(props: { inputRef.current?.focus(); }; - const scrollInput = () => { - const dom = inputRef.current; - if (!dom) return; - const paddingBottomNum: number = parseInt( - window.getComputedStyle(dom).paddingBottom, - 10, - ); - dom.scrollTop = dom.scrollHeight - dom.offsetHeight + paddingBottomNum; - }; - // auto grow input const [inputRows, setInputRows] = useState(2); const measure = useDebouncedCallback( @@ -476,7 +466,6 @@ export function Chat(props: { // only search prompts when user input is short const SEARCH_TEXT_LIMIT = 30; const onInput = (text: string) => { - scrollInput(); setUserInput(text); const n = text.trim().length; From 47a2911ee2cd229feb14967a10d02148d2ae2913 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sat, 15 Apr 2023 02:37:24 +0800 Subject: [PATCH 2/2] feat: edit session title button --- app/components/chat.tsx | 24 +++++++++++------------- app/icons/rename.svg | 1 + 2 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 app/icons/rename.svg diff --git a/app/components/chat.tsx b/app/components/chat.tsx index b0deb5a51..f7b67b293 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -3,6 +3,7 @@ import { memo, useState, useRef, useEffect, useLayoutEffect } from "react"; import SendWhiteIcon from "../icons/send-white.svg"; import BrainIcon from "../icons/brain.svg"; +import RenameIcon from "../icons/rename.svg"; import ExportIcon from "../icons/share.svg"; import ReturnIcon from "../icons/return.svg"; import CopyIcon from "../icons/copy.svg"; @@ -589,6 +590,13 @@ export function Chat(props: { const [showPromptModal, setShowPromptModal] = useState(false); + const renameSession = () => { + const newTopic = prompt(Locale.Chat.Rename, session.topic); + if (newTopic && newTopic !== session.topic) { + chatStore.updateCurrentSession((session) => (session.topic = newTopic!)); + } + }; + // Auto focus useEffect(() => { if (props.sideBarShowing && isMobileScreen()) return; @@ -602,14 +610,7 @@ export function Chat(props: {
{ - const newTopic = prompt(Locale.Chat.Rename, session.topic); - if (newTopic && newTopic !== session.topic) { - chatStore.updateCurrentSession( - (session) => (session.topic = newTopic!), - ); - } - }} + onClickCapture={renameSession} > {session.topic}
@@ -628,12 +629,9 @@ export function Chat(props: {
} + icon={} bordered - title={Locale.Chat.Actions.CompressedHistory} - onClick={() => { - setShowPromptModal(true); - }} + onClick={renameSession} />
diff --git a/app/icons/rename.svg b/app/icons/rename.svg new file mode 100644 index 000000000..cee69eb8d --- /dev/null +++ b/app/icons/rename.svg @@ -0,0 +1 @@ +