Added ability to resume previous chat on copilot

This commit is contained in:
n4ze3m
2024-05-24 21:01:10 +05:30
parent 9e2ef72486
commit 961f5180c6
7 changed files with 88 additions and 26 deletions

View File

@@ -3,6 +3,7 @@ import {
formatToMessage,
getRecentChatFromCopilot
} from "@/db"
import { copilotResumeLastChat } from "@/services/app"
import React from "react"
import { SidePanelBody } from "~/components/Sidepanel/Chat/body"
import { SidepanelForm } from "~/components/Sidepanel/Chat/form"
@@ -19,6 +20,11 @@ const SidepanelChat = () => {
useMessage()
const setRecentMessagesOnLoad = async () => {
const isEnabled = await copilotResumeLastChat();
if (!isEnabled) {
return;
}
if (messages.length === 0) {
const recentChat = await getRecentChatFromCopilot()
if (recentChat) {
@@ -86,6 +92,11 @@ const SidepanelChat = () => {
}
}, [])
React.useEffect(() => {
setRecentMessagesOnLoad()
}, [])
return (
<div
ref={drop}