fix: prevent empty-model warning modal from staying open after OK (#18046)

This commit is contained in:
chanx
2026-08-10 17:27:31 +08:00
committed by GitHub
parent 5a2cd36b45
commit e9123ea764

View File

@@ -5,6 +5,8 @@ import { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigatePage } from './logic-hooks/navigate-hooks';
let isWarningVisible = false;
export const useWarnEmptyModel = (
showEmptyModelWarn: boolean,
embdId?: string,
@@ -19,12 +21,14 @@ export const useWarnEmptyModel = (
if (
showEmptyModelWarn &&
!warnedRef.current &&
!isWarningVisible &&
!loading &&
(isEmpty(embdId) || isEmpty(llmId)) &&
typeof embdId === 'string' &&
typeof llmId === 'string'
) {
warnedRef.current = true;
isWarningVisible = true;
Modal.warning({
title: t('common.warn'),
content: (
@@ -37,6 +41,7 @@ export const useWarnEmptyModel = (
closable: false,
showCancel: false,
onOk() {
isWarningVisible = false;
navigateToModelSetting();
},
});