11import React , { useEffect , useState } from 'react'
22
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'
413import classNames from 'classnames'
514import { useLocation , useNavigate } from 'react-router-dom'
615
@@ -41,6 +50,7 @@ import styles from './CodyChatPage.module.scss'
4150
4251interface CodyChatPageProps {
4352 authenticatedUser : AuthenticatedUser | null
53+ isSourcegraphApp : boolean
4454 context : Pick < SourcegraphContext , 'authProviders' >
4555}
4656
@@ -78,7 +88,11 @@ const onTranscriptHistoryLoad = (
7888 }
7989}
8090
81- export const CodyChatPage : React . FunctionComponent < CodyChatPageProps > = ( { authenticatedUser, context } ) => {
91+ export const CodyChatPage : React . FunctionComponent < CodyChatPageProps > = ( {
92+ authenticatedUser,
93+ context,
94+ isSourcegraphApp,
95+ } ) => {
8296 const { pathname } = useLocation ( )
8397 const navigate = useNavigate ( )
8498
@@ -119,6 +133,12 @@ export const CodyChatPage: React.FunctionComponent<CodyChatPageProps> = ({ authe
119133 }
120134 } , [ transcriptId , loaded , pathname , navigate ] )
121135
136+ const [ showMobileHistory , setShowMobileHistory ] = useState < boolean > ( false )
137+ // Close mobile history list when transcript changes
138+ useEffect ( ( ) => {
139+ setShowMobileHistory ( false )
140+ } , [ transcript ] )
141+
122142 if ( ! loaded ) {
123143 return null
124144 }
@@ -137,7 +157,7 @@ export const CodyChatPage: React.FunctionComponent<CodyChatPageProps> = ({ authe
137157 }
138158
139159 return (
140- < Page className = "overflow-hidden" >
160+ < Page className = { classNames ( 'd-flex flex-column' , styles . page ) } >
141161 < PageTitle title = "Cody AI Chat" />
142162 < PageHeader
143163 actions = {
@@ -154,23 +174,25 @@ export const CodyChatPage: React.FunctionComponent<CodyChatPageProps> = ({ authe
154174 graph.
155175 </ >
156176 }
157- className = "mb-3"
177+ className = { styles . pageHeader }
158178 >
159179 < PageHeader . Heading as = "h2" styleAs = "h1" >
160180 < PageHeader . Breadcrumb icon = { CodyColorIcon } >
161181 < div className = "d-inline-flex align-items-center" >
162182 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+ ) }
166188 </ div >
167189 </ PageHeader . Breadcrumb >
168190 </ PageHeader . Heading >
169191 </ PageHeader >
170192
171193 { /* 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 ) } >
174196 < div className = { styles . sidebarHeader } >
175197 < H4 >
176198 < b > Chats</ b >
@@ -285,9 +307,54 @@ export const CodyChatPage: React.FunctionComponent<CodyChatPageProps> = ({ authe
285307 ) ) }
286308 </ div >
287309
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 >
289332 < ChatUI codyChatStore = { codyChatStore } />
290333 </ 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+ ) }
291358 </ div >
292359 </ Page >
293360 )
0 commit comments