Skip to content

Commit bfcda23

Browse files
committed
feat: Optimize ai interface
1 parent 59eb2c4 commit bfcda23

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • chat2db-client/src/components/Console

chat2db-client/src/components/Console/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ function Console(props: IProps) {
249249
if (isNL2SQL) {
250250
setIsLoading(true);
251251
} else {
252+
setAiContent('');
252253
setIsAiDrawerOpen(true);
253254
setIsAiDrawerLoading(true);
254255
}
@@ -264,11 +265,11 @@ function Console(props: IProps) {
264265
const handleMessage = (message: string) => {
265266
// console.log('message', message);
266267
setIsLoading(false);
268+
setIsAiDrawerLoading(false);
267269
try {
268270
const isEOF = message === '[DONE]';
269271
if (isEOF) {
270272
closeEventSource();
271-
setIsLoading(false);
272273
if (isChat2DBAI) {
273274
dispatch({
274275
type: 'ai/fetchRemainingUse',
@@ -326,9 +327,11 @@ function Console(props: IProps) {
326327
editorRef?.current?.setValue(JSON.parse(message).content);
327328
} else {
328329
chatResult.current += JSON.parse(message).content;
330+
setAiContent(chatResult.current);
329331
}
330332
} catch (error) {
331333
setIsLoading(false);
334+
setIsAiDrawerLoading(false);
332335
}
333336
};
334337

0 commit comments

Comments
 (0)