@@ -19,6 +19,8 @@ import SettingsIcon from '@mui/icons-material/Settings';
19
19
import AddIcon from '@mui/icons-material/Add' ;
20
20
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined' ;
21
21
import * as prompts from './prompts'
22
+ import CleaningServicesIcon from '@mui/icons-material/CleaningServices' ;
23
+ import CleanWidnow from './CleanWindow' ;
22
24
23
25
const { useEffect, useState } = React
24
26
@@ -36,7 +38,7 @@ function App() {
36
38
// 是否展示应用更新提示
37
39
const [ needCheckUpdate , setNeedCheckUpdate ] = useState ( true )
38
40
39
- const [ scrollToMsg , setScrollToMsg ] = useState < { msgId : string , smooth ?: boolean } > ( null )
41
+ const [ scrollToMsg , setScrollToMsg ] = useState < { msgId : string , smooth ?: boolean } > ( null )
40
42
useEffect ( ( ) => {
41
43
if ( ! scrollToMsg ) {
42
44
return
@@ -70,7 +72,7 @@ function App() {
70
72
return
71
73
}
72
74
const last = store . currentSession . messages [ store . currentSession . messages . length - 1 ]
73
- setScrollToMsg ( { msgId : last . id , smooth : false } )
75
+ setScrollToMsg ( { msgId : last . id , smooth : false } )
74
76
} , [ store . currentSession ] )
75
77
76
78
// 会话名称自动生成
@@ -82,6 +84,8 @@ function App() {
82
84
83
85
const [ configureChatConfig , setConfigureChatConfig ] = React . useState < Session | null > ( null ) ;
84
86
87
+ const [ sessionClean , setSessionClean ] = React . useState < Session | null > ( null ) ;
88
+
85
89
const generateName = async ( session : Session ) => {
86
90
client . replay (
87
91
store . settings . openaiKey ,
@@ -114,7 +118,7 @@ function App() {
114
118
}
115
119
}
116
120
store . updateChatSession ( session )
117
- setScrollToMsg ( { msgId : targetMsg . id , smooth : false } )
121
+ setScrollToMsg ( { msgId : targetMsg . id , smooth : false } )
118
122
} ,
119
123
( err ) => {
120
124
for ( let i = 0 ; i < session . messages . length ; i ++ ) {
@@ -267,9 +271,14 @@ function App() {
267
271
< IconButton edge = "start" color = "inherit" aria-label = "menu" sx = { { mr : 2 } } >
268
272
< ChatBubbleOutlineOutlinedIcon />
269
273
</ IconButton >
270
- < Typography variant = "h6" color = "inherit" component = "div" noWrap >
274
+ < Typography variant = "h6" color = "inherit" component = "div" noWrap sx = { { flexGrow : 1 } } >
271
275
{ store . currentSession . name }
272
276
</ Typography >
277
+ < IconButton edge = "start" color = "inherit" aria-label = "menu" sx = { { mr : 2 } }
278
+ onClick = { ( ) => setSessionClean ( store . currentSession ) }
279
+ >
280
+ < CleaningServicesIcon />
281
+ </ IconButton >
273
282
</ Toolbar >
274
283
< Divider />
275
284
< List
@@ -318,7 +327,7 @@ function App() {
318
327
store . currentSession . messages = [ ...store . currentSession . messages , newUserMsg , newAssistantMsg ]
319
328
store . updateChatSession ( store . currentSession )
320
329
generate ( store . currentSession , promptsMsgs , newAssistantMsg )
321
- setScrollToMsg ( { msgId : newAssistantMsg . id , smooth : true } )
330
+ setScrollToMsg ( { msgId : newAssistantMsg . id , smooth : true } )
322
331
} } />
323
332
</ Box >
324
333
</ Stack >
@@ -344,6 +353,18 @@ function App() {
344
353
/>
345
354
)
346
355
}
356
+ {
357
+ sessionClean !== null && (
358
+ < CleanWidnow open = { sessionClean !== null }
359
+ session = { sessionClean }
360
+ save = { ( session ) => {
361
+ store . updateChatSession ( session )
362
+ setSessionClean ( null )
363
+ } }
364
+ close = { ( ) => setSessionClean ( null ) }
365
+ />
366
+ )
367
+ }
347
368
{
348
369
store . toasts . map ( ( toast ) => (
349
370
< Snackbar
0 commit comments