Girish Jeswani commited on
Commit
4c7bb24
·
1 Parent(s): ac2723c

design changes

Browse files
phd-advisor-frontend/src/components/SuggestionsPanel.js CHANGED
@@ -1,3 +1,4 @@
 
1
  import React from 'react';
2
  import { BookOpen, FlaskConical, PenTool, Heart } from 'lucide-react';
3
 
@@ -90,7 +91,8 @@ const SuggestionsPanel = ({ onSuggestionClick }) => {
90
  style={{
91
  borderColor: category.color + '20',
92
  '--hover-bg': category.bgColor,
93
- '--hover-border': category.color
 
94
  }}
95
  >
96
  {suggestion}
 
1
+ // src/components/SuggestionsPanel.js
2
  import React from 'react';
3
  import { BookOpen, FlaskConical, PenTool, Heart } from 'lucide-react';
4
 
 
91
  style={{
92
  borderColor: category.color + '20',
93
  '--hover-bg': category.bgColor,
94
+ '--hover-border': category.color,
95
+ '--hover-text': category.color
96
  }}
97
  >
98
  {suggestion}
phd-advisor-frontend/src/pages/ChatPage.js CHANGED
@@ -1,19 +1,24 @@
 
1
  import React, { useState, useEffect, useRef } from 'react';
2
- import { Home, MessageCircle, Reply, X } from 'lucide-react';
3
  import ChatInput from '../components/ChatInput';
4
  import MessageBubble from '../components/MessageBubble';
5
  import ThinkingIndicator from '../components/ThinkingIndicator';
6
  import SuggestionsPanel from '../components/SuggestionsPanel';
7
  import ThemeToggle from '../components/ThemeToggle';
 
8
  import { advisors, getAdvisorColors } from '../data/advisors';
9
  import { useTheme } from '../contexts/ThemeContext';
 
10
 
11
  const ChatPage = ({ onNavigateToHome }) => {
12
  const [messages, setMessages] = useState([]);
13
  const [isLoading, setIsLoading] = useState(false);
14
  const [thinkingAdvisors, setThinkingAdvisors] = useState([]);
15
  const [collectedInfo, setCollectedInfo] = useState({});
16
- const [replyingTo, setReplyingTo] = useState(null); // { advisorId, messageId, advisorName }
 
 
17
  const messagesEndRef = useRef(null);
18
  const { isDark } = useTheme();
19
 
@@ -25,18 +30,84 @@ const ChatPage = ({ onNavigateToHome }) => {
25
  scrollToBottom();
26
  }, [messages, thinkingAdvisors]);
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  const generateMessageId = () => {
29
  return Date.now().toString() + Math.random().toString(36).substr(2, 9);
30
  };
31
 
32
  const handleSendMessage = async (inputMessage) => {
33
- // Check if this is a reply to a specific advisor
34
  if (replyingTo) {
35
  await handleReplyToAdvisor(inputMessage, replyingTo);
36
  return;
37
  }
38
 
39
- // Regular message flow - add user message immediately
40
  const userMessage = {
41
  id: generateMessageId(),
42
  type: 'user',
@@ -46,7 +117,7 @@ const ChatPage = ({ onNavigateToHome }) => {
46
  setMessages(prev => [...prev, userMessage]);
47
 
48
  setIsLoading(true);
49
- setThinkingAdvisors(['system']); // Show thinking indicator for orchestrator/system
50
 
51
  try {
52
  const response = await fetch('http://localhost:8000/chat-sequential', {
@@ -60,19 +131,14 @@ const ChatPage = ({ onNavigateToHome }) => {
60
  });
61
 
62
  if (!response.ok) {
63
- throw new Error('Failed to send message');
64
  }
65
 
66
  const data = await response.json();
 
67
  setThinkingAdvisors([]);
68
-
69
- // Update collected info if provided
70
- if (data.collected_info) {
71
- setCollectedInfo(data.collected_info);
72
- }
73
 
74
  if (data.type === 'orchestrator_question') {
75
- // Orchestrator is asking for clarification
76
  const orchestratorMessage = {
77
  id: generateMessageId(),
78
  type: 'orchestrator',
@@ -80,81 +146,75 @@ const ChatPage = ({ onNavigateToHome }) => {
80
  timestamp: new Date()
81
  };
82
  setMessages(prev => [...prev, orchestratorMessage]);
83
-
84
  } else if (data.type === 'sequential_responses') {
85
- // Show advisor responses sequentially with realistic timing
86
- await showSequentialResponses(data.responses);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
-
89
  } catch (error) {
90
  console.error('Error sending message:', error);
91
- setThinkingAdvisors([]);
92
- setMessages(prev => [...prev, {
93
  id: generateMessageId(),
94
  type: 'error',
95
- content: 'Sorry, there was an error processing your message. Please try again.',
96
  timestamp: new Date()
97
- }]);
 
98
  } finally {
99
  setIsLoading(false);
 
100
  }
101
  };
102
 
103
- const showSequentialResponses = async (responses) => {
104
- const advisorOrder = ['methodist', 'theorist', 'pragmatist'];
105
-
106
- for (let i = 0; i < advisorOrder.length; i++) {
107
- const advisorId = advisorOrder[i];
108
-
109
- // Show thinking indicator for this specific advisor
110
- setThinkingAdvisors([advisorId]);
111
-
112
- // Wait a bit to simulate thinking time (since responses are pre-generated)
113
- await new Promise(resolve => setTimeout(resolve, 800));
114
-
115
- // Find the response for this advisor
116
- const advisorResponse = responses.find(r => r.persona_id === advisorId);
117
-
118
- if (advisorResponse) {
119
- // Remove thinking indicator and add message
120
- setThinkingAdvisors([]);
121
-
122
- const message = {
123
- id: generateMessageId(),
124
- type: 'advisor',
125
- advisorId: advisorResponse.persona_id,
126
- content: advisorResponse.response,
127
- timestamp: new Date()
128
- };
129
-
130
- setMessages(prev => [...prev, message]);
131
-
132
- // Small delay before next advisor starts thinking
133
- if (i < advisorOrder.length - 1) {
134
- await new Promise(resolve => setTimeout(resolve, 300));
135
- }
136
- }
137
- }
138
-
139
- // Clear any remaining thinking indicators
140
- setThinkingAdvisors([]);
141
- };
142
-
143
  const handleReplyToAdvisor = async (inputMessage, replyInfo) => {
144
- // Add user reply message
145
  const userReplyMessage = {
146
  id: generateMessageId(),
147
  type: 'user',
148
  content: inputMessage,
149
- timestamp: new Date(),
150
- replyTo: replyInfo
 
 
 
 
151
  };
152
  setMessages(prev => [...prev, userReplyMessage]);
153
-
154
- // Show thinking for the specific advisor
155
  setThinkingAdvisors([replyInfo.advisorId]);
156
- setReplyingTo(null); // Clear reply state
157
-
158
  try {
159
  const response = await fetch('http://localhost:8000/reply-to-advisor', {
160
  method: 'POST',
@@ -169,33 +229,35 @@ const ChatPage = ({ onNavigateToHome }) => {
169
  });
170
 
171
  if (!response.ok) {
172
- throw new Error('Failed to send reply');
173
  }
174
 
175
  const data = await response.json();
176
- setThinkingAdvisors([]);
177
 
178
- // Add advisor reply
179
  const advisorReplyMessage = {
180
  id: generateMessageId(),
181
  type: 'advisor',
182
- advisorId: data.persona_id,
183
  content: data.response,
184
- timestamp: new Date(),
185
- isReply: true
186
  };
187
-
188
  setMessages(prev => [...prev, advisorReplyMessage]);
189
-
190
  } catch (error) {
191
  console.error('Error sending reply:', error);
192
- setThinkingAdvisors([]);
193
- setMessages(prev => [...prev, {
194
  id: generateMessageId(),
195
  type: 'error',
196
- content: 'Sorry, there was an error sending your reply. Please try again.',
197
  timestamp: new Date()
198
- }]);
 
 
 
 
 
199
  }
200
  };
201
 
@@ -214,139 +276,164 @@ const ChatPage = ({ onNavigateToHome }) => {
214
  setReplyingTo(null);
215
  };
216
 
 
 
217
  return (
218
- <div className="chat-page">
219
- {/* Header */}
220
- <header className="chat-header">
221
- <div className="chat-header-content">
222
- <div className="chat-header-left">
223
- <button
224
- onClick={onNavigateToHome}
225
- className="home-button"
226
- >
227
- <Home className="home-icon" />
228
- </button>
229
- <div>
230
- <h1 className="chat-title">Advisory Panel Chat</h1>
231
- <p className="chat-subtitle">
232
- {Object.keys(collectedInfo).length > 0
233
- ? `Context: ${Object.entries(collectedInfo).map(([k,v]) => `${k}: ${v}`).join(', ')}`
234
- : replyingTo
235
- ? `Replying to ${replyingTo.advisorName}`
236
- : 'Consulting with your three advisors'
237
- }
238
- </p>
239
  </div>
240
- </div>
241
- <div style={{ display: 'flex', alignItems: 'center', gap: '16px' }}>
242
- <div className="advisor-indicators">
243
- {Object.entries(advisors).map(([id, advisor]) => {
244
- const Icon = advisor.icon;
245
- const colors = getAdvisorColors(id, isDark);
246
- return (
247
- <div
248
- key={id}
249
- className="advisor-indicator"
250
- style={{ backgroundColor: colors.bgColor }}
251
- >
252
- <Icon style={{ color: colors.color }} />
253
- </div>
254
- );
255
- })}
256
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  <ThemeToggle />
258
  </div>
259
  </div>
260
- </header>
261
-
262
- {/* Chat Area */}
263
- <div className="chat-container">
264
- <div className="chat-box">
265
- {/* Messages */}
266
- <div className="messages-container">
267
- {messages.length === 0 && !replyingTo && (
268
  <SuggestionsPanel onSuggestionClick={handleSendMessage} />
269
- )}
270
-
271
- {messages.map((message, index) => {
272
- if (message.type === 'orchestrator') {
273
- return (
274
- <div key={message.id || index} className="advisor-message-container">
275
- <div className="advisor-avatar orchestrator-avatar">
276
- <MessageCircle className="orchestrator-icon" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  </div>
278
- <div className="advisor-message-bubble orchestrator-bubble">
279
- <div className="advisor-message-header">
280
- <h4 className="advisor-message-name orchestrator-name">
281
- PhD Assistant
282
- </h4>
283
- <span className="message-time orchestrator-time">
284
- {message.timestamp.toLocaleTimeString([], {
285
- hour: '2-digit',
286
- minute: '2-digit'
287
- })}
288
- </span>
289
  </div>
290
- <p className="advisor-message-text orchestrator-text">{message.content}</p>
291
  </div>
292
  </div>
293
- );
294
- }
295
- return (
296
- <MessageBubble
297
- key={message.id || index}
298
- message={message}
299
- onClick={() => handleMessageClick(message)}
300
- showReplyButton={message.type === 'advisor'}
301
- />
302
- );
303
- })}
304
-
305
- {/* Thinking Indicators */}
306
- {thinkingAdvisors.includes('system') && (
307
- <div className="thinking-container">
308
- <div className="advisor-avatar orchestrator-avatar">
309
- <MessageCircle className="orchestrator-icon" />
310
- </div>
311
- <div className="thinking-bubble orchestrator-bubble">
312
- <div className="thinking-header">
313
- <h4 className="advisor-name orchestrator-name">
314
- Processing...
315
- </h4>
316
- </div>
317
- <div className="thinking-dots">
318
- <div className="thinking-dot orchestrator-dot" style={{ animationDelay: '0ms' }}></div>
319
- <div className="thinking-dot orchestrator-dot" style={{ animationDelay: '150ms' }}></div>
320
- <div className="thinking-dot orchestrator-dot" style={{ animationDelay: '300ms' }}></div>
321
- </div>
322
- <p className="thinking-text orchestrator-thinking-text">analyzing your question...</p>
323
- </div>
324
- </div>
325
- )}
326
-
327
- {thinkingAdvisors.filter(id => id !== 'system').map(advisorId => (
328
- <ThinkingIndicator key={advisorId} advisorId={advisorId} />
329
- ))}
330
-
331
- <div ref={messagesEndRef} />
332
- </div>
333
 
334
- {/* Reply Banner */}
335
- {replyingTo && (
336
- <div className="reply-banner">
337
- <div className="reply-info">
338
- <Reply className="reply-icon" />
339
- <span>Replying to {replyingTo.advisorName}</span>
340
  </div>
341
- <button onClick={cancelReply} className="cancel-reply-btn">
342
- <X size={16} />
343
- </button>
344
  </div>
345
- )}
 
 
346
 
347
- {/* Input Area */}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  <ChatInput
349
- onSendMessage={handleSendMessage}
350
  isLoading={isLoading}
351
  placeholder={
352
  replyingTo
 
1
+ // src/pages/ChatPage.js
2
  import React, { useState, useEffect, useRef } from 'react';
3
+ import { Home, MessageCircle, Reply, X, Sparkles, Users, Settings2 } from 'lucide-react';
4
  import ChatInput from '../components/ChatInput';
5
  import MessageBubble from '../components/MessageBubble';
6
  import ThinkingIndicator from '../components/ThinkingIndicator';
7
  import SuggestionsPanel from '../components/SuggestionsPanel';
8
  import ThemeToggle from '../components/ThemeToggle';
9
+ import ProviderDropdown from '../components/ProviderDropdown';
10
  import { advisors, getAdvisorColors } from '../data/advisors';
11
  import { useTheme } from '../contexts/ThemeContext';
12
+ import '../styles/ChatPage.css';
13
 
14
  const ChatPage = ({ onNavigateToHome }) => {
15
  const [messages, setMessages] = useState([]);
16
  const [isLoading, setIsLoading] = useState(false);
17
  const [thinkingAdvisors, setThinkingAdvisors] = useState([]);
18
  const [collectedInfo, setCollectedInfo] = useState({});
19
+ const [replyingTo, setReplyingTo] = useState(null);
20
+ const [currentProvider, setCurrentProvider] = useState('gemini');
21
+ const [isProviderSwitching, setIsProviderSwitching] = useState(false);
22
  const messagesEndRef = useRef(null);
23
  const { isDark } = useTheme();
24
 
 
30
  scrollToBottom();
31
  }, [messages, thinkingAdvisors]);
32
 
33
+ useEffect(() => {
34
+ fetchCurrentProvider();
35
+ }, []);
36
+
37
+ const fetchCurrentProvider = async () => {
38
+ try {
39
+ const response = await fetch('http://localhost:8000/current-provider');
40
+ if (response.ok) {
41
+ const data = await response.json();
42
+ setCurrentProvider(data.current_provider);
43
+ console.log('Loaded provider:', data.current_provider, 'Available:', data.available_providers);
44
+ }
45
+ } catch (error) {
46
+ console.error('Error fetching current provider:', error);
47
+ }
48
+ };
49
+
50
+ const handleProviderSwitch = async (newProvider) => {
51
+ if (newProvider === currentProvider || isProviderSwitching) return;
52
+
53
+ setIsProviderSwitching(true);
54
+ try {
55
+ const response = await fetch('http://localhost:8000/switch-provider', {
56
+ method: 'POST',
57
+ headers: {
58
+ 'Content-Type': 'application/json',
59
+ },
60
+ body: JSON.stringify({
61
+ provider: newProvider
62
+ }),
63
+ });
64
+
65
+ if (response.ok) {
66
+ const data = await response.json();
67
+ setCurrentProvider(newProvider);
68
+
69
+ const switchMessage = {
70
+ id: generateMessageId(),
71
+ type: 'system',
72
+ content: `✨ Switched to ${newProvider.charAt(0).toUpperCase() + newProvider.slice(1)} provider. Your advisors are now ready with the new AI model.`,
73
+ timestamp: new Date()
74
+ };
75
+ setMessages(prev => [...prev, switchMessage]);
76
+ } else {
77
+ const error = await response.json();
78
+ console.error('Failed to switch provider:', error);
79
+ const errorMessage = {
80
+ id: generateMessageId(),
81
+ type: 'error',
82
+ content: `Failed to switch to ${newProvider}: ${error.detail || 'Unknown error'}`,
83
+ timestamp: new Date()
84
+ };
85
+ setMessages(prev => [...prev, errorMessage]);
86
+ }
87
+ } catch (error) {
88
+ console.error('Error switching provider:', error);
89
+ const errorMessage = {
90
+ id: generateMessageId(),
91
+ type: 'error',
92
+ content: `Error switching to ${newProvider}. Please try again.`,
93
+ timestamp: new Date()
94
+ };
95
+ setMessages(prev => [...prev, errorMessage]);
96
+ } finally {
97
+ setIsProviderSwitching(false);
98
+ }
99
+ };
100
+
101
  const generateMessageId = () => {
102
  return Date.now().toString() + Math.random().toString(36).substr(2, 9);
103
  };
104
 
105
  const handleSendMessage = async (inputMessage) => {
 
106
  if (replyingTo) {
107
  await handleReplyToAdvisor(inputMessage, replyingTo);
108
  return;
109
  }
110
 
 
111
  const userMessage = {
112
  id: generateMessageId(),
113
  type: 'user',
 
117
  setMessages(prev => [...prev, userMessage]);
118
 
119
  setIsLoading(true);
120
+ setThinkingAdvisors(['system']);
121
 
122
  try {
123
  const response = await fetch('http://localhost:8000/chat-sequential', {
 
131
  });
132
 
133
  if (!response.ok) {
134
+ throw new Error(`HTTP error! status: ${response.status}`);
135
  }
136
 
137
  const data = await response.json();
138
+ setCollectedInfo(data.collected_info || {});
139
  setThinkingAdvisors([]);
 
 
 
 
 
140
 
141
  if (data.type === 'orchestrator_question') {
 
142
  const orchestratorMessage = {
143
  id: generateMessageId(),
144
  type: 'orchestrator',
 
146
  timestamp: new Date()
147
  };
148
  setMessages(prev => [...prev, orchestratorMessage]);
 
149
  } else if (data.type === 'sequential_responses') {
150
+ const advisorIds = ['methodist', 'theorist', 'pragmatist'];
151
+
152
+ for (let i = 0; i < advisorIds.length; i++) {
153
+ const advisorId = advisorIds[i];
154
+ const response = data.responses.find(r => r.persona_id === advisorId);
155
+
156
+ if (response) {
157
+ setThinkingAdvisors([advisorId]);
158
+ await new Promise(resolve => setTimeout(resolve, 1000));
159
+
160
+ const advisorMessage = {
161
+ id: generateMessageId(),
162
+ type: 'advisor',
163
+ advisorId: advisorId,
164
+ content: response.response,
165
+ timestamp: new Date()
166
+ };
167
+
168
+ setMessages(prev => [...prev, advisorMessage]);
169
+ setThinkingAdvisors([]);
170
+
171
+ if (i < advisorIds.length - 1) {
172
+ await new Promise(resolve => setTimeout(resolve, 500));
173
+ }
174
+ }
175
+ }
176
+ } else if (data.type === 'error') {
177
+ const errorMessage = {
178
+ id: generateMessageId(),
179
+ type: 'error',
180
+ content: data.responses[0].response,
181
+ timestamp: new Date()
182
+ };
183
+ setMessages(prev => [...prev, errorMessage]);
184
  }
185
+
186
  } catch (error) {
187
  console.error('Error sending message:', error);
188
+ const errorMessage = {
 
189
  id: generateMessageId(),
190
  type: 'error',
191
+ content: 'Sorry, I encountered an error. Please try again.',
192
  timestamp: new Date()
193
+ };
194
+ setMessages(prev => [...prev, errorMessage]);
195
  } finally {
196
  setIsLoading(false);
197
+ setThinkingAdvisors([]);
198
  }
199
  };
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  const handleReplyToAdvisor = async (inputMessage, replyInfo) => {
 
202
  const userReplyMessage = {
203
  id: generateMessageId(),
204
  type: 'user',
205
  content: inputMessage,
206
+ replyTo: {
207
+ advisorId: replyInfo.advisorId,
208
+ advisorName: replyInfo.advisorName,
209
+ messageId: replyInfo.messageId
210
+ },
211
+ timestamp: new Date()
212
  };
213
  setMessages(prev => [...prev, userReplyMessage]);
214
+
 
215
  setThinkingAdvisors([replyInfo.advisorId]);
216
+ setIsLoading(true);
217
+
218
  try {
219
  const response = await fetch('http://localhost:8000/reply-to-advisor', {
220
  method: 'POST',
 
229
  });
230
 
231
  if (!response.ok) {
232
+ throw new Error(`HTTP error! status: ${response.status}`);
233
  }
234
 
235
  const data = await response.json();
 
236
 
 
237
  const advisorReplyMessage = {
238
  id: generateMessageId(),
239
  type: 'advisor',
240
+ advisorId: replyInfo.advisorId,
241
  content: data.response,
242
+ isReply: true,
243
+ timestamp: new Date()
244
  };
245
+
246
  setMessages(prev => [...prev, advisorReplyMessage]);
247
+
248
  } catch (error) {
249
  console.error('Error sending reply:', error);
250
+ const errorMessage = {
 
251
  id: generateMessageId(),
252
  type: 'error',
253
+ content: 'Sorry, I encountered an error with your reply. Please try again.',
254
  timestamp: new Date()
255
+ };
256
+ setMessages(prev => [...prev, errorMessage]);
257
+ } finally {
258
+ setIsLoading(false);
259
+ setThinkingAdvisors([]);
260
+ setReplyingTo(null);
261
  }
262
  };
263
 
 
276
  setReplyingTo(null);
277
  };
278
 
279
+ const hasMessages = messages.length > 0;
280
+
281
  return (
282
+ <div className="modern-chat-page">
283
+ {/* Floating Header */}
284
+ <div className="floating-header">
285
+ <div className="header-left">
286
+ <button onClick={onNavigateToHome} className="modern-home-btn">
287
+ <Home size={20} />
288
+ </button>
289
+ <div className="header-brand">
290
+ <div className="brand-icon">
291
+ <Users size={24} />
 
 
 
 
 
 
 
 
 
 
 
292
  </div>
293
+ <div className="brand-text">
294
+ <h1>PhD Advisory</h1>
295
+ <p>AI-Powered Academic Guidance</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  </div>
297
+ </div>
298
+ </div>
299
+
300
+ <div className="header-right">
301
+ <div className="advisor-pills">
302
+ {Object.entries(advisors).map(([id, advisor]) => {
303
+ const Icon = advisor.icon;
304
+ const colors = getAdvisorColors(id, isDark);
305
+ const isThinking = thinkingAdvisors.includes(id);
306
+
307
+ return (
308
+ <div
309
+ key={id}
310
+ className={`advisor-pill ${isThinking ? 'thinking' : ''}`}
311
+ style={{
312
+ backgroundColor: colors.bgColor,
313
+ borderColor: colors.color + '20'
314
+ }}
315
+ >
316
+ <Icon size={16} style={{ color: colors.color }} />
317
+ <span style={{ color: colors.color }}>{advisor.name.split(' ')[1]}</span>
318
+ {isThinking && <div className="thinking-pulse" style={{ backgroundColor: colors.color }}></div>}
319
+ </div>
320
+ );
321
+ })}
322
+ </div>
323
+
324
+ <div className="header-controls">
325
+ <ProviderDropdown
326
+ currentProvider={currentProvider}
327
+ onProviderChange={handleProviderSwitch}
328
+ isLoading={isProviderSwitching}
329
+ />
330
  <ThemeToggle />
331
  </div>
332
  </div>
333
+ </div>
334
+
335
+ {/* Main Content Area */}
336
+ <div className="main-content">
337
+ {!hasMessages ? (
338
+ /* Welcome State - Just Suggestions */
339
+ <div className="welcome-state">
340
+ <div className="suggestions-container">
341
  <SuggestionsPanel onSuggestionClick={handleSendMessage} />
342
+ </div>
343
+ </div>
344
+ ) : (
345
+ /* Chat State */
346
+ <div className="chat-state">
347
+ <div className="messages-area">
348
+ <div className="messages-scroll">
349
+ {messages.map((message, index) => {
350
+ if (message.type === 'orchestrator') {
351
+ return (
352
+ <div key={message.id || index} className="orchestrator-message">
353
+ <div className="orchestrator-avatar">
354
+ <MessageCircle size={20} />
355
+ </div>
356
+ <div className="orchestrator-content">
357
+ <div className="orchestrator-header">
358
+ <span className="orchestrator-name">PhD Assistant</span>
359
+ <span className="message-timestamp">
360
+ {message.timestamp.toLocaleTimeString([], {
361
+ hour: '2-digit',
362
+ minute: '2-digit'
363
+ })}
364
+ </span>
365
+ </div>
366
+ <div className="orchestrator-text">{message.content}</div>
367
+ </div>
368
+ </div>
369
+ );
370
+ }
371
+
372
+ if (message.type === 'system') {
373
+ return (
374
+ <div key={message.id || index} className="system-notification">
375
+ <div className="system-content">
376
+ {message.content}
377
+ </div>
378
+ </div>
379
+ );
380
+ }
381
+
382
+ return (
383
+ <MessageBubble
384
+ key={message.id || index}
385
+ message={message}
386
+ onClick={() => handleMessageClick(message)}
387
+ showReplyButton={message.type === 'advisor'}
388
+ />
389
+ );
390
+ })}
391
+
392
+ {/* Thinking Indicators */}
393
+ {thinkingAdvisors.includes('system') && (
394
+ <div className="orchestrator-thinking">
395
+ <div className="orchestrator-avatar">
396
+ <MessageCircle size={20} />
397
  </div>
398
+ <div className="thinking-content">
399
+ <span className="thinking-label">PhD Assistant is thinking...</span>
400
+ <div className="thinking-animation">
401
+ <div className="dot"></div>
402
+ <div className="dot"></div>
403
+ <div className="dot"></div>
 
 
 
 
 
404
  </div>
 
405
  </div>
406
  </div>
407
+ )}
408
+
409
+ {thinkingAdvisors.filter(id => id !== 'system').map(advisorId => (
410
+ <ThinkingIndicator key={advisorId} advisorId={advisorId} />
411
+ ))}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
 
413
+ <div ref={messagesEndRef} />
 
 
 
 
 
414
  </div>
 
 
 
415
  </div>
416
+ </div>
417
+ )}
418
+ </div>
419
 
420
+ {/* Floating Input Area */}
421
+ <div className="floating-input-area">
422
+ {replyingTo && (
423
+ <div className="reply-banner">
424
+ <div className="reply-info">
425
+ <Reply size={16} />
426
+ <span>Replying to <strong>{replyingTo.advisorName}</strong></span>
427
+ </div>
428
+ <button onClick={cancelReply} className="cancel-reply">
429
+ <X size={16} />
430
+ </button>
431
+ </div>
432
+ )}
433
+
434
+ <div className="input-wrapper">
435
  <ChatInput
436
+ onSendMessage={handleSendMessage}
437
  isLoading={isLoading}
438
  placeholder={
439
  replyingTo
phd-advisor-frontend/src/styles/components.css CHANGED
@@ -1,3 +1,5 @@
 
 
1
  /* CSS Custom Properties for Theming */
2
  :root[data-theme="light"] {
3
  /* Background Colors */
@@ -91,22 +93,25 @@
91
 
92
  /* Theme Toggle Button */
93
  .theme-toggle {
94
- padding: 8px;
95
- background-color: transparent;
96
  border: 1px solid var(--border-primary);
97
- border-radius: 8px;
98
  cursor: pointer;
99
  transition: all 0.2s ease;
100
  color: var(--text-secondary);
101
  display: flex;
102
  align-items: center;
103
  justify-content: center;
 
104
  }
105
 
106
  .theme-toggle:hover {
107
- background-color: var(--bg-tertiary);
108
  border-color: var(--accent-primary);
109
  color: var(--accent-primary);
 
 
110
  }
111
 
112
  .theme-icon {
@@ -114,8 +119,6 @@
114
  height: 20px;
115
  }
116
 
117
- /* Updated Component Styles with Theme Variables */
118
-
119
  /* Homepage Styles */
120
  .homepage {
121
  min-height: 100vh;
@@ -238,15 +241,10 @@
238
  height: 24px;
239
  }
240
 
241
- .cta-arrow {
242
- width: 20px;
243
- height: 20px;
244
- }
245
-
246
- /* Advisor Cards */
247
  .advisors-grid {
248
  display: grid;
249
- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
250
  gap: 32px;
251
  margin-bottom: 64px;
252
  }
@@ -254,14 +252,16 @@
254
  .advisor-card {
255
  background-color: var(--bg-primary);
256
  border-radius: 16px;
257
- box-shadow: var(--shadow-md);
258
  padding: 32px;
 
259
  border: 1px solid var(--border-primary);
260
- transition: box-shadow 0.3s ease;
 
261
  }
262
 
263
  .advisor-card:hover {
264
- box-shadow: var(--shadow-lg);
 
265
  }
266
 
267
  .advisor-card-icon {
@@ -271,7 +271,7 @@
271
  display: flex;
272
  align-items: center;
273
  justify-content: center;
274
- margin-bottom: 24px;
275
  }
276
 
277
  .advisor-card-icon svg {
@@ -287,12 +287,13 @@
287
  }
288
 
289
  .advisor-card-role {
290
- font-weight: 500;
291
- margin-bottom: 16px;
292
  font-size: 16px;
 
 
293
  }
294
 
295
  .advisor-card-description {
 
296
  color: var(--text-secondary);
297
  line-height: 1.6;
298
  margin: 0;
@@ -300,11 +301,7 @@
300
 
301
  /* Features Section */
302
  .features-section {
303
- background-color: var(--bg-primary);
304
- border-radius: 24px;
305
- box-shadow: var(--shadow-xl);
306
- padding: 48px;
307
- border: 1px solid var(--border-primary);
308
  }
309
 
310
  .features-title {
@@ -317,151 +314,46 @@
317
 
318
  .features-grid {
319
  display: grid;
320
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
321
  gap: 32px;
322
  }
323
 
324
  .feature-card {
325
  text-align: center;
 
326
  }
327
 
328
  .feature-icon {
329
- width: 48px;
330
- height: 48px;
331
  background-color: var(--feature-bg);
332
- border-radius: 12px;
333
  display: flex;
334
  align-items: center;
335
  justify-content: center;
336
- margin: 0 auto 16px auto;
337
  }
338
 
339
  .feature-icon svg {
340
- width: 24px;
341
- height: 24px;
342
  color: var(--feature-icon-color);
343
  }
344
 
345
  .feature-title {
346
- font-weight: 600;
 
347
  color: var(--text-primary);
348
- margin-bottom: 8px;
349
- font-size: 18px;
350
  }
351
 
352
  .feature-description {
 
353
  color: var(--text-secondary);
354
- margin: 0;
355
  line-height: 1.6;
356
- }
357
-
358
- /* Chat Page Styles */
359
- .chat-page {
360
- min-height: 100vh;
361
- background-color: var(--bg-secondary);
362
- }
363
-
364
- .chat-header {
365
- background-color: var(--bg-primary);
366
- box-shadow: var(--shadow-sm);
367
- border-bottom: 1px solid var(--border-primary);
368
- position: sticky;
369
- top: 0;
370
- z-index: 10;
371
- }
372
-
373
- .chat-header-content {
374
- max-width: 1024px;
375
- margin: 0 auto;
376
- padding: 16px 24px;
377
- display: flex;
378
- align-items: center;
379
- justify-content: space-between;
380
- }
381
-
382
- .chat-header-left {
383
- display: flex;
384
- align-items: center;
385
- gap: 12px;
386
- }
387
-
388
- .home-button {
389
- padding: 8px;
390
- background-color: transparent;
391
- border: none;
392
- border-radius: 8px;
393
- cursor: pointer;
394
- transition: background-color 0.2s ease;
395
- }
396
-
397
- .home-button:hover {
398
- background-color: var(--bg-tertiary);
399
- }
400
-
401
- .home-icon {
402
- width: 20px;
403
- height: 20px;
404
- color: var(--text-secondary);
405
- }
406
-
407
- .chat-title {
408
- font-size: 18px;
409
- font-weight: 600;
410
- color: var(--text-primary);
411
- margin: 0;
412
- }
413
-
414
- .chat-subtitle {
415
- font-size: 14px;
416
- color: var(--text-secondary);
417
  margin: 0;
418
  }
419
 
420
- .advisor-indicators {
421
- display: flex;
422
- align-items: center;
423
- gap: 8px;
424
- }
425
-
426
- .advisor-indicator {
427
- width: 32px;
428
- height: 32px;
429
- border-radius: 50%;
430
- display: flex;
431
- align-items: center;
432
- justify-content: center;
433
- }
434
-
435
- .advisor-indicator svg {
436
- width: 16px;
437
- height: 16px;
438
- }
439
-
440
- /* Chat Container */
441
- .chat-container {
442
- max-width: 1024px;
443
- margin: 0 auto;
444
- padding: 24px;
445
- }
446
-
447
- .chat-box {
448
- background-color: var(--bg-primary);
449
- border-radius: 16px;
450
- box-shadow: var(--shadow-md);
451
- height: calc(100vh - 200px);
452
- display: flex;
453
- flex-direction: column;
454
- }
455
-
456
- .messages-container {
457
- flex: 1;
458
- overflow-y: auto;
459
- padding: 24px;
460
- display: flex;
461
- flex-direction: column;
462
- gap: 16px;
463
- }
464
-
465
  /* Suggestions Panel */
466
  .suggestions-panel {
467
  padding: 32px 0;
@@ -532,8 +424,6 @@
532
  font-size: 16px;
533
  font-weight: 600;
534
  margin: 0;
535
- line-height: 1.3;
536
- color: var(--text-primary);
537
  }
538
 
539
  .suggestion-buttons {
@@ -544,157 +434,26 @@
544
  }
545
 
546
  .suggestion-button {
547
- background-color: var(--bg-primary);
548
- border: 1px solid var(--border-primary);
549
- border-radius: 8px;
550
- padding: 12px 16px;
551
  text-align: left;
 
 
 
 
 
552
  font-size: 14px;
553
  line-height: 1.4;
554
- color: var(--text-accent);
555
  cursor: pointer;
556
  transition: all 0.2s ease;
557
- width: 100%;
558
  }
559
 
560
  .suggestion-button:hover {
561
- background-color: var(--bg-tertiary);
562
- border-color: var(--accent-primary);
563
- transform: translateY(-1px);
564
- box-shadow: var(--shadow-sm);
565
- }
566
-
567
- .suggestion-button:active {
568
- transform: translateY(0);
569
- }
570
-
571
- /* Reply Functionality Styles */
572
- .reply-banner {
573
- background-color: var(--bg-tertiary);
574
- border-top: 1px solid var(--border-primary);
575
- padding: 12px 16px;
576
- display: flex;
577
- align-items: center;
578
- justify-content: space-between;
579
- }
580
-
581
- .reply-info {
582
- display: flex;
583
- align-items: center;
584
- gap: 8px;
585
- color: var(--text-secondary);
586
- font-size: 14px;
587
- }
588
-
589
- .reply-icon {
590
- width: 16px;
591
- height: 16px;
592
- color: var(--accent-primary);
593
- }
594
-
595
- .cancel-reply-btn {
596
- background: transparent;
597
- border: none;
598
- color: var(--text-secondary);
599
- cursor: pointer;
600
- padding: 4px;
601
- border-radius: 4px;
602
- transition: background-color 0.2s ease;
603
- }
604
-
605
- .cancel-reply-btn:hover {
606
- background-color: var(--bg-primary);
607
- color: var(--text-primary);
608
- }
609
-
610
- .reply-indicator {
611
- display: flex;
612
- align-items: center;
613
- gap: 4px;
614
- font-size: 12px;
615
- opacity: 0.8;
616
- margin-bottom: 4px;
617
- }
618
-
619
- .reply-badge {
620
- font-size: 11px;
621
- opacity: 0.7;
622
- margin-left: 8px;
623
- }
624
-
625
- .advisor-message-bubble.clickable {
626
- cursor: pointer;
627
- transition: all 0.2s ease;
628
- position: relative;
629
- }
630
-
631
- .advisor-message-bubble.clickable:hover {
632
- transform: translateY(-1px);
633
- box-shadow: var(--shadow-md);
634
- }
635
-
636
- .message-actions {
637
- margin-top: 8px;
638
- opacity: 0;
639
- transition: opacity 0.2s ease;
640
- }
641
-
642
- .advisor-message-bubble.clickable:hover .message-actions {
643
- opacity: 1;
644
- }
645
-
646
- .reply-button {
647
- background: transparent;
648
- border: 1px solid;
649
- border-radius: 6px;
650
- padding: 4px 8px;
651
- font-size: 12px;
652
- cursor: pointer;
653
- display: flex;
654
- align-items: center;
655
- gap: 4px;
656
- transition: all 0.2s ease;
657
- }
658
-
659
- .reply-button:hover {
660
- background-color: var(--bg-tertiary);
661
  transform: translateY(-1px);
662
  }
663
 
664
- /* Orchestrator/PhD Assistant Styles */
665
- .orchestrator-avatar {
666
- background-color: var(--bg-tertiary) !important;
667
- }
668
-
669
- .orchestrator-icon {
670
- color: var(--text-secondary) !important;
671
- }
672
-
673
- .orchestrator-bubble {
674
- background-color: var(--bg-tertiary) !important;
675
- border-color: var(--border-secondary) !important;
676
- }
677
-
678
- .orchestrator-name {
679
- color: var(--text-secondary) !important;
680
- }
681
-
682
- .orchestrator-time {
683
- color: var(--text-tertiary) !important;
684
- }
685
-
686
- .orchestrator-text {
687
- color: var(--text-accent) !important;
688
- }
689
-
690
- .orchestrator-dot {
691
- background-color: var(--text-secondary) !important;
692
- }
693
-
694
- .orchestrator-thinking-text {
695
- color: var(--text-secondary) !important;
696
- opacity: 0.8;
697
- }
698
  .user-message-container {
699
  display: flex;
700
  justify-content: flex-end;
@@ -713,6 +472,18 @@
713
  margin: 0;
714
  }
715
 
 
 
 
 
 
 
 
 
 
 
 
 
716
  .advisor-message-container {
717
  display: flex;
718
  align-items: flex-start;
@@ -741,6 +512,12 @@
741
  border: 1px solid;
742
  padding: 16px;
743
  max-width: 512px;
 
 
 
 
 
 
744
  }
745
 
746
  .advisor-message-header {
@@ -755,6 +532,15 @@
755
  font-size: 14px;
756
  }
757
 
 
 
 
 
 
 
 
 
 
758
  .message-time {
759
  font-size: 12px;
760
  }
@@ -764,6 +550,29 @@
764
  margin: 0;
765
  }
766
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
767
  /* Error Messages */
768
  .error-message-container {
769
  display: flex;
@@ -910,7 +719,7 @@
910
  }
911
  }
912
 
913
- /* Responsive adjustments */
914
  @media (max-width: 1024px) {
915
  .suggestions-panel {
916
  padding: 24px 16px;
@@ -965,20 +774,4 @@
965
  .features-grid {
966
  grid-template-columns: 1fr;
967
  }
968
-
969
- .chat-header-content {
970
- padding: 12px 16px;
971
- }
972
-
973
- .chat-container {
974
- padding: 16px;
975
- }
976
-
977
- .chat-box {
978
- height: calc(100vh - 160px);
979
- }
980
-
981
- .messages-container {
982
- padding: 16px;
983
- }
984
  }
 
1
+ /* components.css - General Component Styles */
2
+
3
  /* CSS Custom Properties for Theming */
4
  :root[data-theme="light"] {
5
  /* Background Colors */
 
93
 
94
  /* Theme Toggle Button */
95
  .theme-toggle {
96
+ padding: 10px;
97
+ background: var(--bg-primary);
98
  border: 1px solid var(--border-primary);
99
+ border-radius: 12px;
100
  cursor: pointer;
101
  transition: all 0.2s ease;
102
  color: var(--text-secondary);
103
  display: flex;
104
  align-items: center;
105
  justify-content: center;
106
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
107
  }
108
 
109
  .theme-toggle:hover {
110
+ background: var(--bg-secondary);
111
  border-color: var(--accent-primary);
112
  color: var(--accent-primary);
113
+ transform: translateY(-1px);
114
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
115
  }
116
 
117
  .theme-icon {
 
119
  height: 20px;
120
  }
121
 
 
 
122
  /* Homepage Styles */
123
  .homepage {
124
  min-height: 100vh;
 
241
  height: 24px;
242
  }
243
 
244
+ /* Advisors Grid */
 
 
 
 
 
245
  .advisors-grid {
246
  display: grid;
247
+ grid-template-columns: repeat(3, 1fr);
248
  gap: 32px;
249
  margin-bottom: 64px;
250
  }
 
252
  .advisor-card {
253
  background-color: var(--bg-primary);
254
  border-radius: 16px;
 
255
  padding: 32px;
256
+ box-shadow: var(--shadow-md);
257
  border: 1px solid var(--border-primary);
258
+ text-align: center;
259
+ transition: all 0.3s ease;
260
  }
261
 
262
  .advisor-card:hover {
263
+ transform: translateY(-4px);
264
+ box-shadow: var(--shadow-xl);
265
  }
266
 
267
  .advisor-card-icon {
 
271
  display: flex;
272
  align-items: center;
273
  justify-content: center;
274
+ margin: 0 auto 24px auto;
275
  }
276
 
277
  .advisor-card-icon svg {
 
287
  }
288
 
289
  .advisor-card-role {
 
 
290
  font-size: 16px;
291
+ font-weight: 600;
292
+ margin-bottom: 16px;
293
  }
294
 
295
  .advisor-card-description {
296
+ font-size: 16px;
297
  color: var(--text-secondary);
298
  line-height: 1.6;
299
  margin: 0;
 
301
 
302
  /* Features Section */
303
  .features-section {
304
+ margin-bottom: 64px;
 
 
 
 
305
  }
306
 
307
  .features-title {
 
314
 
315
  .features-grid {
316
  display: grid;
317
+ grid-template-columns: repeat(3, 1fr);
318
  gap: 32px;
319
  }
320
 
321
  .feature-card {
322
  text-align: center;
323
+ padding: 24px;
324
  }
325
 
326
  .feature-icon {
327
+ width: 64px;
328
+ height: 64px;
329
  background-color: var(--feature-bg);
330
+ border-radius: 16px;
331
  display: flex;
332
  align-items: center;
333
  justify-content: center;
334
+ margin: 0 auto 24px auto;
335
  }
336
 
337
  .feature-icon svg {
338
+ width: 32px;
339
+ height: 32px;
340
  color: var(--feature-icon-color);
341
  }
342
 
343
  .feature-title {
344
+ font-size: 20px;
345
+ font-weight: bold;
346
  color: var(--text-primary);
347
+ margin-bottom: 12px;
 
348
  }
349
 
350
  .feature-description {
351
+ font-size: 16px;
352
  color: var(--text-secondary);
 
353
  line-height: 1.6;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  margin: 0;
355
  }
356
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
  /* Suggestions Panel */
358
  .suggestions-panel {
359
  padding: 32px 0;
 
424
  font-size: 16px;
425
  font-weight: 600;
426
  margin: 0;
 
 
427
  }
428
 
429
  .suggestion-buttons {
 
434
  }
435
 
436
  .suggestion-button {
 
 
 
 
437
  text-align: left;
438
+ padding: 12px 16px;
439
+ border: 1px solid var(--border-secondary);
440
+ border-radius: 8px;
441
+ background-color: transparent;
442
+ color: var(--text-accent);
443
  font-size: 14px;
444
  line-height: 1.4;
 
445
  cursor: pointer;
446
  transition: all 0.2s ease;
 
447
  }
448
 
449
  .suggestion-button:hover {
450
+ background-color: var(--hover-bg, var(--bg-secondary));
451
+ border-color: var(--hover-border, var(--accent-primary));
452
+ color: var(--hover-text, var(--text-primary));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
  transform: translateY(-1px);
454
  }
455
 
456
+ /* Message Components */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  .user-message-container {
458
  display: flex;
459
  justify-content: flex-end;
 
472
  margin: 0;
473
  }
474
 
475
+ .reply-indicator {
476
+ display: flex;
477
+ align-items: center;
478
+ gap: 8px;
479
+ margin-bottom: 8px;
480
+ padding: 4px 8px;
481
+ background-color: var(--bg-tertiary);
482
+ border-radius: 8px;
483
+ font-size: 12px;
484
+ color: var(--text-secondary);
485
+ }
486
+
487
  .advisor-message-container {
488
  display: flex;
489
  align-items: flex-start;
 
512
  border: 1px solid;
513
  padding: 16px;
514
  max-width: 512px;
515
+ transition: all 0.2s ease;
516
+ }
517
+
518
+ .advisor-message-bubble.clickable:hover {
519
+ transform: translateY(-1px);
520
+ box-shadow: var(--shadow-md);
521
  }
522
 
523
  .advisor-message-header {
 
532
  font-size: 14px;
533
  }
534
 
535
+ .reply-badge {
536
+ font-size: 10px;
537
+ background: var(--accent-primary);
538
+ color: white;
539
+ padding: 2px 6px;
540
+ border-radius: 4px;
541
+ margin-left: 4px;
542
+ }
543
+
544
  .message-time {
545
  font-size: 12px;
546
  }
 
550
  margin: 0;
551
  }
552
 
553
+ .message-actions {
554
+ margin-top: 12px;
555
+ padding-top: 12px;
556
+ border-top: 1px solid var(--border-tertiary);
557
+ }
558
+
559
+ .reply-button {
560
+ display: flex;
561
+ align-items: center;
562
+ gap: 6px;
563
+ background: none;
564
+ border: 1px solid;
565
+ padding: 6px 12px;
566
+ border-radius: 6px;
567
+ font-size: 12px;
568
+ cursor: pointer;
569
+ transition: all 0.2s ease;
570
+ }
571
+
572
+ .reply-button:hover {
573
+ background: var(--bg-secondary);
574
+ }
575
+
576
  /* Error Messages */
577
  .error-message-container {
578
  display: flex;
 
719
  }
720
  }
721
 
722
+ /* Responsive Design */
723
  @media (max-width: 1024px) {
724
  .suggestions-panel {
725
  padding: 24px 16px;
 
774
  .features-grid {
775
  grid-template-columns: 1fr;
776
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
777
  }