remove jump on chat finish

This commit is contained in:
Dallin Romney 2024-11-04 17:14:48 -08:00
parent 10b16201a7
commit c7e765c5d0
2 changed files with 22 additions and 18 deletions

View file

@ -93,7 +93,7 @@ function StepContainer(props: StepContainerProps) {
hidden={!props.open}
isUserInput={isUserInput}
fontSize={getFontSize()}
// className="pb-2"
>
{uiConfig?.displayRawMarkdown ? (
<pre
@ -111,7 +111,8 @@ function StepContainer(props: StepContainerProps) {
</ContentDiv>
{shouldRenderActions && (
<div className="flex items-center justify-end gap-0.5 xs:flex text-xs text-gray-400 p-2 pb-0 cursor-default">
// Height of this should be the same as height of "Cancel" div to prevent jump
<div className="h-9 mb-4 flex items-center justify-end gap-0.5 xs:flex text-xs text-gray-400 pb-0 cursor-default">
{truncatedEarly && (
<ButtonWithTooltip
tabIndex={-1}

View file

@ -149,15 +149,14 @@ export function Chat() {
useHistory(dispatch);
useEffect(() => {
if (!active || !topGuiDivRef.current) return;
if (!active || !topGuiDivRef.current) return
const scrollAreaElement = topGuiDivRef.current;
scrollAreaElement.scrollTop =
scrollAreaElement.scrollHeight - scrollAreaElement.clientHeight;
setIsAtBottom(true);
}, [active]);
}, [topGuiDivRef, active, setIsAtBottom])
useEffect(() => {
// Cmd + Backspace to delete current step
@ -436,20 +435,23 @@ export function Chat() {
</StopButton>
)}
{active && (
<StopButton
className="mb-4 mt-auto"
onClick={() => {
dispatch(setInactive());
if (
state.history[state.history.length - 1]?.message.content
.length === 0
) {
dispatch(clearLastResponse());
}
}}
<div
className="mb-4 h-9"
>
{getMetaKeyLabel()} ⌫ Cancel
</StopButton>
<StopButton
onClick={() => {
dispatch(setInactive());
if (
state.history[state.history.length - 1]?.message.content
.length === 0
) {
dispatch(clearLastResponse());
}
}}
>
{getMetaKeyLabel()} ⌫ Cancel
</StopButton>
</div>
)}
<div className={`${state.history.length > 0 ? 'pt-1 border-0 border-t border-solid border-t-zinc-700' : ''}`}>
<ContinueInputBox
@ -461,6 +463,7 @@ export function Chat() {
/>
<div style={{
opacity: active ? 0 : 1,
pointerEvents: active ? 'none' : 'auto',
}}>
{state.history.length > 0 ? (
<div className="xs:inline mt-2 hidden">