Skip to content

Commit 437f573

Browse files
committed
fix:bug fix
1 parent e5f9ecc commit 437f573

2 files changed

Lines changed: 27 additions & 32 deletions

File tree

src/frontend/client/src/components/Chat/Input/ChatForm.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const ChatForm = ({ isLingsi, setShowCode, readOnly, index = 0 }) => {
114114
? sameSopLabel
115115
? "请输入与此案例相似的目标"
116116
: bsConfig?.linsightConfig?.input_placeholder ||
117-
localize("com_linsight_input_placeholder")
117+
localize("com_linsight_input_placeholder")
118118
: bsConfig?.inputPlaceholder,
119119
});
120120

@@ -173,7 +173,7 @@ const ChatForm = ({ isLingsi, setShowCode, readOnly, index = 0 }) => {
173173
isAssistantsEndpoint(conversation?.endpoint) &&
174174
(!(conversation?.assistant_id ?? "") ||
175175
!assistantMap?.[conversation?.endpoint ?? ""][
176-
conversation?.assistant_id ?? ""
176+
conversation?.assistant_id ?? ""
177177
]),
178178
[conversation?.assistant_id, conversation?.endpoint, assistantMap]
179179
);
@@ -249,8 +249,8 @@ const ChatForm = ({ isLingsi, setShowCode, readOnly, index = 0 }) => {
249249
// 如果已经有保存的状态,恢复它
250250
console.log("恢复已保存的状态", savedState);
251251
setSelectedOrgKbs(savedState.selectedOrgKbs || []);
252-
setEnableOrgKb(savedState.enableOrgKb || false);
253-
setSearchType(savedState.searchType || "");
252+
setEnableOrgKb(savedState.enableOrgKb ?? false);
253+
setSearchType(savedState.searchType ?? "");
254254
} else {
255255
// 如果没有保存的状态,保存当前状态
256256
console.log("保存当前状态到新ID");
@@ -406,9 +406,8 @@ const ChatForm = ({ isLingsi, setShowCode, readOnly, index = 0 }) => {
406406
)}
407407
>
408408
<div
409-
className={`relative flex h-full flex-1 items-stretch md:flex-col ${
410-
!isLingsi && "overflow-hidden"
411-
}`}
409+
className={`relative flex h-full flex-1 items-stretch md:flex-col ${!isLingsi && "overflow-hidden"
410+
}`}
412411
>
413412
{/* 切换模型 */}
414413
{/* {showPlusPopover && !isAssistantsEndpoint(endpoint) && (
@@ -434,7 +433,7 @@ const ChatForm = ({ isLingsi, setShowCode, readOnly, index = 0 }) => {
434433
className={cn(
435434
"transitional-all relative flex w-full flex-grow flex-col overflow-hidden rounded-3xl bg-surface-tertiary pb-8 z-10 text-text-primary duration-200 border border-transparent",
436435
isLingsi &&
437-
"border-blue-400 bg-gradient-to-b from-[#F2F5FF] to-white"
436+
"border-blue-400 bg-gradient-to-b from-[#F2F5FF] to-white"
438437
)}
439438
>
440439
{/* 临时对话 */}
@@ -481,11 +480,14 @@ const ChatForm = ({ isLingsi, setShowCode, readOnly, index = 0 }) => {
481480

482481
{setSelectedOrgKbs && (
483482
<button
484-
onClick={() =>
483+
onClick={() => {
485484
setSelectedOrgKbs((prev) =>
486485
prev.filter((i) => i.id !== kb.id)
487-
)
488-
}
486+
);
487+
if (kb.id === "personal_knowledge_base") {
488+
setSearchType("");
489+
}
490+
}}
489491
className="absolute right-1 top-1/2 -translate-y-1/2
490492
opacity-0 group-hover:opacity-100
491493
w-4 h-4 flex items-center justify-center
@@ -564,7 +566,7 @@ const ChatForm = ({ isLingsi, setShowCode, readOnly, index = 0 }) => {
564566
/>
565567
)}
566568
{(isSubmitting || isSubmittingAdded) &&
567-
(showStopButton || showStopAdded) ? (
569+
(showStopButton || showStopAdded) ? (
568570
<StopButton
569571
stop={handleStopGenerating}
570572
setShowStopButton={setShowStopButton}

src/frontend/client/src/components/Chat/Input/ChatKnowledge.tsx

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,33 +121,26 @@ export const ChatKnowledge = ({
121121
});
122122
};
123123
useEffect(() => {
124-
if (searchType === "knowledgeSearch") {
125-
// 检查是否已经包含个人知识库
126-
const hasPersonalKb = selectedOrgKbs.some(
127-
(kb) => kb.id === PERSONAL_KB.id
128-
);
129-
if (!hasPersonalKb && enableOrgKb) {
130-
setSelectedOrgKbs((prev) => [...prev, PERSONAL_KB]);
131-
} else {
132-
setSelectedOrgKbs([PERSONAL_KB]);
133-
}
134-
} else {
135-
// 关闭个人知识库时移除
136-
setSelectedOrgKbs((prev) =>
137-
prev.filter((kb) => kb.id !== PERSONAL_KB.id)
138-
);
139-
}
140-
}, [searchType, setSelectedOrgKbs]);
124+
setSelectedOrgKbs((prev) => {
125+
const filtered = prev.filter((kb) => kb.id !== PERSONAL_KB.id);
126+
return searchType === "knowledgeSearch" ? [...filtered, PERSONAL_KB] : filtered;
127+
});
128+
}, [searchType]);
129+
141130
useEffect(() => {
142131
if (!enableOrgKb) {
132+
// 仅删除组织 KB
143133
setSelectedOrgKbs((prev) =>
144-
prev.filter((kb) => kb.id === PERSONAL_KB.id)
134+
prev.filter((kb) => kb.id === PERSONAL_KB.id || kb.id === PERSONAL_KB.id)
145135
);
146136
}
147137
}, [enableOrgKb, setSelectedOrgKbs]);
138+
148139
useEffect(() => {
149-
setSelectedOrgKbs([]);
150-
setEnableOrgKb(false);
140+
if (!selectedOrgKbs.length && !enableOrgKb) {
141+
setSelectedOrgKbs([]);
142+
setEnableOrgKb(false);
143+
}
151144
}, []);
152145

153146
return (

0 commit comments

Comments
 (0)