diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx
index ac7063be..ca12df54 100644
--- a/frontend/src/Navigation.tsx
+++ b/frontend/src/Navigation.tsx
@@ -5,10 +5,13 @@ import { NavLink, useNavigate } from 'react-router-dom';
import conversationService from './api/services/conversationService';
import userService from './api/services/userService';
import Add from './assets/add.svg';
+import openNewChat from './assets/openNewChat.svg';
+import Hamburger from './assets/hamburger.svg';
import DocsGPT3 from './assets/cute_docsgpt3.svg';
import Discord from './assets/discord.svg';
import Expand from './assets/expand.svg';
import Github from './assets/github.svg';
+import Info from './assets/info.svg';
import SettingGear from './assets/settingGear.svg';
import Twitter from './assets/TwitterX.svg';
import UploadIcon from './assets/upload.svg';
@@ -37,6 +40,7 @@ import {
setSelectedDocs,
setSourceDocs,
} from './preferences/preferenceSlice';
+import { selectQueries } from './conversation/conversationSlice';
import Upload from './upload/Upload';
import ShareButton from './components/ShareButton';
import Help from './components/Help';
@@ -63,6 +67,7 @@ NavImage.propTypes = {
}; */
export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
const dispatch = useDispatch();
+ const queries = useSelector(selectQueries);
const docs = useSelector(selectSourceDocs);
const selectedDocs = useSelector(selectSelectedDocs);
const conversations = useSelector(selectConversations);
@@ -92,6 +97,9 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
if (!conversations) {
fetchConversations();
}
+ if (queries.length === 0) {
+ resetConversation();
+ }
}, [conversations, dispatch]);
async function fetchConversations() {
@@ -163,7 +171,11 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
}),
);
};
-
+ const newChat = () => {
+ if (queries && queries?.length > 0) {
+ resetConversation();
+ }
+ };
async function updateConversationName(updatedConversation: {
name: string;
id: string;
@@ -199,26 +211,45 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
return (
<>
{!navOpen && (
-
+
+
+
+ {queries?.length > 0 && (
+
+ )}
+
+ DocsGPT
+
+
+
)}
-
-
- {conversationId &&
}
+
+
+
DocsGPT
+
+
+
+
diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx
index ae4ed7a9..a8326da7 100644
--- a/frontend/src/conversation/Conversation.tsx
+++ b/frontend/src/conversation/Conversation.tsx
@@ -1,20 +1,24 @@
import { Fragment, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
-
+import newChatIcon from '../assets/openNewChat.svg';
import ArrowDown from '../assets/arrow-down.svg';
import Send from '../assets/send.svg';
import SendDark from '../assets/send_dark.svg';
import SpinnerDark from '../assets/spinner-dark.svg';
import Spinner from '../assets/spinner.svg';
import RetryIcon from '../components/RetryIcon';
+import { useNavigate } from 'react-router-dom';
import Hero from '../Hero';
import { useDarkTheme, useMediaQuery } from '../hooks';
+import { ShareConversationModal } from '../modals/ShareConversationModal';
+import { setConversation, updateConversationId } from './conversationSlice';
import { selectConversationId } from '../preferences/preferenceSlice';
import { AppDispatch } from '../store';
import ConversationBubble from './ConversationBubble';
import { handleSendFeedback } from './conversationHandlers';
import { FEEDBACK, Query } from './conversationModels';
+import ShareIcon from '../assets/share.svg';
import {
addQuery,
fetchAnswer,
@@ -22,10 +26,10 @@ import {
selectStatus,
updateQuery,
} from './conversationSlice';
-import ShareButton from '../components/ShareButton';
export default function Conversation() {
const queries = useSelector(selectQueries);
+ const navigate = useNavigate();
const status = useSelector(selectStatus);
const conversationId = useSelector(selectConversationId);
const dispatch = useDispatch();
@@ -36,6 +40,7 @@ export default function Conversation() {
const fetchStream = useRef(null);
const [eventInterrupt, setEventInterrupt] = useState(false);
const [lastQueryReturnedErr, setLastQueryReturnedErr] = useState(false);
+ const [isShareModalOpen, setShareModalState] = useState(false);
const { t } = useTranslation();
const { isMobile } = useMediaQuery();
@@ -44,6 +49,9 @@ export default function Conversation() {
};
useEffect(() => {
!eventInterrupt && scrollIntoView();
+ if (queries.length == 0) {
+ resetConversation();
+ }
}, [queries.length, queries[queries.length - 1]]);
useEffect(() => {
@@ -118,6 +126,17 @@ export default function Conversation() {
handleInput();
}
};
+ const resetConversation = () => {
+ dispatch(setConversation([]));
+ dispatch(
+ updateConversationId({
+ query: { conversationId: null },
+ }),
+ );
+ };
+ const newChat = () => {
+ if (queries && queries.length > 0) resetConversation();
+ };
const prepResponseView = (query: Query, index: number) => {
let responseView;
@@ -195,10 +214,49 @@ export default function Conversation() {
};
}, []);
return (
-
- {conversationId && (
-
-
+
+ {conversationId && queries.length > 0 && (
+
+ {' '}
+
+ {isMobile && queries.length > 0 && (
+
+ )}
+
+
+
+ {isShareModalOpen && (
+
{
+ setShareModalState(false);
+ }}
+ conversationId={conversationId}
+ />
+ )}
)}