@@ -46,6 +46,7 @@ import { ProductCardWrapper } from 'components/ProductCard/ProductCardWrapper'
4646import { DashboardProps } from 'components/Dashboard/DashboardWrapper'
4747import { FilteredTableMessage } from 'components/AccessTokens/FilteredTableMessage/FilteredTableMessage'
4848import { CreatedDbLabCards } from 'components/CreateDbLabCards/CreateDbLabCards'
49+ import { convertThread } from "../../api/bot/convertThread" ;
4950
5051interface DashboardWithStylesProps extends DashboardProps {
5152 classes : ClassesType
@@ -163,6 +164,8 @@ class Dashboard extends Component<DashboardWithStylesProps, DashboardState> {
163164 } )
164165
165166 Actions . refresh ( )
167+
168+ this . convertThreadAndRedirectToBot ( )
166169 }
167170
168171 componentWillUnmount ( ) {
@@ -212,6 +215,24 @@ class Dashboard extends Component<DashboardWithStylesProps, DashboardState> {
212215 this . setState ( { filterValue : event . target . value } )
213216 }
214217
218+ convertThreadAndRedirectToBot = async ( ) => {
219+ const cookieName = "pgai_tmp_thread_id=" ;
220+ const cookies = document . cookie . split ( ';' ) . map ( cookie => cookie . trim ( ) ) ;
221+ const pgaiTmpThreadId = cookies . find ( cookie => cookie . startsWith ( cookieName ) ) ?. substring ( cookieName . length ) || null ;
222+
223+ if ( pgaiTmpThreadId ) {
224+ try {
225+ const data = await convertThread ( pgaiTmpThreadId ) ;
226+ if ( data ?. response ?. final_thread_id ) {
227+ document . cookie = `${ cookieName } =; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.${ window . location . hostname . split ( '.' ) . slice ( - 2 ) . join ( '.' ) } ` ;
228+ this . props . history . push ( `demo/bot/${ data . response . final_thread_id } ` ) ;
229+ }
230+ } catch ( error ) {
231+ console . error ( 'Error converting thread:' , error ) ;
232+ }
233+ }
234+ }
235+
215236 render ( ) {
216237 const renderProjects = this . props . onlyProjects
217238
0 commit comments