Skip to content

Commit 0155708

Browse files
Merge pull request #47 from ModusCreateOrg/ADE-171
[ADE-171] - Add new MCP configuration and enhance chat functionality
2 parents 90afaa0 + f2b7e31 commit 0155708

File tree

6 files changed

+45
-9
lines changed

6 files changed

+45
-9
lines changed

bunx

Whitespace-only changes.

frontend/capacitor.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const config: CapacitorConfig = {
2020
},
2121
server: {
2222
allowNavigation: [
23-
"https://*"
23+
"*"
2424
]
2525
}
2626
};

frontend/src/common/utils/i18n/resources/en/home.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"uploadDate": "Upload Date",
2727
"noReports": {
2828
"title": "No Reports",
29-
"message": "Upload a report or try again later",
29+
"message": "Upload a report or try again",
3030
"uploadButton": "Upload Report",
3131
"connectButton": "Connect Provider"
3232
},

frontend/src/pages/Chat/ChatPage.tsx

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/react';
22
import { useTranslation } from 'react-i18next';
3-
import { useState, useEffect } from 'react';
3+
import { useState, useEffect, useRef } from 'react';
4+
import { useLocation } from 'react-router-dom';
45
import ChatContainer from '../../common/components/Chat/ChatContainer';
56
import ChatInput from '../../common/components/Chat/ChatInput';
67
import { chatService } from '../../common/services/ChatService';
@@ -16,19 +17,51 @@ import './ChatPage.scss';
1617
const ChatPage = (): JSX.Element => {
1718
const { t } = useTranslation();
1819
const [messages, setMessages] = useState<ChatMessageData[]>([]);
20+
const location = useLocation();
21+
const prevPathRef = useRef(location.pathname);
1922

20-
// Reset chat session when component unmounts
23+
const resetChatState = () => {
24+
setMessages([]);
25+
};
26+
27+
// Handle initial setup and cleanup
2128
useEffect(() => {
22-
// Create a new session when the component mounts
23-
chatService.resetSession();
29+
// Create a new session when the component mounts using an IIFE
30+
(async () => {
31+
await chatService.resetSession();
32+
resetChatState();
33+
})();
2434

2535
// Reset the chat session when the component unmounts
2636
return () => {
37+
// We need to call this synchronously in the cleanup function
38+
// but we can at least trigger the reset process
2739
chatService.resetSession();
28-
// We don't need to clear messages array since the component is unmounting
40+
resetChatState();
2941
};
3042
}, []);
3143

44+
// Listen for route changes to reset chat when navigating away
45+
useEffect(() => {
46+
// If we came back to this page from another route, reset the chat
47+
if (prevPathRef.current !== location.pathname && location.pathname === '/tabs/chat') {
48+
// We're returning to the chat page
49+
(async () => {
50+
await chatService.resetSession();
51+
resetChatState();
52+
})();
53+
}
54+
55+
// If we're navigating away, reset chat state
56+
if (prevPathRef.current === '/tabs/chat' && location.pathname !== '/tabs/chat') {
57+
chatService.resetSession();
58+
resetChatState();
59+
}
60+
61+
// Update ref for next comparison
62+
prevPathRef.current = location.pathname;
63+
}, [location.pathname]);
64+
3265
const handleSendMessage = async (text: string) => {
3366
const userMessage = chatService.createUserMessage(text);
3467
setMessages(prevMessages => [...prevMessages, userMessage]);

frontend/src/pages/Home/HomePage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ const HomePage: React.FC = () => {
8585
if (!reports || reports.length === 0) {
8686
return (
8787
<div className="home-page__empty-state">
88-
<NoReportsMessage onUpload={handleUpload} />
88+
<NoReportsMessage
89+
onUpload={handleUpload}
90+
onRetry={handleRetry}
91+
/>
8992
</div>
9093
);
9194
}

frontend/src/pages/Home/components/NoReportsMessage/NoReportsMessage.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
&--secondary {
5252
--background: white;
5353
--color: var(--ion-color-primary);
54-
--border-color: var(--ion-color-light);
54+
--border-color: var(--ion-color-primary);
5555
}
5656
}
5757
}

0 commit comments

Comments
 (0)