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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 19 deletions

View File

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

View File

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

View File

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