Minor tweaks for deployment

This commit is contained in:
sageTheDM 2024-10-08 16:09:35 +02:00
parent 8dffff4482
commit 553f316953
3 changed files with 40 additions and 33 deletions

View file

@ -1,12 +1,12 @@
import React, { ForwardedRef, useState, useEffect, useRef } from 'react';
import Markdown from 'react-markdown'
import Markdown from 'react-markdown';
import rehypeRaw from 'rehype-raw';
import remarkGfm from 'remark-gfm';
type Message = {
role: string
content: string
}
role: string;
content: string;
};
interface ConversationProps {
messages: Message[];
@ -14,7 +14,7 @@ interface ConversationProps {
onResendClick: () => void;
onEditClick: () => void;
onCopyClick: () => void;
isClicked: boolean
isClicked: boolean;
}
const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>(
@ -26,16 +26,14 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
const observer = new IntersectionObserver(
(entries) => {
if (entries[0].isIntersecting) {
console.log('End of messages reached');
setIsScrolling(true);
} else {
console.log('End of messages not reached');
setIsScrolling(false);
}
},
{
root: document.querySelector('.output'),
threshold: 1.0, // Ensure the whole element is visible
threshold: 1.0,
}
);
@ -51,7 +49,6 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
};
}, [messages]);
// Scroll to bottom when new messages arrive
useEffect(() => {
if (isScrolling) {
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
@ -63,7 +60,6 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
<div className="conversation resize" id="conversation">
{messages.map((message, index) => {
if (index >= 1) {
return (
<div
key={index}
@ -75,8 +71,9 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
</div>
);
}
return null; // Ensure to return null for the first message or if condition is not met
})}
<div ref={messagesEndRef} />
<div className="button-container">
<div className="tooltip">
<button type="button" onClick={onStopClick}>
@ -108,6 +105,7 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
<svg style={{ fill: "var(--text-color)" }} viewBox="0 0 384 512" height={30}><path d="M169.4 470.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 370.8 224 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 306.7L54.6 265.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" /></svg>
</button>
</div>
);
}
);