forked from React-Group/interstellar_ai
Merge branch 'main' into main
This commit is contained in:
commit
588cc98db5
8 changed files with 202 additions and 121 deletions
|
@ -2,6 +2,7 @@ import React, { ForwardedRef, useState, useEffect, useRef } from 'react';
|
|||
import Markdown from 'react-markdown';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { useChatHistory } from '../hooks/useChatHistory';
|
||||
|
||||
type Message = {
|
||||
role: string;
|
||||
|
@ -21,6 +22,7 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
|
|||
({ messages, onStopClick, onResendClick, onEditClick, onCopyClick, isClicked }, ref: ForwardedRef<HTMLDivElement>) => {
|
||||
const [isScrolling, setIsScrolling] = useState(true);
|
||||
const messagesEndRef = useRef<HTMLDivElement | null>(null);
|
||||
const [chatHistory, setChatHistory, setSelectedIndex] = useChatHistory()
|
||||
|
||||
useEffect(() => {
|
||||
const observer = new IntersectionObserver(
|
||||
|
@ -58,7 +60,7 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
|
|||
return (
|
||||
<div className="output" ref={ref}>
|
||||
<div className="conversation resize" id="conversation">
|
||||
{messages.map((message, index) => {
|
||||
{chatHistory.chats[chatHistory.selectedIndex].messages.map((message, index) => {
|
||||
if (index >= 1) {
|
||||
return (
|
||||
<div
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import React, { useState } from 'react';
|
||||
import { useChatHistory } from '../hooks/useChatHistory';
|
||||
|
||||
interface HistoryProps{
|
||||
selectedIndex: number;
|
||||
setSelectedIndex: (index: number) => void;
|
||||
}
|
||||
|
||||
const History: React.FC<HistoryProps> = ({selectedIndex, setSelectedIndex}) => {
|
||||
const History: React.FC = () => {
|
||||
const [chatHistory, setChatHistory, setSelectedIndex] = useChatHistory()
|
||||
|
||||
const handleHistoryClick = (index: number) => {
|
||||
setSelectedIndex(index)
|
||||
|
@ -16,9 +13,9 @@ const History: React.FC<HistoryProps> = ({selectedIndex, setSelectedIndex}) => {
|
|||
<div className="history">
|
||||
<ul>
|
||||
{/* Populate with history items */}
|
||||
{Array.from({ length: 20 }, (_, index) => (
|
||||
{chatHistory.chats.map((chats, index) => (
|
||||
<li key={index}>
|
||||
<a href="#" onClick={()=>handleHistoryClick(index)}>history{index + 1}</a>
|
||||
<a href="#" onClick={() => handleHistoryClick(index)}>{chatHistory.chats[index].name}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue