address pablo's nits (#2368)

This commit is contained in:
pablodanswer
2024-09-09 14:44:27 -07:00
committed by GitHub
parent e4e4765c60
commit dbd56f946f
3 changed files with 25 additions and 19 deletions

View File

@@ -964,6 +964,11 @@ export function ChatPage({
(message) => message.messageId === messageIdToResend (message) => message.messageId === messageIdToResend
); );
updateRegenerationState(
regenerationRequest
? { regenerating: true, finalMessageIndex: messageIdToResend || 0 }
: null
);
const messageMap = currentMessageMap(completeMessageDetail); const messageMap = currentMessageMap(completeMessageDetail);
const messageToResendParent = const messageToResendParent =
messageToResend?.parentMessageId !== null && messageToResend?.parentMessageId !== null &&
@@ -991,12 +996,6 @@ export function ChatPage({
setSubmittedMessage(currMessage); setSubmittedMessage(currMessage);
updateRegenerationState(
regenerationRequest
? { regenerating: true, finalMessageIndex: messageIdToResend || 0 }
: null
);
updateChatState("loading"); updateChatState("loading");
const currMessageHistory = const currMessageHistory =
@@ -1811,9 +1810,14 @@ export function ChatPage({
? messageMap.get(message.parentMessageId) ? messageMap.get(message.parentMessageId)
: null; : null;
if ( if (
currentSessionRegenerationState?.regenerating && (currentSessionRegenerationState?.regenerating &&
message.messageId > message.messageId >
currentSessionRegenerationState?.finalMessageIndex! currentSessionRegenerationState?.finalMessageIndex!) ||
(currentSessionChatState == "loading" &&
((i >= messageHistory.length - 2 &&
message.type == "user") ||
(i >= messageHistory.length - 1 &&
!currentSessionRegenerationState?.regenerating)))
) { ) {
return <></>; return <></>;
} }
@@ -1890,7 +1894,8 @@ export function ChatPage({
if ( if (
currentSessionRegenerationState?.regenerating && currentSessionRegenerationState?.regenerating &&
currentSessionChatState == "loading" && currentSessionChatState == "loading" &&
message.messageId == messageHistory.length - 1 (i == messageHistory.length - 1 ||
currentSessionRegenerationState?.regenerating)
) { ) {
return <></>; return <></>;
} }
@@ -2093,17 +2098,17 @@ export function ChatPage({
} }
})} })}
{currentSessionChatState == "loading" || {(currentSessionChatState == "loading" ||
(loadingError && (loadingError &&
!currentSessionRegenerationState?.regenerating && !currentSessionRegenerationState?.regenerating &&
messageHistory[messageHistory.length - 1] messageHistory[messageHistory.length - 1]
?.type != "user" && ( ?.type != "user")) && (
<HumanMessage <HumanMessage
key={-2} key={-2}
messageId={-1} messageId={-1}
content={submittedMessage} content={submittedMessage}
/> />
))} )}
{currentSessionChatState == "loading" && ( {currentSessionChatState == "loading" && (
<div <div

View File

@@ -34,7 +34,6 @@ import { Hoverable } from "@/components/Hoverable";
import { SettingsContext } from "@/components/settings/SettingsProvider"; import { SettingsContext } from "@/components/settings/SettingsProvider";
import { ChatState } from "../types"; import { ChatState } from "../types";
import UnconfiguredProviderText from "@/components/chat_search/UnconfiguredProviderText"; import UnconfiguredProviderText from "@/components/chat_search/UnconfiguredProviderText";
import { useSearchContext } from "@/components/context/SearchContext";
const MAX_INPUT_HEIGHT = 200; const MAX_INPUT_HEIGHT = 200;

View File

@@ -715,6 +715,7 @@ export const HumanMessage = ({
// Move the cursor to the end of the text // Move the cursor to the end of the text
textareaRef.current.selectionStart = textareaRef.current.value.length; textareaRef.current.selectionStart = textareaRef.current.value.length;
textareaRef.current.selectionEnd = textareaRef.current.value.length; textareaRef.current.selectionEnd = textareaRef.current.value.length;
textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;
} }
}, [isEditing]); }, [isEditing]);
@@ -787,6 +788,7 @@ export const HumanMessage = ({
style={{ scrollbarWidth: "thin" }} style={{ scrollbarWidth: "thin" }}
onChange={(e) => { onChange={(e) => {
setEditedContent(e.target.value); setEditedContent(e.target.value);
textareaRef.current!.style.height = "auto";
e.target.style.height = `${e.target.scrollHeight}px`; e.target.style.height = `${e.target.scrollHeight}px`;
}} }}
onKeyDown={(e) => { onKeyDown={(e) => {