remember current chat input
This commit is contained in:
parent
4b640f884b
commit
17c690dfb1
@ -1,4 +1,4 @@
|
|||||||
import React, { FC, useEffect, useRef, useState } from 'react';
|
import React, { FC, useEffect, useRef } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Avatar, PresenceBadge, Textarea } from '@fluentui/react-components';
|
import { Avatar, PresenceBadge, Textarea } from '@fluentui/react-components';
|
||||||
import commonStore, { ModelStatus } from '../stores/commonStore';
|
import commonStore, { ModelStatus } from '../stores/commonStore';
|
||||||
@ -47,7 +47,6 @@ let chatSseController: AbortController | null = null;
|
|||||||
|
|
||||||
const ChatPanel: FC = observer(() => {
|
const ChatPanel: FC = observer(() => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [message, setMessage] = useState('');
|
|
||||||
const bodyRef = useRef<HTMLDivElement>(null);
|
const bodyRef = useRef<HTMLDivElement>(null);
|
||||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||||
const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
|
const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
|
||||||
@ -98,9 +97,9 @@ const ChatPanel: FC = observer(() => {
|
|||||||
toast(t('Please click the button in the top right corner to start the model'), { type: 'warning' });
|
toast(t('Please click the button in the top right corner to start the model'), { type: 'warning' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!message) return;
|
if (!commonStore.currentInput) return;
|
||||||
onSubmit(message);
|
onSubmit(commonStore.currentInput);
|
||||||
setMessage('');
|
commonStore.setCurrentInput('');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -267,8 +266,8 @@ const ChatPanel: FC = observer(() => {
|
|||||||
className="grow"
|
className="grow"
|
||||||
resize="vertical"
|
resize="vertical"
|
||||||
placeholder={t('Type your message here')!}
|
placeholder={t('Type your message here')!}
|
||||||
value={message}
|
value={commonStore.currentInput}
|
||||||
onChange={(e) => setMessage(e.target.value)}
|
onChange={(e) => commonStore.setCurrentInput(e.target.value)}
|
||||||
onKeyDown={handleKeyDownOrClick}
|
onKeyDown={handleKeyDownOrClick}
|
||||||
/>
|
/>
|
||||||
<ToolTipButton desc={generating ? t('Stop') : t('Send')}
|
<ToolTipButton desc={generating ? t('Stop') : t('Send')}
|
||||||
|
@ -41,6 +41,7 @@ class CommonStore {
|
|||||||
// home
|
// home
|
||||||
introduction: IntroductionContent = manifest.introduction;
|
introduction: IntroductionContent = manifest.introduction;
|
||||||
// chat
|
// chat
|
||||||
|
currentInput: string = '';
|
||||||
conversations: Conversations = {};
|
conversations: Conversations = {};
|
||||||
conversationsOrder: string[] = [];
|
conversationsOrder: string[] = [];
|
||||||
// completion
|
// completion
|
||||||
@ -182,6 +183,10 @@ class CommonStore {
|
|||||||
setPlatform(value: Platform) {
|
setPlatform(value: Platform) {
|
||||||
this.platform = value;
|
this.platform = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setCurrentInput(value: string) {
|
||||||
|
this.currentInput = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new CommonStore();
|
export default new CommonStore();
|
Loading…
Reference in New Issue
Block a user