mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-04 05:12:38 +02:00
Merge pull request #1324 from guangyang1206/feat/key-prop-llm-role-manager-1018
refactor(settings): use key prop to reset LLM role manager form state
This commit is contained in:
commit
e5b2ac7918
2 changed files with 2 additions and 21 deletions
|
|
@ -11,7 +11,7 @@ import {
|
||||||
RefreshCw,
|
RefreshCw,
|
||||||
ScanEye,
|
ScanEye,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import {
|
import {
|
||||||
globalImageGenConfigsAtom,
|
globalImageGenConfigsAtom,
|
||||||
|
|
@ -143,23 +143,6 @@ export function LLMRoleManager({ searchSpaceId }: LLMRoleManagerProps) {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const [savingRole, setSavingRole] = useState<string | null>(null);
|
const [savingRole, setSavingRole] = useState<string | null>(null);
|
||||||
const savingRef = useRef(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!savingRef.current) {
|
|
||||||
setAssignments({
|
|
||||||
agent_llm_id: preferences.agent_llm_id ?? "",
|
|
||||||
document_summary_llm_id: preferences.document_summary_llm_id ?? "",
|
|
||||||
image_generation_config_id: preferences.image_generation_config_id ?? "",
|
|
||||||
vision_llm_config_id: preferences.vision_llm_config_id ?? "",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [
|
|
||||||
preferences?.agent_llm_id,
|
|
||||||
preferences?.document_summary_llm_id,
|
|
||||||
preferences?.image_generation_config_id,
|
|
||||||
preferences?.vision_llm_config_id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const handleRoleAssignment = useCallback(
|
const handleRoleAssignment = useCallback(
|
||||||
async (prefKey: string, configId: string) => {
|
async (prefKey: string, configId: string) => {
|
||||||
|
|
@ -167,7 +150,6 @@ export function LLMRoleManager({ searchSpaceId }: LLMRoleManagerProps) {
|
||||||
|
|
||||||
setAssignments((prev) => ({ ...prev, [prefKey]: value }));
|
setAssignments((prev) => ({ ...prev, [prefKey]: value }));
|
||||||
setSavingRole(prefKey);
|
setSavingRole(prefKey);
|
||||||
savingRef.current = true;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await updatePreferences({
|
await updatePreferences({
|
||||||
|
|
@ -177,7 +159,6 @@ export function LLMRoleManager({ searchSpaceId }: LLMRoleManagerProps) {
|
||||||
toast.success("Role assignment updated");
|
toast.success("Role assignment updated");
|
||||||
} finally {
|
} finally {
|
||||||
setSavingRole(null);
|
setSavingRole(null);
|
||||||
savingRef.current = false;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[updatePreferences, searchSpaceId]
|
[updatePreferences, searchSpaceId]
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ export function SearchSpaceSettingsDialog({ searchSpaceId }: SearchSpaceSettings
|
||||||
const content: Record<string, React.ReactNode> = {
|
const content: Record<string, React.ReactNode> = {
|
||||||
general: <GeneralSettingsManager searchSpaceId={searchSpaceId} />,
|
general: <GeneralSettingsManager searchSpaceId={searchSpaceId} />,
|
||||||
models: <AgentModelManager searchSpaceId={searchSpaceId} />,
|
models: <AgentModelManager searchSpaceId={searchSpaceId} />,
|
||||||
roles: <LLMRoleManager searchSpaceId={searchSpaceId} />,
|
roles: <LLMRoleManager key={searchSpaceId} searchSpaceId={searchSpaceId} />,
|
||||||
"image-models": <ImageModelManager searchSpaceId={searchSpaceId} />,
|
"image-models": <ImageModelManager searchSpaceId={searchSpaceId} />,
|
||||||
"vision-models": <VisionModelManager searchSpaceId={searchSpaceId} />,
|
"vision-models": <VisionModelManager searchSpaceId={searchSpaceId} />,
|
||||||
"team-roles": <RolesManager searchSpaceId={searchSpaceId} />,
|
"team-roles": <RolesManager searchSpaceId={searchSpaceId} />,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue