fix(chat): avoid handleChat temporal dead zone (#3132)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
alanchen
2026-07-15 14:01:52 +08:00
committed by GitHub
parent 2d1663cf5c
commit f5adbef2ac
79 changed files with 111 additions and 111 deletions

View File

@@ -127,17 +127,6 @@ const Chat: React.FC = () => {
const [knowledgeValue, setKnowledgeValue] = useState<string | null>(null);
const [modelValue, setModelValue] = useState<string>('');
// Auto-send init message if present
useEffect(() => {
if (initMsg && chatId && !history.length && !replyLoading) {
// Small delay to ensure everything is loaded
const timer = setTimeout(() => {
handleChat(initMsg);
}, 500);
return () => clearTimeout(timer);
}
}, [chatId, handleChat, history.length, initMsg, replyLoading]);
useEffect(() => {
setTemperatureValue(appInfo?.param_need?.filter(item => item.type === 'temperature')[0]?.value || 0.6);
setMaxNewTokensValue(appInfo?.param_need?.filter(item => item.type === 'max_new_tokens')[0]?.value || 4000);
@@ -343,6 +332,17 @@ const Chat: React.FC = () => {
[chat, chatId, history, modelValue, scene],
);
// Auto-send init message if present
useEffect(() => {
if (initMsg && chatId && !history.length && !replyLoading) {
// Small delay to ensure everything is loaded
const timer = setTimeout(() => {
handleChat(initMsg);
}, 500);
return () => clearTimeout(timer);
}
}, [chatId, handleChat, history.length, initMsg, replyLoading]);
useAsyncEffect(async () => {
// 如果是默认小助手,不获取历史记录
if (isChatDefault) {