Skip to content

Commit e220b5b

Browse files
committed
Revert "Unify global modals:"
This reverts commit cbc12a2.
1 parent cbc12a2 commit e220b5b

File tree

3 files changed

+661
-2
lines changed

3 files changed

+661
-2
lines changed

frontend/app/[locale]/chat/components/chatHeader.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { useAuth } from "@/hooks/useAuth";
1414
import { USER_ROLES } from "@/const/modelConfig";
1515
import { saveView } from "@/lib/viewPersistence";
1616

17+
import MemoryManageModal from "../internal/memory/memoryManageModal";
18+
1719
interface ChatHeaderProps {
1820
title: string;
1921
onRename?: (newTitle: string) => void;
@@ -23,7 +25,8 @@ export function ChatHeader({ title, onRename }: ChatHeaderProps) {
2325
const router = useRouter();
2426
const [isEditing, setIsEditing] = useState(false);
2527
const [editTitle, setEditTitle] = useState(title);
26-
28+
const [memoryModalVisible, setMemoryModalVisible] = useState(false);
29+
const [embeddingConfigured, setEmbeddingConfigured] = useState<boolean>(true);
2730
const [showConfigPrompt, setShowConfigPrompt] = useState(false);
2831
const [showAutoOffPrompt, setShowAutoOffPrompt] = useState(false);
2932
const inputRef = useRef<HTMLInputElement>(null);
@@ -59,8 +62,9 @@ export function ChatHeader({ title, onRename }: ChatHeaderProps) {
5962
const modelConfig = configStore.getModelConfig();
6063
const configured = Boolean(
6164
modelConfig?.embedding?.modelName ||
62-
modelConfig?.multiEmbedding?.modelName
65+
modelConfig?.multiEmbedding?.modelName
6366
);
67+
setEmbeddingConfigured(configured);
6468

6569
if (!configured) {
6670
// If memory switch is on, turn it off automatically and notify the user
@@ -81,6 +85,7 @@ export function ChatHeader({ title, onRename }: ChatHeaderProps) {
8185
});
8286
}
8387
} catch (e) {
88+
setEmbeddingConfigured(false);
8489
log.error("Failed to read model config for embedding check", e);
8590
}
8691
}, []);
@@ -222,6 +227,10 @@ export function ChatHeader({ title, onRename }: ChatHeaderProps) {
222227
</div>
223228
</div>
224229
</Modal>
230+
<MemoryManageModal
231+
visible={memoryModalVisible}
232+
onClose={() => setMemoryModalVisible(false)}
233+
/>
225234
</>
226235
);
227236
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import React from "react";
2+
import { useTranslation, Trans } from "react-i18next";
3+
import { Modal } from "antd";
4+
import { WarningFilled } from "@ant-design/icons";
5+
import { MemoryDeleteModalProps } from "@/types/memory";
6+
7+
/**
8+
* Hosts the "Clear Memory" secondary confirmation popup window and is responsible only for UI display.
9+
* The upper-level component is responsible for controlling visible and callback logic.
10+
*/
11+
const MemoryDeleteModal: React.FC<MemoryDeleteModalProps> = ({
12+
visible,
13+
targetTitle,
14+
onOk,
15+
onCancel,
16+
}) => {
17+
const { t } = useTranslation();
18+
return (
19+
<Modal
20+
open={visible}
21+
title={
22+
<div className="flex items-center gap-2 text-lg font-bold">
23+
<span>{t("memoryDeleteModal.title")}</span>
24+
</div>
25+
}
26+
onOk={onOk}
27+
onCancel={onCancel}
28+
okText={t("memoryDeleteModal.clear")}
29+
cancelText={t("common.cancel")}
30+
okButtonProps={{ danger: true }}
31+
destroyOnClose
32+
>
33+
<div className="flex items-start gap-3 mt-4">
34+
<WarningFilled
35+
className="text-yellow-500 mt-1 mr-2"
36+
style={{ fontSize: "48px" }}
37+
/>
38+
<div className="space-y-2">
39+
<p>
40+
<Trans
41+
i18nKey="memoryDeleteModal.description"
42+
values={{ title: targetTitle || "" }}
43+
components={{ strong: <strong /> }}
44+
/>
45+
</p>
46+
<p className="text-gray-500 text-sm">
47+
{t("memoryDeleteModal.prompt")}
48+
</p>
49+
</div>
50+
</div>
51+
</Modal>
52+
);
53+
};
54+
55+
export default MemoryDeleteModal;

0 commit comments

Comments
 (0)