1
1
import React , { useEffect , useState } from 'react'
2
2
3
- import { mdiClose , mdiCogOutline , mdiDelete , mdiDotsVertical , mdiOpenInNew , mdiPlus , mdiChevronRight } from '@mdi/js'
3
+ import {
4
+ mdiClose ,
5
+ mdiCogOutline ,
6
+ mdiDelete ,
7
+ mdiDotsVertical ,
8
+ mdiOpenInNew ,
9
+ mdiPlus ,
10
+ mdiChevronRight ,
11
+ mdiViewList ,
12
+ } from '@mdi/js'
4
13
import classNames from 'classnames'
5
14
import { useLocation , useNavigate } from 'react-router-dom'
6
15
@@ -41,6 +50,7 @@ import styles from './CodyChatPage.module.scss'
41
50
42
51
interface CodyChatPageProps {
43
52
authenticatedUser : AuthenticatedUser | null
53
+ isSourcegraphApp : boolean
44
54
context : Pick < SourcegraphContext , 'authProviders' >
45
55
}
46
56
@@ -78,7 +88,11 @@ const onTranscriptHistoryLoad = (
78
88
}
79
89
}
80
90
81
- export const CodyChatPage : React . FunctionComponent < CodyChatPageProps > = ( { authenticatedUser, context } ) => {
91
+ export const CodyChatPage : React . FunctionComponent < CodyChatPageProps > = ( {
92
+ authenticatedUser,
93
+ context,
94
+ isSourcegraphApp,
95
+ } ) => {
82
96
const { pathname } = useLocation ( )
83
97
const navigate = useNavigate ( )
84
98
@@ -119,6 +133,12 @@ export const CodyChatPage: React.FunctionComponent<CodyChatPageProps> = ({ authe
119
133
}
120
134
} , [ transcriptId , loaded , pathname , navigate ] )
121
135
136
+ const [ showMobileHistory , setShowMobileHistory ] = useState < boolean > ( false )
137
+ // Close mobile history list when transcript changes
138
+ useEffect ( ( ) => {
139
+ setShowMobileHistory ( false )
140
+ } , [ transcript ] )
141
+
122
142
if ( ! loaded ) {
123
143
return null
124
144
}
@@ -137,7 +157,7 @@ export const CodyChatPage: React.FunctionComponent<CodyChatPageProps> = ({ authe
137
157
}
138
158
139
159
return (
140
- < Page className = "overflow-hidden" >
160
+ < Page className = { classNames ( 'd-flex flex-column' , styles . page ) } >
141
161
< PageTitle title = "Cody AI Chat" />
142
162
< PageHeader
143
163
actions = {
@@ -154,23 +174,25 @@ export const CodyChatPage: React.FunctionComponent<CodyChatPageProps> = ({ authe
154
174
graph.
155
175
</ >
156
176
}
157
- className = "mb-3"
177
+ className = { styles . pageHeader }
158
178
>
159
179
< PageHeader . Heading as = "h2" styleAs = "h1" >
160
180
< PageHeader . Breadcrumb icon = { CodyColorIcon } >
161
181
< div className = "d-inline-flex align-items-center" >
162
182
Cody Chat
163
- < Badge variant = "info" className = "ml-2" >
164
- Beta
165
- </ Badge >
183
+ { ! isSourcegraphApp && (
184
+ < Badge variant = "info" className = "ml-2" >
185
+ Beta
186
+ </ Badge >
187
+ ) }
166
188
</ div >
167
189
</ PageHeader . Breadcrumb >
168
190
</ PageHeader . Heading >
169
191
</ PageHeader >
170
192
171
193
{ /* Page content */ }
172
- < div className = { classNames ( 'row mb-5 ' , styles . pageWrapper ) } >
173
- < div className = "d-flex flex-column col-sm-3 h-100" >
194
+ < div className = { classNames ( 'row flex-1 overflow-hidden ' , styles . pageWrapper ) } >
195
+ < div className = { classNames ( ' col-md-3' , styles . sidebarWrapper ) } >
174
196
< div className = { styles . sidebarHeader } >
175
197
< H4 >
176
198
< b > Chats</ b >
@@ -285,9 +307,54 @@ export const CodyChatPage: React.FunctionComponent<CodyChatPageProps> = ({ authe
285
307
) ) }
286
308
</ div >
287
309
288
- < div className = { classNames ( 'd-flex flex-column col-sm-9 h-100' , styles . chatMainWrapper ) } >
310
+ < div
311
+ className = { classNames (
312
+ 'col-md-9 h-100' ,
313
+ styles . chatMainWrapper ,
314
+ showMobileHistory && styles . chatMainWrapperWithMobileHistory
315
+ ) }
316
+ >
317
+ < div className = { styles . mobileTopBar } >
318
+ < Button
319
+ variant = "icon"
320
+ className = { styles . mobileTopBarButton }
321
+ onClick = { ( ) => setShowMobileHistory ( true ) }
322
+ >
323
+ < Icon aria-hidden = { true } svgPath = { mdiViewList } className = "mr-2" />
324
+ All chats
325
+ </ Button >
326
+ < div className = { classNames ( 'border-right' , styles . mobileTopBarDivider ) } />
327
+ < Button variant = "icon" className = { styles . mobileTopBarButton } onClick = { initializeNewChat } >
328
+ < Icon aria-hidden = { true } svgPath = { mdiPlus } className = "mr-2" />
329
+ New chat
330
+ </ Button >
331
+ </ div >
289
332
< ChatUI codyChatStore = { codyChatStore } />
290
333
</ div >
334
+
335
+ { showMobileHistory && (
336
+ < div className = { styles . mobileHistoryWrapper } >
337
+ < div className = { styles . mobileTopBar } >
338
+ < Button
339
+ variant = "icon"
340
+ className = { classNames ( 'w-100' , styles . mobileTopBarButton ) }
341
+ onClick = { ( ) => setShowMobileHistory ( false ) }
342
+ >
343
+ < Icon aria-hidden = { true } svgPath = { mdiClose } className = "mr-2" />
344
+ Close
345
+ </ Button >
346
+ </ div >
347
+ < div className = { styles . mobileHistory } >
348
+ < HistoryList
349
+ currentTranscript = { transcript }
350
+ transcriptHistory = { transcriptHistory }
351
+ truncateMessageLength = { 60 }
352
+ loadTranscriptFromHistory = { loadTranscriptFromHistory }
353
+ deleteHistoryItem = { deleteHistoryItem }
354
+ />
355
+ </ div >
356
+ </ div >
357
+ ) }
291
358
</ div >
292
359
</ Page >
293
360
)
0 commit comments