Skip to content

Commit a877e9c

Browse files
Merge pull request #33 from ModusCreateOrg/ADE-30-bedrock
[ADE-30] - Implement Amazon Bedrock Integration
2 parents d9a14c1 + 03755de commit a877e9c

File tree

27 files changed

+3041
-790
lines changed

27 files changed

+3041
-790
lines changed
114 KB
Loading

frontend/android/app/capacitor.build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ android {
1010
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
1111
dependencies {
1212
implementation project(':capacitor-app')
13+
implementation project(':capacitor-filesystem')
1314
implementation project(':capacitor-haptics')
1415
implementation project(':capacitor-keyboard')
1516
implementation project(':capacitor-status-bar')

frontend/android/capacitor.settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/
55
include ':capacitor-app'
66
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')
77

8+
include ':capacitor-filesystem'
9+
project(':capacitor-filesystem').projectDir = new File('../node_modules/@capacitor/filesystem/android')
10+
811
include ':capacitor-haptics'
912
project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android')
1013

frontend/package-lock.json

Lines changed: 2574 additions & 665 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@aws-amplify/auth": "^6.0.15",
3939
"@aws-amplify/core": "^6.0.15",
4040
"@aws-amplify/ui-react": "^6.1.1",
41+
"@aws-sdk/client-bedrock-runtime": "^3.775.0",
4142
"@capacitor/android": "6.2.0",
4243
"@capacitor/app": "6.0.2",
4344
"@capacitor/assets": "3.0.5",

frontend/src/common/components/AIAssistant/AIAssistantModal.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { chatService } from '../../services/ChatService';
1717
import { ChatMessageData } from '../Chat/ChatMessage';
1818
import './AIAssistantModal.scss';
1919
import aiIcon from '../../../assets/img/ai-icon.svg';
20+
2021
interface AIAssistantModalProps {
2122
isOpen: boolean;
2223
setIsOpen: (isOpen: boolean) => void;
@@ -39,14 +40,24 @@ const AIAssistantModal: React.FC<AIAssistantModalProps> = ({
3940
}
4041
}, [isOpen]);
4142

42-
const handleClose = () => {
43+
const handleClose = async () => {
4344
setIsOpen(false);
45+
46+
// Reset the chat session and clear messages when modal is closed
47+
await chatService.resetSession();
48+
setMessages([]);
4449
};
4550

4651
const handleExpand = () => {
4752
setIsExpanded(!isExpanded);
4853
};
4954

55+
// Also handle reset when modal is dismissed directly
56+
const handleDismiss = async () => {
57+
await chatService.resetSession();
58+
setMessages([]);
59+
};
60+
5061
const handleSendMessage = async (text: string) => {
5162
// Always expand the modal on any message
5263
if (!isExpanded) {
@@ -70,7 +81,10 @@ const AIAssistantModal: React.FC<AIAssistantModalProps> = ({
7081
return (
7182
<IonModal
7283
isOpen={isOpen}
73-
onDidDismiss={() => setIsOpen(false)}
84+
onDidDismiss={() => {
85+
setIsOpen(false);
86+
handleDismiss();
87+
}}
7488
ref={modalRef}
7589
className={`ai-assistant-modal ${isExpanded ? 'expanded' : ''}`}
7690
data-testid={testid}

frontend/src/common/components/AIAssistant/__tests__/AIAssistantModal.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ vi.mock('../../../services/ChatService', () => {
2828
sender: 'assistant',
2929
timestamp: new Date()
3030
})),
31-
sendMessage: vi.fn(async () => 'Mock response')
31+
sendMessage: vi.fn(async () => 'Mock response'),
32+
resetSession: vi.fn(async () => Promise.resolve())
3233
}
3334
};
3435
});

frontend/src/common/components/Chat/ChatContainer.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
padding: 1rem;
66
height: 100%;
77
overflow-y: auto;
8+
scroll-behavior: smooth;
9+
10+
/* Use relative units for padding and adjust bottom padding */
11+
padding-bottom: 1.5rem;
812

913
.chat-empty-state {
1014
display: flex;

frontend/src/common/components/Chat/ChatContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const ChatContainer: React.FC<ChatContainerProps> = ({
4343
>
4444
{messages.length === 0 ? (
4545
<div className="chat-empty-state" data-testid={`${testid}-empty`}>
46-
<p>{t('common.aiAssistant.emptyState', 'How can I help you today?')}</p>
46+
<p>{t('aiAssistant.emptyState', 'How can I help you today?')}</p>
4747
</div>
4848
) : (
4949
messages.map((message) => (

frontend/src/common/components/Chat/ChatInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const ChatInput: React.FC<ChatInputProps> = ({
2525
const [inputValue, setInputValue] = useState<string>('');
2626
const inputRef = useRef<HTMLIonInputElement>(null);
2727

28-
const defaultPlaceholder = t('common.aiAssistant.inputPlaceholder', 'Type your question...');
28+
const defaultPlaceholder = t('aiAssistant.inputPlaceholder', 'Type your question...');
2929
const inputPlaceholder = placeholder || defaultPlaceholder;
3030

3131
const handleSendMessage = () => {

0 commit comments

Comments
 (0)