@@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next'
12
12
import { handleCompletionStreamError } from './error'
13
13
import { getCompletionStream } from './util'
14
14
15
- import { Box , Typography } from '@mui/material'
15
+ import { Box , Typography , Fade , Collapse } from '@mui/material'
16
16
import SettingsIcon from '@mui/icons-material/Settings'
17
17
import EmailIcon from '@mui/icons-material/Email'
18
18
import DeleteIcon from '@mui/icons-material/Delete'
@@ -40,13 +40,15 @@ export const ChatV2 = () => {
40
40
const [ model , setModel ] = useLocalStorageState < { name : string } > ( 'model-v2' , {
41
41
name : DEFAULT_MODEL ,
42
42
} )
43
- const [ system , setSystem ] = useLocalStorageState < { content : string } > ( 'general-chat-system' , { content : '' } )
44
- const [ message , setMessage ] = useLocalStorageState < { content : string } > ( 'general-chat-current' , { content : '' } )
45
- const [ messages , setMessages ] = useLocalStorageState < Message [ ] > ( 'general-chat-messages' , [ ] )
46
- const [ prevResponse , setPrevResponse ] = useLocalStorageState < {
47
- id : string
48
- } > ( 'general-prev-response' , { id : '' } )
49
43
44
+ // local storage
45
+ const localStoragePrefix = 'general'
46
+ const [ system , setSystem ] = useLocalStorageState < { content : string } > ( `${ localStoragePrefix } -chat-system` , { content : '' } )
47
+ const [ message , setMessage ] = useLocalStorageState < { content : string } > ( `${ localStoragePrefix } -chat-current` , { content : '' } )
48
+ const [ messages , setMessages ] = useLocalStorageState < Message [ ] > ( `${ localStoragePrefix } -chat-messages` , [ ] )
49
+ const [ prevResponse , setPrevResponse ] = useLocalStorageState < { id : string } > ( `${ localStoragePrefix } -prev-response` , { id : '' } )
50
+
51
+ // States
50
52
const [ settingsModalOpen , setSettingsModalOpen ] = useState ( false )
51
53
const [ activePromptId , setActivePromptId ] = useState ( '' )
52
54
const [ fileName , setFileName ] = useState < string > ( '' )
@@ -63,6 +65,7 @@ export const ChatV2 = () => {
63
65
const [ ragIndexId , setRagIndexId ] = useState < number | null > ( null )
64
66
const ragIndex = ragIndices ?. find ( ( index ) => index . id === ragIndexId ) ?? null
65
67
68
+ // Refs
66
69
const appContainerRef = useContext ( AppContext )
67
70
const chatContainerRef = useRef < HTMLDivElement > ( null )
68
71
const conversationRef = useRef < HTMLElement > ( null )
@@ -207,6 +210,12 @@ export const ChatV2 = () => {
207
210
clearRetryTimeout ( )
208
211
}
209
212
213
+ useEffect ( ( ) => {
214
+ // Fethces data from local storage according to chat
215
+ console . log ( "course changed" )
216
+
217
+ } , [ course ] )
218
+
210
219
useEffect ( ( ) => {
211
220
// Scrolls to bottom on initial load only
212
221
if ( ! appContainerRef . current || ! conversationRef . current || ! chatHeaderRef . current || messages . length === 0 ) return
@@ -253,8 +262,8 @@ export const ChatV2 = () => {
253
262
minWidth : 1400 ,
254
263
} }
255
264
>
256
- { /* Course chats columns */ }
257
- < Box sx = { { position : 'relative' , flex : 1 , borderRight : '1px solid lightgray ' } } >
265
+ { /* Chat selection column ------------------------------------------------------------------------------------------- */ }
266
+ < Box sx = { { position : 'relative' , flex : 1 , borderRight : '1px solid rgba(0, 0, 0, 0.12) ' } } >
258
267
< Box sx = { { position : 'sticky' , top : 80 , padding : '2rem 1.5rem' } } >
259
268
< Typography variant = "h6" fontWeight = "light" >
260
269
Currechat
@@ -278,11 +287,11 @@ export const ChatV2 = () => {
278
287
</ Box >
279
288
</ Box >
280
289
281
- { /* Chat view */ }
290
+ { /* Chat view column ------------------------------------------------------------------------------------------------ */ }
282
291
< Box
283
292
ref = { chatContainerRef }
284
293
sx = { {
285
- flex : 4 ,
294
+ flex : 3 ,
286
295
display : 'flex' ,
287
296
position : 'relative' ,
288
297
flexDirection : 'column' ,
@@ -301,11 +310,13 @@ export const ChatV2 = () => {
301
310
zIndex : 10 ,
302
311
} }
303
312
>
304
- { course && (
305
- < Typography variant = "h5" sx = { { textAlign : 'center' , fontWeight : 'bold' , mb : '1.5rem' } } >
306
- { course . id === 'sandbox' ? 'OHTE Sandbox' : course . id }
307
- </ Typography >
308
- ) }
313
+ < Collapse in = { ! ! course } timeout = { 100 } >
314
+ < Fade in = { true } timeout = { 800 } >
315
+ < Typography variant = "h5" sx = { { textAlign : 'center' , fontWeight : 'bold' , mb : '1.5rem' } } >
316
+ { course ?. id === 'sandbox' ? 'OHTE Sandbox' : course ?. id }
317
+ </ Typography >
318
+ </ Fade >
319
+ </ Collapse >
309
320
310
321
< Box sx = { { display : 'flex' , alignItems : 'center' , justifyContent : 'center' , gap : '1.5rem' } } >
311
322
{ /* {disclaimerInfo && <Disclaimer disclaimer={disclaimerInfo} /> }
@@ -358,15 +369,37 @@ export const ChatV2 = () => {
358
369
</ Box >
359
370
</ Box >
360
371
361
- { /* Annotations columns */ }
362
- < Box sx = { { flex : 1 , borderLeft : 'none' , position : 'relative' } } >
363
- { ragIndex && (
364
- < Box sx = { { position : 'sticky' , top : 80 } } >
365
- < CitationsBox messages = { messages } fileSearchResult = { fileSearchResult } />
366
- </ Box >
367
- ) }
372
+ { /* Annotations columns ----------------------------------------------------------------------------------------------------- */ }
373
+ < Box sx = { { position : 'relative' , flex : 1 } } >
374
+ < Box sx = { { position : 'sticky' , top : 80 , padding : '4rem 2rem 2rem 0' } } >
375
+ { /* {ragIndex && ( */ }
376
+ { course && (
377
+ < Box sx = { { height : '100%' , display : 'flex' , flexDirection : 'column' , gap : '1.5rem' } } >
378
+ < Typography variant = "h6" > Lähteet</ Typography >
379
+ < Box sx = { { flex : 1 , borderRadius : '1rem' , backgroundColor : 'rgba(0,0,0,0.0)' , display : 'flex' , flexDirection : 'column' , gap : '1.5rem' } } >
380
+ { /* <CitationsBox messages={messages} fileSearchResult={fileSearchResult} /> */ }
381
+ < Box sx = { { borderLeft : '4px solid #3f51b5' , paddingLeft : '1rem' , backgroundColor : 'white' , borderRadius : '4px' } } >
382
+ < Typography variant = "body2" color = "textSecondary" >
383
+ Make sure your ref is attached to a real DOM element (component="div" for MUI Box). Only access .current.clientHeight after the DOM is rendered...
384
+ </ Typography >
385
+ </ Box >
386
+ < Box sx = { { borderLeft : '4px solid #3f51b5' , paddingLeft : '1rem' , backgroundColor : 'white' , borderRadius : '4px' } } >
387
+ < Typography variant = "body2" color = "textSecondary" >
388
+ Make sure your ref is attached to a real DOM element (component="div" for MUI Box). Only access .current.clientHeight after the DOM is rendered...
389
+ </ Typography >
390
+ </ Box >
391
+ < Box sx = { { borderLeft : '4px solid #3f51b5' , paddingLeft : '1rem' , backgroundColor : 'white' , borderRadius : '4px' } } >
392
+ < Typography variant = "body2" color = "textSecondary" >
393
+ Make sure your ref is attached to a real DOM element (component="div" for MUI Box). Only access .current.clientHeight after the DOM is rendered...
394
+ </ Typography >
395
+ </ Box >
396
+ </ Box >
397
+ </ Box >
398
+ ) }
399
+ </ Box >
368
400
</ Box >
369
401
402
+ { /* Modal --------------------------------------*/ }
370
403
< SettingsModal
371
404
open = { settingsModalOpen }
372
405
setOpen = { setSettingsModalOpen }
0 commit comments